三轮车物流详情空指针兼容
This commit is contained in:
parent
8fb6427a6b
commit
3a485e846d
@ -148,17 +148,24 @@ class Logistics extends BaseController
|
||||
// 第二页 物流信息统计
|
||||
public function logisticsCount()
|
||||
{
|
||||
$topCourier = [];
|
||||
|
||||
// 查询镇辖区内配送订单最多的配送员
|
||||
|
||||
// 先从供销系统 查出镇下边的所有配送员-小组服务公司的负责人
|
||||
$serviceGroupCompanyIds = Db::connect('work_task')->name('company')
|
||||
->where(['street'=> $this->streetCode, 'company_type'=>18])
|
||||
->column('id');
|
||||
if (empty($serviceGroupCompanyIds)) {
|
||||
return app('json')->success($topCourier);
|
||||
}
|
||||
$userIdList = Db::connect('work_task')->name('user')
|
||||
->whereIn('company_id', $serviceGroupCompanyIds)
|
||||
->where(['group_id'=>5])
|
||||
->column('id');
|
||||
|
||||
if (empty($userIdList)) {
|
||||
return app('json')->success($topCourier);
|
||||
}
|
||||
// 从物流系统 查物流订单排序 确定谁是 镇辖区内配送订单最多的配送员
|
||||
$topCourier = Db::connect('logistics')->name('logistics')
|
||||
->field(['courier_id','courier_name','COUNT(order_id) AS order_count'])
|
||||
@ -166,6 +173,17 @@ class Logistics extends BaseController
|
||||
->group('courier_id')
|
||||
->order('order_count DESC')
|
||||
->find();
|
||||
|
||||
if (!empty($userIdList) && empty($topCourier)) {
|
||||
$user = Db::connect('work_task')->name('user')->where('id', $userIdList[0])->find();
|
||||
$topCourier['courier_id'] = $user['id'];
|
||||
$topCourier['courier_name'] = $user['nickname'];
|
||||
$topCourier['order_count'] = 0;
|
||||
}
|
||||
|
||||
if (empty($topCourier)) {
|
||||
return app('json')->success($topCourier);
|
||||
}
|
||||
// 返查配送员的物流配送订单统计信息
|
||||
// 待取货数
|
||||
$topCourier['pending_order_count'] = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$topCourier['courier_id']])->count();
|
||||
|
Loading…
x
Reference in New Issue
Block a user