修改生成租赁信息接口

This commit is contained in:
unknown 2023-08-25 17:04:03 +08:00
parent fc1b51703d
commit c02180a9fa

View File

@ -45,24 +45,24 @@ class VehicleLogic extends BaseLogic
}
}
public static function setRent($data):array {
public static function setRent($param):array {
VehicleRent::startTrans();
try {
if($data['rent_type'] == 1){
if($param['rent_type'] == 1){
//设置数据
$ids = explode(',',$data['car_id']);
$ids = explode(',',$param['car_id']);
$data = [];
foreach($ids as $v){
$car = Vehicle::where('id',$v)->find();
if($car){
$data[] = [
'car_id' => $v,
'lessee_one_contract_id' => $data['contract_id'],
'lessee_one_company_id' => $data['company_id'],
'lessee_one_company' => $data['company_name'],
'lessee_one_user_id' => $data['company_user_id'],
'lessee_one_user' => $data['company_user_name'],
'lessee_one_phone' => $data['company_user_phone'],
'lessee_one_contract_id' => $param['contract_id'],
'lessee_one_company_id' => $param['company_id'],
'lessee_one_company' => $param['company_name'],
'lessee_one_user_id' => $param['company_user_id'],
'lessee_one_user' => $param['company_user_name'],
'lessee_one_phone' => $param['company_user_phone'],
'lessee_one_start_time' => time(),
'lessee_one_flag' => 1,
];
@ -71,18 +71,18 @@ class VehicleLogic extends BaseLogic
$res = (new VehicleRent()) -> saveAll($data);
//更新车辆列表中的车辆状态
Vehicle::where('id','in',$ids)->update(['status'=>1]);
}elseif($data['rent_type'] == 2){
}elseif($param['rent_type'] == 2){
//获取数据
$rent = VehicleRent::where('car_id',$data['car_id'])->find();
$rent = VehicleRent::where('car_id',$param['car_id'])->find();
//设置数据
$data = [
'id' => $rent['id'],
'lessee_two_contract_id' => $data['contract_id'],
'lessee_two_company_id' => $data['company_id'],
'lessee_two_company_name' => $data['company_name'],
'lessee_two_user_id' => $data['company_user_id'],
'lessee_two_user' => $data['company_user_name'],
'lessee_two_phone' => $data['company_user_phone'],
'lessee_two_contract_id' => $param['contract_id'],
'lessee_two_company_id' => $param['company_id'],
'lessee_two_company_name' => $param['company_name'],
'lessee_two_user_id' => $param['company_user_id'],
'lessee_two_user' => $param['company_user_name'],
'lessee_two_phone' => $param['company_user_phone'],
'lessee_two_start_time' => time(),
'lessee_two_flag' => 1,
];