新增删除自有车辆接口
This commit is contained in:
parent
7b092cc06a
commit
6d40b063c6
@ -14,7 +14,7 @@ use think\response\Json;
|
||||
*/
|
||||
class VehicleController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['getCarLocal','getCarHistory','addSelfCar','updateVehicleRent','cancelRent','getFreeCars'];
|
||||
public array $notNeedLogin = ['getCarLocal','getCarHistory','addSelfCar','updateVehicleRent','cancelRent','delRentUseInfo','getFreeCars'];
|
||||
|
||||
//获取车辆当前位置
|
||||
public function getCarLocal():Json {
|
||||
@ -154,6 +154,30 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
public function delRentUseInfo() {
|
||||
if(!$this->request->isPost()){
|
||||
return $this->fail('请求方式错误');
|
||||
}
|
||||
$carId = $this->request->post('car_id');
|
||||
if(empty($carId)){
|
||||
return $this->fail('参数错误');
|
||||
}
|
||||
//获取车辆信息
|
||||
$carInfo = Vehicle::where('id',$carId)->findOrEmpty();
|
||||
if($carInfo->isEmpty()){
|
||||
return $this->fail('数据不存在');
|
||||
}
|
||||
if($carInfo['type'] == 0){
|
||||
//修改租赁信息
|
||||
VehicleRent::where('car_id',$carId)->update(['use_user_id'=>0,'use_user_name'=>'','use_user_phone'=>'']);
|
||||
}
|
||||
if($carInfo['type'] == 1){
|
||||
VehicleRent::where('car_id',$carId)->delete();
|
||||
Vehicle::where('id',$carInfo['id'])->delete();
|
||||
}
|
||||
return $this->success('修改成功');
|
||||
}
|
||||
|
||||
//获取空闲车辆
|
||||
public function getFreeCars(): Json
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user