Commit bab09805 authored by zhz's avatar zhz

Merge branch 'master_dev' of git.shenbd.com:qm-develop/shenbd into master_dev

parents ad41a631 452bb572
......@@ -421,6 +421,7 @@ class ApiConst
const deliveryOrderType = 16;
//pcClient 消息推送消息模板类型常量
const messageWaitReceive=101;
//售后
const messageRefund=102;
//待配送
const messageWaitSend=102;
......
......@@ -875,6 +875,7 @@ class OrderServiceModel extends \Business\AbstractModel
$orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$orderCommonDao = \DAO\Order\OrderCommonModel::getInstance(DbNameConst::salveDBConnectName);
$refundReturnDao=\DAO\Order\RefundReturnModel::getInstance(DbNameConst::salveDBConnectName);
$memberDao = \DAO\MemberModel::getInstance(DbNameConst::salveDBConnectName);
$qmMans=$qmDeliveryMan->getListByMemberId($memberId);
$diliverymanIds=array_column($qmMans,'id');
......@@ -882,8 +883,26 @@ class OrderServiceModel extends \Business\AbstractModel
if (empty($diliverymanIds)) {
ErrorModel::throwException(CodeConfigModel::commonError);
}
$qmDeliveryLogList = $qmDeliveryLogDao->getListByDeliverymanIdAndTypeCache($diliverymanIds, $type, $pageIndex, $pageSize,array('get_time' => 'desc'),$memberId);
$orderIds = array_column($qmDeliveryLogList['list'], 'orderId');
$qmDeliveryLogList = $qmDeliveryLogDao->getListByDeliverymanIdAndTypeCache($diliverymanIds, $type, ApiConst::pageIndex, $pageSize,array('get_time' => 'desc'),$memberId);
$orderIds=Array();
foreach($qmDeliveryLogList['list'] as $qmDeliveryLog){
if($qmDeliveryLog['orderType']==ApiConst::orderTypeRefund){
$refundids[]=$qmDeliveryLog['orderId'];
}else{
$orderIds[]=$qmDeliveryLog['orderId'];
}
}
if(!empty($refundids)){
$refundWhere['refund_id']=array('in',$refundids);
$refundOrders=$refundReturnDao->getList($refundWhere,$refundReturnDao->refundDetailField,ApiConst::zero,ApiConst::pageSize);
$refundOrders=$refundReturnDao->convertCommonList($refundOrders['list'],'orderGoodsId');
$refundReturnOrders=$refundReturnDao->convertCommonList($refundOrders,'refundId');
$refundOrderIds=array_column($refundOrders, 'orderId');
}
if(!empty($refundOrderIds)){
$orderIds=array_merge($refundOrderIds,$orderIds);
}
// $orderIds = array_column($qmDeliveryLogList['list'], 'orderId');
// echo json_encode($orderIds);exit;
// $where['delete_state'] = ApiConst::undeleteOrder;
......@@ -901,14 +920,20 @@ class OrderServiceModel extends \Business\AbstractModel
$goodsDao = \DAO\GoodsModel::getInstance();
$orderIds = array_column($orders['list'], 'orderId');
$orderCommons = $orderCommonDao->getAllByOrderIdsCache($orderIds, $diliverymanId, $orderCommonDao->orderCommonField);
$orderGoods = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsByOrderIds'), array($orderIds, $this->getGoodsDetailField()), \Our\ApiConst::oneDaySecond, array($diliverymanId.'_'));
$orderMerge = Common::intergrateOneToMany($orders['list'], $orderGoods, 'orderId', 'orderId', 'orderGoods');
$orderMerge = Common::intergrateOneToOne($orderMerge, $orderCommons, 'orderId', 'orderId');
$orderMerge = $orderDao->convertOrderList($orderMerge);
$convertResult = array();
//$orderGoods = $goodsDao->convert($orderGoods);
foreach ($qmDeliveryLogList['list'] as &$value) {
if($value['orderType']==ApiConst::orderTypeRefund){
$delivery=$orderMerge[$refundReturnOrders[$value['orderId']]['orderId']];
}else{
$delivery = $orderMerge[$value['orderId']];
}
$delivery['id'] = $value['id'];
$delivery['reciverInfo'] = unserialize($delivery['reciverInfo']);
$delivery['mobPhone'] = $delivery['reciverInfo']['mob_phone'];
......@@ -916,7 +941,14 @@ class OrderServiceModel extends \Business\AbstractModel
$delivery['finishTime'] = $value['finishTime'];
$delivery['mobPhone'] = $delivery['mobPhone'] ? $delivery['mobPhone'] : '';
$delivery['finishTime'] = $delivery['finishTime'] ? $delivery['finishTime'] : ApiConst::zero;
if($value['orderType']==ApiConst::orderTypeRefund){
//因为$value['orderId']=refundId
$orderMergeGoods=$goodsDao->convert($orderMerge[$refundReturnOrders[$value['orderId']]['orderId']]['orderGoods'],false,$refundOrders);
$delivery['orderGoods'] =$orderMergeGoods?$orderMergeGoods:array();
}else{
$delivery['orderGoods'] = !empty($goodsDao->convert($orderMerge[$value['orderId']]['orderGoods']))?$goodsDao->convert($orderMerge[$value['orderId']]['orderGoods']):array();
}
$delivery['street'] =$orderCommonDao->convertReceiveAddress($delivery['reciverInfo']['address']);
$delivery['lng'] = $delivery['reciverInfo']['lng'] ? $delivery['reciverInfo']['lng'] : 0.0;
$delivery['lat'] = $delivery['reciverInfo']['lat'] ? $delivery['reciverInfo']['lat'] : 0.0;
......@@ -970,6 +1002,7 @@ class OrderServiceModel extends \Business\AbstractModel
$orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
$addressDao = \DAO\AddressModel::getInstance(DbNameConst::salveDBConnectName);
$orderCommonDao = \DAO\Order\OrderCommonModel::getInstance(DbNameConst::salveDBConnectName);
$refundReturnDao=\DAO\Order\RefundReturnModel::getInstance();
$orderGoodsDao = \DAO\Order\OrderGoodsModel::getInstance(DbNameConst::salveDBConnectName);
$diliverymanDao = \DAO\Order\DiliverymanModel::getInstance(DbNameConst::salveDBConnectName);
$goodsDao = \DAO\GoodsModel::getInstance(DbNameConst::salveDBConnectName);
......@@ -979,7 +1012,13 @@ class OrderServiceModel extends \Business\AbstractModel
if (empty($delivery)) {
ErrorModel::throwException(CodeConfigModel::notExsitDeliver);
}
if($delivery['orderType']==ApiConst::orderTypeRefund){
$refundReturn=$refundReturnDao->findByRefundId($delivery['orderId'],$refundReturnDao->refundDetailField);
$orderId = $refundReturn['orderId'];
}else{
$orderId = $delivery['orderId'];
}
//订单
$order = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$orderDao, 'findByOrderId'), array($orderId), \Our\ApiConst::oneDaySecond,array($orderId));
......@@ -998,11 +1037,11 @@ class OrderServiceModel extends \Business\AbstractModel
if (empty($this->orderGoodsList)) {
ErrorModel::throwException(CodeConfigModel::notExistOrderGoods);
}
//商店相关信息
$this->store = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$storeDao, 'getInfoById'), array($this->order['storeId'],$storeDao->detailField), \Our\ApiConst::oneDaySecond);
$orderGoods = $goodsDao->convert($this->orderGoodsList);
$convertRefundReturn=Array();
$convertRefundReturn[$refundReturn['orderGoodsId']]=$refundReturn;
$orderGoods = $goodsDao->convert($this->orderGoodsList,false,$convertRefundReturn);
if (empty($orderGoods)) {
$orderGoods = array();
}
......
......@@ -122,7 +122,6 @@ class RefundServiceModel extends \Business\AbstractModel
// if (($refund['seller_state'] != '2' && $refund['platform_state'] != '1') || $refund['goods_state'] != '2') {//检查状态,防止页面刷新不及时造成数据错误
// return false;
// }
error_reporting(E_ALL);
$refund_array = array();
if ($goodsState == '3' && $delay_time > 0) {
$refund_array['goods_state'] = 3;
......@@ -184,7 +183,22 @@ class RefundServiceModel extends \Business\AbstractModel
$orderDao->deleteOrderCache($refund['buyer_id'], $refund['order_id'], $refund['store_id']);
$storeDAO->deleteStoreRefundCache($refund['store_id'],$refund['order_id']);
$refundReturnDao->db->doCommit();
$push=\Our\Push::getInstance();
$pushData=array('storeId'=>$order_info['storeId'],
'type'=>ApiConst::messageRefund,
'waitReceiveCount'=>ApiConst::zero,
'waitDeliveryCount'=>ApiConst::zero,
'waitGetCount'=>ApiConst::zero,
'orderCount'=>ApiConst::zero,
'waitRefundProccessCount'=>ApiConst::zero,
'waitRefundReceiveCount'=>ApiConst::reduceOne,
'refundCount'=>ApiConst::reduceOne,
'alertCount'=>ApiConst::zero,
'params'=>array('c'=>'shopkeeper',
'm'=>'orderDetail',
'refundId'=>$refund['refund_id']));
$push->addOneToClient($pushData);
$push->sendTcpMessage();
return true;
}
$refundReturnDao->db->doRollback();
......@@ -195,7 +209,7 @@ class RefundServiceModel extends \Business\AbstractModel
* 退货审核页
*
*/
public function returnGoods($storeId,$refundId,$sellerState,$sellerMessage,$isGiveUp=ApiConst::zero) {
public function returnGoods($storeId,$refundId,$sellerState,$refundAmount,$sellerMessage,$isGiveUp=ApiConst::zero) {
$refundReturnDao = \DAO\Order\RefundReturnModel::getInstance(DbNameConst::masterDBConnectName);
$orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::masterDBConnectName);
$orderGoodsDao=\DAO\Order\OrderGoodsModel::getInstance(DbNameConst::masterDBConnectName);
......@@ -268,12 +282,14 @@ class RefundServiceModel extends \Business\AbstractModel
$refund_array['return_type'] = '2';//退货类型:1为不用退货,2为需要退货
$refund_array['goods_state']=2;
} elseif ($refund_array['seller_state'] == '3') {
$refund_array['refund_state'] = '3';//状态:1为处理中,2为待管理员处理,3为已完成
} else {
$refund_array['seller_state'] = '2';
$refund_array['refund_state'] = '2';
$refund_array['return_type'] = '1';//选择弃货
}
$refund_array['refund_amount']=$refundAmount;
$state = $refundReturnDao->update($condition, $refund_array);
if ($state) {
$sellerLogDao=\DAO\SellerLogModel::getInstance(DbNameConst::masterDBConnectName);
......@@ -336,7 +352,7 @@ class RefundServiceModel extends \Business\AbstractModel
$whereRefund['refund_id']= $refundId;
$refund = $refundReturnDao->find($whereRefund);
if($refund['refund_type']==ApiConst::refundTypeGoods){
if($this->returnGoods($storeId,$refundId,$seller_state,$text,$isGiveUp)){
if($this->returnGoods($storeId,$refundId,$refund['sellerState'],$refundAmount,$text,$isGiveUp)){
$refundReturnDao->deleteRefundCache($refund['buyer_id'], $refund['refund_id']);
$orderDao->deleteOrderCache($refund['buyer_id'],$refund['order_id'],$refund['store_id']);
\Our\RedisHelper::delCachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$refundReturnDao, 'getList'), array(), array($refund['store_id']));
......@@ -556,7 +572,8 @@ class RefundServiceModel extends \Business\AbstractModel
$orderDao=\DAO\Order\OrderModel::getInstance(DbNameConst::salveDBConnectName);
$goodsDao=\DAO\GoodsModel::getInstance(DbNameConst::salveDBConnectName);
$diliverymanDao=\DAO\Order\DiliverymanModel::getInstance();
$qmDeliveryManLogDao=\DAO\Order\QmDeliverymanLogModel::getInstance();
$addressDao = \DAO\Order\DAddressModel::getInstance(DbNameConst::salveDBConnectName);
$orderCommonDao = \DAO\Order\OrderCommonModel::getInstance();
......@@ -590,8 +607,15 @@ class RefundServiceModel extends \Business\AbstractModel
$orderGoods = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderGoodsDao, 'getOrderGoodsByRecIds'), array($orderGoodsId, $this->refundOrderGoodsField), \Our\ApiConst::oneDaySecond, array($storeId));
$refundMerge = Common::intergrateOneToOne($refundReturns['list'], $orderGoods, 'orderGoodsId', 'recId');
$orderIds= array_column($refundMerge, 'orderId');
$refundIds=array_column($refundMerge,'refundId');
$diliveryWhere['order_id']=array('in',$refundIds);
$diliveryWhere['order_type']=ApiConst::orderTypeRefund;
$orderWhere['order_id']=array('in',$orderIds);
$orders = \Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$orderDao, 'getList'), array($orderWhere, $orderDao->getOrderDetailField(), ApiConst::zero, $pageSize), \Our\ApiConst::oneDaySecond, array($storeId));
$qmDeliveryManLogWhere['order_id']=array('in',$refundIds);
$qmDeliveryManLogWhere['order_type']= ApiConst::orderTypeRefund;
$qmDeliveryManLogs=\Our\RedisHelper::cachedFunction(\Redis\Db6\StoreRedisModel::getInstance(), array(&$qmDeliveryManLogDao, 'getList'), array($qmDeliveryManLogWhere, $qmDeliveryManLogDao->fieldDetail,ApiConst::zero,$pageSize), \Our\ApiConst::oneDaySecond, array($storeId));
$qmDeliveryManLogs=$qmDeliveryManLogDao->convertListByField($qmDeliveryManLogs['list'],'orderId');
$orders=$orderDao->convertOrder($orders['list'],'orderId');
$orderCommons = $orderCommonDao->getAllByOrderIds($orderIds, $orderCommonDao->orderCommonField);
$orderCommons=$orderDao->convertOrder($orderCommons,'orderId');
......@@ -611,6 +635,14 @@ class RefundServiceModel extends \Business\AbstractModel
$extent=$orderDao->getClienOrderCommon($orders[$value['orderId']]);
$value=array_merge($value,$extent);
$goodGroup=unserialize($value['goodsGroup']);
if ($value['diliverymanId']) {
$diliverymanDao = \DAO\Order\DiliverymanModel::getInstance();
$res = \Our\RedisHelper::cachedFunction(\Redis\Db5\OrderRedisModel::getInstance(), array(&$diliverymanDao, 'findById'), array($value['diliverymanId']), \Our\ApiConst::oneDaySecond, array($value['diliverymanId']));
$value['deliveryman'] = $diliverymanDao->convert($res);
$value['deliveryman']['distributionFee']=$qmDeliveryManLogs[$value['refundId']]['distributionFee'];
}else{
$value['deliveryman']=new \stdClass();
}
$value['goodsGroup']=!empty($goodGroup)?$goodGroup:[];
if ($value['refundType'] == ApiConst::refundTypeGoods) {
if($value['refundShippingType']==ApiConst::bySeller){
......
......@@ -33,11 +33,19 @@ class DeliveryServiceModel extends \Business\AbstractModel
{
$orderDao = \DAO\Order\OrderModel::getInstance(DbNameConst::masterDBConnectName);
$storeDao=\DAO\StoreModel::getInstance();
$refundReturnDao=\DAO\Order\RefundReturnModel::getInstance(DbNameConst::masterDBConnectName);
$qmDeliveryManLog = \DAO\Order\QmDeliverymanLogModel::getInstance(DbNameConst::masterDBConnectName);
$messageService=\Business\Message\MessageServiceModel::getInstance();
$deliveryManDao=\DAO\Order\DiliverymanModel::getInstance();
$orderDao->setDb($orderDao->dbName);
if($data['orderType']==ApiConst::orderTypeRefund){
//如果是退货orderId就是refundId
$orderOne= $refundReturnDao->findByRefundId($data['orderId'],$refundReturnDao->refundDetailField);
$orderD= $orderDao->find($orderOne['orderId'],$orderDao->getOrderDetailField());
}else{
$orderD= $orderDao->find($data['orderId'],$orderDao->getOrderDetailField());
}
// if( $orderD['diliveryman_id']== $data['id']){
// ErrorModel::throwException(CodeConfigModel::alreadyExsitQmDeliveryLog);
// }
......@@ -46,12 +54,18 @@ class DeliveryServiceModel extends \Business\AbstractModel
// }
$orderDao->db->doTransaction();
$orderData['diliveryman_id'] = $data['id'];
if($data['orderType']==ApiConst::orderTypeRefund){
$returnWhere['refund_id']=$data['orderId'];
$orderRes= $refundReturnDao->update($returnWhere,$orderData);
}else{
$orderData['order_state']=ApiConst::orderStateWaitRecieve;
$orderRes = $orderDao->updateByOrderId($orderData, $data['orderId']);
// if (!$orderRes) {
// $orderDao->db->doRollback();
// ErrorModel::throwException(CodeConfigModel::updateOrderFail);
// }
}
if ($orderRes===false) {
$orderDao->db->doRollback();
ErrorModel::throwException(CodeConfigModel::updateOrderFail);
}
$qmDeliveryManLogData['diliveryman_id'] = $data['id'];
$qmDeliveryManLogData['store_id'] = $data['storeId'];
$qmDeliveryManLogData['order_id'] = $data['orderId'];
......@@ -86,6 +100,7 @@ class DeliveryServiceModel extends \Business\AbstractModel
$deliveryManMemberIds=array($deliveryManMemberId,$oringeDeliveryManMemberId);
$orderDao->deleteOrderCache(null, $data['orderId'], $data['storeId'], true,false,$deliveryManMemberIds);
$storeDao->deleteStoreCache($data['storeId'],$data['orderId']);
$storeDao->deleteStoreRefundCache($data['storeId'],$data['orderId']);
//配送员推送
$push=\Our\Push::getInstance();
$push->sendDelivery($oringeDeliveryManMemberId,$data['orderId']);
......
......@@ -28,6 +28,13 @@ abstract class AbstractModel {
$this->db=LinkMySQLModel::get($dbLink);
}
}
public function convertCommonList($list,$filed){
$returnList=Array();
foreach($list as $li){
$returnList[$li[$filed]]=$li;
}
return $returnList;
}
public function unsetDb(){
unset($this->db);
// LinkMySQLModel::unsetDbConecet();
......
......@@ -473,7 +473,16 @@ class GoodsModel extends \DAO\AbstractModel {
return $orderGoodses;
}
//ccw
public function convert($goodses,$extentField=false){
public function convert($goodses,$extentField=false,$refundOrders=false){
if($refundOrders){
$newGoods=Array();
foreach($goodses as $goods){
if($refundOrders[$goods['recId']]){
array_push($newGoods,$goods);
}
}
$goodses=$newGoods;
}
foreach($goodses as &$goods){
if($goods['refundId']==ApiConst::zero){
if((!empty($extentField) || empty($goods['refundStateName'])) ){
......
......@@ -274,6 +274,7 @@ class OrderModel extends \DAO\AbstractModel
$where = $this->db->getSqlWhereByArray($where);
if($status==ApiConst::orderStateComplete){
$data['is_receive_payment']=ApiConst::receivePayment;
$data['payment_time']=TIMESTAMP;
}
$data['order_state'] = $status;
$data['finnshed_time']=TIMESTAMP;
......
......@@ -16,8 +16,9 @@ use Our\ImageConst;
class QmDeliverymanLogModel extends \DAO\AbstractModel
{
public $fieldList = 'id,finish_time finishTime,get_time as getTime,order_id as orderId,distribution_fee as distributionFee';
public $fieldDetail = 'id,finish_time finishTime,get_time as getTime,order_id as orderId,delivery_state as deliveryState,order_type as orderType,distribution_fee as distributionFee';
public $fieldList = 'id,finish_time finishTime,get_time as getTime,order_id as orderId,distribution_fee as distributionFee,order_type as orderType,distribution_fee as distributionFee,shipping_fee as shippingFee,order_sn as orderSn';
public $fieldDetail = 'id,finish_time finishTime,get_time as getTime,order_id as orderId,delivery_state as deliveryState,order_type as orderType,distribution_fee as distributionFee,shipping_fee as shippingFee,order_sn as orderSn';
/**
......@@ -180,6 +181,15 @@ class QmDeliverymanLogModel extends \DAO\AbstractModel
return $convertInfo;
}
public function convertListByField($list,$field='orderId'){
$returnList=Array();
foreach($list as $li){
$returnList[$li[$field]]=$li;
}
return $returnList;
}
//删除订单详情缓存
public function deletefindByIdCache($id)
{
......
......@@ -538,6 +538,9 @@ class RefundReturnModel extends \DAO\AbstractModel {
public function getList($where, $field, $pageIndex=ApiConst::zero, $pageSize=ApiConst::pageSize, $order = array('add_time' => 'desc'))
{
$this->setDb($this->dbName);
if(is_array($where)){
$where = $this->db->getSqlWhereByArray($where);
}
$refunds = $this->lists($where, $order, $field, $pageIndex, $pageSize);
return $refunds ? $refunds : array();
}
......
......@@ -748,7 +748,7 @@ class CodeConfigModel
self::confirmReceiveError => '确认收款失败',
self::alreadyExsitDeliveryMan=>'您的店铺已经存在此配送员',
self::alreadyExsitQmDeliveryLog=>'已经分配此配送员',
self::notExsitDeliveryMan=>'用户不存在或未绑定手机号码',
self::notExsitDeliveryMan=>'您输入的手机号不存在,请先通知配送员注册【我的身边店】',
self::addDeliveryManError=>'添加配送员失败',
self::noStorageForBundlingGoods => '组合销售商品库存不存在',
self::bundlingGoodsOfflineForCartOrOrder => '组合销售活动已下架',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment