From 6d40b063c6d5f19d10f80f7f10fae45a0807eb36 Mon Sep 17 00:00:00 2001 From: unknown <736250432@qq.com> Date: Fri, 13 Oct 2023 13:47:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=A0=E9=99=A4=E8=87=AA?= =?UTF-8?q?=E6=9C=89=E8=BD=A6=E8=BE=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/VehicleController.php | 26 +++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/app/api/controller/VehicleController.php b/app/api/controller/VehicleController.php index 110f521b..b45e5f04 100644 --- a/app/api/controller/VehicleController.php +++ b/app/api/controller/VehicleController.php @@ -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 {