feat: 师傅拒接支持填写原因
This commit is contained in:
parent
ebe4f9549a
commit
6b6fb2cf86
|
|
@ -18,4 +18,14 @@ class OrderDispatch extends Model
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Order::class,'order_id', 'id');
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,12 +103,14 @@ class OrderDispatchService extends BaseService
|
||||||
/**
|
/**
|
||||||
* 师傅接单/拒接
|
* 师傅接单/拒接
|
||||||
* @param int $workerId 师傅id
|
* @param int $workerId 师傅id
|
||||||
* @param int $orderDispatchId 派单id
|
* @param array $params 请求参数
|
||||||
* @param string $type 类型:accept=接单,reject=拒接
|
|
||||||
* @return true
|
* @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()
|
$orderDispatch = $this->getOrderDispatchModel()
|
||||||
->where('worker_id', $workerId)
|
->where('worker_id', $workerId)
|
||||||
->where('id', $orderDispatchId)
|
->where('id', $orderDispatchId)
|
||||||
|
|
@ -128,6 +130,15 @@ class OrderDispatchService extends BaseService
|
||||||
try {
|
try {
|
||||||
//接单
|
//接单
|
||||||
$orderDispatch->status = $orderDispatchStatus;
|
$orderDispatch->status = $orderDispatchStatus;
|
||||||
|
|
||||||
|
//拒接原因
|
||||||
|
if ($type == 'reject') {
|
||||||
|
if (empty($params['reject_reason'])) {
|
||||||
|
$this->apiError('请输入拒接原因');
|
||||||
|
}
|
||||||
|
$orderDispatch->reject_reason = $params['reject_reason'];
|
||||||
|
}
|
||||||
|
|
||||||
$orderDispatch->save();
|
$orderDispatch->save();
|
||||||
|
|
||||||
$orderDispatchChangeParams = [
|
$orderDispatchChangeParams = [
|
||||||
|
|
@ -173,15 +184,45 @@ class OrderDispatchService extends BaseService
|
||||||
*/
|
*/
|
||||||
public function dispatchInfo(int $workerId, int $orderDispatchId)
|
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()
|
$res = $this->getOrderDispatchModel()
|
||||||
->with(['orderInfo' => function ($query) {
|
->with(['orderInfo' => function ($query) use ($orderFields) {
|
||||||
$query->with(['area' => function ($query) {
|
$query->with(['area' => function ($query) {
|
||||||
$query->field('id,area_code,merge_name');
|
$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('id', $orderDispatchId)
|
||||||
->where('worker_id', $workerId)
|
->where('worker_id', $workerId)
|
||||||
->field(['id', 'order_id', 'status', 'remark', 'create_time', 'total', 'online_total', 'is_receipt', 'plan_time'])
|
->field($orderDispatchFields)
|
||||||
->find();
|
->find();
|
||||||
if (!$res) {
|
if (!$res) {
|
||||||
$this->apiError('订单不存在');
|
$this->apiError('订单不存在');
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ class OrderDispatch extends WorkerApi
|
||||||
$this->error($validate);
|
$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);
|
$this->success('操作成功', $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ class OrderDispatch extends Validate
|
||||||
'amount|收款金额' => 'require|number|between:0,10000000',
|
'amount|收款金额' => 'require|number|between:0,10000000',
|
||||||
'payment_image|收款图片' => 'require|max:255',
|
'payment_image|收款图片' => 'require|max:255',
|
||||||
'offline_total_type|尾款收款方' => 'in:1,2',
|
'offline_total_type|尾款收款方' => 'in:1,2',
|
||||||
|
'reject_reason|拒接原因' => 'max:255',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $message = [
|
protected $message = [
|
||||||
|
|
@ -25,7 +26,7 @@ class OrderDispatch extends Validate
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $scene = [
|
protected $scene = [
|
||||||
'orderConfirm' => ['type', 'order_dispatch_id'],
|
'orderConfirm' => ['type', 'order_dispatch_id', 'reject_reason'],
|
||||||
'workbenchOrderList' => ['workbench_type'],
|
'workbenchOrderList' => ['workbench_type'],
|
||||||
'info' => ['order_dispatch_id'],
|
'info' => ['order_dispatch_id'],
|
||||||
'appointmentTime' => ['order_dispatch_id', 'plan_time'],
|
'appointmentTime' => ['order_dispatch_id', 'plan_time'],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user