Commit 7e217a74 authored by christ's avatar christ

pc

parent 24ce00e6
......@@ -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;
......@@ -916,7 +935,14 @@ class OrderServiceModel extends \Business\AbstractModel
$delivery['finishTime'] = $value['finishTime'];
$delivery['mobPhone'] = $delivery['mobPhone'] ? $delivery['mobPhone'] : '';
$delivery['finishTime'] = $delivery['finishTime'] ? $delivery['finishTime'] : ApiConst::zero;
$delivery['orderGoods'] = !empty($goodsDao->convert($orderMerge[$value['orderId']]['orderGoods']))?$goodsDao->convert($orderMerge[$value['orderId']]['orderGoods']):array();
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;
......
......@@ -556,7 +556,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 +591,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 +619,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){
......
......@@ -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();
}
......
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