feat: 预约上门时间

This commit is contained in:
苟川东 2025-04-14 16:45:47 +08:00
parent e986fc8dbd
commit e25a2c29ea
3 changed files with 66 additions and 2 deletions

View File

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

View File

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

View File

@ -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'],
];
}