소스 검색

feat(lakala): add update time column and receiver update functionality

- Added update time column to profit share receiver table
- Implemented receiver information update API endpoint
- Added update action enum value and status handling
- Updated configuration fields for org code and notify URLs
- Enhanced receiver list view with action type display
- Improved transaction handling for receiver updates
- Added duplicate submission prevention logic
runphp 4 달 전
부모
커밋
d37191874b

+ 16 - 16
config.php

@@ -206,6 +206,21 @@ return json_decode(<<<'JSON'
         "display": true,
         "hidden": false
       },
+   {
+   "type": "input",
+    "title": "机构代码(org_code)",
+    "field": "org_code",
+    "value":"1",
+    "props": {
+      "placeholder": "请输入机构代码"
+    },
+    "$required": true,
+    "_fc_id": "id_F0j5md1fz7stawc",
+    "name": "ref_Ffipmd1fz7staxc",
+    "_fc_drag_tag": "input",
+    "display": true,
+    "hidden": false
+   },
        {
     "type": "input",
     "title": "支付回调地址",
@@ -235,22 +250,7 @@ return json_decode(<<<'JSON'
     "_fc_drag_tag": "input",
     "display": true,
     "hidden": false
-  },
-   {
-   "type": "input",
-    "title": "机构代码",
-    "field": "org_code",
-    "value":"1",
-    "props": {
-      "placeholder": "请输入机构代码"
-    },
-    "$required": true,
-    "_fc_id": "id_F0j5md1fz7stawc",
-    "name": "ref_Ffipmd1fz7staxc",
-    "_fc_drag_tag": "input",
-    "display": true,
-    "hidden": false
-   }
+  }
     ],
     "_fc_drag_tag": "elCard",
     "_fc_id": "id_Fpcxmh2zkilk14fc",

+ 5 - 1
resource/admin/ProfitShareReceiver.vue

@@ -58,8 +58,9 @@
         </el-table-column>
         <el-table-column prop="contact_mobile" label="联系手机号" width="120" />
         <el-table-column prop="status_text" label="状态" width="100" />
-        <el-table-column prop="create_time" label="申请时间" width="180" />
         <el-table-column prop="fail_reason" label="失败原因" min-width="150" />
+        <el-table-column prop="create_time" label="申请时间" width="180" />
+        <el-table-column prop="update_time" label="更新时间" width="180" />
         <el-table-column label="操作" width="150" fixed="right">
           <template #default="{ row }">
             <el-button type="primary" size="small" @click="handleView(row)">详情</el-button>
@@ -135,6 +136,9 @@
         <el-form-item label="申请时间:">
           <span>{{ detailData.create_time }}</span>
         </el-form-item>
+        <el-form-item label="更新时间:">
+          <span>{{ detailData.update_time }}</span>
+        </el-form-item>
         <el-form-item v-if="detailData.entrust_local_path" label="合作协议:">
           <el-link 
             :href="detailData.entrust_local_full_url || detailData.entrust_local_path" 

+ 26 - 0
src/Controller/Api/ProfitShareReceiverController.php

@@ -5,9 +5,12 @@ namespace SixShop\Lakala\Controller\Api;
 use SixShop\Core\Request;
 use SixShop\Lakala\Config;
 use SixShop\Lakala\Entity\ProfitShareReceiverEntity;
+use SixShop\Lakala\Enum\ReceiverActionEnum;
+use SixShop\Lakala\Enum\ReceiverStatusEnum;
 use think\Response;
 use function SixShop\Core\page_response;
 use function SixShop\Core\success_response;
+use function SixShop\Core\throw_logic_exception;
 
 class ProfitShareReceiverController
 {
@@ -30,4 +33,27 @@ class ProfitShareReceiverController
         $params = ['user_id' => $request->userID, 'id' => $id];
         return success_response($entity->getReceiver($params));
     }
