Просмотр исходного кода

refactor(core): 替换Helper调用为直接函数调用

- 将多个文件中的SixShop\Core\Helper调用替换为对应的直接函数调用
- 移除了对Helper类的依赖引用
- 更新了extension_path函数的调用方式
- 统一了throw_logic_exception函数的使用方式
- 清理了无用的Helper类导入语句
runphp 3 месяцев назад
Родитель
Сommit
31a365c44f
2 измененных файлов с 7 добавлено и 7 удалено
  1. 2 2
      src/Entity/ExtensionBalpayLogEntity.php
  2. 5 5
      src/PaymentProvider.php

+ 2 - 2
src/Entity/ExtensionBalpayLogEntity.php

@@ -4,7 +4,7 @@ declare(strict_types=1);
 namespace SixShop\Balpay\Entity;
 
 use app\model\User;
-use SixShop\Core\Helper;
+use function SixShop\Core\throw_logic_exception;
 use SixShop\Balpay\Enum\BalpayLogTypeEnum;
 use SixShop\Core\Entity\BaseEntity;
 use think\Paginator;
@@ -23,7 +23,7 @@ class ExtensionBalpayLogEntity extends BaseEntity
         }
         if ($type->negative()) {
             if ($user->balance < $amount) {
-                Helper::throw_logic_exception('余额不足', status: 'not_enough_balance');
+                throw_logic_exception('余额不足', status: 'not_enough_balance');
             }
             $user->dec('balance', $amount);
             $amount = -$amount;

+ 5 - 5
src/PaymentProvider.php

@@ -4,7 +4,7 @@ declare(strict_types=1);
 namespace SixShop\Balpay;
 
 use app\model\User;
-use SixShop\Core\Helper;
+use function SixShop\Core\throw_logic_exception;
 use SixShop\Balpay\Entity\ExtensionBalpayLogEntity;
 use SixShop\Balpay\Enum\BalpayLogTypeEnum;
 use SixShop\Payment\Contracts\PaymentNotifyResult;
@@ -45,7 +45,7 @@ class PaymentProvider implements PaymentProviderInterface
             'biz_type' => $bizType,
         ])->findOrEmpty();
         if (!$payment->isEmpty()) {
-            Helper::throw_logic_exception('订单已支付', status: 'balpay.order_already_paid');
+            throw_logic_exception('订单已支付', status: 'balpay.order_already_paid');
         }
         $payment->transaction(function () use ($bizType, $order, $payment) {
             $payment->save([
@@ -121,14 +121,14 @@ class PaymentProvider implements PaymentProviderInterface
     {
         $password = $params['pay_password'] ?? '';
         if (empty($password)) {
-            Helper::throw_logic_exception('请输入支付密码', status: 'balpay.pay_password_empty');
+            throw_logic_exception('请输入支付密码', status: 'balpay.pay_password_empty');
         }
         $user = User::find($order['user_id']);
         if (empty($user->pay_password)) {
-            Helper::throw_logic_exception('请先设置支付密码', status: 'balpay.pay_password_not_set');
+            throw_logic_exception('请先设置支付密码', status: 'balpay.pay_password_not_set');
         }
         if (!password_verify($password, $user->pay_password)) {
-            Helper::throw_logic_exception('支付密码错误', status: 'balpay.pay_password_error');
+            throw_logic_exception('支付密码错误', status: 'balpay.pay_password_error');
         }
     }
 }