diff --git a/app/controller/VehicleController.php b/app/controller/VehicleController.php index 36d85fc..e2d020d 100644 --- a/app/controller/VehicleController.php +++ b/app/controller/VehicleController.php @@ -155,19 +155,19 @@ class VehicleController if(is_numeric($vehicle->status)) { $vehicle->status = $this->status[$lang][$vehicle->status]??$this->status[$lang][0]; } -// if(!empty($vehicle['img_url'])) { -// $img_url = Cache::get('img_dib_'.$vehicle->id); -// if ($img_url) { -// $vehicle['img_url'] = $img_url; -// } else { -// $ossservice = empty($ossservice)?new OssService():$ossservice; -// $img_url = $ossservice->generatePrivateUrl($vehicle['img_url'],86400); -// $vehicle['img_url'] = $img_url; -// Cache::set('img_dib_'.$vehicle->id, $img_url, 86390); -// } -// }else{ -// $vehicle['img_url'] = ''; -// } + if(!empty($vehicle['img_url'])) { + $img_url = Cache::get('img_dib_'.$vehicle->id); + if ($img_url) { + $vehicle['img_url'] = $img_url; + } else { + $ossservice = empty($ossservice)?new OssService():$ossservice; + $img_url = $ossservice->generatePrivateUrl($vehicle['img_url'],86400); + $vehicle['img_url'] = $img_url; + Cache::set('img_dib_'.$vehicle->id, $img_url, 86390); + } + }else{ + $vehicle['img_url'] = ''; + } if(!empty($vehicle['ship_id'])){ $vehicle['ship'] = LogisticsShip::find($vehicle['ship_id'])->toArray(); } @@ -185,8 +185,6 @@ class VehicleController } public function ship(Request $request){ -// $res = ShipService::getShipInfo('636023678'); -// return Util::success($res); $lang = $request->post('lang', 'zh'); $id = $request->post('id'); if(empty($id)){ @@ -195,7 +193,6 @@ class VehicleController // 接收请求参数(Webman自动注入) $page = $request->post('page', 1); // 默认第1页 $pageSize = $request->post('pageSize', 30); // 默认每页30条 -// var_dump($id);die; switch ($lang) { case 'zh': @@ -249,6 +246,82 @@ class VehicleController } unset($vehicle); + $logisticsShip = LogisticsShip::where(['id' => $id])->first(); + $logisticsShipHis = LogisticsShipHis::where(['ship_id'=> $id])->get(); + foreach ($logisticsShipHis as &$his) { + $his['eta_utc'] = date('Y-m-d H:i:s', $his['eta_utc']); + $his['last_time_utc'] = date('Y-m-d H:i:s', $his['last_time_utc']); + } + unset($his); + $logisticsShip['last_time_utc'] = date('Y-m-d H:i:s', $logisticsShip['last_time_utc']); + $logisticsShip['eta_utc'] = date('Y-m-d H:i:s', $logisticsShip['eta_utc']); + + $count = Vehicle::where(['ship_id' => $id])->count(); + $result = ['list' => $vehicles,'ship' => $logisticsShip,'ship_his' => $logisticsShipHis,'count'=>$count]; + return Util::success($result); + } + public function location(Request $request){ + $lang = $request->post('lang', 'zh'); + $id = $request->post('id'); + if(empty($id)){ + return Util::fail([],'id不能为空'); + } + // 接收请求参数(Webman自动注入) + $page = $request->post('page', 1); // 默认第1页 + $pageSize = $request->post('pageSize', 30); // 默认每页30条 + + switch ($lang) { + case 'zh': + $vehicles = Vehicle::with('location')->with('finalLocation')->where(['locations_id' => $id])->offset(($page-1)*$pageSize) ->limit($pageSize)->get(); + $hz = new Location(); + break; + + case 'en': + $vehicles = VehicleEn::with('location')->with('finalLocation')->where(['locations_id' => $id])->offset(($page-1)*$pageSize) ->limit($pageSize)->get(); + $hz = new LocationEn(); + break; + + case 'ru': + $vehicles = VehicleRu::with('location')->with('finalLocation')->where(['locations_id' => $id])->offset(($page-1)*$pageSize) ->limit($pageSize)->get(); + $hz = new LocationRu(); + break; + + case 'ar': + $vehicles = VehicleAr::with('location')->with('finalLocation')->where(['locations_id' => $id])->offset(($page-1)*$pageSize) ->limit($pageSize)->get(); + $hz = new LocationAr(); + break; + } + // 组装数据 + foreach ($vehicles as &$vehicle) { + if (isset($vehicle->vin)) { + $vehicle->vin = $this->maskVin($vehicle->vin); + } + $vehicle->purchase_location=''; + $vehicle->procedure_location=''; + $vehicle->fbo_destination = isset($arr[$vehicle->fbo_locations_id]) ? $arr[$vehicle->fbo_locations_id]['name'] : ''; + $vehicle->status_val = $vehicle->status; + if(is_numeric($vehicle->status)) { + $vehicle->status = $this->status[$lang][$vehicle->status]??$this->status[$lang][0]; + } + if(!empty($vehicle['img_url'])) { + $img_url = Cache::get('img_dib_'.$vehicle->id); + if ($img_url) { + $vehicle['img_url'] = $img_url; + } else { + $ossservice = empty($ossservice)?new OssService():$ossservice; + $img_url = $ossservice->generatePrivateUrl($vehicle['img_url'],86400); + $vehicle['img_url'] = $img_url; + Cache::set('img_dib_'.$vehicle->id, $img_url, 86390); + } + }else{ + $vehicle['img_url'] = ''; + } + if(!empty($vehicle['ship_id'])){ + $vehicle['ship'] = LogisticsShip::find($vehicle['ship_id'])->toArray(); + } + } + unset($vehicle); + $logisticsShip = LogisticsShip::where(['id' => $id])->first(); $logisticsShipHis = LogisticsShipHis::where(['ship_id'=> $id])->get();