购买车辆数量bug修复

This commit is contained in:
weiz 2023-10-19 10:10:17 +08:00
parent ad93d3f05c
commit 43802d4b23

View File

@ -32,8 +32,13 @@ class VehicleController extends BaseApiController
//购买车辆数量
//获取下面的小组服务公司
$villageCompanys = Contract::field('party_b')->where('party_a',$this->userInfo['company_id'])->where('signing_timer',2)->select()->toArray();
$villageCompanys_ids = array_column($villageCompanys,'party_b');
$buyCar = VehicleContract::field('id')->where('company_b_id','in',$villageCompanys_ids)->where('type',3)->where('status','in','-1,0,1,2,3')->count();
$buyCar = 0;
foreach ($villageCompanys as $v) {
$aa = VehicleContract::field('id')->where('company_b_id',$v['party_b'])->where('type',3)->where('status','in','-1,0,1,2,3')->findOrEmpty();
if(!$aa->isEmpty()){
$buyCar += 1;
}
}
//可在租车辆
$doubleRentCar = max($villageCompany - $rentCar - $applyCar - $selfCar - $buyCar,0);
if($params['num'] > $doubleRentCar ){
@ -410,8 +415,13 @@ class VehicleController extends BaseApiController
//购买车辆数量
//获取下面的小组服务公司
$villageCompanys = Contract::field('party_b')->where('party_a',$company['id'])->where('signing_timer',2)->select()->toArray();
$villageCompanys_ids = array_column($villageCompanys,'party_b');
$buyCar = VehicleContract::field('id')->where('company_b_id','in',$villageCompanys_ids)->where('type',3)->where('status','in','-1,0,1,2,3')->count();
$buyCar = 0;
foreach ($villageCompanys as $v) {
$aa = VehicleContract::field('id')->where('company_b_id',$v['party_b'])->where('type',3)->where('status','in','-1,0,1,2,3')->findOrEmpty();
if(!$aa->isEmpty()){
$buyCar += 1;
}
}
//可在租车辆
$doubleRentCar = max($villageCompany - $rentCar - $applyCar - $selfCar - $buyCar,0);
//设置数据