Преглед изворни кода

feat(lakala): implement profit share receiver binding application

- Add LedgerService::applyBind call in ProfitShareReceiverEntity
- Update LedgerService::applyBind to include merchant info and notify URL
- Improve response handling with proper error exceptions
- Set receiver status to BOUND after successful binding
- Remove debug print statements and unused response outputs
runphp пре 4 месеци
родитељ
комит
13e62a6c3a
2 измењених фајлова са 19 додато и 12 уклоњено
  1. 9 1
      src/Entity/ProfitShareReceiverEntity.php
  2. 10 11
      src/Service/LedgerService.php

+ 9 - 1
src/Entity/ProfitShareReceiverEntity.php

@@ -137,7 +137,15 @@ class ProfitShareReceiverEntity extends BaseEntity
             $entity->entrust_file_path = $response->attFileId;
             $entity->save();
         }
-        // todo 绑定申请
+        LedgerService::applyBind([
+            'orderNo' => $entity->order_no,
+            'orgCode' => $entity->org_code,
+            'receiverNo' => $entity->receiver_no,
+            'entrustFileName' => $entity->entrust_file_name,
+            'entrustFilePath' => $entity->entrust_file_path,
+        ]);
+        $entity->status = ReceiverStatusEnum::BOUND;
+        $entity->save();
         return $entity;
     }
 }

+ 10 - 11
src/Service/LedgerService.php

@@ -102,24 +102,23 @@ class LedgerService
      * @param string $version
      * @link https://o.lakala.com/#/home/document/detail?id=386
      */
-    public  function applyBind(array $reqData, string $version = '1.0')
+    public  function applyBind(array $reqData, string $version = '1.0'): object
     {
         $request = new V2ModelRequest();
         $reqData['version'] = $version;
+        $reqData['merCupNo'] = $this->config->merchant_no;
+        $reqData['retUrl'] = $this->config->notify_url;
         $request->setReqData($reqData);
         $response = $this->v2LakalaApi->tradeApi('/api/v2/mms/openApi/ledger/applyBind', $request);
-        if ($response->getRespData()) {
-            print_r($response->getRespData());
+        if ($response->getRetCode() == '000000') {
+            return $response->getRespData();
         } else {
-            print_r($response);
+            throw_logic_exception(
+                msg:$response->getRetMsg(),
+                code: (int)$response->getRetCode(),
+                data: $response->getRespData(),
+            );
         }
-        echo $response->getRetCode();
-
-        # 响应头信息
-        print_r($response->getHeaders());
-
-        # 响应原文
-        echo $response->getOriginalText();
     }
 
     /**