Ver Fonte

feat(lakala): 新增分账接收方状态管理功能

- 修改数据表名 profit_share_receivers为 profit_share_receiver
- 新增 status 字段用于记录接收方状态,包含7种状态枚举值
- 创建 ProfitShareReceiverEntity 和 ProfitShareReceiverModel 类
- 添加 ReceiverStatusEnum 枚举类定义状态码及中文描述-重命名 UploadFileType 枚举类为 UploadFileTypeEnum 并更新引用
- 升级 six-shop/payment 依赖版本至 v0.2.14- 在 MMSService 中更新附件上传接口参数类型声明- 实现状态字段自动转换为对应中文文本的功能
runphp há 4 meses atrás
pai
commit
f349bfcc5d

+ 1 - 1
composer.json

@@ -10,7 +10,7 @@
   ],
   "require": {
     "php": ">=8.3",
-    "six-shop/payment": ">=v0.2.13 <1.0",
+    "six-shop/payment": ">=v0.2.14 <1.0",
     "six-shop/core": ">=0.6 <1.0"
   },
   "authors": [

+ 2 - 1
database/migrations/20251109121623_profit_share_receiver.php

@@ -19,7 +19,7 @@ final class ProfitShareReceiver extends AbstractMigration
      */
     public function change(): void
     {
-        $this->table('profit_share_receivers', ['comment' => '分账接收方'])
+        $this->table('profit_share_receiver', ['comment' => '分账接收方'])
             ->addColumn('user_id', 'integer', ['null' => false, 'signed' => false, 'comment' => '用户ID'])
             ->addColumn('order_no', 'string', ['null' => false, 'limit' => 22, 'comment' => '订单编号'])
             ->addColumn('org_code', 'string', ['null' => false, 'limit' => 32, 'comment' => '机构编号'])
@@ -37,6 +37,7 @@ final class ProfitShareReceiver extends AbstractMigration
             ->addColumn('org_id', 'string', ['null' => true, 'limit' => 32,  'comment' => '接收方所属机构'])
             ->addColumn('org_name', 'string', ['null' => true, 'limit' => 32, 'comment' => '接收方所属机构名称'])
             ->addColumn('receiver_no', 'string', ['null' => true, 'limit' => 32, 'comment' => '接收方编号'])
+            ->addColumn('status', 'integer', ['signed' => false, 'default' => 1, 'comment' => '状态 1: 待审核 2:提交中 3: 验证通过 4: 验证失败 5:绑定中 6: 绑定成功 7: 绑定失败'])
             ->addTimestamps('create_time', 'update_time')
             ->create();
     }

+ 14 - 0
src/Entity/ProfitShareReceiverEntity.php

@@ -0,0 +1,14 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Lakala\Entity;
+
+use SixShop\Core\Entity\BaseEntity;
+use SixShop\Lakala\Model\ProfitShareReceiverModel;
+
+/**
+ * @mixin ProfitShareReceiverModel
+ */
+class ProfitShareReceiverEntity extends BaseEntity
+{
+
+}

+ 28 - 0
src/Enum/ReceiverStatusEnum.php

@@ -0,0 +1,28 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Lakala\Enum;
+
+enum ReceiverStatusEnum:int
+{
+    case PENDING = 1;
+    case SUBMITTING = 2;
+    case VERIFIED = 3;
+    case VERIFY_FAILED = 4;
+    case BINDING = 5;
+    case BOUND = 6;
+    case BIND_FAILED = 7;
+
+    public function toString(): string
+    {
+        return match ($this) {
+            self::PENDING => '待审核',
+            self::SUBMITTING => '提交中',
+            self::VERIFIED => '验证通过',
+            self::VERIFY_FAILED => '验证失败',
+            self::BINDING => '绑定中',
+            self::BOUND => '绑定成功',
+            self::BIND_FAILED => '绑定失败',
+            default => '未知状态',
+        };
+    }
+}

+ 1 - 1
src/Enum/UploadFileType.php → src/Enum/UploadFileTypeEnum.php

@@ -2,7 +2,7 @@
 declare(strict_types=1);
 namespace SixShop\Lakala\Enum;
 
-enum UploadFileType:string
+enum UploadFileTypeEnum:string
 {
     /**
      * 法人身份证正面

+ 30 - 0
src/Model/ProfitShareReceiverModel.php

@@ -0,0 +1,30 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Lakala\Model;
+
+use SixShop\Lakala\Enum\ReceiverStatusEnum;
+use SixShop\Payment\Enum\NumberBizEnum;
+use think\Model;
+
+class ProfitShareReceiverModel extends Model
+{
+
+    protected function getOptions(): array
+    {
+        return [
+            'name' => 'profit_share_receiver',
+            'type' => [
+                'status' => ReceiverStatusEnum::class
+            ]
+        ];
+    }
+
+    protected function setOrderNoAttr($value, $data): string
+    {
+        return generate_number(NumberBizEnum::PROFIT_SHARE_RECEIVER, 5);
+    }
+    public function getStatusTextAttr($value, $data)
+    {
+        return $data['status']->toString();
+    }
+}

+ 3 - 3
src/Service/MMSService.php

@@ -4,7 +4,7 @@ declare(strict_types=1);
 namespace SixShop\Lakala\Service;
 
 use SixShop\Lakala\Config;
-use SixShop\Lakala\Enum\UploadFileType;
+use SixShop\Lakala\Enum\UploadFileTypeEnum;
 use SixShop\Lakala\OpenAPISDK\V2\Api\V2LakalaApi;
 use SixShop\Lakala\OpenAPISDK\V2\Model\V2ModelRequest;
 
@@ -54,7 +54,7 @@ class MMSService
      * 附件上传
      *
      * @param string $orderNo
-     * @param UploadFileType $attType
+     * @param UploadFileTypeEnum $attType
      * @param string $attExtName
      * @param string $data
      * @param string $orgCode
@@ -62,7 +62,7 @@ class MMSService
      *
      * @link https://o.lakala.com/#/home/document/detail?id=90
      */
-    public function uploadFile(string $orderNo, UploadFileType $attType, string  $attExtName, string $data, string $orgCode = '1',  string $version = '1.0')
+    public function uploadFile(string $orderNo, UploadFileTypeEnum $attType, string  $attExtName, string $data, string $orgCode = '1',  string $version = '1.0')
     {
         $request = new V2ModelRequest();
         $attContext = base64_encode($data);