Răsfoiți Sursa

feat(profit-share): add effective time and modify receiver info

- Add `effective_time` column to profit share receiver migration
- Display effective time in admin table and detail view
- Add 'modify' route and controller method for receiver info updates
- Implement `modify` logic in ProfitShareReceiverEntity
- Add frontend handling for receiver modification application
- Adjust Vue template conditions for action buttons
- Remove `acct_name` from API request validation
- Automatically set effective time when status is bound
- Disable account name input in uniapp receiver change form
runphp 4 luni în urmă
părinte
comite
37685ecd9e

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

@@ -44,6 +44,7 @@ final class ProfitShareReceiver extends AbstractMigration
             ->addColumn('entrust_file_path', 'string', ['null' => true, 'limit' => 255, 'comment' => '合作协议附件路径'])
             ->addColumn('entrust_local_path', 'string', ['null' => true, 'limit' => 255, 'comment' => '合作协议附件本地路径'])
             ->addColumn('wallet_id', 'string', ['null' => true, 'limit' => 32, 'comment' => '钱包ID'])
+            ->addColumn('effective_time', 'timestamp', ['null' => true, 'comment' => '生效时间'])
             ->addTimestamps('create_time', 'update_time')
             ->addColumn('delete_time', 'timestamp', ['null' => true, 'comment' => '删除时间'])
             ->addIndex('user_id', ['name' => 'idx_user_id'])

+ 41 - 2
resource/admin/ProfitShareReceiver.vue

@@ -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="effective_time" label="生效时间" 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" />
@@ -97,12 +98,16 @@
         <el-form-item label="订单编号:">
           <span>{{ detailData.order_no }}</span>
         </el-form-item>
+        <el-form-item label="生效时间:">
+          <span>{{ detailData.effective_time }}</span>
+        </el-form-item>
         <el-form-item label="分账接收方名称:">
           <span>{{ detailData.receiver_name }}</span>
         </el-form-item>
         <el-form-item label="接收方编号:">
           <span>{{ detailData.receiver_no }}</span>
         </el-form-item>
+
         <el-form-item label="联系手机号:">
           <span>{{ detailData.contact_mobile }}</span>
         </el-form-item>
@@ -152,7 +157,7 @@
       <template #footer>
         <span class="dialog-footer">
           <el-button 
-            v-if="detailData.status === 1 && detailData.action === 'ADD'"
+            v-if="detailData.status === 1 && detailData.action === 'add'"
             type="success" 
             @click="handleCreateApplication"
             :loading="applyLoading"
@@ -160,7 +165,15 @@
             分账接收方创建申请
           </el-button>
           <el-button 
-            v-if="detailData.status === 3 && detailData.action === 'ADD'"
+            v-if="detailData.status === 1 && detailData.action === 'update'"
+            type="success" 
+            @click="handleUpdateApplication"
+            :loading="applyLoading"
+          >
+            分账接收方信息变更
+          </el-button>
+          <el-button 
+            v-if="detailData.status === 3 && detailData.action === 'add'"
             type="success" 
             @click="handleBindApplication"
             :loading="applyLoading"
@@ -385,6 +398,32 @@ export default {
       }
     },
     
+    // 分账接收方信息变更申请
+    async handleUpdateApplication() {
+      if (!this.axiosInstance) {
+        this.$message.error('无法获取请求实例')
+        return
+      }
+
+      this.applyLoading = true
+      try {
+        const res = await this.axiosInstance.put(`/lakala/profit_share_receiver/${this.detailData.id}/modify`)
+        if (res.code === 200) {
+          this.$message.success('分账接收方信息变更申请已提交')
+          this.handleCloseDetailDialog()
+          // 重新加载列表数据以更新状态
+          await this.fetchData()
+        } else {
+          this.$message.error(res.msg || res.message || '申请提交失败')
+        }
+      } catch (error) {
+        console.error('分账接收方信息变更申请失败:', error)
+        this.$message.error('申请提交失败: ' + (error.message || '未知错误'))
+      } finally {
+        this.applyLoading = false
+      }
+    },
+    
     // 分页相关
     handleSizeChange(val) {
       this.pagination.limit = val

+ 1 - 0
route/admin.php

@@ -16,6 +16,7 @@ use SixShop\System\Middleware\MacroPageMiddleware;
 Route::resource('profit_share_receiver', ProfitShareReceiverController::class, function () {
     Route::put('apply', [ProfitShareReceiverController::class, 'apply']);
     Route::put('bind', [ProfitShareReceiverController::class, 'bind']);
+    Route::put('modify', [ProfitShareReceiverController::class, 'modify']);
 })
     ->middleware(['auth', MacroPageMiddleware::class]);
 

+ 5 - 0
src/Controller/Admin/ProfitShareReceiverController.php

@@ -35,4 +35,9 @@ class ProfitShareReceiverController
     {
         return success_response($entity->bind($id));
     }
+
+    public function modify(int $id, ProfitShareReceiverEntity $entity): Response
+    {
+        return success_response($entity->modify($id));
+    }
 }

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

@@ -45,7 +45,6 @@ class ProfitShareReceiverController
             'contact_mobile/s',
             'acct_certificate_no/s',
             'acct_type_code/s',
-            'acct_name/s',
             'acct_open_bank_name/s',
             'acct_no/s',
         ]);

+ 32 - 0
src/Entity/ProfitShareReceiverEntity.php

@@ -81,6 +81,9 @@ class ProfitShareReceiverEntity extends BaseEntity
                     '1' => ReceiverStatusEnum::BOUND,
                     '2' => ReceiverStatusEnum::BIND_FAILED
                 };
+                if ($entity->status == ReceiverStatusEnum::BOUND) {
+                    $entity->effective_time = date('Y-m-d H:i:s');
+                }
                 $entity->fail_reason = $response->list[0]->remark;
                 $entity->save();
             }
@@ -193,4 +196,33 @@ class ProfitShareReceiverEntity extends BaseEntity
         });
         return  $this;
     }
+
+    public function modify(int $id): self
+    {
+        $entity = $this->where(['id' => $id])
+            ->append(['action_text','status_text'])
+            ->findOrEmpty();
+        if ($entity->isEmpty()) {
+            throw_logic_exception('分账接收方申请记录不存在!');
+        }
+        $reqData = [
+            'orderNo' => $entity->order_no,
+            'orgCode' => $entity->org_code,
+            'receiverNo' => $entity->receiver_no,
+            'receiverName' => $entity->receiver_name,
+            'contactMobile' => $entity->contact_mobile,
+            'acctNo' => $entity->acct_no,
+            'acctTypeCode' => $entity->acct_type_code,
+            'acctOpenBankCode' => $entity->acct_open_bank_code,
+            'acctOpenBankName' => $entity->acct_open_bank_name,
+            'acctClearBankCode' => $entity->acct_clear_bank_code,
+        ];
+        $response = LedgerService::modifyLedgerReceiver($reqData);
+        if ($response->receiverNo == $entity->receiver_no) {
+            $entity->status = ReceiverStatusEnum::BOUND;
+            $entity->effective_time = date('Y-m-d H:i:s');
+            $entity->save();
+        }
+        return $entity;
+    }
 }