diff --git a/.env.example b/.env.example
index bc1788f7..945da88e 100644
--- a/.env.example
+++ b/.env.example
@@ -61,5 +61,3 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
MIX_PROXY=beikeshop.test
MIX_HOST=192.168.0.122
-# 自动获取最新汇率API KEY
-RATE_KEY=
diff --git a/beike/Admin/Providers/AdminServiceProvider.php b/beike/Admin/Providers/AdminServiceProvider.php
index 8d6e26b7..d3c2718b 100644
--- a/beike/Admin/Providers/AdminServiceProvider.php
+++ b/beike/Admin/Providers/AdminServiceProvider.php
@@ -24,11 +24,11 @@ use Beike\Admin\View\Components\Header;
use Beike\Admin\View\Components\NoData;
use Beike\Admin\View\Components\Sidebar;
use Beike\Console\Commands\ChangeRootPassword;
+use Beike\Console\Commands\FetchCurrencyRate;
use Beike\Console\Commands\GenerateDatabaseDict;
use Beike\Console\Commands\GenerateSitemap;
use Beike\Console\Commands\MakeRootAdminUser;
use Beike\Console\Commands\MigrateFromOpenCart;
-use Beike\Console\Commands\FetchCurrencyRate;
use Beike\Models\AdminUser;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
diff --git a/beike/Config/beike.php b/beike/Config/beike.php
index 42eb3270..98116119 100644
--- a/beike/Config/beike.php
+++ b/beike/Config/beike.php
@@ -16,5 +16,4 @@ return [
'admin_name' => env('ADMIN_NAME'),
'force_url_https' => env('APP_FORCE_HTTPS', false),
- 'rate_key' => env('RATE_KEY')
];
diff --git a/beike/Console/Commands/FetchCurrencyRate.php b/beike/Console/Commands/FetchCurrencyRate.php
index 9d59edd5..cd7e590d 100644
--- a/beike/Console/Commands/FetchCurrencyRate.php
+++ b/beike/Console/Commands/FetchCurrencyRate.php
@@ -32,6 +32,4 @@ class FetchCurrencyRate extends Command
$this->error(sprintf('获取 %s 汇率数据失败', $today));
}
}
-
-
}
diff --git a/beike/Models/Currency.php b/beike/Models/Currency.php
index 529ddefc..54eebc34 100644
--- a/beike/Models/Currency.php
+++ b/beike/Models/Currency.php
@@ -33,6 +33,4 @@ class Currency extends Base
return $this->value;
}
}
-
-
}
diff --git a/beike/Services/CurrencyService.php b/beike/Services/CurrencyService.php
index 1615791e..3ef6821c 100644
--- a/beike/Services/CurrencyService.php
+++ b/beike/Services/CurrencyService.php
@@ -99,8 +99,16 @@ class CurrencyService
if ($rates = cache()->get($cacheKey)) {
return $rates;
}
- $data = Http::get(sprintf('https://v6.exchangerate-api.com/v6/%s/latest/USD', config('beike.rate_key')))
- ->json();
+ if (empty(system_setting('base.rate_api_key'))) {
+ return [];
+ }
+ $data = Http::get(
+ sprintf(
+ 'https://v6.exchangerate-api.com/v6/%s/latest/%s',
+ system_setting('base.rate_api_key'),
+ system_setting('base.currency', 'USD')
+ )
+ )->json();
$rates = $data['conversion_rates'] ?? [];
cache()->set($cacheKey, $rates);
diff --git a/database/seeders/SettingsSeeder.php b/database/seeders/SettingsSeeder.php
index 55715119..6841bda6 100644
--- a/database/seeders/SettingsSeeder.php
+++ b/database/seeders/SettingsSeeder.php
@@ -75,7 +75,8 @@ class SettingsSeeder extends Seeder
["type" => "plugin", "space" => "stripe", "name" => "status", "value" => "1", "json" => 0],
["type" => "plugin", "space" => "latest_products", "name" => "status", "value" => "1", "json" => 0],
["type" => "plugin", "space" => "flat_shipping", "name" => "status", "value" => "1", "json" => 0],
- ["type" => "plugin", "space" => "paypal", "name" => "status", "value" => "1", "json" => 0]
+ ["type" => "plugin", "space" => "paypal", "name" => "status", "value" => "1", "json" => 0],
+ ["type" => "system", "space" => "base", "name" => "rate_api_key", "value" => "", "json" => 0],
];
}
diff --git a/resources/beike/admin/views/pages/setting.blade.php b/resources/beike/admin/views/pages/setting.blade.php
index 2d2ce665..e5808bdd 100644
--- a/resources/beike/admin/views/pages/setting.blade.php
+++ b/resources/beike/admin/views/pages/setting.blade.php
@@ -208,6 +208,9 @@
+
+
+
@hook('admin.setting.after')
diff --git a/resources/lang/de/admin/setting.php b/resources/lang/de/admin/setting.php
index 7ffba4a1..baf5ffe8 100644
--- a/resources/lang/de/admin/setting.php
+++ b/resources/lang/de/admin/setting.php
@@ -69,4 +69,5 @@ return [
'placeholder_image_info' => 'Das Platzhalterbild wird angezeigt, wenn kein Bild vorhanden ist oder das Bild nicht gefunden wird, empfohlene Größe: 500*500',
'head_code' => 'Code einfügen',
'head_code_info' => 'Der Code im Eingabefeld wird in den Kopf der Frontend-Seite eingefügt, die zum Zählen des Codes oder zum Hinzufügen spezieller Plug-Ins usw. verwendet werden kann',
+ 'rate_api_key' => 'Tauschrate API KEY',
];
diff --git a/resources/lang/en/admin/setting.php b/resources/lang/en/admin/setting.php
index 527625b5..10fca776 100644
--- a/resources/lang/en/admin/setting.php
+++ b/resources/lang/en/admin/setting.php
@@ -70,4 +70,5 @@ return [
'placeholder_image_info' => 'The placeholder image displayed when there is no image or the image is not found, recommended size: 500*500',
'head_code' => 'Insert code',
'head_code_info' => 'The code in the input box will be inserted into the head of the front-end page, which can be used to count the code or add special plug-ins, etc',
+ 'rate_api_key' => 'Exchange rate API KEY',
];
diff --git a/resources/lang/es/admin/setting.php b/resources/lang/es/admin/setting.php
index 0952af29..bb765529 100644
--- a/resources/lang/es/admin/setting.php
+++ b/resources/lang/es/admin/setting.php
@@ -70,4 +70,5 @@ return [
'placeholder_image_info' => 'La imagen del marcador de posición se muestra cuando no hay imagen o no se encuentra la imagen, tamaño recomendado: 500*500',
'head_code' => 'insertar código',
'head_code_info' => 'El código en el cuadro de entrada se insertará en el encabezado de la página principal, que se puede usar para contar el código o agregar complementos especiales, etc.',
+ 'rate_api_key' => 'tipo de cambio API KEY',
];
diff --git a/resources/lang/fr/admin/setting.php b/resources/lang/fr/admin/setting.php
index e992611e..272803fa 100644
--- a/resources/lang/fr/admin/setting.php
+++ b/resources/lang/fr/admin/setting.php
@@ -69,4 +69,5 @@ return [
'placeholder_image_info' => 'L\'image d\'espace réservé s\'affiche lorsqu\'il n\'y a pas d\'image ou si l\'image n\'est pas trouvée, taille recommandée: 500*500',
'head_code' => 'insérer le code',
'head_code_info' => 'Le code dans la zone de saisie sera inséré dans l\'en-tête de la page frontale, qui peut être utilisé pour compter le code ou ajouter des plug-ins spéciaux, etc',
+ 'rate_api_key' => 'taux de change API KEY',
];
diff --git a/resources/lang/it/admin/setting.php b/resources/lang/it/admin/setting.php
index 3372b2d0..9245e9ff 100644
--- a/resources/lang/it/admin/setting.php
+++ b/resources/lang/it/admin/setting.php
@@ -69,4 +69,5 @@ return [
'placeholder_image_info' => 'Immagine segnaposto visualizzata quando non viene trovata alcuna immagine o immagine, dimensione consigliata: 500*500',
'head_code' => 'inserisci codice',
'head_code_info' => 'Il codice nella casella di input verrà inserito nell\'intestazione della pagina front-end, che può essere utilizzata per contare il codice o aggiungere plug-in speciali, ecc.',
+ 'rate_api_key' => 'tasso di cambio API KEY',
];
diff --git a/resources/lang/ja/admin/setting.php b/resources/lang/ja/admin/setting.php
index 54b2e955..a74bd45c 100644
--- a/resources/lang/ja/admin/setting.php
+++ b/resources/lang/ja/admin/setting.php
@@ -69,4 +69,5 @@ return [
'placeholder_image_info' => '画像がない場合や画像が見つからない場合に表示されるプレースホルダー画像、推奨サイズ: 500*500',
'head_code' => '挿入コード',
'head_code_info' => '入力ボックスのコードはフロントエンド ページの先頭に挿入され、コードのカウントや特別なプラグインの追加などに使用できます',
+ 'rate_api_key' => '為替レート API KEY',
];
diff --git a/resources/lang/ru/admin/setting.php b/resources/lang/ru/admin/setting.php
index 917dff30..f86fa924 100644
--- a/resources/lang/ru/admin/setting.php
+++ b/resources/lang/ru/admin/setting.php
@@ -69,4 +69,5 @@ return [
'placeholder_image_info' => 'Изображение-заполнитель, отображаемое, когда изображение отсутствует или изображение не найдено, рекомендуемый размер: 500*500',
'head_code' => 'вставить код',
'head_code_info' => 'Код из поля ввода будет вставлен в шапку страницы интерфейса, что можно использовать для подсчета кода или добавления специальных плагинов и т.д.',
+ 'rate_api_key' => 'обменный курс API KEY',
];
diff --git a/resources/lang/zh_cn/admin/setting.php b/resources/lang/zh_cn/admin/setting.php
index 94be63bb..613a5700 100644
--- a/resources/lang/zh_cn/admin/setting.php
+++ b/resources/lang/zh_cn/admin/setting.php
@@ -68,4 +68,5 @@ return [
'placeholder_image' => '占位图',
'head_code' => '插入代码',
'head_code_info' => '会将输入框中的代码插入到前端页面 head 中,可用于统计代码或者添加特殊插件等',
+ 'rate_api_key' => '汇率 API KEY',
];
diff --git a/resources/lang/zh_hk/admin/setting.php b/resources/lang/zh_hk/admin/setting.php
index 2c27bf8a..b4b289c9 100644
--- a/resources/lang/zh_hk/admin/setting.php
+++ b/resources/lang/zh_hk/admin/setting.php
@@ -69,4 +69,5 @@ return [
'placeholder_image_info' => '無圖片或圖片未找到時顯示的佔位圖,建議尺寸:500*500',
'head_code' => '插入代碼',
'head_code_info' => '會將輸入框中的代碼插入到前端頁面 head 中,可用於統計代碼或者添加特殊插件等',
+ 'rate_api_key' => '匯率 API KEY',
];