diff --git a/app/adminapi/logic/vehicle/VehicleLogic.php b/app/adminapi/logic/vehicle/VehicleLogic.php index 416ee570..ccac10cb 100644 --- a/app/adminapi/logic/vehicle/VehicleLogic.php +++ b/app/adminapi/logic/vehicle/VehicleLogic.php @@ -4,6 +4,7 @@ namespace app\adminapi\logic\vehicle; use app\common\logic\GpsLogic; use app\common\model\vehicle\Vehicle; use app\common\logic\BaseLogic; +use app\common\model\vehicle\VehicleRent; use think\facade\Db; @@ -77,6 +78,12 @@ class VehicleLogic extends BaseLogic public static function detail($params): array { $data = Vehicle::findOrEmpty($params['id']); + $data['mileage'] = 0; + if($data['status'] == 2){ + //获取租赁信息 + $data['rent_info'] = VehicleRent::where('car_id',$data['id'])->find(); + + } return $data->toArray(); } } \ No newline at end of file diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 5e3cc9fe..5a72053d 100755 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -128,6 +128,7 @@ class IndexController extends BaseApiController foreach($vehicle as $v){ $data[] = [ 'car_id' => $v['id'], + 'contract_id' => $contract['id'], 'company_id' => $contract['company_b_id'], 'company_name' => $contract['company_b_name'], 'company_user' => $contract['company_b_user'], diff --git a/app/api/controller/VehicleController.php b/app/api/controller/VehicleController.php index 3e76bbe3..58dbcbd4 100644 --- a/app/api/controller/VehicleController.php +++ b/app/api/controller/VehicleController.php @@ -78,6 +78,7 @@ class VehicleController extends BaseApiController ]); $vehicleRent = VehicleRent::create([ 'car_id'=> $vehicle->id, + 'contract_id' => 0, 'company_id' => $params['company_id'], 'company_name' => $params['company_name'], 'company_user' => $params['company_user'],