修改驳回申请逻辑

This commit is contained in:
unknown 2023-09-08 17:13:33 +08:00
parent 7ce89ea50d
commit 60d28963cb

View File

@ -299,16 +299,50 @@ class VehicleController extends BaseApiController
if($vehicleContract['company_a_id'] != $this->userInfo['company_id']){ if($vehicleContract['company_a_id'] != $this->userInfo['company_id']){
return $this->fail('数据不匹配'); return $this->fail('数据不匹配');
} }
//判断合同类型
if($vehicleContract['type'] == 2){
Db::startTrans();
try{
//查找原合同
$car = json_decode($vehicleContract['cars_info'],true);
$carRentInfo = VehicleRent::where('car_id',$car['id'])->findOrEmpty();
$oldVehicleContractUpdate = VehicleContract::where('id',$carRentInfo['contract_id'])->update(['status'=>3]);
//更新
$result = VehicleContract::where('id',$params['id'])->update([
'status' => 4,
'reject_message' => $params['content']
]);
if($oldVehicleContractUpdate && $result){
Db::commit();
return $this->success('驳回成功');
}else{
Db::rollback();
return $this->fail('驳回失败');
}
}catch (\Exception $e) {
Db::rollback();
return $this->fail($e->getMessage());
}
}else{
Db::startTrans();
try{
//更新 //更新
$result = VehicleContract::where('id',$params['id'])->update([ $result = VehicleContract::where('id',$params['id'])->update([
'status' => 4, 'status' => 4,
'reject_message' => $params['content'] 'reject_message' => $params['content']
]); ]);
if($result){ if($result){
Db::commit();
return $this->success('驳回成功'); return $this->success('驳回成功');
}else{ }else{
Db::rollback();
return $this->fail('驳回失败'); return $this->fail('驳回失败');
} }
}catch (\Exception $e) {
Db::rollback();
return $this->fail($e->getMessage());
}
}
} }
//镇街公司收到的小组服务公司租赁申请列表 //镇街公司收到的小组服务公司租赁申请列表