feat: 师傅拒接支持填写原因

This commit is contained in:
苟川东 2025-04-19 23:44:07 +08:00
parent ebe4f9549a
commit 6b6fb2cf86
4 changed files with 60 additions and 8 deletions

View File

@ -18,4 +18,14 @@ class OrderDispatch extends Model
{
return $this->belongsTo(Order::class,'order_id', 'id');
}
public function getArriveImagesAttr($val)
{
$images = explode(',', $val);
foreach ($images as $k => $v) {
$images[$k] = cdnurl($v, true);
}
return $images;
}
}

View File

@ -103,12 +103,14 @@ class OrderDispatchService extends BaseService
/**
* 师傅接单/拒接
* @param int $workerId 师傅id
* @param int $orderDispatchId 派单id
* @param string $type 类型accept=接单,reject=拒接
* @param array $params 请求参数
* @return true
*/
public function orderConfirm(int $workerId, int $orderDispatchId, string $type)
public function orderConfirm(int $workerId, array $params)
{
$orderDispatchId = $params['order_dispatch_id'];
$type = $params['type'];
$orderDispatch = $this->getOrderDispatchModel()
->where('worker_id', $workerId)
->where('id', $orderDispatchId)
@ -128,6 +130,15 @@ class OrderDispatchService extends BaseService
try {
//接单
$orderDispatch->status = $orderDispatchStatus;
//拒接原因
if ($type == 'reject') {
if (empty($params['reject_reason'])) {
$this->apiError('请输入拒接原因');
}
$orderDispatch->reject_reason = $params['reject_reason'];
}
$orderDispatch->save();
$orderDispatchChangeParams = [
@ -173,15 +184,45 @@ class OrderDispatchService extends BaseService
*/
public function dispatchInfo(int $workerId, int $orderDispatchId)
{
$orderFields = [
'id',
'order_no',
'item_id',
'item_title',
'receive_type',
'address',
'lng',
'lat',
'plan_time',
'online_amount',
'discount_amount',
'area_id',
'customer',
'tel',
];
$orderDispatchFields = [
'id',
'order_id',
'status',
'remark',
'create_time',
'total',
'online_total',
'is_receipt',
'plan_time',
'reject_reason',
'arrive_images',
'arrive_time',
];
$res = $this->getOrderDispatchModel()
->with(['orderInfo' => function ($query) {
->with(['orderInfo' => function ($query) use ($orderFields) {
$query->with(['area' => function ($query) {
$query->field('id,area_code,merge_name');
}])->field('id,order_no,item_id,item_title,receive_type,address,lng,lat,plan_time,online_amount,discount_amount,area_id,customer,tel');
}])->field($orderFields);
}])
->where('id', $orderDispatchId)
->where('worker_id', $workerId)
->field(['id', 'order_id', 'status', 'remark', 'create_time', 'total', 'online_total', 'is_receipt', 'plan_time'])
->field($orderDispatchFields)
->find();
if (!$res) {
$this->apiError('订单不存在');

View File

@ -73,7 +73,7 @@ class OrderDispatch extends WorkerApi
$this->error($validate);
}
$res = $this->getOrderDispatchService()->orderConfirm($this->user['id'], $params['order_dispatch_id'], $params['type']);
$res = $this->getOrderDispatchService()->orderConfirm($this->user['id'], $params);
$this->success('操作成功', $res);
}

View File

@ -18,6 +18,7 @@ class OrderDispatch extends Validate
'amount|收款金额' => 'require|number|between:0,10000000',
'payment_image|收款图片' => 'require|max:255',
'offline_total_type|尾款收款方' => 'in:1,2',
'reject_reason|拒接原因' => 'max:255',
];
protected $message = [
@ -25,7 +26,7 @@ class OrderDispatch extends Validate
];
protected $scene = [
'orderConfirm' => ['type', 'order_dispatch_id'],
'orderConfirm' => ['type', 'order_dispatch_id', 'reject_reason'],
'workbenchOrderList' => ['workbench_type'],
'info' => ['order_dispatch_id'],
'appointmentTime' => ['order_dispatch_id', 'plan_time'],