From 12f73c0934015a5dc3d373ded27217b66dc7c84c Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Fri, 22 Dec 2023 14:28:51 +0800 Subject: [PATCH] =?UTF-8?q?=E9=95=87=E5=86=9C=E7=A7=91=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E4=B8=89=E8=BD=AE=E7=AD=96=E5=88=92=E5=88=97=E8=A1=A8=E5=81=9A?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/dataview/Logistics.php | 28 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/app/controller/api/dataview/Logistics.php b/app/controller/api/dataview/Logistics.php index 7bb44361..d5ecf841 100755 --- a/app/controller/api/dataview/Logistics.php +++ b/app/controller/api/dataview/Logistics.php @@ -37,26 +37,39 @@ class Logistics extends BaseController { // 查区县的镇农科公司 $list = []; - $companyList = Db::connect('work_task')->name('company')->where(['area' => $this->areaCode, 'company_type'=>41])->select()->toArray(); + $companyList = Db::connect('work_task')->name('company')->where('id', 69)->where(['area' => $this->areaCode, 'company_type'=>41])->select()->toArray(); foreach ($companyList as $company) { // 先从供销系统 查出镇下边的所有配送员-小组服务公司的负责人 $serviceGroupCompanyIds = Db::connect('work_task')->name('company') ->where(['street'=> $company['street'], 'company_type'=>18]) ->column('id'); - + if (empty($serviceGroupCompanyIds)) { + continue; + } $userIdList = Db::connect('work_task')->name('user') ->whereIn('company_id', $serviceGroupCompanyIds) ->where(['group_id'=>5]) - ->column('id'); + ->field('id, nickname')->select()->toArray(); + + if (empty($userIdList)) { + continue; + } // 从物流系统 查物流订单排序 确定谁是 镇辖区内配送订单最多的配送员 $topCourier = Db::connect('logistics')->name('logistics') ->field(['courier_id','courier_name','COUNT(order_id) AS order_count']) - ->whereIn('courier_id', $userIdList) + ->whereIn('courier_id', array_column($userIdList, 'id')) ->group('courier_id') ->order('order_count DESC') ->find(); + + if (!empty($userIdList) && empty($topCourier)) { + $topCourier['courier_id'] = $userIdList[0]['id']; + $topCourier['courier_name'] = $userIdList[0]['nickname']; + $topCourier['order_count'] = 0; + } + // 小组公司没有配送员或是没有三轮车 if (empty($topCourier)) { continue; @@ -65,8 +78,15 @@ class Logistics extends BaseController // 三轮车车牌号 根据配送员id反查公司id,公司id反查车牌号 $courier = Db::connect('work_task')->name('user')->where(['id'=>$topCourier['courier_id']])->find(); + if (empty($courier)) { + continue; + } $vehicleRent = Db::connect('work_task')->name('vehicle_rent')->where(['rent_company_id'=>$courier['company_id']])->find(); + if (empty($vehicleRent)) { + continue; + } + $topCourier['id'] = $vehicleRent['car_id']; $topCourier['license'] = $vehicleRent['car_license']; $topCourier['area_code'] = $courier['area'];