update 首页三轮车列表-返回每个乡镇订单最多的三轮车。第二页物流统计信息接口根据列表接口的配送员id-courier_id直接查统计数据
This commit is contained in:
parent
b72d791ff9
commit
01e31ae283
@ -23,32 +23,64 @@ class Logistics extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 三轮车列表 从供销系统获取
|
// 三轮车列表 每个乡镇订单最多的配送员的三轮车
|
||||||
public function vehicleList()
|
public function vehicleList()
|
||||||
{
|
{
|
||||||
// 镇区域码为空,查区县的公司
|
// 查区县的镇农科公司
|
||||||
if (empty($this->streetCode)) {
|
$list = [];
|
||||||
$companyList = Db::connect('work_task')->name('company')->where('area', $this->areaCode)->select()->toArray();
|
$companyList = Db::connect('work_task')->name('company')->where(['area' => $this->areaCode, 'company_type'=>41])->select()->toArray();
|
||||||
} else {
|
|
||||||
$companyList = Db::connect('work_task')->name('company')->where('street', $this->streetCode)->select()->toArray();
|
foreach ($companyList as $company) {
|
||||||
|
// 先从供销系统 查出镇下边的所有配送员-小组服务公司的负责人
|
||||||
|
$serviceGroupCompanyIds = Db::connect('work_task')->name('company')
|
||||||
|
->where(['street'=> $company['street'], '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();
|
||||||
|
// 小组公司没有配送员或是没有三轮车
|
||||||
|
if (empty($topCourier)) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
$companyIds = array_column($companyList, 'id');
|
|
||||||
|
// 三轮车车牌号 根据配送员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;
|
||||||
|
}
|
||||||
|
|
||||||
// 查镇车辆列表
|
// 查镇车辆列表
|
||||||
$list = Db::connect('work_task')->name('vehicle_rent')
|
// $list = Db::connect('work_task')->name('vehicle_rent')
|
||||||
->field('company_id, car_id as id, car_license as license')
|
// ->field('company_id, car_id as id, car_license as license')
|
||||||
->append(['area_code','street_code'])
|
// ->append(['area_code','street_code'])
|
||||||
->whereIn('company_id', $companyIds)
|
// ->whereIn('company_id', $companyIds)
|
||||||
->where('status','in','0,1,2')
|
// ->where('status','in','0,1,2')
|
||||||
->withAttr('area_code', function ($value, $data){
|
// ->withAttr('area_code', function ($value, $data){
|
||||||
$company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find();
|
// $company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find();
|
||||||
return $company['area'];
|
// return $company['area'];
|
||||||
})
|
// })
|
||||||
->withAttr('street_code', function ($value, $data){
|
// ->withAttr('street_code', function ($value, $data){
|
||||||
$company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find();
|
// $company = Db::connect('work_task')->name('company')->where('id', $data['company_id'])->find();
|
||||||
return $company['street'];
|
// return $company['street'];
|
||||||
})
|
// })
|
||||||
->group('company_id')
|
// ->group('company_id')
|
||||||
->select()->toArray();
|
// ->select()->toArray();
|
||||||
|
|
||||||
$count = count($list);
|
$count = count($list);
|
||||||
return app('json')->success(compact('count', 'list'));
|
return app('json')->success(compact('count', 'list'));
|
||||||
@ -87,38 +119,24 @@ class Logistics extends BaseController
|
|||||||
// 第二页 物流信息统计
|
// 第二页 物流信息统计
|
||||||
public function logisticsCount()
|
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();
|
|
||||||
// 返查配送员的物流配送订单统计信息
|
|
||||||
// 待取货数
|
// 待取货数
|
||||||
$topCourier['pending_order_count'] = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$topCourier['courier_id']])->count();
|
$pending_order_count = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$courierId])->count();
|
||||||
// 配送中数
|
// 配送中数
|
||||||
$topCourier['delivering_order_count'] = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$topCourier['courier_id']])->count();
|
$delivering_order_count = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id'=>$courierId])->count();
|
||||||
// 已完成数
|
// 已完成数
|
||||||
$topCourier['finished_order_count'] = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$topCourier['courier_id']])->count();
|
$finished_order_count = Db::connect('logistics')->name('logistics')->where([['status', 'in', [2,3]], 'courier_id'=>$courierId])->count();
|
||||||
|
|
||||||
// 三轮车车牌号 根据配送员id反查公司id,公司id反查车牌号
|
return app('json')->success(compact('pending_order_count', 'delivering_order_count', 'finished_order_count'));
|
||||||
$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笔配送订单地址 以及最近一次取货地址发散
|
||||||
|
public function logisticsMapCount()
|
||||||
|
{
|
||||||
|
$courierId = $this->request->param('courier_id');
|
||||||
|
// 最近一次取货地址 最新一笔的配送中订单的取货地址
|
||||||
|
Db::connect('work_task')->name('vehicle_rent');
|
||||||
|
// 最新的10笔订单
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user