diff --git a/app/adminapi/controller/contract/VehicleContractController.php b/app/adminapi/controller/contract/VehicleContractController.php index b01d48259..6958551ef 100644 --- a/app/adminapi/controller/contract/VehicleContractController.php +++ b/app/adminapi/controller/contract/VehicleContractController.php @@ -273,14 +273,32 @@ class VehicleContractController extends BaseAdminController } if(!empty($cars)){ foreach ($cars as $k=>$v) { - if($data['type'] == 0 || $data['type'] == 2){ + if($data['type'] == 0){ $cars[$k]['type'] = 0; } if($data['type'] == 1){ - $cars[$k]['type'] = 1; + $rentInfo = VehicleRent::where('car_id',$v['id'])->findOrEmpty(); + if($rentInfo->isEmpty()){ + $cars[$k]['type'] = 0; + }else{ + $cars[$k]['type'] = $rentInfo['type']; + } + } + if($data['type'] == 2){ + $rentInfo = VehicleRent::where('car_id',$v['id'])->findOrEmpty(); + if($rentInfo->isEmpty()){ + $cars[$k]['type'] = 0; + }else{ + $cars[$k]['type'] = $rentInfo['type']; + } } if($data['type'] == 3){ - $cars[$k]['type'] = 2; + $rentInfo = VehicleRent::where('car_id',$v['id'])->findOrEmpty(); + if($rentInfo->isEmpty()){ + $cars[$k]['type'] = 2; + }else{ + $cars[$k]['type'] = $rentInfo['type']; + } } $cars[$k]['rent_time'] = $data['update_time']; }