feat: 工作台订单接口
This commit is contained in:
parent
11ec750e49
commit
e2031cb75b
|
|
@ -25,6 +25,55 @@ class OrderDispatchService extends BaseService
|
||||||
->paginate($pageSize);
|
->paginate($pageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $workerId 师傅id
|
||||||
|
* @param string $type 类型:ongoing=进行中,today=当日,tomorrow=昨日,all=全部订单
|
||||||
|
* @param int $pageSize
|
||||||
|
*/
|
||||||
|
public function workbenchOrderList(int $workerId, string $type, int $pageSize)
|
||||||
|
{
|
||||||
|
$model = $this->getOrderDispatchModel()
|
||||||
|
->with(['orderInfo' => function ($query) {
|
||||||
|
$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');
|
||||||
|
}])
|
||||||
|
->where('worker_id', $workerId);
|
||||||
|
|
||||||
|
$status = [
|
||||||
|
OrderDispatch::STATUS_GOTIT,
|
||||||
|
OrderDispatch::STATUS_PLANIT,
|
||||||
|
OrderDispatch::STATUS_CLOCK,
|
||||||
|
];
|
||||||
|
switch ($type) {
|
||||||
|
case 'ongoing':
|
||||||
|
//所有已接单未完成的订单
|
||||||
|
$model->whereIn('status', $status);
|
||||||
|
break;
|
||||||
|
case 'today':
|
||||||
|
$model->whereIn('status', $status);
|
||||||
|
$model->where('plan_time', '>=', date('Y-m-d 00:00:00'));
|
||||||
|
$model->where('plan_time', '<=', date('Y-m-d 23:59:59'));
|
||||||
|
break;
|
||||||
|
case 'tomorrow':
|
||||||
|
$model->whereIn('status', $status);
|
||||||
|
$model->where('plan_time', '>=', date('Y-m-d 00:00:00', strtotime('+1 day')));
|
||||||
|
$model->where('plan_time', '<=', date('Y-m-d 23:59:59', strtotime('+1 day')));
|
||||||
|
break;
|
||||||
|
case 'all':
|
||||||
|
$status[] = OrderDispatch::STATUS_FINISH;
|
||||||
|
$model->whereIn('status', $status);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $model
|
||||||
|
->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time'])
|
||||||
|
->order('id desc')
|
||||||
|
->paginate($pageSize);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 师傅接单/拒接
|
* 师傅接单/拒接
|
||||||
* @param int $workerId 师傅id
|
* @param int $workerId 师傅id
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,24 @@ class OrderDispatch extends WorkerApi
|
||||||
$this->success('获取成功', $res);
|
$this->success('获取成功', $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工作台订单列表
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function workbenchOrderList()
|
||||||
|
{
|
||||||
|
$params = $this->request->request();
|
||||||
|
$validate = $this->validate($params, \app\worker\validate\OrderDispatch::class . '.workbenchOrderList');
|
||||||
|
if ($validate !== true) {
|
||||||
|
$this->error($validate);
|
||||||
|
}
|
||||||
|
|
||||||
|
$pageSize = $this->request->request('page_size', 20);
|
||||||
|
$type = $this->request->request('workbench_type');
|
||||||
|
$res = $this->getOrderDispatchService()->workbenchOrderList($this->user['id'], $type, $pageSize);
|
||||||
|
$this->success('获取成功', $res);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 接单/拒接
|
* 接单/拒接
|
||||||
* @return void
|
* @return void
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ class OrderDispatch extends Validate
|
||||||
protected $rule = [
|
protected $rule = [
|
||||||
'type|确认类型' => 'require|in:accept,reject',
|
'type|确认类型' => 'require|in:accept,reject',
|
||||||
'order_dispatch_id|订单派单id' => 'require|number',
|
'order_dispatch_id|订单派单id' => 'require|number',
|
||||||
|
'workbench_type|工作台类型' => 'require|in:ongoing,today,tomorrow,all',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $message = [
|
protected $message = [
|
||||||
|
|
@ -17,5 +18,6 @@ class OrderDispatch extends Validate
|
||||||
|
|
||||||
protected $scene = [
|
protected $scene = [
|
||||||
'orderConfirm' => ['type', 'order_dispatch_id'],
|
'orderConfirm' => ['type', 'order_dispatch_id'],
|
||||||
|
'workbenchOrderList' => ['workbench_type'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user