diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 165278172..0f455e2c4 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -33,6 +33,7 @@ class OrderController extends BaseApiController ApiDoc\url('/api/order/order/write_list'), ApiDoc\Method('POST'), ApiDoc\Param(name: "status", type: "int", require: true, desc: "1:待核销;2:已核销"), + ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"), ApiDoc\Param(name: "page_no", type: "int", require: true, desc: "默认1页数"), ApiDoc\Param(name: "page_size", type: "int", require: false, desc: "条数默认15"), ApiDoc\NotHeaders(), @@ -56,6 +57,24 @@ class OrderController extends BaseApiController return $this->success('ok',$res); } + + #[ + ApiDoc\Title('核销数量'), + ApiDoc\url('/api/order/order/write_count'), + ApiDoc\Method('POST'), + ApiDoc\Param(name: "name", type: "string", require: false, desc: "搜商品或者订单id"), + ApiDoc\NotHeaders(), + ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + ApiDoc\ResponseSuccess("data", type: "array"), + ] + public function write_count() + { + $info = $this->userInfo; + $params = $this->request->post(); + $res = OrderLogic::write_count($info,$params); + return $this->success('ok',$res); + } + #[ ApiDoc\Title('订单校验'), ApiDoc\url('/api/order/order/checkOrder'), diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 7585a7d7b..d95294fed 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -442,6 +442,46 @@ class OrderLogic extends BaseLogic } + public static function write_count($info,$params) + { + $store_id = SystemStoreStaff::where('phone',$info['mobile'])->value('store_id'); + if(empty($store_id)){ + throw new \Exception('该用户未绑定店铺请查看'); + } + $query = StoreOrderCartInfo::alias('o') + ->leftJoin('store_branch_product p','p.id = o.product_id') + ->leftJoin('store_order s','s.id = o.oid') + ->field('o.oid,p.store_name,s.order_id') + ->where('o.store_id',$store_id); + + if(isset($params['name']) && $params['name']){ + if($params['name'] && preg_match('/[\x{4e00}-\x{9fff}]+/u', $params['name'])==1){ + $query->where('p.store_name','like','%'.$params['name'].'%'); + }else{ + $query->where('s.order_id',$params['name']); + } + } + $product = $query->select(); + if(empty($product)){ + return [ + 'no_send'=>0, + 'send'=>0 + ]; + } + $oids = array_column($product->toArray(), 'oid'); + $uniqueOids = array_unique($oids); + $no_send = StoreOrder::whereIn('id',$uniqueOids) + ->where('status',1)->count(); + $send = StoreOrder::whereIn('id',$uniqueOids) + ->where('status',2)->count(); + return [ + 'no_send'=>$no_send, + 'send'=>$send + ]; + + } + + public static function write_list($info,$status,$params) { @@ -463,7 +503,6 @@ class OrderLogic extends BaseLogic }else{ $query->where('s.order_id',$params['name']); } - } $product = $query->select(); if(empty($product)){