From b06ae1a1ae8fbb024aadda92ada6ea9d7ca947ed Mon Sep 17 00:00:00 2001 From: gcd Date: Thu, 3 Apr 2025 17:26:53 +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=E7=BB=9F=E8=AE=A1=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 | 38 ++++++++++++++++--- .../worker/controller/OrderDispatch.php | 9 +++++ 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 082f179..4374bdf 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -31,6 +31,37 @@ class OrderDispatchService extends BaseService * @param int $pageSize */ public function workbenchOrderList(int $workerId, string $type, int $pageSize) + { + $model = $this->getWorkbenchOrderModel($workerId, $type); + $result = $model + ->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time']) + ->order('id desc') + ->paginate($pageSize); + + return $result; + } + + /** + * 统计工作台订单 + * @param int $workerId + * @return array + */ + public function countWorkbenchOrder(int $workerId) + { + return [ + 'ongoing' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(), + 'today' => $this->getWorkbenchOrderModel($workerId, 'today')->count(), + 'tomorrow' => $this->getWorkbenchOrderModel($workerId, 'tomorrow')->count(), + 'all' => $this->getWorkbenchOrderModel($workerId, 'all')->count(), + ]; + } + + /** + * 获取工作台订单模型 + * @param int $workerId + * @param string $type + */ + private function getWorkbenchOrderModel(int $workerId, string $type) { $model = $this->getOrderDispatchModel() ->with(['orderInfo' => function ($query) { @@ -66,12 +97,7 @@ class OrderDispatchService extends BaseService break; } - $result = $model - ->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time']) - ->order('id desc') - ->paginate($pageSize); - - return $result; + return $model; } /** diff --git a/application/worker/controller/OrderDispatch.php b/application/worker/controller/OrderDispatch.php index c8a39c4..aca2ede 100644 --- a/application/worker/controller/OrderDispatch.php +++ b/application/worker/controller/OrderDispatch.php @@ -36,6 +36,15 @@ class OrderDispatch extends WorkerApi $this->success('获取成功', $res); } + /** + * 统计工作台订单 + */ + public function countWorkbenchOrder() + { + $res = $this->getOrderDispatchService()->countWorkbenchOrder($this->user['id']); + $this->success('获取成功', $res); + } + /** * 接单/拒接 * @return void