From 70cc6a12ca5678da2da4733a233f6ab49bf644aa Mon Sep 17 00:00:00 2001 From: jianghanbo <jhba001200> Date: Tue, 25 Mar 2025 18:52:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/app/admin/controller/IndexController.php | 2 +- service/support/helpers.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/service/app/admin/controller/IndexController.php b/service/app/admin/controller/IndexController.php index 9327af53..06481c99 100644 --- a/service/app/admin/controller/IndexController.php +++ b/service/app/admin/controller/IndexController.php @@ -196,7 +196,7 @@ class IndexController extends base END) AS tobeused_price_80 '); - if ($request->admin->id != 1) { + if ($request->admin->is_super != 1) { $order = $order->where('admin_id', $request->admin->id); } diff --git a/service/support/helpers.php b/service/support/helpers.php index ab5b9c60..c6573ccb 100644 --- a/service/support/helpers.php +++ b/service/support/helpers.php @@ -15,6 +15,7 @@ use app\server\BaiduApiService; use support\Container; +use support\Redis; use support\Request; use support\Response; use support\Translation; @@ -540,6 +541,10 @@ function input(string $param = null, $default = null) } function get_ip_address($ip) { + $key = 'ip:' . $ip; + if ($ipAddress = Redis::get($key)) { + return $ipAddress; + } $apiKey = 'a343376de75af8'; // 需注册获取免费额度 $url = "https://ipinfo.io/{$ip}/json?token={$apiKey}&language=zh-CN"; @@ -551,5 +556,7 @@ function get_ip_address($ip) { } $str = $data['country'] . '-' . $data['region'] . '-'. $data['city']; - return (new BaiduApiService())->translate($str, 'auto', 'zh'); + $ipAddress = (new BaiduApiService())->translate($str, 'auto', 'zh'); + Redis::set($key, $ipAddress); + return $ipAddress; }