物流大屏-三轮车订单排行榜

This commit is contained in:
chenbo 2024-01-02 13:58:45 +08:00
parent 16546484cd
commit 836630a8e4
2 changed files with 40 additions and 0 deletions

View File

@ -115,6 +115,44 @@ class Logistics extends BaseController
return app('json')->success(compact('count', 'list'));
}
// 三轮车订单排行榜
public function vehicleOrderRanking()
{
// 查区县的镇农科公司
$list = [];
// 先从供销系统 查出镇下边的所有配送员-小组服务公司的负责人
$serviceGroupCompanyIds = Db::connect('work_task')->name('company')
->where(['area'=> $this->areaCode, 'company_type'=>18])
->column('id');
$userIdList = Db::connect('work_task')->name('user')
->whereIn('company_id', $serviceGroupCompanyIds)
->where(['group_id'=>5])
->field('id, nickname')->select()->toArray();
// 从物流系统 查物流订单排序
$topCourierList = Db::connect('logistics')->name('logistics')
->field(['courier_id','courier_name','COUNT(order_id) AS order_count'])
->whereIn('courier_id', array_column($userIdList, 'id'))
->group('courier_id')
->order('order_count DESC')
->select();
foreach ($topCourierList as $topCourier) {
// 三轮车车牌号 根据配送员id反查公司id公司id反查车牌号
$courier = Db::connect('work_task')->name('user')->where(['id'=>$topCourier['courier_id']])->find();
$vehicleRent = Db::connect('work_task')->name('vehicle_rent')->where(['rent_company_id'=>$courier['company_id']])->find();
$topCourier['id'] = $vehicleRent['car_id'];
$topCourier['license'] = $vehicleRent['car_license'];
$topCourier['area_code'] = $courier['area'];
$topCourier['street_code'] = $courier['street'];
$list[] = $topCourier;
}
return app('json')->success($list);
}
// 镇级最新物流配送详情
public function latestLogistics()
{

View File

@ -766,6 +766,8 @@ Route::group('api/', function () {
Route::get('logistics_count', 'Logistics/logisticsCount');
Route::get('logistics_map_count', 'Logistics/logisticsMapCount');
Route::get('logistics_list', 'Logistics/logisticsList');
Route::get('vehicle_order_ranking', 'Logistics/vehicleOrderRanking');
/**---------------------物流溯源监控大屏api---------------------- end **/