From cfb91dc2aa8329ec0c4d3aba3c03f19e1781d607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=9F=E5=B7=9D=E4=B8=9C?= Date: Thu, 17 Apr 2025 16:20:13 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8F=90=E4=BA=A4=E4=B8=8A=E9=97=A8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=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 | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 946ca2d..e9a1510 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -199,14 +199,7 @@ class OrderDispatchService extends BaseService */ 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 = $this->getOrderDispatchInfo($workerId, $orderDispatchId); $orderDispatch->status = OrderDispatch::STATUS_PLANIT; $orderDispatch->plan_time = $planTime; $orderDispatch->save(); @@ -219,6 +212,37 @@ class OrderDispatchService extends BaseService return true; } + + public function arrivedOnSite(int $workerId, int $orderDispatchId, string $img) + { + $time = datetime(time()); + $orderDispatch = $this->getOrderDispatchInfo($workerId, $orderDispatchId); + $orderDispatch->status = OrderDispatch::STATUS_CLOCK; + $orderDispatch->arrive_image = $img; + $orderDispatch->arrive_time = $time; + $orderDispatch->save(); + + //派单状态变更 + $orderDispatchChangeParams = [ + 'dispatch' => $orderDispatch, + 'remark' => '师傅已上门,上门时间:' . $time, + ]; + Hook::listen('order_dispatch_change', $orderDispatchChangeParams); + + return true; + } + + private function getOrderDispatchInfo(int $workerId, int $orderDispatchId) { + $res = $this->getOrderDispatchModel() + ->where('id', $orderDispatchId) + ->where('worker_id', $workerId) + ->find(); + if (!$res) { + $this->apiError('订单不存在'); + } + + return $res; + } }