feat: 工作台页面调整

This commit is contained in:
苟川东 2025-05-09 11:47:45 +08:00
parent 4066e74c1e
commit d3df3a1d41
3 changed files with 41 additions and 31 deletions

View File

@ -26,13 +26,15 @@ class OrderDispatchService extends BaseService
} }
/** /**
* 工作台列表
* @param int $workerId 师傅id * @param int $workerId 师傅id
* @param string $type 类型pending=待沟通,need_visit=待上门,ongoing=服务中,finished=已完成 * @param string $type 类型pending=待沟通,need_visit=待上门,ongoing=服务中,finished=已完成
* @param string $needVisitType 待上门类型today=今日,tomorrow=明日,all=全部
* @param int $pageSize * @param int $pageSize
*/ */
public function workbenchOrderList(int $workerId, string $type, int $pageSize) public function workbenchOrderList(int $workerId, string $type, int $pageSize, string $needVisitType)
{ {
$model = $this->getWorkbenchOrderModel($workerId, $type); $model = $this->getWorkbenchOrderModel($workerId, $type, $needVisitType);
$result = $model $result = $model
->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time']) ->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time'])
->order('id desc') ->order('id desc')
@ -49,10 +51,13 @@ class OrderDispatchService extends BaseService
public function countWorkbenchOrder(int $workerId) public function countWorkbenchOrder(int $workerId)
{ {
return [ return [
'pending' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(), 'pending' => $this->getWorkbenchOrderModel($workerId, 'pending')->count(),
'need_visit' => $this->getWorkbenchOrderModel($workerId, 'today')->count(), 'need_visit' => $this->getWorkbenchOrderModel($workerId, 'need_visit')->count(),
'ongoing' => $this->getWorkbenchOrderModel($workerId, 'tomorrow')->count(), 'ongoing' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(),
'finished' => $this->getWorkbenchOrderModel($workerId, 'all')->count(), 'finished' => $this->getWorkbenchOrderModel($workerId, 'finished')->count(),
'today' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'today')->count(),
'tomorrow' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'tomorrow')->count(),
'all' => $this->getWorkbenchOrderModel($workerId, 'need_visit', 'all')->count(),
]; ];
} }
@ -60,8 +65,9 @@ class OrderDispatchService extends BaseService
* 获取工作台订单模型 * 获取工作台订单模型
* @param int $workerId * @param int $workerId
* @param string $type * @param string $type
* @param string $needVisitType
*/ */
private function getWorkbenchOrderModel(int $workerId, string $type) private function getWorkbenchOrderModel(int $workerId, string $type, string $needVisitType = '')
{ {
$model = $this->getOrderDispatchModel() $model = $this->getOrderDispatchModel()
->with(['orderInfo' => function ($query) { ->with(['orderInfo' => function ($query) {
@ -71,30 +77,32 @@ class OrderDispatchService extends BaseService
}]) }])
->where('worker_id', $workerId); ->where('worker_id', $workerId);
$status = [
OrderDispatch::STATUS_GOTIT,
OrderDispatch::STATUS_PLANIT,
OrderDispatch::STATUS_CLOCK,
];
switch ($type) { switch ($type) {
case 'ongoing': case 'pending':
//所有已接单未完成的订单 //待沟通
$model->whereIn('status', $status); $model->where('status', OrderDispatch::STATUS_GOTIT);
break; break;
case 'need_visit':
//待上门
$model->where('status', OrderDispatch::STATUS_PLANIT);
switch ($needVisitType) {
case 'today': 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 00:00:00'));
$model->where('plan_time', '<=', date('Y-m-d 23:59:59')); $model->where('plan_time', '<=', date('Y-m-d 23:59:59'));
break; break;
case 'tomorrow': 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 00:00:00', strtotime('+1 day')));
$model->where('plan_time', '<=', date('Y-m-d 23:59:59', strtotime('+1 day'))); $model->where('plan_time', '<=', date('Y-m-d 23:59:59', strtotime('+1 day')));
break; break;
case 'all': }
$status[] = OrderDispatch::STATUS_REFUSED; break;
$status[] = OrderDispatch::STATUS_FINISH; case 'ongoing':
$model->whereIn('status', $status); //服务中
$model->where('status', OrderDispatch::STATUS_CLOCK);
break;
case 'finished':
//已完成
$model->where('status', OrderDispatch::STATUS_FINISH);
break; break;
} }

View File

@ -48,7 +48,8 @@ class OrderDispatch extends WorkerApi
$pageSize = $this->request->request('page_size', 20); $pageSize = $this->request->request('page_size', 20);
$type = $this->request->request('workbench_type'); $type = $this->request->request('workbench_type');
$res = $this->getOrderDispatchService()->workbenchOrderList($this->user['id'], $type, $pageSize); $needVisitType = $this->request->request('need_visit_type');
$res = $this->getOrderDispatchService()->workbenchOrderList($this->user['id'], $type, $pageSize, $needVisitType);
$this->success('获取成功', $res); $this->success('获取成功', $res);
} }

View File

@ -9,7 +9,8 @@ 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', 'workbench_type|工作台类型' => 'require|in:pending,need_visit,ongoing,finished',
'need_visit_type|待上门类型' => 'require|in:today,tomorrow,all',
'plan_time|预约时间' => 'require|date', 'plan_time|预约时间' => 'require|date',
'images|上门图片' => 'require|max:3000', 'images|上门图片' => 'require|max:3000',
@ -30,7 +31,7 @@ class OrderDispatch extends Validate
protected $scene = [ protected $scene = [
'orderConfirm' => ['type', 'order_dispatch_id', 'reject_reason'], 'orderConfirm' => ['type', 'order_dispatch_id', 'reject_reason'],
'workbenchOrderList' => ['workbench_type'], 'workbenchOrderList' => ['workbench_type', 'need_visit_type'],
'info' => ['order_dispatch_id'], 'info' => ['order_dispatch_id'],
'appointmentTime' => ['order_dispatch_id', 'plan_time'], 'appointmentTime' => ['order_dispatch_id', 'plan_time'],
'arrivedOnSite' => ['order_dispatch_id', 'images'], 'arrivedOnSite' => ['order_dispatch_id', 'images'],