feat(split): 添加分账诊断功能用于后台展示

- 新增 SplitCalculator::diagnose() 方法,用于诊断订单分账问题
- 返回分账来源、佣金总额、规则总额及具体问题说明
- 在管理员分账订单控制器中集成诊断信息显示
- 优化前端表格显示分账来源标签和诊断提示信息
- 修复佣金奖励查询中 agent_id 使用错误的问题
```
这个提交包含在:
可乐加冰
2026-10-05 13:05:53 +08:00
父节点 9181c7144f
当前提交 34c005d271
共有 3 个文件被更改,包括 137 次插入 和 4 次删除

查看文件

@@ -148,6 +148,13 @@ class Order extends Base
$data['receiver_summary'] = $summaryLines ? implode(';', $summaryLines) : '—';
$data['fail_reason'] = $this->formatFailReason($data['wx_result'] ?? '', $status);
$diag = (new SplitCalculator())->diagnose($orderId);
$data['split_source'] = $diag['final_source'];
$data['split_source_text'] = $this->formatSplitSourceText($diag);
$data['split_diagnose'] = $diag['issues'];
$data['commission_total'] = $diag['commission_total'];
$data['rule_total'] = $diag['rule_total'];
unset($data['order'], $data['receivers']);
$rows[] = $data;
}
@@ -280,6 +287,22 @@ class Order extends Base
return $mobile;
}
protected function formatSplitSourceText(array $diag)
{
$map = [
'commission' => '按佣金分账',
'rule' => '按规则分账(兜底)',
'none' => '未算出明细',
];
$text = $map[$diag['final_source'] ?? ''] ?? '-';
if (($diag['final_source'] ?? '') === 'commission' && ($diag['commission_total'] ?? 0) > 0) {
$text .= ' ¥' . number_format(floatval($diag['commission_total']), 2, '.', '');
} elseif (($diag['final_source'] ?? '') === 'rule' && ($diag['rule_total'] ?? 0) > 0) {
$text .= ' ¥' . number_format(floatval($diag['rule_total']), 2, '.', '');
}
return $text;
}
protected function formatFailReason($wxResult, $status)
{
if ($status !== 4 || $wxResult === '' || $wxResult === null) {