diff --git a/app/adminapi/logic/vehicle/VehicleLogic.php b/app/adminapi/logic/vehicle/VehicleLogic.php index f4f1fa6d..931644c4 100644 --- a/app/adminapi/logic/vehicle/VehicleLogic.php +++ b/app/adminapi/logic/vehicle/VehicleLogic.php @@ -105,8 +105,8 @@ class VehicleLogic extends BaseLogic } } //获取车辆使用情况 - $data['travel_info'] = []; - + $travel = (new GpsLogic()) -> mileage($gpsCarInfo['data']['carId'],date('Y-m-d H:i:s',(time() - 604800)),date('Y-m-d').' 23:59:59'); + $data['travel_info'] = $travel['data']; if($data['status'] == 2){ //获取租赁信息 $rentInfo = VehicleRent::where('car_id',$data['id'])->find(); diff --git a/app/api/logic/VehicleLogic.php b/app/api/logic/VehicleLogic.php index 532b1c57..299898f0 100644 --- a/app/api/logic/VehicleLogic.php +++ b/app/api/logic/VehicleLogic.php @@ -73,4 +73,20 @@ class VehicleLogic extends BaseLogic return ['code'=>0,'msg'=>$result['msg']]; } } + + public static function getCarMileage($params):array { + $car = Vehicle::field('gps_imei')->where('id',$params['car_id'])->find(); + if(!$car){ + return ['code'=>0,'msg'=>'车辆不存在']; + } + //获取车辆在gps系统中的id + $gps_car_id = (new GpsLogic()) -> info($car['gps_imei']); + //获取车辆当前位置 + $res = (new GpsLogic()) -> mileage($gps_car_id['data']['carId'],$params['start_time'],$params['end_time']); + if($res['code'] == 1){ + return ['code'=>1,'msg'=>'请求成功','data'=>$res['data']]; + }else{ + return ['code'=>0,'msg'=>$res['msg']]; + } + } }