diff --git a/application/services/OrderDispatchService.php b/application/services/OrderDispatchService.php index 23ddf93..64fb368 100644 --- a/application/services/OrderDispatchService.php +++ b/application/services/OrderDispatchService.php @@ -245,6 +245,9 @@ class OrderDispatchService extends BaseService 'image', 'finish_time', 'offline_total_type', + 'is_finish_today', + 'estimated_finish_time', + 'work_progress', ]; $res = $this->getOrderDispatchModel() ->with(['orderInfo' => function ($query) use ($orderFields) { @@ -431,6 +434,21 @@ class OrderDispatchService extends BaseService return true; } + + public function updateProgress(int $workerId, array $params) + { + $orderDispatch = $this->getOrderDispatchInfo($workerId, $params['order_dispatch_id']); + $orderDispatch->is_finish_today = $params['is_finish_today']; + $orderDispatch->estimated_finish_time = $params['estimated_finish_time']; + + if ($params['is_finish_today'] == 0) { + $orderDispatch->work_progress = $params['work_progress']; + } + + $orderDispatch->save(); + + return true; + } } diff --git a/application/worker/controller/OrderDispatch.php b/application/worker/controller/OrderDispatch.php index 5e9f151..7aec6cd 100644 --- a/application/worker/controller/OrderDispatch.php +++ b/application/worker/controller/OrderDispatch.php @@ -94,6 +94,22 @@ class OrderDispatch extends WorkerApi $this->success('操作成功', $res); } + /** + * 更新施工进度 + * @return void + */ + public function updateProgress() + { + $params = $this->request->request(); + $validate = $this->validate($params, \app\worker\validate\OrderDispatch::class . '.updateProgress'); + if ($validate !== true) { + $this->error($validate); + } + + $res = $this->getOrderDispatchService()->updateProgress($this->user['id'], $params); + $this->success('操作成功', $res); + } + /** * 修改上门时间 * @return void diff --git a/application/worker/validate/OrderDispatch.php b/application/worker/validate/OrderDispatch.php index 95e8039..4e5553e 100644 --- a/application/worker/validate/OrderDispatch.php +++ b/application/worker/validate/OrderDispatch.php @@ -23,6 +23,10 @@ class OrderDispatch extends Validate 'reject_reason|拒接原因' => 'max:100', 'worker_remark|备注信息' => 'max:500', + + 'is_finish_today|今日完成' => 'require|in:0,1', + 'estimated_finish_time|完成时间' => 'require|date', + 'work_progress|当前施工进度' => 'max:200', ]; protected $message = [ @@ -37,5 +41,6 @@ class OrderDispatch extends Validate 'arrivedOnSite' => ['order_dispatch_id', 'images'], 'completeService' => ['order_dispatch_id', 'complete_images', 'offline_total_type', 'amount', 'payment_image', 'offline_total_type'], 'saveWorkerRemark' => ['order_dispatch_id', 'worker_remark'], + 'updateProgress' => ['order_dispatch_id', 'is_finish_today', 'estimated_finish_time', 'work_progress'], ]; }