Jelajahi Sumber

feat(lakala): 新增分账接收方管理及文件上传功能

- 新增 UploadFileType 枚举类,定义各类上传文件类型
- 在 LedgerService 中增加 modifyLedgerReceiver 和 queryReceiverDetail 方法
-优化 applyLedgerReceiver 方法参数,支持自定义版本号
- 在 MMSService 中新增 uploadFile 方法,支持文件上传
- 调整 cardBin 方法参数顺序并设置默认机构代码
- 统一接口响应处理逻辑,增加响应头与原始文本输出
runphp 4 bulan lalu
induk
melakukan
c673a02cd9
3 mengubah file dengan 168 tambahan dan 4 penghapusan
  1. 79 0
      src/Enum/UploadFileType.php
  2. 61 2
      src/Service/LedgerService.php
  3. 28 2
      src/Service/MMSService.php

+ 79 - 0
src/Enum/UploadFileType.php

@@ -0,0 +1,79 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Lakala\Enum;
+
+enum UploadFileType:string
+{
+    /**
+     * 法人身份证正面
+     */
+    case FR_ID_CARD_FRONT = 'FR_ID_CARD_FRONT';
+    /**
+     * 法人身份证反面
+     */
+    case FR_ID_CARD_BEHIND = 'FR_ID_CARD_BEHIND';
+    /**
+     * 结算人身份证正面
+     */
+    case ID_CARD_FRONT = 'ID_CARD_FRONT';
+    /**
+     * 结算人身份证反面
+     */
+    case ID_CARD_BEHIND = 'ID_CARD_BEHIND';
+    /**
+     * 银行卡
+     */
+    case BANK_CARD = 'BANK_CARD';
+    /**
+     * 营业执照
+     */
+    case BUSINESS_LICENCE = 'BUSINESS_LICENCE';
+    /**
+     * 商户门头照
+     */
+    case MERCHANT_PHOTO = 'MERCHANT_PHOTO';
+    /**
+     * 商户门头照
+     */
+    case SHOPINNER = 'SHOPINNER';
+    /**
+     * 线下纸质协议
+     */
+    case XY = 'XY';
+    /**
+     * 电子协议
+     */
+    case NETWORK_XY = 'NETWORK_XY';
+    /**
+     * 合约
+     */
+    case HT = 'HT';
+    /**
+     * 合作资质证明
+     */
+    case COOPERATION_QUALIFICATION_PROOF = 'COOPERATION_QUALIFICATION_PROOF';
+    /**
+     * 食品经营相关资质
+     */
+    case FOOD_QUALIFICATION_PROOF = 'FOOD_QUALIFICATION_PROOF';
+    /**
+     * 非法人结算授权书
+     */
+    case NO_LEGAL_PERSON_SETT_AUTH_LETTER = 'NO_LEGAL_PERSON_SETT_AUTH_LETTER';
+    /**
+     * 结算授权委托书
+     */
+    case SPLIT_ENTRUST_FILE = 'SPLIT_ENTRUST_FILE';
+    /**
+     * 集市方与场地方间的租赁协议
+     */
+    case RENTAL_AGREEMENT = 'RENTAL_AGREEMENT';
+    /**
+     * 集市方与摊主间的合作协议
+     */
+    case SPLIT_COOPERATION_FILE = 'SPLIT_COOPERATION_FILE';
+    /**
+     * 其他
+     */
+    case OTHERS = 'OTHERS';
+}

+ 61 - 2
src/Service/LedgerService.php

@@ -24,10 +24,10 @@ class LedgerService
      *
      * @link https://o.lakala.com/#/home/document/detail?id=382
      */
-    public function applyLedgerReceiver(array $reqData)
+    public function applyLedgerReceiver(array $reqData, string $version = '1.0')
     {
         $request = new V2ModelRequest();
-        $reqData['version'] = '1.0';
+        $reqData['version'] = $version;
         $request->setReqData($reqData);
         $response = $this->v2LakalaApi->tradeApi('/api/v2/mms/openApi/ledger/applyLedgerReceiver', $request);
         if ($response->getRespData()) {
@@ -43,4 +43,63 @@ class LedgerService
         # 响应原文
         echo $response->getOriginalText();
     }
+
+    /**
+     * 分账接收方信息变更
+     *
+     * @link https://o.lakala.com/#/home/document/detail?id=383
+     */
+    public function modifyLedgerReceiver(array $reqData, string $version = '1.0')
+    {
+        $request = new V2ModelRequest();
+        $reqData['version'] = $version;
+        $request->setReqData($reqData);
+        $response = $this->v2LakalaApi->tradeApi('/api/v2/mms/openApi/ledger/modifyLedgerReceiver', $request);
+        if ($response->getRespData()) {
+            print_r($response->getRespData());
+        } else {
+            print_r($response);
+        }
+        echo $response->getRetCode();
+
+        # 响应头信息
+        print_r($response->getHeaders());
+
+        # 响应原文
+        echo $response->getOriginalText();
+    }
+
+    /**
+     * 分账接收方详情查询
+     *
+     * @param string $orderNo 订单号
+     * @param string $receiverNo 接收方编号
+     * @param string $orgCode 机构编号
+     * @param string $version 接口版本号 默认1.0
+     *
+     * @link https://o.lakala.com/#/home/document/detail?id=385
+     */
+    public function queryReceiverDetail(string $orderNo, string  $receiverNo, string $orgCode = '1', string $version = '1.0')
+    {
+        $request = new V2ModelRequest();
+        $request->setReqData([
+            'version' => $version,
+            'orderNo' => $orderNo,
+            'orgCode' => $orgCode,
+            'receiverNo' => $receiverNo,
+        ]);
+        $response = $this->v2LakalaApi->tradeApi('/api/v2/mms/openApi/ledger/queryReceiverDetail', $request);
+        if ($response->getRespData()) {
+            print_r($response->getRespData());
+        } else {
+            print_r($response);
+        }
+        echo $response->getRetCode();
+
+        # 响应头信息
+        print_r($response->getHeaders());
+
+        # 响应原文
+        echo $response->getOriginalText();
+    }
 }

+ 28 - 2
src/Service/MMSService.php

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