diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 6a140bf..13f5286 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -264,6 +264,21 @@ class OrderDispatchService extends BaseService return true; } + public function updatePlanTime(int $workerId, int $orderDispatchId, string $planTime) + { + $orderDispatch = $this->getOrderDispatchInfo($workerId, $orderDispatchId); + $orderDispatch->plan_time = $planTime; + $orderDispatch->save(); + + $orderDispatchChangeParams = [ + 'dispatch' => $orderDispatch, + 'remark' => `师傅已修改上门时间,旧的时间:${$orderDispatch->plan_time},新的时间:${$planTime}` + ]; + Hook::listen('order_dispatch_change', $orderDispatchChangeParams); + + return true; + } + /** * 完成上门 * @param int $workerId 师傅id diff --git a/application/worker/controller/OrderDispatch.php b/application/worker/controller/OrderDispatch.php index 6f07222..e9218c1 100644 --- a/application/worker/controller/OrderDispatch.php +++ b/application/worker/controller/OrderDispatch.php @@ -93,6 +93,22 @@ class OrderDispatch extends WorkerApi $this->success('操作成功', $res); } + /** + * 修改上门时间 + * @return void + */ + public function updatePlanTime() + { + $params = $this->request->request(); + $validate = $this->validate($params, \app\worker\validate\OrderDispatch::class . '.appointmentTime'); + if ($validate !== true) { + $this->error($validate); + } + + $res = $this->getOrderDispatchService()->updatePlanTime($this->user['id'], $params['order_dispatch_id'], $params['plan_time']); + $this->success('操作成功', $res); + } + /** * 提交上门信息 * @return void