Merge pull request 'update' (#120) from zhangwei into dev
Reviewed-on: #120
This commit is contained in:
commit
c5f35f6532
@ -21,16 +21,21 @@ class VehicleController extends BaseApiController
|
|||||||
if(empty($params['num'])){
|
if(empty($params['num'])){
|
||||||
return $this->fail('缺少必要参数');
|
return $this->fail('缺少必要参数');
|
||||||
}
|
}
|
||||||
//获取该公司已签约的小组服务公司数量
|
//获取该公司已签约的小组服务公司数量
|
||||||
$villageCompany = Contract::field('id')->where('party_a',$this->userInfo['company_id'])->where('signing_timer',2)->count();
|
$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','<>', 1)->count();
|
$rentCar = VehicleRent::field('id')->where('company_id',$this->userInfo['company_id'])->whereNotIn('type','1,2')->count();
|
||||||
//申请中的车辆
|
//申请中的车辆
|
||||||
$applyCar = VehicleContract::field('num')->where('company_b_id',$this->userInfo['company_id'])->where('status','in','-1,0,1,2')->sum('num');
|
$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('status','<>',3)->where('type',1)->count();
|
$selfCar = VehicleContract::field('id')->where('company_a_id',$this->userInfo['company_id'])->where('type',1)->where('status','in','-1,0,1,2,3')->sum('num');
|
||||||
//可在租车辆
|
//购买车辆数量
|
||||||
$doubleRentCar = max($villageCompany - $rentCar - $applyCar - $selfCar,0);
|
//获取下面的小组服务公司
|
||||||
|
$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();
|
||||||
|
//可在租车辆
|
||||||
|
$doubleRentCar = max($villageCompany - $rentCar - $applyCar - $selfCar - $buyCar,0);
|
||||||
if($params['num'] > $doubleRentCar ){
|
if($params['num'] > $doubleRentCar ){
|
||||||
return $this->fail('数量超过可再租车辆数');
|
return $this->fail('数量超过可再租车辆数');
|
||||||
}
|
}
|
||||||
@ -397,13 +402,18 @@ class VehicleController extends BaseApiController
|
|||||||
//获取该公司已签约的小组服务公司数量
|
//获取该公司已签约的小组服务公司数量
|
||||||
$villageCompany = Contract::field('id')->where('party_a',$company['id'])->where('signing_timer',2)->count();
|
$villageCompany = Contract::field('id')->where('party_a',$company['id'])->where('signing_timer',2)->count();
|
||||||
//已经租赁车辆
|
//已经租赁车辆
|
||||||
$rentCar = VehicleRent::field('id')->where('company_id',$company['id'])->where('type','<>', 1)->count();
|
$rentCar = VehicleRent::field('id')->where('company_id',$company['id'])->whereNotIn('type','1,2')->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('status','<>',3)->where('type',1)->count();
|
$selfCar = VehicleContract::field('id')->where('company_a_id',$company['id'])->where('type',1)->where('status','in','-1,0,1,2,3')->sum('num');
|
||||||
|
//购买车辆数量
|
||||||
|
//获取下面的小组服务公司
|
||||||
|
$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();
|
||||||
//可在租车辆
|
//可在租车辆
|
||||||
$doubleRentCar = max($villageCompany - $rentCar - $applyCar - $selfCar,0);
|
$doubleRentCar = max($villageCompany - $rentCar - $applyCar - $selfCar - $buyCar,0);
|
||||||
//设置数据
|
//设置数据
|
||||||
$data = [
|
$data = [
|
||||||
'apply' => $vehicleContract,
|
'apply' => $vehicleContract,
|
||||||
@ -412,6 +422,7 @@ class VehicleController extends BaseApiController
|
|||||||
'rent_num' => $rentCar,
|
'rent_num' => $rentCar,
|
||||||
'can_rent_num' => intval($doubleRentCar),
|
'can_rent_num' => intval($doubleRentCar),
|
||||||
'self_num' => $selfCar,
|
'self_num' => $selfCar,
|
||||||
|
'buy_num' => $buyCar,
|
||||||
'apply_num' => $applyCar
|
'apply_num' => $applyCar
|
||||||
];
|
];
|
||||||
//返回
|
//返回
|
||||||
|
Loading…
x
Reference in New Issue
Block a user