diff --git a/app/admin/controller/SysCurrencyController.php b/app/admin/controller/SysCurrencyController.php index 0e96169..db9d589 100644 --- a/app/admin/controller/SysCurrencyController.php +++ b/app/admin/controller/SysCurrencyController.php @@ -2,6 +2,7 @@ namespace app\admin\controller; use app\common\controller\BaseController; +use app\common\model\Country; use app\common\traits\crud\CrudControllerTrait; use app\admin\service\SysCurrencyService; @@ -30,6 +31,11 @@ class SysCurrencyController extends BaseController $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); if (isset($data['last_updated'])) $data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']); + if (isset($data['country_id'])){ + $data['country_name'] = Country::where('id',$data['country_id'])->value('item_label'); + } else { + $data['country_name'] = ''; + } return $data; } @@ -47,6 +53,11 @@ class SysCurrencyController extends BaseController $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); if (isset($data['last_updated'])) $data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']); + if (isset($data['country_id'])){ + $data['country_name'] = Country::where('id',$data['country_id'])->value('item_label'); + } else { + $data['country_name'] = ''; + } return $data; } } \ No newline at end of file diff --git a/app/admin/service/SysPortService.php b/app/admin/service/SysPortService.php index 7a2dfd0..6e8774c 100644 --- a/app/admin/service/SysPortService.php +++ b/app/admin/service/SysPortService.php @@ -58,6 +58,14 @@ class SysPortService $config['orWhere'][] = [$col, 'like', $k]; } } + // 场景 + if (isset($p['scene']) && $p['scene']) { + if($p['country_id'] == 'domestic'){ + $config['where']['country_id'] = 45; + }else{ + $config['where']['country_id'] = ['<>', 45]; + } + } //$config['where']['status'] = 1; break; case 'show': diff --git a/app/common/controller/PresetController.php b/app/common/controller/PresetController.php index 0d3ebf1..1abe3de 100644 --- a/app/common/controller/PresetController.php +++ b/app/common/controller/PresetController.php @@ -147,10 +147,11 @@ class PresetController extends BaseController } } - public function port() + public function port(Request $request) { try { - $result = (new SysPortService)->getList(); + $params = $request->all(); + $result = (new SysPortService)->getList($params); return $this->success($result, '获取港口列表'); } catch (\Throwable $e) { return $this->error($e->getMessage()); diff --git a/app/common/logic/SysCurrencyLogic.php b/app/common/logic/SysCurrencyLogic.php index b1faedc..4de7559 100644 --- a/app/common/logic/SysCurrencyLogic.php +++ b/app/common/logic/SysCurrencyLogic.php @@ -16,6 +16,6 @@ class SysCurrencyLogic public function getList() { - return SysCurrency::where('status', 1)->get(['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'float_percent_up', 'float_percent_down']); + return SysCurrency::where('status', 1)->get(['id', 'country_id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'float_percent_up', 'float_percent_down']); } } \ No newline at end of file diff --git a/app/common/logic/SysPortLogic.php b/app/common/logic/SysPortLogic.php index a2e78a8..e12c260 100644 --- a/app/common/logic/SysPortLogic.php +++ b/app/common/logic/SysPortLogic.php @@ -14,9 +14,9 @@ class SysPortLogic */ protected string $modelClass = SysPort::class; - public function getList() + public function getList($where) { - return SysPort::where('status', 1)->orderBy('sort','desc')->get(['id', 'port_code', 'port_name', 'country_id', 'description']); + return SysPort::where('status', 1)->where($where)->orderBy('sort','desc')->get(['id', 'port_code', 'port_name', 'country_id', 'description']); } } \ No newline at end of file diff --git a/app/common/model/SysCurrency.php b/app/common/model/SysCurrency.php index a13d120..57b4339 100644 --- a/app/common/model/SysCurrency.php +++ b/app/common/model/SysCurrency.php @@ -40,7 +40,7 @@ class SysCurrency extends Model /** * 允许自动填充模型字段 */ - protected $fillable = ['id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'base_currency', 'float_percent_up', 'float_percent_down', 'status', 'last_updated', 'created_at', 'updated_at']; + protected $fillable = ['id', 'country_id', 'currency_code', 'currency_name', 'currency_symbol', 'exchange_rate', 'base_currency', 'float_percent_up', 'float_percent_down', 'status', 'last_updated', 'created_at', 'updated_at']; /** * 不允许自动填充模型字段 diff --git a/app/common/service/SysPortService.php b/app/common/service/SysPortService.php index 2918a96..a4ed6cd 100644 --- a/app/common/service/SysPortService.php +++ b/app/common/service/SysPortService.php @@ -21,8 +21,16 @@ class SysPortService /** * 获取系统list */ - public function getList() + public function getList($params) { - return $this->logic->getList(); + $where = []; + if(isset($params['scene']) && $params['scene']) { + if($params['scene'] == 'domestic'){ + $where['country_id'] = 45; + }else{ + $where['country_id'] = ['<>', 45]; + } + } + return $this->logic->getList($where); } } \ No newline at end of file