update
This commit is contained in:
parent
e5a5631384
commit
d4f018f4c5
@ -4,7 +4,6 @@ namespace app\api\controller;
|
||||
use app\api\logic\VehicleLogic;
|
||||
use app\common\model\vehicle\Vehicle;
|
||||
use app\common\model\vehicle\VehicleRent;
|
||||
use app\common\model\vehicle\VehicleUser;
|
||||
use think\facade\Db;
|
||||
use think\response\Json;
|
||||
|
||||
@ -15,7 +14,7 @@ use think\response\Json;
|
||||
*/
|
||||
class VehicleController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['getCarLocal','getCarHistory','addSelfCar'];
|
||||
public array $notNeedLogin = ['getCarLocal','getCarHistory','addSelfCar','updateVehicleRent'];
|
||||
|
||||
//获取车辆当前位置
|
||||
public function getCarLocal():Json {
|
||||
@ -63,6 +62,11 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
Db::startTrans();
|
||||
try {
|
||||
//获取数据
|
||||
$vehicle = Vehicle::where('license',$params['license'])->find();
|
||||
if(!empty($vehicle)){
|
||||
return $this->fail('该车牌号的车辆已存在');
|
||||
}
|
||||
//写入数据
|
||||
$vehicle = Vehicle::create([
|
||||
'license' => $params['license'],
|
||||
@ -76,7 +80,7 @@ class VehicleController extends BaseApiController
|
||||
'car_id'=> $vehicle->id,
|
||||
'company_id' => $params['company_id'],
|
||||
'company_name' => $params['company_name'],
|
||||
'company_user' => $params['company_a_user'],
|
||||
'company_user' => $params['company_user'],
|
||||
'company_phone' => $params['company_phone'],
|
||||
]);
|
||||
if($vehicle->id && $vehicleRent->id){
|
||||
@ -92,4 +96,27 @@ class VehicleController extends BaseApiController
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function updateVehicleRent(){
|
||||
//获取参数
|
||||
$params = $this->request->post(['car_id','use_user_id','use_user_name','use_user_phone']);
|
||||
if(empty($params['car_id']) || empty($params['use_user_id']) || empty($params['use_user_name']) || empty($params['use_user_phone'])){
|
||||
return false;
|
||||
}
|
||||
//更新
|
||||
$vehicleRent = VehicleRent::where('car_id',$params['car_id'])->find();
|
||||
if(empty($vehicleRent)){
|
||||
return false;
|
||||
}
|
||||
$result = VehicleRent::where('car_id',$params['car_id'])->update([
|
||||
'use_user_id' => $params['use_user_id'],
|
||||
'use_user_name' => $params['use_user_name'],
|
||||
'use_user_phone' => $params['use_user_phone'],
|
||||
]);
|
||||
if($result){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ Route::rule('hasCourier','Logistics/hasCourier','get');
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
Route::rule('getCarLocal','Vehicle/getCarLocal','get');
|
||||
Route::rule('getCarHistory','Vehicle/getCarHistory','get');
|
||||
Route::rule('addSelfCar','Contract/addSelfCar','post');
|
||||
Route::rule('addSelfCar','Vehicle/addSelfCar','post');
|
||||
Route::rule('updateVehicleRent','Vehicle/updateVehicleRent','post');
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user