From e2031cb75b982c10d3a354ccb482a9f731ea5e95 Mon Sep 17 00:00:00 2001 From: gcd Date: Tue, 1 Apr 2025 22:48:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B7=A5=E4=BD=9C=E5=8F=B0=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/services/OrderDispatchService.php | 49 +++++++++++++++++++ .../worker/controller/OrderDispatch.php | 18 +++++++ application/worker/validate/OrderDispatch.php | 2 + 3 files changed, 69 insertions(+) diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 97ecc43..082f179 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -25,6 +25,55 @@ class OrderDispatchService extends BaseService ->paginate($pageSize); } + /** + * @param int $workerId 师傅id + * @param string $type 类型:ongoing=进行中,today=当日,tomorrow=昨日,all=全部订单 + * @param int $pageSize + */ + public function workbenchOrderList(int $workerId, string $type, int $pageSize) + { + $model = $this->getOrderDispatchModel() + ->with(['orderInfo' => function ($query) { + $query->with(['area' => function ($query) { + $query->field('id,area_code,merge_name'); + }])->field('id,order_no,item_id,item_title,receive_type,address,lng,lat,plan_time,online_amount,discount_amount,area_id,customer,tel'); + }]) + ->where('worker_id', $workerId); + + $status = [ + OrderDispatch::STATUS_GOTIT, + OrderDispatch::STATUS_PLANIT, + OrderDispatch::STATUS_CLOCK, + ]; + switch ($type) { + case 'ongoing': + //所有已接单未完成的订单 + $model->whereIn('status', $status); + break; + case 'today': + $model->whereIn('status', $status); + $model->where('plan_time', '>=', date('Y-m-d 00:00:00')); + $model->where('plan_time', '<=', date('Y-m-d 23:59:59')); + break; + case 'tomorrow': + $model->whereIn('status', $status); + $model->where('plan_time', '>=', date('Y-m-d 00:00:00', strtotime('+1 day'))); + $model->where('plan_time', '<=', date('Y-m-d 23:59:59', strtotime('+1 day'))); + break; + case 'all': + $status[] = OrderDispatch::STATUS_FINISH; + $model->whereIn('status', $status); + break; + } + + $result = $model + ->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time']) + ->order('id desc') + ->paginate($pageSize); + + return $result; + } + /** * 师傅接单/拒接 * @param int $workerId 师傅id diff --git a/application/worker/controller/OrderDispatch.php b/application/worker/controller/OrderDispatch.php index e044ae3..c8a39c4 100644 --- a/application/worker/controller/OrderDispatch.php +++ b/application/worker/controller/OrderDispatch.php @@ -18,6 +18,24 @@ class OrderDispatch extends WorkerApi $this->success('获取成功', $res); } + /** + * 工作台订单列表 + * @return void + */ + public function workbenchOrderList() + { + $params = $this->request->request(); + $validate = $this->validate($params, \app\worker\validate\OrderDispatch::class . '.workbenchOrderList'); + if ($validate !== true) { + $this->error($validate); + } + + $pageSize = $this->request->request('page_size', 20); + $type = $this->request->request('workbench_type'); + $res = $this->getOrderDispatchService()->workbenchOrderList($this->user['id'], $type, $pageSize); + $this->success('获取成功', $res); + } + /** * 接单/拒接 * @return void diff --git a/application/worker/validate/OrderDispatch.php b/application/worker/validate/OrderDispatch.php index 981661c..0f2efe1 100644 --- a/application/worker/validate/OrderDispatch.php +++ b/application/worker/validate/OrderDispatch.php @@ -9,6 +9,7 @@ class OrderDispatch extends Validate protected $rule = [ 'type|确认类型' => 'require|in:accept,reject', 'order_dispatch_id|订单派单id' => 'require|number', + 'workbench_type|工作台类型' => 'require|in:ongoing,today,tomorrow,all', ]; protected $message = [ @@ -17,5 +18,6 @@ class OrderDispatch extends Validate protected $scene = [ 'orderConfirm' => ['type', 'order_dispatch_id'], + 'workbenchOrderList' => ['workbench_type'], ]; }