+
+    public function update(int $id, Request $request, ProfitShareReceiverEntity $entity):Response
+    {
+        $params = [
+            'user_id' => $request->userID,
+            'id' => $id
+        ];
+        $data = $request->post([
+            'receiver_name/s',
+            'contact_mobile/s',
+            'acct_certificate_no/s',
+            'acct_type_code/s',
+            'acct_name/s',
+            'acct_open_bank_name/s',
+            'acct_no/s',
+        ]);
+        $entity->where([
+            'user_id' => $request->userID,
+            'action' => ReceiverActionEnum::UPDATE,
+            'status' => ReceiverStatusEnum::PENDING,
+        ])->count() > 0 && throw_logic_exception('有待处理的变更申请,请勿重复提交');
+        return success_response($entity->updateReceiver($params, $data));
+    }
 }

+ 30 - 2
src/Entity/ProfitShareReceiverEntity.php

@@ -5,6 +5,7 @@ namespace SixShop\Lakala\Entity;
 
 use SixShop\Core\Entity\BaseEntity;
 use SixShop\Core\Exception\LogicException;
+use SixShop\Lakala\Enum\ReceiverActionEnum;
 use SixShop\Lakala\Enum\UploadFileTypeEnum;
 use SixShop\Lakala\Facade\Config;
 use SixShop\Lakala\Enum\ProfitShareOrderStatusEnum;
@@ -31,6 +32,8 @@ class ProfitShareReceiverEntity extends BaseEntity
         }
         $entity->data($data);
         Db::transaction(function () use ($entity) {
+            $entity->action = ReceiverActionEnum::ADD;
+            $entity->status = ReceiverStatusEnum::PENDING;
             $entity->save();
             $result = MMSService::cardBin($entity->order_no, $entity->acct_no, $entity->org_code);
             $entity->acct_open_bank_code = $result->bankCode;
@@ -45,6 +48,7 @@ class ProfitShareReceiverEntity extends BaseEntity
     {
         return $this->withSearch(['order_no', 'status', 'user_id'], $params)
             ->append(['action_text','status_text'])
+            ->order('id', 'desc')
             ->paginate($pageAndLimit);
     }
 
@@ -87,8 +91,8 @@ class ProfitShareReceiverEntity extends BaseEntity
     public function apply(int $id): self
     {
         $entity = $this->getReceiver(['id' => $id]);
-        if ($entity->status != ReceiverStatusEnum::PENDING) {
-            throw_logic_exception('待审核状态才可以申请!');
+        if ($entity->status != ReceiverStatusEnum::PENDING || $entity->action != ReceiverActionEnum::ADD) {
+            throw_logic_exception('待审核状态新增记录才可以申请!');
         }
         $reqData = [
             'orderNo' => $entity->order_no,
@@ -165,4 +169,28 @@ class ProfitShareReceiverEntity extends BaseEntity
         $entity->save();
         return $entity;
     }
+
+    public function updateReceiver(array $params, array $data):self
+    {
+        /* @var self $entity */
+        $entity = $this->where($params)->findOrEmpty();
+        if ($entity->isEmpty()) {
+            throw_logic_exception('分账接收方申请记录不存在!');
+        }
+        $saveData = $entity->toArray();
+        unset($saveData['id'], $saveData['order_no'], $saveData['create_time']);
+        $saveData = array_merge($saveData, $data);
+        $this->data($saveData);
+        Db::transaction(function () use ($entity) {
+            $this->action = ReceiverActionEnum::UPDATE;
+            $this->status = ReceiverStatusEnum::PENDING;
+            $this->save();
+            $result = MMSService::cardBin($this->order_no, $this->acct_no, $this->org_code);
+            $this->acct_open_bank_code = $result->bankCode;
+            $this->acct_clear_bank_code = $result->clearingBankCode;
+            $this->fail_reason = '';
+            $this->save();
+        });
+        return  $this;
+    }
 }

+ 1 - 1
src/Enum/ReceiverActionEnum.php

@@ -10,7 +10,7 @@ enum ReceiverActionEnum:string
     public function toString()
     {
         return match ($this) {
-            self::ADD => '创建',
+            self::ADD => '新增',
             self::UPDATE => '变更',
         };
     }