This commit is contained in:
unknown 2023-08-31 08:54:24 +08:00
parent fc96a26498
commit e5a5631384
2 changed files with 6 additions and 23 deletions

View File

@ -15,7 +15,7 @@ use think\response\Json;
*/ */
class VehicleController extends BaseApiController class VehicleController extends BaseApiController
{ {
public array $notNeedLogin = ['getCarLocal','getCarHistory','createRentCarUser']; public array $notNeedLogin = ['getCarLocal','getCarHistory','addSelfCar'];
//获取车辆当前位置 //获取车辆当前位置
public function getCarLocal():Json { public function getCarLocal():Json {
@ -53,26 +53,13 @@ class VehicleController extends BaseApiController
} }
} }
public function createRentCarUser() {
//获取参数
$params = $this->request->post(['company_id','car_id','user_id','user_name','user_phone']);
if(empty($params['company_id']) || empty($params['car_id']) || empty($params['user_id']) || empty($params['user_name']) || empty($params['user_phone'])){
return $this->fail('缺少必要参数');
}
$vehicleRent = VehicleRent::where('car_id',$params['car_id'])->where('company_id',$params['company_id'])->find();
$vehicleRent -> user_id = $params['user_id'];
$vehicleRent -> user_name = $params['user_name'];
$vehicleRent -> user_phone = $params['user_phone'];
$result = $vehicleRent -> save();
return $result ? $this->success('sucess') : $this->fail('error');
}
//添加自有车辆 //添加自有车辆
public function addSelfCar() { public function addSelfCar() {
//获取参数 //获取参数
$params = $this->request->post(['license','company_id','company_name','company_user','company_phone','user_id','user_name','user_phone']); $params = $this->request->post(['license','company_id','company_name','company_user','company_phone']);
if(empty($params['license']) || empty($params['user_id']) || empty($params['user_name']) || empty($params['user_phone'])){ if(empty($params['license']) || empty($params['company_id']) || empty($params['company_name']) || empty($params['company_user']) || empty($params['company_phone'])){
return $this->fail('error'); return $this->fail('缺少必要参数');
} }
Db::startTrans(); Db::startTrans();
try { try {
@ -82,7 +69,6 @@ class VehicleController extends BaseApiController
'gps_imei' => '', 'gps_imei' => '',
'type' => 1, 'type' => 1,
'status' => 3, 'status' => 3,
'is_del' => 1,
'create_time' => time(), 'create_time' => time(),
'update_time' => time(), 'update_time' => time(),
]); ]);
@ -90,11 +76,8 @@ class VehicleController extends BaseApiController
'car_id'=> $vehicle->id, 'car_id'=> $vehicle->id,
'company_id' => $params['company_id'], 'company_id' => $params['company_id'],
'company_name' => $params['company_name'], 'company_name' => $params['company_name'],
'company_user' => $params['company_user'], 'company_user' => $params['company_a_user'],
'company_phone' => $params['company_phone'], 'company_phone' => $params['company_phone'],
'use_user_id' => $params['user_id'],
'use_user_name' => $params['user_name'],
'use_user_phone' => $params['user_phone'],
]); ]);
if($vehicle->id && $vehicleRent->id){ if($vehicle->id && $vehicleRent->id){
Db::commit(); Db::commit();

View File

@ -27,7 +27,7 @@ Route::rule('hasCourier','Logistics/hasCourier','get');
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
Route::rule('getCarLocal','Vehicle/getCarLocal','get'); Route::rule('getCarLocal','Vehicle/getCarLocal','get');
Route::rule('getCarHistory','Vehicle/getCarHistory','get'); Route::rule('getCarHistory','Vehicle/getCarHistory','get');
Route::rule('createRentCarUser','Contract/createRentCarUser','post'); Route::rule('addSelfCar','Contract/addSelfCar','post');
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/