diff --git a/app/controller/api/dataview/Logistics.php b/app/controller/api/dataview/Logistics.php index c94e5015..7e3e6a19 100755 --- a/app/controller/api/dataview/Logistics.php +++ b/app/controller/api/dataview/Logistics.php @@ -3,6 +3,7 @@ namespace app\controller\api\dataview; use app\common\model\Company; +use app\common\model\store\order\StoreOrderProduct; use app\common\repositories\BaseRepository; use crmeb\basic\BaseController; use think\App; @@ -126,6 +127,9 @@ class Logistics extends BaseController ->where(['area'=> $this->areaCode, 'company_type'=>18]) ->column('id'); + if (empty($serviceGroupCompanyIds)) { + return app('json')->success($list); + } $userIdList = Db::connect('work_task')->name('user') ->whereIn('company_id', $serviceGroupCompanyIds) ->where(['group_id'=>5]) @@ -139,10 +143,15 @@ class Logistics extends BaseController ->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(); + if (empty($vehicleRent)) { + continue; + } $topCourier['id'] = $vehicleRent['car_id']; $topCourier['license'] = $vehicleRent['car_license']; $topCourier['area_code'] = $courier['area']; @@ -305,6 +314,10 @@ class Logistics extends BaseController $query->whereBetween('ps_time', [$startTime, $endTime]); })->count(); } + foreach ($list as &$item) { + $item['product_name'] = StoreOrderProduct::alias('o')->join('store_product p', 'o.product_id=p.product_id')->where('o.order_id', $item['order_id'])->value('p.store_name'); + } + unset($item); return app('json')->success(compact('count', 'list')); } } \ No newline at end of file