Răsfoiți Sursa

feat(lakala): 新增卡BIN查询功能并优化台账接收方申请接口

- 在 LedgerService 中移除调试代码并支持传入请求数据
- 新增 MMSService 类实现卡BIN查询接口调用
- 统一接口版本号默认值为1.0
- 优化响应数据处理逻辑和错误输出方式- 添加响应头信息和原始报文输出功能
- 完善接口文档注释和参数说明
runphp 4 luni în urmă
părinte
comite
992ccd7d89
2 a modificat fișierele cu 57 adăugiri și 8 ștergeri
  1. 6 8
      src/Service/LedgerService.php
  2. 51 0
      src/Service/MMSService.php

+ 6 - 8
src/Service/LedgerService.php

@@ -1,5 +1,6 @@
 <?php
 <?php
 declare(strict_types=1);
 declare(strict_types=1);
+
 namespace SixShop\Lakala\Service;
 namespace SixShop\Lakala\Service;
 
 
 use SixShop\Lakala\Config;
 use SixShop\Lakala\Config;
@@ -12,6 +13,7 @@ use SixShop\Lakala\OpenAPISDK\V2\Model\V2ModelRequest;
 class LedgerService
 class LedgerService
 {
 {
     private V2LakalaApi $v2LakalaApi;
     private V2LakalaApi $v2LakalaApi;
+
     public function __construct(Config $config)
     public function __construct(Config $config)
     {
     {
         $this->v2LakalaApi = new V2LakalaApi($config->getV2Config());
         $this->v2LakalaApi = new V2LakalaApi($config->getV2Config());
@@ -22,19 +24,15 @@ class LedgerService
      *
      *
      * @link https://o.lakala.com/#/home/document/detail?id=382
      * @link https://o.lakala.com/#/home/document/detail?id=382
      */
      */
-    public function applyLedgerReceiver()
+    public function applyLedgerReceiver(array $reqData)
     {
     {
         $request = new V2ModelRequest();
         $request = new V2ModelRequest();
-        $request->setReqData([
-
-        ]);
+        $reqData['version'] = '1.0';
+        $request->setReqData($reqData);
         $response = $this->v2LakalaApi->tradeApi('/api/v2/mms/openApi/ledger/applyLedgerReceiver', $request);
         $response = $this->v2LakalaApi->tradeApi('/api/v2/mms/openApi/ledger/applyLedgerReceiver', $request);
-      dd($response);
         if ($response->getRespData()) {
         if ($response->getRespData()) {
             print_r($response->getRespData());
             print_r($response->getRespData());
-            print_r($response->getAccRespFields());
-        }
-        else {
+        } else {
             print_r($response);
             print_r($response);
         }
         }
         echo $response->getRetCode();
         echo $response->getRetCode();

+ 51 - 0
src/Service/MMSService.php

@@ -0,0 +1,51 @@
+<?php
+declare(strict_types=1);
+
+namespace SixShop\Lakala\Service;
+
+use SixShop\Lakala\Config;
+use SixShop\Lakala\OpenAPISDK\V2\Api\V2LakalaApi;
+use SixShop\Lakala\OpenAPISDK\V2\Model\V2ModelRequest;
+
+class MMSService
+{
+    private V2LakalaApi $v2LakalaApi;
+
+    public function __construct(Config $config)
+    {
+        $this->v2LakalaApi = new V2LakalaApi($config->getV2Config());
+    }
+
+    /**
+     * 卡BIN查询
+     *
+     * @param string $orderNo 订单编号(便于后续跟踪排查问题及核对报文) 14位年月日时(24小时制)分秒+8位的随机数(不重复)如:2021020112000012345678
+     * @param string $orgCode 机构代码
+     * @param string $cardNo 银行卡号
+     * @param string $version 接口版本号 默认1.0
+     * @return void
+     */
+    public function cardBin(string $orderNo, string $orgCode, string $cardNo, string $version = '1.0')
+    {
+        $request = new V2ModelRequest();
+        $request->setReqData([
+            'version' => $version,
+            'orderNo' => $orderNo,
+            'orgCode' => $orgCode,
+            'cardNo' => $cardNo,
+        ]);
+        $response = $this->v2LakalaApi->tradeApi('/api/v2/mms/openApi/cardBin', $request);
+        if ($response->getRespData()) {
+            print_r($response->getRespData());
+        } else {
+            print_r($response);
+        }
+        echo $response->getRetCode();
+
+        # 响应头信息
+        print_r($response->getHeaders());
+
+        # 响应原文
+        echo $response->getOriginalText();
+    }
+}