diff --git a/app/common/dao/store/order/StoreGroupOrderDao.php b/app/common/dao/store/order/StoreGroupOrderDao.php index a9ecd3aa..8567626c 100644 --- a/app/common/dao/store/order/StoreGroupOrderDao.php +++ b/app/common/dao/store/order/StoreGroupOrderDao.php @@ -43,11 +43,12 @@ class StoreGroupOrderDao extends BaseDao * @author xaboy * @day 2020/6/11 */ - public function orderNumber($uid = null) + public function orderNumber($uid = null, $productType = 0) { - return StoreGroupOrder::when($uid, function ($query, $uid) { - $query->where('uid', $uid); - })->where('is_del', 0)->where('paid', 0)->count(); + $storeOrderWhere = StoreOrder::where('activity_type', $productType); + return StoreGroupOrder::hasWhere('orderList', $storeOrderWhere)->when($uid, function ($query, $uid) { + $query->where('StoreGroupOrder.uid', $uid); + })->where('StoreGroupOrder.is_del', 0)->where('StoreGroupOrder.paid', 0)->count(); } /** diff --git a/app/common/dao/store/order/StoreOrderDao.php b/app/common/dao/store/order/StoreOrderDao.php index 36e60b62..7a24fd64 100644 --- a/app/common/dao/store/order/StoreOrderDao.php +++ b/app/common/dao/store/order/StoreOrderDao.php @@ -109,9 +109,6 @@ class StoreOrderDao extends BaseDao case 2 : $query->where('StoreOrder.status', $where['status'])->where('pay_type', '<>', StoreGroupOrder::PAY_TYPE_CREDIT_BUY); break; - case 20 : - $query->whereRaw('paid=0 or (StoreOrder.status=' . StoreOrder::STATUS_WAIT_COMMENT . ' and pay_type=' . StoreGroupOrder::PAY_TYPE_CREDIT_BUY . ')'); - break; default: $query->where('StoreOrder.status', $where['status']); break; diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 8c07a3fe..68a2a70f 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -195,7 +195,7 @@ class StoreOrderRepository extends BaseRepository //修改订单状态 Db::transaction(function () use ($subOrders, $is_combine, $groupOrder) { $time = date('Y-m-d H:i:s'); - $groupOrder->paid = 1; + $groupOrder->paid = $groupOrder->pay_type == StoreGroupOrder::PAY_TYPE_CREDIT_BUY ? 0 : 1; $groupOrder->pay_time = $time; $groupOrder->is_combine = $is_combine; $orderStatus = []; @@ -562,7 +562,7 @@ class StoreOrderRepository extends BaseRepository */ public function userOrderNumber(int $uid, $product_type=0) { - $noPay = $this->dao->search(['uid' => $uid, 'status' => 20,'is_user' => 1, 'product_type' => $product_type])->where('StoreOrder.is_del', 0)->count(); + $noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid, $product_type); $noPostage = $this->dao->search(['uid' => $uid, 'status' => 0, 'paid' => 1,'is_user' => 1, 'product_type' => $product_type])->where('StoreOrder.is_del', 0)->count(); $all = $this->dao->search(['uid' => $uid, 'status' => -2,'is_user' => 1, 'product_type' => $product_type])->where('StoreOrder.is_del', 0)->count(); $noDeliver = $this->dao->search(['uid' => $uid, 'status' => 1, 'paid' => 1, 'product_type' => $product_type])->where('StoreOrder.is_del', 0)->count(); @@ -2497,6 +2497,8 @@ class StoreOrderRepository extends BaseRepository $merchantRepo = app()->make(MerchantRepository::class); $merchantRepo->unfreeze($groupOrder->interest->mer_id); } + $groupOrder->paid = 1; + $groupOrder->save(); } $groupOrder->interest->save(); Db::commit(); diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 4792f557..506c814c 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -135,9 +135,7 @@ class StoreOrder extends BaseController $where['product_type'] = $this->request->param('product_type',0); $where['search'] = $this->request->param('store_name'); $where['uid'] = $this->request->uid(); - if ($where['status'] != 20) { - $where['paid'] = 1; - } + $where['paid'] = 1; $where['is_user'] = 1; return app('json')->success($this->repository->getList($where, $page, $limit)); } diff --git a/crmeb/listens/pay/OrderSettlePaySuccessListen.php b/crmeb/listens/pay/OrderSettlePaySuccessListen.php index f63edbf4..4d3d9811 100644 --- a/crmeb/listens/pay/OrderSettlePaySuccessListen.php +++ b/crmeb/listens/pay/OrderSettlePaySuccessListen.php @@ -46,6 +46,8 @@ class OrderSettlePaySuccessListen implements ListenerInterface $merchantRepo = app()->make(MerchantRepository::class); $merchantRepo->unfreeze($groupOrder->interest->mer_id); } + $groupOrder->paid = 1; + $groupOrder->save(); Db::commit(); } catch (\Exception $e) { Db::rollback();