feat: 提交上门信息接口

This commit is contained in:
苟川东 2025-04-17 16:20:13 +08:00
parent 04dd0ac106
commit cfb91dc2aa

View File

@ -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;
}
}