diff --git a/app/api/controller/ContractController.php b/app/api/controller/ContractController.php index c5c91794..9b7373d3 100644 --- a/app/api/controller/ContractController.php +++ b/app/api/controller/ContractController.php @@ -46,15 +46,14 @@ class ContractController extends BaseApiController ]; Db::startTrans(); try { - $res1 = Contract::create($data); - if($res1->id){ - $data['contract_logistic_id'] = $res1->id; - Db::commit(); - return $this->success('合同发起成功,等待审核',$data); - }else{ - Db::rollback(); - return $this->fail('合同发起失败,请稍后重试'); + $res1= Contract::create($data); + if(isset($params['cars_info']) && !empty($params['cars_info'])){ + $cars = json_decode($params['cars_info'], true); + Vehicle::where('id','in',array_column($cars,'id'))->update(['status'=>1]); } + $data['contract_logistic_id'] = $res1->id; + Db::commit(); + return $this->success('合同发起成功,等待审核',$data); } catch (\Exception $e) { // 回滚事务 Db::rollback();