feat(split): 添加批量查询手动分账覆盖和变更历史功能

- 新增 SplitManualService::orderIdsWithOverride 方法用于批量查询存在手动覆盖的订单
- 新增 SplitManualService::orderIdsWithLog 方法用于批量查询存在变更历史的订单
- 在订单列表页面优化性能,批量查询订单的手动覆盖和变更历史状态
- 添加 can_view_manual_history 权限控制,允许成功/失败后查看变更历史
- 更新前端界面显示逻辑,优化变更历史查看权限判断
- 增强操作提示文案,说明变更历史查看功能
```
这个提交包含在:
可乐加冰
2026-10-23 00:15:38 +08:00
父节点 af08af8d47
当前提交 d2f22d7ecf
共有 4 个文件被更改,包括 55 次插入 和 3 次删除

查看文件

@@ -26,6 +26,34 @@ class SplitManualService
return (bool) SplitManual::where('order_id', intval($orderId))->find();
}
/**
* 批量:存在手动覆盖的 order_id
* @param int[] $orderIds
* @return int[]
*/
public function orderIdsWithOverride(array $orderIds)
{
$orderIds = array_values(array_unique(array_filter(array_map('intval', $orderIds))));
if (!$orderIds) {
return [];
}
return array_map('intval', SplitManual::where('order_id', 'in', $orderIds)->column('order_id'));
}
/**
* 批量:存在变更历史的 order_id
* @param int[] $orderIds
* @return int[]
*/
public function orderIdsWithLog(array $orderIds)
{
$orderIds = array_values(array_unique(array_filter(array_map('intval', $orderIds))));
if (!$orderIds) {
return [];
}
return array_map('intval', SplitManualLog::where('order_id', 'in', $orderIds)->group('order_id')->column('order_id'));
}
/**
* 供 SplitCalculator 使用的明细
* @return array

查看文件

@@ -135,6 +135,18 @@ class Order extends Base
protected function formatSplitOrderList($list)
{
$rows = [];
$manualService = new SplitManualService();
$orderIds = [];
foreach ($list as $item) {
$data = is_array($item) ? $item : $item->toArray();
$oid = intval($data['order_id'] ?? 0);
if ($oid > 0) {
$orderIds[] = $oid;
}
}
$overrideOrderIds = array_flip($manualService->orderIdsWithOverride($orderIds));
$logOrderIds = array_flip($manualService->orderIdsWithLog($orderIds));
foreach ($list as $item) {
$data = is_array($item) ? $item : $item->toArray();
@@ -193,8 +205,14 @@ class Order extends Base
$orderSplitSource = $data['split_source'] ?? 'auto';
$data['split_source'] = $orderSplitSource;
$data['split_source_text'] = $orderSplitSource === 'manual' ? '手动指定' : $data['calc_source_text'];
$data['has_manual_override'] = (new SplitManualService())->hasOverride($orderId);
$hasOverride = isset($overrideOrderIds[$orderId]);
$hasManualLog = isset($logOrderIds[$orderId]);
$data['has_manual_override'] = $hasOverride;
$data['has_manual_log'] = $hasManualLog;
$data['can_edit_manual'] = ($status === 4 && $channel === 'huifu');
// 变更历史:成功/失败后均可查看,不限于 status=4
$data['can_view_manual_history'] = ($channel === 'huifu')
&& ($hasOverride || $hasManualLog || $orderSplitSource === 'manual');
unset($data['order'], $data['receivers']);
$rows[] = $data;

查看文件

@@ -377,7 +377,7 @@
<el-table-column label="操作" width="200" fixed="right">
<template slot-scope="s">
<el-button type="text" size="small" v-if="s.row.can_edit_manual" @click="openManualDialog(s.row)">指定接收方</el-button>
<el-button type="text" size="small" v-if="s.row.can_edit_manual && (s.row.has_manual_override || s.row.split_source === 'manual')" @click="openHistoryDrawer(s.row)">变更历史</el-button>
<el-button type="text" size="small" v-if="s.row.can_view_manual_history" @click="openHistoryDrawer(s.row)">变更历史</el-button>
<el-button type="text" size="small" v-if="s.row.status == 4" @click="retry(s.row)">重试</el-button>
<el-button type="text" size="small" @click="query(s.row.id)">同步</el-button>
</template>
@@ -395,7 +395,7 @@
@size-change="onSizeChange">
</el-pagination>
</div>
<p class="op-hint">失败汇付单可「指定接收方」改人改金额后重试;「同步」只更新状态,不会重复扣款。</p>
<p class="op-hint">失败汇付单可「指定接收方」改人改金额后重试;分账成功或失败后均可点「变更历史」查看每次改人记录。「同步」只更新状态,不会重复扣款。</p>
</div>
<!-- 指定接收方弹窗 -->
@@ -452,6 +452,7 @@
</div>
<span slot="footer">
<el-button size="small" @click="manualDialogVisible = false">取消</el-button>
<el-button size="small" type="text" v-if="manualRow && manualRow.order_id" @click="openHistoryDrawer(manualRow)">查看变更历史</el-button>
<el-button size="small" v-if="manualContext.has_manual" @click="clearManualOverride">清除手动指定</el-button>
<el-button size="small" type="primary" plain :loading="manualSaving" @click="saveManual(false)">仅保存</el-button>
<el-button size="small" type="primary" :loading="manualSaving" @click="saveManual(true)">保存并重试</el-button>

查看文件

@@ -258,7 +258,12 @@ define(['jquery', 'bootstrap', 'backend', 'form'], function ($, undefined, Backe
});
},
openHistoryDrawer(row) {
if (!row || !row.order_id) {
Layer.msg('无法加载变更历史');
return;
}
this.historyRow = row;
this.manualDialogVisible = false;
this.historyDrawerVisible = true;
this.historyLoading = true;
this.historyList = [];