Merge pull request 'update' (#82) from zhangwei into master

Reviewed-on: http://git.excellentkk.cn/mkm/TaskSystem/pulls/82
This commit is contained in:
wei1990 2023-08-31 19:20:50 +08:00
commit d81416c6e0

View File

@ -22,6 +22,19 @@ class VehicleController extends BaseApiController
if(empty($params['num'])){
return $this->fail('缺少必要参数');
}
//获取该公司已签约的小组服务公司数量
$villageCompany = Contract::field('id')->where('party_a',$this->userInfo['company_id'])->where('signing_timer',2)->count();
//系统车辆数量
$rentCar = VehicleRent::field('id')->where('company_id',$this->userInfo['company_id'])->where('type',0)->count();
//申请中的车辆
$applyCar = VehicleContract::field('num')->where('company_b_id',$this->userInfo['company_id'])->where('status','in','-1,0,1,2')->sum('num');
//自有车辆数量
$selfCar = VehicleRent::field('id')->where('company_id',$this->userInfo['company_id'])->where('type',1)->count();
//可在租车辆
$doubleRentCar = $villageCompany - $rentCar - $applyCar - $selfCar;
if($params['num'] > $doubleRentCar ){
return $this->fail('数量超过可再租车辆数');
}
//查找乙方公司信息
$party_b = Company::field('id,company_name,organization_code,master_name,master_phone,master_email,company_type')->where('id',$this->userInfo['company_id'])->find();
if(empty($party_b)) {
@ -302,7 +315,7 @@ class VehicleController extends BaseApiController
//系统车辆数量
$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');
$applyCar = VehicleContract::field('num')->where('company_b_id',$company['id'])->where('status','in','-1,0,1,2')->sum('num');
//自有车辆数量
$selfCar = VehicleRent::field('id')->where('company_id',$company['id'])->where('type',1)->count();
//可在租车辆