feat: 工作台订单统计接口

This commit is contained in:
gcd 2025-04-03 17:26:53 +08:00
parent e2031cb75b
commit b06ae1a1ae
2 changed files with 41 additions and 6 deletions

View File

@ -31,6 +31,37 @@ class OrderDispatchService extends BaseService
* @param int $pageSize * @param int $pageSize
*/ */
public function workbenchOrderList(int $workerId, string $type, int $pageSize) public function workbenchOrderList(int $workerId, string $type, int $pageSize)
{
$model = $this->getWorkbenchOrderModel($workerId, $type);
$result = $model
->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time'])
->order('id desc')
->paginate($pageSize);
return $result;
}
/**
* 统计工作台订单
* @param int $workerId
* @return array
*/
public function countWorkbenchOrder(int $workerId)
{
return [
'ongoing' => $this->getWorkbenchOrderModel($workerId, 'ongoing')->count(),
'today' => $this->getWorkbenchOrderModel($workerId, 'today')->count(),
'tomorrow' => $this->getWorkbenchOrderModel($workerId, 'tomorrow')->count(),
'all' => $this->getWorkbenchOrderModel($workerId, 'all')->count(),
];
}
/**
* 获取工作台订单模型
* @param int $workerId
* @param string $type
*/
private function getWorkbenchOrderModel(int $workerId, string $type)
{ {
$model = $this->getOrderDispatchModel() $model = $this->getOrderDispatchModel()
->with(['orderInfo' => function ($query) { ->with(['orderInfo' => function ($query) {
@ -66,12 +97,7 @@ class OrderDispatchService extends BaseService
break; break;
} }
$result = $model return $model;
->field(['id', 'order_id', 'status', 'remark', 'create_time', 'plan_time'])
->order('id desc')
->paginate($pageSize);
return $result;
} }
/** /**

View File

@ -36,6 +36,15 @@ class OrderDispatch extends WorkerApi
$this->success('获取成功', $res); $this->success('获取成功', $res);
} }
/**
* 统计工作台订单
*/
public function countWorkbenchOrder()
{
$res = $this->getOrderDispatchService()->countWorkbenchOrder($this->user['id']);
$this->success('获取成功', $res);
}
/** /**
* 接单/拒接 * 接单/拒接
* @return void * @return void