```
feat(split): 添加分账诊断功能用于后台展示 - 新增 SplitCalculator::diagnose() 方法,用于诊断订单分账问题 - 返回分账来源、佣金总额、规则总额及具体问题说明 - 在管理员分账订单控制器中集成诊断信息显示 - 优化前端表格显示分账来源标签和诊断提示信息 - 修复佣金奖励查询中 agent_id 使用错误的问题 ```
这个提交包含在:
@@ -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) {
|
||||
|
||||
@@ -164,6 +164,24 @@
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.source-tag {
|
||||
display: inline-block;
|
||||
padding: 0 6px;
|
||||
border-radius: 4px;
|
||||
font-size: 11px;
|
||||
line-height: 18px;
|
||||
white-space: nowrap;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.source-tag.commission { background: #ecf5ff; color: #409eff; }
|
||||
.source-tag.rule { background: #fdf6ec; color: #e6a23c; }
|
||||
.diagnose-hint {
|
||||
font-size: 11px;
|
||||
color: #e6a23c;
|
||||
line-height: 1.5;
|
||||
margin-top: 4px;
|
||||
white-space: normal;
|
||||
}
|
||||
.op-hint {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
@@ -230,11 +248,14 @@
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" width="128" align="right">
|
||||
<el-table-column label="金额" width="138" align="right">
|
||||
<template slot-scope="s">
|
||||
<div class="amount-cell">
|
||||
<div class="money-line">订单 <span class="money-text">¥{{ formatMoney(s.row.total_amount) }}</span></div>
|
||||
<div class="money-line split-line">分账 <span class="money-text">¥{{ formatMoney(s.row.split_amount) }}</span></div>
|
||||
<span v-if="s.row.split_source_text" :class="'source-tag ' + (s.row.split_source === 'commission' ? 'commission' : 'rule')">
|
||||
{{ s.row.split_source_text }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -252,6 +273,9 @@
|
||||
<span class="recv-amt">¥{{ formatMoney(r.amount) }}</span>
|
||||
</div>
|
||||
<div v-if="s.row.receiver_preview" class="recv-preview-hint">按当前规则预估(历史失败单未落库明细)</div>
|
||||
<div v-if="s.row.split_diagnose && s.row.split_diagnose.length && s.row.split_source === 'rule'" class="diagnose-hint">
|
||||
{{ s.row.split_diagnose.join(';') }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else class="cell-sub-plain">—</span>
|
||||
</template>
|
||||
|
||||
在新工单中引用
屏蔽一个用户