Merge pull request '修改驳回申请逻辑' () from zhangwei into dev

Reviewed-on: 
This commit is contained in:
weiz 2023-09-08 17:14:08 +08:00
commit 9694f6c91b

@ -299,15 +299,49 @@ class VehicleController extends BaseApiController
if($vehicleContract['company_a_id'] != $this->userInfo['company_id']){
return $this->fail('数据不匹配');
}
//更新
$result = VehicleContract::where('id',$params['id'])->update([
'status' => 4,
'reject_message' => $params['content']
]);
if($result){
return $this->success('驳回成功');
//判断合同类型
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{
return $this->fail('驳回失败');
Db::startTrans();
try{
//更新
$result = VehicleContract::where('id',$params['id'])->update([
'status' => 4,
'reject_message' => $params['content']
]);
if($result){
Db::commit();
return $this->success('驳回成功');
}else{
Db::rollback();
return $this->fail('驳回失败');
}
}catch (\Exception $e) {
Db::rollback();
return $this->fail($e->getMessage());
}
}
}