This commit is contained in:
2025-06-09 11:37:32 +08:00
parent 0eec194a96
commit e5ae751512
8 changed files with 479 additions and 16 deletions
+97 -7
View File
@@ -2,6 +2,8 @@
namespace app\controller;
use app\model\LogisticsShip;
use app\model\LogisticsShipHis;
use app\model\Vehicle;
use app\model\VehicleEn;
use app\model\VehicleRu;
@@ -14,6 +16,7 @@ use app\model\LocationAr;
use app\service\OssService;
// use plugin\admin\app\model\Location;
use app\service\ShipService;
use app\service\TranslatorService;
use util\Util;
use support\Request;
@@ -47,28 +50,42 @@ class VehicleController
{
$lang = $request->post('lang', 'zh');
$status = $request->post('status', '4');
// 接收请求参数(Webman自动注入)
$page = $request->post('page', 1); // 默认第1页
$pageSize = $request->post('pageSize', 30); // 默认每页30条
$where = [];
if($status == 1){
$status = [5,6];
}elseif ($status == 2){
$status = [4];
}elseif ($status == 3){
$status = [1,2,3,7,8];
$where[] = ['vin' ,'!=', null];
}elseif ($status == 4){
$status = [1,2,3,7,8];
$where[] = ['vin' ,'=', null];
}
switch ($lang) {
case 'zh':
$vehicles = Vehicle::with('location')->with('finalLocation') ->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$vehicles = Vehicle::with('location')->with('finalLocation')->where($where)->whereIn('status',$status)->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$hz = new Location();
break;
case 'en':
$vehicles = VehicleEn::with('location')->with('finalLocation')->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$vehicles = VehicleEn::with('location')->with('finalLocation')->where($where)->whereIn('status',$status)->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$hz = new LocationEn();
break;
case 'ru':
$vehicles = VehicleRu::with('location')->with('finalLocation')->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$vehicles = VehicleRu::with('location')->with('finalLocation')->where($where)->whereIn('status',$status)->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$hz = new LocationRu();
break;
case 'ar':
$vehicles = VehicleAr::with('location')->with('finalLocation')->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$vehicles = VehicleAr::with('location')->with('finalLocation')->where($where)->whereIn('status',$status)->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$hz = new LocationAr();
break;
}
@@ -118,6 +135,73 @@ 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['ship_id'])){
$vehicle['ship'] = LogisticsShip::find($vehicle['ship_id'])->toArray();
}
}
unset($vehicle);
// =================================== new ===================================== end
$count = Vehicle::where($where)->whereIn('status',$status)->count();
$result = ['list' => $vehicles,'count'=>$count];
return Util::success($result);
}
public function ship(Request $request,$id){
// $res = ShipService::getShipInfo('413399120');
// return Util::success($res);
$lang = $request->post('lang', 'zh');
// 接收请求参数(Webman自动注入)
$page = $request->post('page', 1); // 默认第1页
$pageSize = $request->post('pageSize', 30); // 默认每页30条
// var_dump($id);die;
switch ($lang) {
case 'zh':
$vehicles = Vehicle::with('location')->with('finalLocation')->where(['ship_id' => $id])->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$hz = new Location();
break;
case 'en':
$vehicles = VehicleEn::with('location')->with('finalLocation')->where(['ship_id' => $id])->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$hz = new LocationEn();
break;
case 'ru':
$vehicles = VehicleRu::with('location')->with('finalLocation')->where(['ship_id' => $id])->offset(($page-1)*$pageSize) ->limit($pageSize)->get();
$hz = new LocationRu();
break;
case 'ar':
$vehicles = VehicleAr::with('location')->with('finalLocation')->where(['ship_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) {
@@ -131,11 +215,17 @@ class VehicleController
}else{
$vehicle['img_url'] = '';
}
if(!empty($vehicle['ship_id'])){
$vehicle['ship'] = LogisticsShip::find($vehicle['ship_id'])->toArray();
}
}
unset($vehicle);
// =================================== new ===================================== end
$count = Vehicle::count();
$result = ['list' => $vehicles,'count'=>$count];
$logisticsShip = LogisticsShip::where(['id' => $id])->first();
$logisticsShipHis = LogisticsShipHis::where(['ship_id'=> $id])->get();
$count = Vehicle::where(['ship_id' => $id])->count();
$result = ['list' => $vehicles,'ship' => $logisticsShip,'ship_his' => $logisticsShipHis,'count'=>$count];
return Util::success($result);
}