Răsfoiți Sursa

refactor: 统一代码风格

runphp 2 săptămâni în urmă
părinte
comite
9022237ae7

+ 1 - 0
config.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 return [];

+ 1 - 0
database/migrations/20250728173547_extension_balpay_log.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 use Phinx\Migration\AbstractMigration;

+ 1 - 0
info.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 return array(
     'id' => 'balpay',

+ 1 - 0
route/admin.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 

+ 2 - 1
route/api.php

@@ -1,8 +1,9 @@
 <?php
+
 declare(strict_types=1);
 
 
 use SixShop\Balpay\Controller\TransferController;
 use think\facade\Route;
 
-Route::post('transfer', [TransferController::class, 'save'])->middleware(['auth']);
+Route::post('transfer', [TransferController::class, 'save'])->middleware(['auth']);

+ 3 - 2
src/Controller/LogController.php

@@ -1,13 +1,14 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Balpay\Controller;
 
-
 use SixShop\Balpay\Entity\ExtensionBalpayLogEntity;
 use SixShop\Balpay\Enum\BalpayLogTypeEnum;
 use SixShop\Core\Request;
 use think\Response;
+
 use function SixShop\Core\page_response;
 use function SixShop\Core\success_response;
 
@@ -54,4 +55,4 @@ class LogController
         );
         return success_response($entity);
     }
-}
+}

+ 4 - 1
src/Controller/TransferController.php

@@ -1,11 +1,14 @@
 <?php
+
 declare(strict_types=1);
+
 namespace SixShop\Balpay\Controller;
 
 use app\model\User;
 use SixShop\Balpay\Entity\ExtensionBalpayLogEntity;
 use SixShop\Core\Request;
 use think\Response;
+
 use function SixShop\Core\success_response;
 use function SixShop\Core\throw_logic_exception;
 
@@ -31,4 +34,4 @@ class TransferController
         $extensionBalpayLogEntity->transfer((int)$request->userID, $params['user_id'], $params['amount']);
         return success_response(msg: '转账成功');
     }
-}
+}

+ 5 - 4
src/Entity/ExtensionBalpayLogEntity.php

@@ -1,20 +1,21 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Balpay\Entity;
 
 use app\model\User;
-use function SixShop\Core\throw_logic_exception;
 use SixShop\Balpay\Enum\BalpayLogTypeEnum;
 use SixShop\Core\Entity\BaseEntity;
 use think\Paginator;
 
+use function SixShop\Core\throw_logic_exception;
+
 /**
  * @mixin \SixShop\Balpay\Model\ExtensionBalpayLogModel
  */
 class ExtensionBalpayLogEntity extends BaseEntity
 {
-
     public function change(int $userID, float $amount, BalpayLogTypeEnum $type, string $description, int $orderID = 0): void
     {
         $user = User::withTrashed()->find($userID);
@@ -46,7 +47,7 @@ class ExtensionBalpayLogEntity extends BaseEntity
     public function getList(int $user_id, ?BalpayLogTypeEnum $type, array $pageAndLimit): Paginator
     {
         return $this->where('user_id', $user_id)
-            ->when($type, fn($query) => $query->where('type', $type))
+            ->when($type, fn ($query) => $query->where('type', $type))
             ->append(['type_text'])
             ->order('id', 'desc')
             ->paginate($pageAndLimit);
@@ -66,4 +67,4 @@ class ExtensionBalpayLogEntity extends BaseEntity
             $this->change($toUserID, $amount, BalpayLogTypeEnum::RECHARGE, sprintf('接收来自UID:%d的转账', $fromUserID));
         });
     }
-}
+}

+ 1 - 1
src/Extension.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Balpay;
@@ -10,7 +11,6 @@ use SixShop\Payment\Contracts\PaymentProviderInterface;
 
 class Extension extends ExtensionAbstract implements PaymentExtensionInterface
 {
-
     public function getPaymentProvider(): PaymentProviderInterface
     {
         return app(PaymentProvider::class);

+ 2 - 2
src/Hook/BalpayHook.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Balpay\Hook;
@@ -10,7 +11,6 @@ use SixShop\Payment\PaymentInfo;
 
 class BalpayHook
 {
-
     /**
      * 上报提供的支付服务信息
      */
@@ -26,4 +26,4 @@ class BalpayHook
             ]
         );
     }
-}
+}

+ 2 - 1
src/Model/ExtensionBalpayLogModel.php

@@ -1,4 +1,5 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Balpay\Model;
@@ -32,4 +33,4 @@ class ExtensionBalpayLogModel extends Model
     {
         return $data['type']->toString();
     }
-}
+}

+ 6 - 6
src/PaymentProvider.php

@@ -1,16 +1,15 @@
 <?php
+
 declare(strict_types=1);
 
 namespace SixShop\Balpay;
 
 use app\model\User;
-use function SixShop\Core\throw_logic_exception;
 use SixShop\Balpay\Entity\ExtensionBalpayLogEntity;
 use SixShop\Balpay\Enum\BalpayLogTypeEnum;
 use SixShop\Payment\Contracts\PaymentNotifyResult;
 use SixShop\Payment\Contracts\PaymentProviderInterface;
 use SixShop\Payment\Contracts\PaymentQueryResult;
-use SixShop\Payment\Contracts\PaymentRefundQueryResult;
 use SixShop\Payment\Contracts\PaymentRefundRequest;
 use SixShop\Payment\Contracts\PaymentRefundResult;
 use SixShop\Payment\Contracts\PaymentResponse;
@@ -24,16 +23,17 @@ use SixShop\Payment\Event\RefundSuccessEvent;
 use think\facade\Db;
 use think\facade\Event;
 
+use function SixShop\Core\throw_logic_exception;
+
 class PaymentProvider implements PaymentProviderInterface
 {
-    const string PAYMENT_TYPE = 'balpay';
+    public const string PAYMENT_TYPE = 'balpay';
 
     public function __construct(
         private readonly ExtensionBalpayLogEntity $logEntity,
         private readonly ExtensionPaymentEntity   $extensionPaymentEntity,
         private readonly ExtensionRefundEntity  $extensionRefundEntity,
-    )
-    {
+    ) {
     }
 
     public function create(array $order, PaymentBizEnum $bizType): PaymentResponse
@@ -131,4 +131,4 @@ class PaymentProvider implements PaymentProviderInterface
             throw_logic_exception('支付密码错误', status: 'balpay.pay_password_error');
         }
     }
-}
+}