update 第二页物流统计信息接口还是动态查询乡镇订单最多的配送员信息
This commit is contained in:
parent
01e31ae283
commit
18276e8539
@ -119,16 +119,39 @@ class Logistics extends BaseController
|
||||
// 第二页 物流信息统计
|
||||
public function logisticsCount()
|
||||
{
|
||||
$courierId = $this->request->param('courier_id');
|
||||
// 查询镇辖区内配送订单最多的配送员
|
||||
|
||||
// 先从供销系统 查出镇下边的所有配送员-小组服务公司的负责人
|
||||
$serviceGroupCompanyIds = Db::connect('work_task')->name('company')
|
||||
->where(['street'=> $this->streetCode, 'company_type'=>18])
|
||||
->column('id');
|
||||
$userIdList = Db::connect('work_task')->name('user')
|
||||
->whereIn('company_id', $serviceGroupCompanyIds)
|
||||
->where(['group_id'=>5])
|
||||
->column('id');
|
||||
|
||||
// 从物流系统 查物流订单排序 确定谁是 镇辖区内配送订单最多的配送员
|
||||
$topCourier = Db::connect('logistics')->name('logistics')
|
||||
->field(['courier_id','courier_name','COUNT(order_id) AS order_count'])
|
||||
->whereIn('courier_id', $userIdList)
|
||||
->group('courier_id')
|
||||
->order('order_count DESC')
|
||||
->find();
|
||||
// 返查配送员的物流配送订单统计信息
|
||||
// 待取货数
|
||||
$pending_order_count = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->count();
|
||||
$topCourier['pending_order_count'] = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$topCourier['courier_id']])->count();
|
||||
// 配送中数
|
||||
$delivering_order_count = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->count();
|
||||
$topCourier['delivering_order_count'] = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$topCourier['courier_id']])->count();
|
||||
// 已完成数
|
||||
$finished_order_count = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->count();
|
||||
$topCourier['finished_order_count'] = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$topCourier['courier_id']])->count();
|
||||
|
||||
return app('json')->success(compact('pending_order_count', 'delivering_order_count', 'finished_order_count'));
|
||||
// 三轮车车牌号 根据配送员id反查公司id,公司id反查车牌号
|
||||
$courierCompanyId = Db::connect('work_task')->name('user')->where(['id'=>$topCourier['courier_id']])->value('company_id');
|
||||
$vehicleRent = Db::connect('work_task')->name('vehicle_rent')->where(['rent_company_id'=>$courierCompanyId])->find();
|
||||
$topCourier['car_id'] = $vehicleRent['car_id'];
|
||||
$topCourier['car_license'] = $vehicleRent['car_license'];
|
||||
|
||||
return app('json')->success($topCourier);
|
||||
}
|
||||
|
||||
// 第二页 地图 最新的10笔配送订单地址 以及最近一次取货地址发散
|
||||
|
Loading…
x
Reference in New Issue
Block a user