From e25a2c29ea44e79d39f1e79cbb06cd78075075fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=9F=E5=B7=9D=E4=B8=9C?= Date: Mon, 14 Apr 2025 16:45:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A2=84=E7=BA=A6=E4=B8=8A=E9=97=A8?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/services/OrderDispatchService.php | 37 ++++++++++++++++++- .../worker/controller/OrderDispatch.php | 29 ++++++++++++++- application/worker/validate/OrderDispatch.php | 2 + 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index a47ab42..946ca2d 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -166,6 +166,11 @@ class OrderDispatchService extends BaseService return true; } + /** + * 派单详情 + * @param int $workerId 师傅id + * @param int $orderDispatchId 派单id + */ public function dispatchInfo(int $workerId, int $orderDispatchId) { $res = $this->getOrderDispatchModel() @@ -176,7 +181,7 @@ class OrderDispatchService extends BaseService }]) ->where('id', $orderDispatchId) ->where('worker_id', $workerId) - ->field(['id', 'order_id', 'status', 'remark', 'create_time', 'total', 'online_total', 'is_receipt']) + ->field(['id', 'order_id', 'status', 'remark', 'create_time', 'total', 'online_total', 'is_receipt', 'plan_time']) ->find(); if (!$res) { $this->apiError('订单不存在'); @@ -184,6 +189,36 @@ class OrderDispatchService extends BaseService return $res; } + + /** + * 提交预约上门时间 + * @param int $workerId 师傅id + * @param int $orderDispatchId 派单id + * @param string $planTime 预约时间 + * @return true + */ + public function appointmentTime(int $workerId, int $orderDispatchId, string $planTime) + { + $orderDispatch = $this->getOrderDispatchModel() + ->where('id', $orderDispatchId) + ->where('worker_id', $workerId) + ->find(); + if (!$orderDispatch) { + $this->apiError('订单不存在'); + } + + $orderDispatch->status = OrderDispatch::STATUS_PLANIT; + $orderDispatch->plan_time = $planTime; + $orderDispatch->save(); + + $orderDispatchChangeParams = [ + 'dispatch' => $orderDispatch, + 'remark' => '师傅已和客户预约,预约时间:' . $planTime, + ]; + Hook::listen('order_dispatch_change', $orderDispatchChangeParams); + + return true; + } } diff --git a/application/worker/controller/OrderDispatch.php b/application/worker/controller/OrderDispatch.php index 0a560c6..a4c036f 100644 --- a/application/worker/controller/OrderDispatch.php +++ b/application/worker/controller/OrderDispatch.php @@ -19,7 +19,7 @@ class OrderDispatch extends WorkerApi } /** - * 订单详情 + * 派单详情 * @return void */ public function info() @@ -76,4 +76,31 @@ class OrderDispatch extends WorkerApi $res = $this->getOrderDispatchService()->orderConfirm($this->user['id'], $params['order_dispatch_id'], $params['type']); $this->success('操作成功', $res); } + + /** + * 提交预约上门时间 + * @return void + */ + public function appointmentTime() + { + $params = $this->request->request(); + $validate = $this->validate($params, \app\worker\validate\OrderDispatch::class . '.appointmentTime'); + if ($validate !== true) { + $this->error($validate); + } + + $res = $this->getOrderDispatchService()->appointmentTime($this->user['id'], $params['order_dispatch_id'], $params['plan_time']); + $this->success('操作成功', $res); + } } + + + + + + + + + + + diff --git a/application/worker/validate/OrderDispatch.php b/application/worker/validate/OrderDispatch.php index c0b875a..a89684c 100644 --- a/application/worker/validate/OrderDispatch.php +++ b/application/worker/validate/OrderDispatch.php @@ -10,6 +10,7 @@ class OrderDispatch extends Validate 'type|确认类型' => 'require|in:accept,reject', 'order_dispatch_id|订单派单id' => 'require|number', 'workbench_type|工作台类型' => 'require|in:ongoing,today,tomorrow,all', + 'plan_time|预约时间' => 'require|date', ]; protected $message = [ @@ -20,5 +21,6 @@ class OrderDispatch extends Validate 'orderConfirm' => ['type', 'order_dispatch_id'], 'workbenchOrderList' => ['workbench_type'], 'info' => ['order_dispatch_id'], + 'appointmentTime' => ['order_dispatch_id', 'plan_time'], ]; }