diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index d45cd0b1..5956bbc5 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -628,7 +628,7 @@ class StoreOrderRepository extends BaseRepository * @author xaboy * @day 2020/6/10 */ - public function userOrderNumber(int $uid, $product_type = 0) + public function userOrderNumber(int $uid, $product_type = 0,$source=2) { //activity_type:0普通订单 98采购订单 99委托商品 //$noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid, $product_type); @@ -636,14 +636,20 @@ class StoreOrderRepository extends BaseRepository if ($product_type == 98 || $product_type == 99) { $isUser = 0; } - $noPay = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(1))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->count(); - $noPostage = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(2))->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); - $noDeliver = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(3))->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); - $noComment = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(4))->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); - $done = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(5))->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); + $where['activity_type']=$product_type; + if($source==103){ + $where['activity_type']=[0,98]; + $where['source']=[2,103]; + } + $noComment = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(4))->where($where)->where('StoreOrder.is_del', 0)->count(); + $noPay = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(1))->whereRaw("(StoreOrder.paid=0 and StoreOrder.pay_type!=8) or (StoreOrder.paid=1 and StoreOrder.pay_type=8 and StoreOrder.status=2)")->where($where)->where('StoreOrder.is_del', 0)->count(); + $noPostage = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(2))->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); + $noDeliver = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(3))->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); + $noComment = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(4))->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); + $done = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(5))->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); $refund = StoreRefundOrder::alias('t1')->join('store_order t2', 't1.order_id=t2.order_id')->where('t1.uid', $uid)->where('t1.status', 3)->where('t2.activity_type', $product_type)->count(); - $orderPrice = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(8))->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->sum('pay_price'); - $orderCount = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where('activity_type', $product_type)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); + $orderPrice = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($this->getOrderType(8))->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->sum('pay_price'); + $orderCount = $this->dao->search(['uid' => $uid, 'is_user' => $isUser])->where($where)->where('StoreOrder.is_del', 0)->fetchSql(false)->count(); return compact('noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderPrice', 'orderCount'); } diff --git a/app/controller/api/store/order/StoreOrder.php b/app/controller/api/store/order/StoreOrder.php index 79f09b98..8ef48321 100644 --- a/app/controller/api/store/order/StoreOrder.php +++ b/app/controller/api/store/order/StoreOrder.php @@ -164,7 +164,8 @@ class StoreOrder extends BaseController public function number() { $productType = $this->request->param('product_type', 0); - return app('json')->success($this->repository->userOrderNumber($this->request->uid(), $productType)); + $source = $this->request->param('source', 2); + return app('json')->success($this->repository->userOrderNumber($this->request->uid(), $productType,$source)); } /**