Commit f111cf6a authored by liuyuzhen's avatar liuyuzhen

下单推送

parent 499c8a72
...@@ -43,6 +43,8 @@ class OrderConfirmUtil { ...@@ -43,6 +43,8 @@ class OrderConfirmUtil {
private $cartCacheDeleteFlag = false; private $cartCacheDeleteFlag = false;
private $pushMessageOrders = array();
public function addOrder($data,$memberId,$currentAddress){ public function addOrder($data,$memberId,$currentAddress){
$storeCartData = $this->checkPostData($data,$memberId,$currentAddress); $storeCartData = $this->checkPostData($data,$memberId,$currentAddress);
//return $storeCartData; //return $storeCartData;
...@@ -349,6 +351,7 @@ class OrderConfirmUtil { ...@@ -349,6 +351,7 @@ class OrderConfirmUtil {
$orderLogList = array(); $orderLogList = array();
$needPayFlag = \Our\ApiConst::zero; $needPayFlag = \Our\ApiConst::zero;
$giftCoupons = array(); $giftCoupons = array();
$this->pushMessageOrders = array();
foreach($storeCartData['cartList'] as $storeId=>$storeCarts){ foreach($storeCartData['cartList'] as $storeId=>$storeCarts){
$order= array(); $order= array();
$order['order_sn'] = $this->makeOrderSn($orderPayResult); $order['order_sn'] = $this->makeOrderSn($orderPayResult);
...@@ -391,6 +394,13 @@ class OrderConfirmUtil { ...@@ -391,6 +394,13 @@ class OrderConfirmUtil {
$orderModel->db->doRollback(); $orderModel->db->doRollback();
\Error\ErrorModel::throwException(\Error\CodeConfigModel::saveOrderPayFailed); \Error\ErrorModel::throwException(\Error\CodeConfigModel::saveOrderPayFailed);
} }
if($order['order_state'] == \Our\ApiConst::orderStateWaitConfirm){
$tempPushOrder = array();
$tempPushOrder['orderId'] = $orderId;
$tempPushOrder['orderSn'] = $order['order_sn'];
$tempPushOrder['storeId'] = $storeId;
$this->pushMessageOrders[] = $tempPushOrder;
}
$orderLog = array(); $orderLog = array();
$orderLog['order_id'] = $orderId; $orderLog['order_id'] = $orderId;
$orderLog['log_msg'] = \Our\DescribeConst::addOrderLog; $orderLog['log_msg'] = \Our\DescribeConst::addOrderLog;
...@@ -512,9 +522,18 @@ class OrderConfirmUtil { ...@@ -512,9 +522,18 @@ class OrderConfirmUtil {
} }
$orderModel->db->doCommit(); $orderModel->db->doCommit();
$this->opCacheInfo(); $this->opCacheInfo();
$this->pushMessage();
return array('needPayFlag'=>$needPayFlag,'paySn'=>$paySn); return array('needPayFlag'=>$needPayFlag,'paySn'=>$paySn);
} }
public function pushMessage(){
if($this->pushMessageOrders){
$orderService=\Business\Order\OrderServiceModel::getInstance();
foreach($this->pushMessageOrders as $tempOrder){
$orderService->pushRecieveOrder($tempOrder);
}
}
}
public function opCacheInfo(){ public function opCacheInfo(){
if($this->cartCacheDeleteFlag){ if($this->cartCacheDeleteFlag){
$this->delCartCache(); $this->delCartCache();
...@@ -921,7 +940,7 @@ class OrderConfirmUtil { ...@@ -921,7 +940,7 @@ class OrderConfirmUtil {
} }
$orderCon = array('pay_sn'=>$paySn,'order_state'=>\Our\ApiConst::orderStateWaitPay); $orderCon = array('pay_sn'=>$paySn,'order_state'=>\Our\ApiConst::orderStateWaitPay);
$orderList = $orderModel->getListByCon($orderCon,'order_id,coupon_id,buyer_id'); $orderList = $orderModel->getListByCon($orderCon,'order_id,coupon_id,buyer_id,store_id,order_sn');
if(!$orderList){ if(!$orderList){
$errorCode = \Error\CodeConfigModel::noOrderListForPay; $errorCode = \Error\CodeConfigModel::noOrderListForPay;
return array('flag'=>\Our\ApiConst::zero,'errorCode'=>$errorCode,'data'=>$data); return array('flag'=>\Our\ApiConst::zero,'errorCode'=>$errorCode,'data'=>$data);
...@@ -941,12 +960,18 @@ class OrderConfirmUtil { ...@@ -941,12 +960,18 @@ class OrderConfirmUtil {
} }
//更新订单支付状态 //更新订单支付状态
$couponIds = array(); $couponIds = array();
$this->pushMessageOrders = array();
foreach($orderList as $tempOrder){ foreach($orderList as $tempOrder){
if($tempOrder['coupon_id']>\Our\ApiConst::zero){ if($tempOrder['coupon_id']>\Our\ApiConst::zero){
$couponIds[$tempOrder['order_id']] = $tempOrder['coupon_id']; $couponIds[$tempOrder['order_id']] = $tempOrder['coupon_id'];
} }
$orderModel->deleteOrderCache($tempOrder['buyer_id'],$tempOrder['order_id'],$tempOrder['store_id'],true,true); $orderModel->deleteOrderCache($tempOrder['buyer_id'],$tempOrder['order_id'],$tempOrder['store_id'],true,true);
\Our\RedisHelper::memberTotalFromStateToState($tempOrder['buyer_id'],ApiConst::orderStateWaitPay,ApiConst::orderStateWaitConfirm); \Our\RedisHelper::memberTotalFromStateToState($tempOrder['buyer_id'],ApiConst::orderStateWaitPay,ApiConst::orderStateWaitConfirm);
$tempPushOrder = array();
$tempPushOrder['orderId'] = $tempOrder['order_id'];
$tempPushOrder['orderSn'] = $tempOrder['order_sn'];
$tempPushOrder['storeId'] = $tempOrder['store_id'];
$this->pushMessageOrders[] = $tempPushOrder;
} }
//送券、送礼品 //送券、送礼品
/*if($couponIds){ /*if($couponIds){
...@@ -955,6 +980,7 @@ class OrderConfirmUtil { ...@@ -955,6 +980,7 @@ class OrderConfirmUtil {
$orderModel->db->doCommit(); $orderModel->db->doCommit();
$this->deleteCacheInfo($memberId); $this->deleteCacheInfo($memberId);
$this->pushMessage();
return array('flag'=>\Our\ApiConst::one,'errorCode'=>$errorCode); return array('flag'=>\Our\ApiConst::one,'errorCode'=>$errorCode);
} }
......
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