Browse Source

refactor(ThirdParty): 新增获取配置 DTO 方法

- 在 WebhookReceiver 服务中添加了抽象方法 getConfigDto
- 要求子类实现该方法并返回 Config 对象
- 为后续的参数校验和处理逻辑做准备
notfff 6 tháng trước cách đây
mục cha
commit
976409773b

+ 1 - 0
ThirdParty/Urs/Dto/Config.php

@@ -12,4 +12,5 @@ class Config extends \App\Module\ThirdParty\Dto\Credential
 
 
 
+
 }

+ 0 - 2
ThirdParty/Urs/Webhook/UrsCheckWebhook.php

@@ -3,9 +3,7 @@
 namespace ThirdParty\Urs\Webhook;
 
 use App\Module\ThirdParty\Models\ThirdPartyService as ServiceModel;
-use App\Module\ThirdParty\Services\WebhookReceiver;
 use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Log;
 
 /**
  * URS余额检查Webhook处理器

+ 9 - 12
ThirdParty/Urs/Webhook/UrsDepositWebhook.php

@@ -3,7 +3,7 @@
 namespace ThirdParty\Urs\Webhook;
 
 use App\Module\ThirdParty\Models\ThirdPartyService as ServiceModel;
-use App\Module\ThirdParty\Services\WebhookReceiver;
+
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Log;
 
@@ -12,7 +12,7 @@ use Illuminate\Support\Facades\Log;
  *
  * 专门处理充值相关的Webhook通知
  */
-class UrsDepositWebhook extends WebhookReceiver
+class UrsDepositWebhook extends \ThirdParty\Urs\Webhook\WebhookReceiver
 {
 
     /**
@@ -46,7 +46,7 @@ class UrsDepositWebhook extends WebhookReceiver
         $this->validateDepositRequest($request);
 
         // 处理充值通知
-        return $this->processDepositNotification($request);
+        return $this->processDepositNotification($request->get('user_id'), $request->get('amount'), $request->get('order_id'));
     }
 
     /**
@@ -91,22 +91,19 @@ class UrsDepositWebhook extends WebhookReceiver
      * @param Request $request 请求对象
      * @return array
      */
-    protected function processDepositNotification(Request $request): array
+    protected function processDepositNotification($user_id, $amount, $order_id): array
     {
-        $userId  = $request->input('user_id');
-        $amount  = $request->input('amount');
-        $orderId = $request->input('order_id');
-
+        $tid = $this->getConfigDto()->
 
         // 记录处理日志
         Log::info("URS充值通知处理", [
-            'user_id'  => $userId,
-            'amount'   => $amount,
-            'order_id' => $orderId,
+            'user_id'    => $user_id,
+            'amount'     => $amount,
+            'order_id'   => $order_id,
             'request_id' => $this->getRequestId(),
         ]);
 
-        // 进行重置钻石逻辑
+
         // 先创建充值单,然后返回成功,通过会队列处理充值单
         $rorder_id = time();
 

+ 0 - 2
ThirdParty/Urs/Webhook/UrsRegisterWebhook.php

@@ -3,9 +3,7 @@
 namespace ThirdParty\Urs\Webhook;
 
 use App\Module\ThirdParty\Models\ThirdPartyService as ServiceModel;
-use App\Module\ThirdParty\Services\WebhookReceiver;
 use Illuminate\Http\Request;
-use Illuminate\Support\Facades\Log;
 
 /**
  * URS注册通知Webhook处理器

+ 0 - 1
ThirdParty/Urs/Webhook/UrsWithdrawWebhook.php

@@ -3,7 +3,6 @@
 namespace ThirdParty\Urs\Webhook;
 
 use App\Module\ThirdParty\Models\ThirdPartyService as ServiceModel;
-use App\Module\ThirdParty\Services\WebhookReceiver;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\Log;
 

+ 22 - 0
ThirdParty/Urs/Webhook/WebhookReceiver.php

@@ -0,0 +1,22 @@
+<?php
+
+namespace ThirdParty\Urs\Webhook;
+
+use App\Module\ThirdParty\Dto\Config;
+use App\Module\ThirdParty\Dto\Credential;
+use Illuminate\Http\Request;
+
+abstract class WebhookReceiver extends \App\Module\ThirdParty\Services\WebhookReceiver
+{
+
+
+    /**
+     *
+     * @return  \ThirdParty\Urs\Dto\Config
+     */
+    protected function getConfigDto(): Config
+    {
+        return \ThirdParty\Urs\Dto\Config::fromArray($this->getConfig());
+    }
+
+}