From d305a9f252208ebcd33b34e4b5e39baca0da7efc Mon Sep 17 00:00:00 2001 From: unknown <736250432@qq.com> Date: Thu, 31 Aug 2023 18:56:12 +0800 Subject: [PATCH] update --- app/api/controller/VehicleController.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/api/controller/VehicleController.php b/app/api/controller/VehicleController.php index 15ce11399..368674439 100644 --- a/app/api/controller/VehicleController.php +++ b/app/api/controller/VehicleController.php @@ -298,21 +298,23 @@ class VehicleController extends BaseApiController } })->toArray(); //获取该公司已签约的小组服务公司数量 - $villageCompany = Contract::where('party_a',$company['id'])->where('signing_timer',2)->select(); + $villageCompany = Contract::field('id')->where('party_a',$company['id'])->where('signing_timer',2)->count(); //系统车辆数量 - $rentCar = VehicleRent::field('id')->where('type',0)->select(); - //可租赁车辆 - $canRentCar = VehicleRent::field('id')->where('type',0)->where('status',0)->select(); + $rentCar = VehicleRent::field('id')->where('company_id',$company['id'])->where('type',0)->count(); + //申请中的车辆 + $applyCar = VehicleContract::field('num')->where('company_b_id',$company['id'])->where('status','in','-1,0,1,2,')->sum('num'); //自有车辆数量 - $selfCar = VehicleRent::field('id')->where('type',1)->select(); + $selfCar = VehicleRent::field('id')->where('company_id',$company['id'])->where('type',1)->count(); + //可在租车辆 + $doubleRentCar = $villageCompany - $rentCar - $applyCar - $selfCar; //设置数据 $data = [ 'apply' => $vehicleContract, 'car_list' => $vehicleRentCars, - 'monitor_num' => $villageCompany->count(), - 'rent_num' => $rentCar->count(), - 'can_rent_num' => $canRentCar->count(), - 'self_num' => $selfCar->count(), + 'monitor_num' => $villageCompany, + 'rent_num' => $rentCar, + 'can_rent_num' => intval($doubleRentCar), + 'self_num' => $selfCar, ]; //返回 return $this->success('请求成功',$data);