浏览代码

feat(lakala): add action type display for profit share receiver

- Add new column "申请类型" to show receiver action type in admin list
- Introduce ReceiverActionEnum with ADD and UPDATE cases
- Append action_text attribute to receiver entity queries
- Register action enum type in ProfitShareReceiverModel
- Implement getActionTextAttr method for model
- Update test case to include response dump for debugging
runphp 4 月之前
父节点
当前提交
462852ac68

+ 2 - 1
resource/admin/ProfitShareReceiver.vue

@@ -34,7 +34,7 @@
     <el-card class="table-card">
       <template #header>
         <div class="table-header">
-          <div class="header-title">分账接收方列表</div>
+          <div class="header-title">申请列表</div>
         </div>
       </template>
       
@@ -46,6 +46,7 @@
       >
         <el-table-column prop="id" label="ID" width="80" />
         <el-table-column prop="order_no" label="订单编号" min-width="180" />
+        <el-table-column prop="action_text" label="申请类型" width="100" />
         <el-table-column prop="receiver_name" label="接收方名称" min-width="120" />
         <el-table-column prop="receiver_no" label="接收方编号" min-width="150" />
         <el-table-column prop="acct_name" label="收款账户名称" min-width="120" />

+ 2 - 2
src/Entity/ProfitShareReceiverEntity.php

@@ -44,14 +44,14 @@ class ProfitShareReceiverEntity extends BaseEntity
     public function getReceiverList(array $params, array $pageAndLimit): Paginator
     {
         return $this->withSearch(['order_no', 'status', 'user_id'], $params)
-            ->append(['status_text'])
+            ->append(['action_text','status_text'])
             ->paginate($pageAndLimit);
     }
 
     public function getReceiver(array $params): self
     {
         $entity = $this->where($params)
-            ->append(['status_text'])
+            ->append(['action_text','status_text'])
             ->findOrEmpty();
         if ($entity->isEmpty()) {
             throw_logic_exception('分账接收方申请记录不存在!');

+ 17 - 0
src/Enum/ReceiverActionEnum.php

@@ -0,0 +1,17 @@
+<?php
+declare(strict_types=1);
+namespace SixShop\Lakala\Enum;
+
+enum ReceiverActionEnum:string
+{
+    case ADD = 'add';
+    case UPDATE = 'update';
+
+    public function toString()
+    {
+        return match ($this) {
+            self::ADD => '创建',
+            self::UPDATE => '变更',
+        };
+    }
+}

+ 7 - 0
src/Model/ProfitShareReceiverModel.php

@@ -2,6 +2,7 @@
 declare(strict_types=1);
 namespace SixShop\Lakala\Model;
 
+use SixShop\Lakala\Enum\ReceiverActionEnum;
 use SixShop\Lakala\Enum\ReceiverStatusEnum;
 use SixShop\Payment\Enum\NumberBizEnum;
 use think\db\Query;
@@ -16,6 +17,7 @@ class ProfitShareReceiverModel extends Model
         return [
             'name' => 'profit_share_receiver',
             'type' => [
+                'action' => ReceiverActionEnum::class,
                 'status' => ReceiverStatusEnum::class
             ],
             'insert' => ['order_no'],
@@ -27,6 +29,11 @@ class ProfitShareReceiverModel extends Model
     {
         return generate_number(NumberBizEnum::PROFIT_SHARE_RECEIVER, 5);
     }
+
+    public function getActionTextAttr($value, $data)
+    {
+        return $data['action']->toString();
+    }
     public function getStatusTextAttr($value, $data)
     {
         return $data['status']->toString();

+ 2 - 1
tests/Service/LedgerServiceTest.php

@@ -60,7 +60,8 @@ class LedgerServiceTest extends TestCase
     #[Test]
     public function queryReceiverDetail():void
     {
-        $this->ledgerService->queryReceiverDetail(generate_number(NumberBizEnum::PROFIT_SHARE_RECEIVER, 5), 'SR2024021200610',);
+        $response = $this->ledgerService->queryReceiverDetail(generate_number(NumberBizEnum::PROFIT_SHARE_RECEIVER, 5), 'SR2024021200610',);
+        dump($response);
     }
 
     #[Test]