diff --git a/beike/Admin/Http/Controllers/CurrencyController.php b/beike/Admin/Http/Controllers/CurrencyController.php
index f38adc76..9eb2d15e 100644
--- a/beike/Admin/Http/Controllers/CurrencyController.php
+++ b/beike/Admin/Http/Controllers/CurrencyController.php
@@ -12,6 +12,7 @@
namespace Beike\Admin\Http\Controllers;
use Beike\Admin\Http\Requests\CurrencyRequest;
+use Beike\Models\Order;
use Beike\Repositories\CurrencyRepo;
use Illuminate\Http\Request;
@@ -66,9 +67,19 @@ class CurrencyController extends Controller
public function destroy(Request $request, int $currencyId)
{
- CurrencyRepo::delete($currencyId);
- hook_action('admin.currency.destroy.after', $currencyId);
+ try {
+ $currency = CurrencyRepo::find($currencyId);
+ $orderExist = Order::query()->where('currency_code', $currency->code)->exists();
+ if ($orderExist) {
+ throw new \Exception(trans('admin/currency.order_exist'));
+ }
- return json_success(trans('common.deleted_success'));
+ CurrencyRepo::delete($currencyId);
+ hook_action('admin.currency.destroy.after', $currencyId);
+
+ return json_success(trans('common.deleted_success'));
+ } catch (\Exception $e) {
+ return json_fail($e->getMessage());
+ }
}
}
diff --git a/beike/Services/CurrencyService.php b/beike/Services/CurrencyService.php
index 85e88118..6cec2b8c 100644
--- a/beike/Services/CurrencyService.php
+++ b/beike/Services/CurrencyService.php
@@ -42,12 +42,17 @@ class CurrencyService
return $amount;
}
- $symbol_left = $this->currencies[$currency]->symbol_left;
- $symbol_right = $this->currencies[$currency]->symbol_right;
- $decimal_place = $this->currencies[$currency]->decimal_place;
+ $currencyRow = $this->currencies[$currency] ?? null;
+ if (empty($currencyRow)) {
+ return $amount;
+ }
+
+ $symbol_left = $currencyRow->symbol_left;
+ $symbol_right = $currencyRow->symbol_right;
+ $decimal_place = $currencyRow->decimal_place;
if (! $value) {
- $value = $this->currencies[$currency]->value;
+ $value = $currencyRow->value;
}
$amount = $value ? (float) $amount * $value : (float) $amount;
diff --git a/resources/lang/en/admin/currency.php b/resources/lang/en/admin/currency.php
index fbe546be..9345a550 100644
--- a/resources/lang/en/admin/currency.php
+++ b/resources/lang/en/admin/currency.php
@@ -16,4 +16,5 @@ return [
'currencies_show' => 'Detail',
'currencies_update' => 'Edit',
'currencies_delete' => 'Delete',
+ 'order_exist' => 'This currency has orders in use and cannot be deleted!',
];
diff --git a/resources/lang/en/admin/marketing.php b/resources/lang/en/admin/marketing.php
index eaac7b73..c72c9cda 100644
--- a/resources/lang/en/admin/marketing.php
+++ b/resources/lang/en/admin/marketing.php
@@ -10,33 +10,33 @@
*/
return [
- 'marketing_list' => 'Marketing',
- 'marketing_index' => 'Index',
- 'marketing_show' => 'Detail',
- 'marketing_buy' => 'Buy',
- 'marketing_download' => 'Download',
- 'set_token' => 'Set Token',
- 'get_token_text' => 'Log in to BeikeShop official website personal center - bind domain name, add current domain name',
- 'get_token' => 'Get Token',
- 'download_count' => 'download count',
- 'last_update' => 'last update',
- 'text_version' => 'version',
- 'text_compatibility' => 'compatibility',
- 'text_author' => 'plug-in author',
- 'download_plugin' => 'download plugin',
- 'download_description' => 'Plugin description',
- 'text_free' => 'free',
- 'btn_buy' => 'Buy',
- 'text_pay' => 'Payment Amount',
- 'select_pay' => 'select payment method',
- 'wxpay' => 'WeChat scan code payment!',
- 'pay_success_title' => 'Payment successful!',
- 'pay_success_text' => 'The plug-in purchase is successful, click OK to refresh the page',
- 'ali_pay_success' => 'Payment completed? ',
- 'ali_pay_text' => 'Payment has been completed, please refresh the page',
- 'version_compatible_text' => 'This plugin is not compatible with the current system version, please upgrade to Latest Version',
- 'to_update' => 'To Upgrade',
- 'bk_register_hint' => 'Register a new account with beikeshop.com',
- 'bk_login_hint' => 'login with beikeshop.com account',
+ 'marketing_list' => 'Marketing',
+ 'marketing_index' => 'Index',
+ 'marketing_show' => 'Detail',
+ 'marketing_buy' => 'Buy',
+ 'marketing_download' => 'Download',
+ 'set_token' => 'Set Token',
+ 'get_token_text' => 'Log in to BeikeShop official website personal center - bind domain name, add current domain name',
+ 'get_token' => 'Get Token',
+ 'download_count' => 'download count',
+ 'last_update' => 'last update',
+ 'text_version' => 'version',
+ 'text_compatibility' => 'compatibility',
+ 'text_author' => 'plug-in author',
+ 'download_plugin' => 'download plugin',
+ 'download_description' => 'Plugin description',
+ 'text_free' => 'free',
+ 'btn_buy' => 'Buy',
+ 'text_pay' => 'Payment Amount',
+ 'select_pay' => 'select payment method',
+ 'wxpay' => 'WeChat scan code payment!',
+ 'pay_success_title' => 'Payment successful!',
+ 'pay_success_text' => 'The plug-in purchase is successful, click OK to refresh the page',
+ 'ali_pay_success' => 'Payment completed? ',
+ 'ali_pay_text' => 'Payment has been completed, please refresh the page',
+ 'version_compatible_text' => 'This plugin is not compatible with the current system version, please upgrade to Latest Version',
+ 'to_update' => 'To Upgrade',
+ 'bk_register_hint' => 'Register a new account with beikeshop.com',
+ 'bk_login_hint' => 'login with beikeshop.com account',
'bind_bk_token' => 'Bind BeikeShop account and get Token automatically',
];
diff --git a/resources/lang/zh_cn/admin/currency.php b/resources/lang/zh_cn/admin/currency.php
index 8e84e5b1..3ea75424 100644
--- a/resources/lang/zh_cn/admin/currency.php
+++ b/resources/lang/zh_cn/admin/currency.php
@@ -16,4 +16,6 @@ return [
'currencies_show' => '货币详情',
'currencies_update' => '更新货币',
'currencies_delete' => '删除货币',
+
+ 'order_exist' => '该货币有订单正在使用, 无法删除!',
];
diff --git a/resources/lang/zh_cn/admin/marketing.php b/resources/lang/zh_cn/admin/marketing.php
index 47cfc418..b06ffb6b 100644
--- a/resources/lang/zh_cn/admin/marketing.php
+++ b/resources/lang/zh_cn/admin/marketing.php
@@ -10,34 +10,34 @@
*/
return [
- 'marketing_list' => '插件市场',
- 'marketing_index' => '市场首页',
- 'marketing_show' => '插件详情',
- 'marketing_buy' => '购买插件',
- 'marketing_download' => '下载插件',
- 'set_token' => '设置 Token',
- 'get_token_text' => '登录 BeikeShop 官网个人中心-绑定域名,添加当前域名',
- 'get_token' => '点击获取 Token',
- 'download_count' => '下载次数',
- 'last_update' => '最后更新',
- 'text_version' => '插件版本',
- 'text_compatibility' => '兼容性',
- 'text_author' => '插件作者',
- 'download_plugin' => '下载插件',
- 'download_description' => '插件描述',
- 'text_free' => '免费',
- 'btn_buy' => '购买',
- 'text_pay' => '支付金额',
- 'select_pay' => '选择支付方式',
- 'wxpay' => '微信扫码支付!',
- 'pay_success_title' => '支付成功!',
- 'pay_success_text' => '插件购买成功,点击确定刷新页面',
- 'ali_pay_success' => '已完成支付?',
- 'ali_pay_text' => '已完成支付,请刷新页面',
- 'ali_pay_text' => '已完成支付,请刷新页面',
- 'version_compatible_text' => '该插件不兼容当前系统版本,请升级到 最新版本',
- 'to_update' => '去升级',
+ 'marketing_list' => '插件市场',
+ 'marketing_index' => '市场首页',
+ 'marketing_show' => '插件详情',
+ 'marketing_buy' => '购买插件',
+ 'marketing_download' => '下载插件',
+ 'set_token' => '设置 Token',
+ 'get_token_text' => '登录 BeikeShop 官网个人中心-绑定域名,添加当前域名',
+ 'get_token' => '点击获取 Token',
+ 'download_count' => '下载次数',
+ 'last_update' => '最后更新',
+ 'text_version' => '插件版本',
+ 'text_compatibility' => '兼容性',
+ 'text_author' => '插件作者',
+ 'download_plugin' => '下载插件',
+ 'download_description' => '插件描述',
+ 'text_free' => '免费',
+ 'btn_buy' => '购买',
+ 'text_pay' => '支付金额',
+ 'select_pay' => '选择支付方式',
+ 'wxpay' => '微信扫码支付!',
+ 'pay_success_title' => '支付成功!',
+ 'pay_success_text' => '插件购买成功,点击确定刷新页面',
+ 'ali_pay_success' => '已完成支付?',
+ 'ali_pay_text' => '已完成支付,请刷新页面',
+ 'ali_pay_text' => '已完成支付,请刷新页面',
+ 'version_compatible_text' => '该插件不兼容当前系统版本,请升级到 最新版本',
+ 'to_update' => '去升级',
'bk_register_hint' => '用 beikeshop.com 上注册新账号',
- 'bk_login_hint' => '用 beikeshop.com 账号登录',
- 'bind_bk_token' => '绑定BeikeShop账号,自动获取Token',
+ 'bk_login_hint' => '用 beikeshop.com 账号登录',
+ 'bind_bk_token' => '绑定BeikeShop账号,自动获取Token',
];
diff --git a/resources/lang/zh_hk/admin/currency.php b/resources/lang/zh_hk/admin/currency.php
index d78d62f5..2ff3ef1b 100644
--- a/resources/lang/zh_hk/admin/currency.php
+++ b/resources/lang/zh_hk/admin/currency.php
@@ -16,4 +16,5 @@ return [
'currencies_show' => '貨幣詳情',
'currencies_update' => '更新貨幣',
'currencies_delete' => '刪除貨幣',
+ 'order_exist' => '該貨幣有訂單正在使用,無法删除!',
];