修改解除合同逻辑
This commit is contained in:
parent
76dc81f9b7
commit
0e44a4d916
@ -22,8 +22,8 @@ class VehicleController extends BaseApiController
|
|||||||
}
|
}
|
||||||
//获取该公司已签约的小组服务公司数量
|
//获取该公司已签约的小组服务公司数量
|
||||||
$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('status','<>',3)->where('type',0)->count();
|
$rentCar = VehicleRent::field('id')->where('company_id',$this->userInfo['company_id'])->where('type','<>', 1)->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');
|
||||||
//自有车辆数量
|
//自有车辆数量
|
||||||
@ -361,8 +361,8 @@ class VehicleController extends BaseApiController
|
|||||||
})->toArray();
|
})->toArray();
|
||||||
//获取该公司已签约的小组服务公司数量
|
//获取该公司已签约的小组服务公司数量
|
||||||
$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('status','<>', 3)->where('type',0)->count();
|
$rentCar = VehicleRent::field('id')->where('company_id',$company['id'])->where('type','<>', 1)->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');
|
||||||
//自有车辆数量
|
//自有车辆数量
|
||||||
@ -393,13 +393,7 @@ class VehicleController extends BaseApiController
|
|||||||
return $this->fail('非小组公司不能访问');
|
return $this->fail('非小组公司不能访问');
|
||||||
}
|
}
|
||||||
//获取申请信息
|
//获取申请信息
|
||||||
$vehicleContract = VehicleContract::where('company_b_id',$company['id'])->order('id desc')->find();
|
$vehicleContract = VehicleContract::where('company_b_id',$company['id'])->order('id desc')->findOrEmpty();
|
||||||
if(empty($vehicleContract)){
|
|
||||||
return $this->success('没有数据,请申请',['status'=>-2]);
|
|
||||||
}
|
|
||||||
if($vehicleContract['type'] == 2){
|
|
||||||
return $this->success('合同已解除',['status'=>-3]);
|
|
||||||
}
|
|
||||||
if($vehicleContract['status'] == 3){
|
if($vehicleContract['status'] == 3){
|
||||||
if(!empty($vehicleContract['cars_info'])){
|
if(!empty($vehicleContract['cars_info'])){
|
||||||
$vehicleContract['cars_info'] = json_decode($vehicleContract['cars_info'],true);
|
$vehicleContract['cars_info'] = json_decode($vehicleContract['cars_info'],true);
|
||||||
@ -528,12 +522,22 @@ class VehicleController extends BaseApiController
|
|||||||
'update_time' => time(),
|
'update_time' => time(),
|
||||||
'old_file' => $contract['contract_url'],
|
'old_file' => $contract['contract_url'],
|
||||||
];
|
];
|
||||||
//写入数据
|
Db::startTrans();
|
||||||
$result = VehicleContract::create($data);
|
try{
|
||||||
if($result){
|
//写入数据
|
||||||
return $this->success('申请成功,待镇街公司审核');
|
$new_result = VehicleContract::create($data);
|
||||||
}else{
|
//修改原合同状态
|
||||||
return $this->fail('申请失败,请稍后重试');
|
$old_result = VehicleContract::where('id',$contract['id'])->update(['status',5]);
|
||||||
|
if($new_result && $old_result){
|
||||||
|
Db::commit();
|
||||||
|
return $this->success('申请成功,待镇街公司审核');
|
||||||
|
}else{
|
||||||
|
Db::rollback();
|
||||||
|
return $this->fail('申请失败,请稍后重试');
|
||||||
|
}
|
||||||
|
}catch (\Exception $e) {
|
||||||
|
Db::rollback();
|
||||||
|
return $this->fail($e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user