```
feat(split): 优化分账计算诊断功能 - 添加用户信息格式化方法,显示带脱敏手机号的用户简要信息 - 实现详细的汇付接收方缺失诊断逻辑,提供具体的错误原因 - 新增分账明细为空时的详细失败消息格式化功能 - 增强后台订单分账失败原因展示,支持完整和摘要两种显示方式 - 添加规则接收方诊断功能,检测分账规则配置问题 - 优化错误信息的可读性和排查效率 ```
这个提交包含在:
@@ -146,10 +146,11 @@ class Order extends Base
|
||||
$data['receiver_details'] = $receiverDetails;
|
||||
$data['receiver_preview'] = $receiverPreview;
|
||||
$data['receiver_summary'] = $summaryLines ? implode(';', $summaryLines) : '—';
|
||||
$data['fail_reason'] = $this->formatFailReason($data['wx_result'] ?? '', $status);
|
||||
$data['fail_reason_full'] = $this->formatFailReasonFull($data['wx_result'] ?? '', $status);
|
||||
|
||||
$diag = (new SplitCalculator())->diagnose($orderId);
|
||||
$data['fail_reason_full'] = $this->formatFailReasonFull($data['wx_result'] ?? '', $status);
|
||||
$data['fail_reason_full'] = $this->enrichFailReasonWithDiagnose($data['fail_reason_full'], $status, $diag);
|
||||
$data['fail_reason'] = $this->summarizeFailReason($data['fail_reason_full'], $diag, $status);
|
||||
|
||||
$data['split_source'] = $diag['final_source'];
|
||||
$data['split_source_text'] = $this->formatSplitSourceText($diag);
|
||||
$data['split_diagnose'] = $diag['issues'];
|
||||
@@ -304,6 +305,57 @@ class Order extends Base
|
||||
return $text;
|
||||
}
|
||||
|
||||
protected function enrichFailReasonWithDiagnose($full, $status, array $diag)
|
||||
{
|
||||
if ($status !== 4) {
|
||||
return $full;
|
||||
}
|
||||
$issues = array_values(array_filter($diag['issues'] ?? []));
|
||||
if (!$issues) {
|
||||
return $full;
|
||||
}
|
||||
$raw = is_string($full) ? $full : '';
|
||||
$isEmptySplit = $raw === ''
|
||||
|| strpos($raw, '分账明细为空') !== false
|
||||
|| strpos($raw, '分账未生成') !== false
|
||||
|| ($diag['final_source'] ?? '') === 'none';
|
||||
if (!$isEmptySplit) {
|
||||
return $full;
|
||||
}
|
||||
$block = implode("\n", $issues);
|
||||
if ($raw === '') {
|
||||
return '分账未生成:' . implode(';', $issues);
|
||||
}
|
||||
if (strpos($raw, implode(';', array_slice($issues, 0, 1))) !== false) {
|
||||
return $raw;
|
||||
}
|
||||
return $raw . "\n" . $block;
|
||||
}
|
||||
|
||||
protected function summarizeFailReason($full, array $diag, $status)
|
||||
{
|
||||
if ($status !== 4 || $full === '') {
|
||||
return $this->formatFailReasonFromFull($full, $status);
|
||||
}
|
||||
$issues = array_values(array_filter($diag['issues'] ?? []));
|
||||
if ($issues) {
|
||||
$brief = $issues[0];
|
||||
if (count($issues) > 1) {
|
||||
$brief .= ' 等' . count($issues) . '项';
|
||||
}
|
||||
return mb_strlen($brief) > 72 ? (mb_substr($brief, 0, 72) . '…') : $brief;
|
||||
}
|
||||
return $this->formatFailReasonFromFull($full, $status);
|
||||
}
|
||||
|
||||
protected function formatFailReasonFromFull($full, $status)
|
||||
{
|
||||
if ($status !== 4 || $full === '') {
|
||||
return '';
|
||||
}
|
||||
return mb_strlen($full) > 72 ? (mb_substr($full, 0, 72) . '…') : $full;
|
||||
}
|
||||
|
||||
protected function formatFailReason($wxResult, $status)
|
||||
{
|
||||
if ($status !== 4 || $wxResult === '' || $wxResult === null) {
|
||||
|
||||
在新工单中引用
屏蔽一个用户