业绩明细:修复导出「差额」列把未匹配行写成 0 的问题

- 未匹配行的差额在库里是 NULL,导出取值用了 ?? '' 变成空字符串,原判断只认 null,
  这些行被导成 0.00,导出合计只剩已匹配行的差额(2026-07 只有 14.7 万)
- 现在空差额按「比对基准金额=0」补算 收入+优惠+冲减,与页面/统计卡口径一致
- 验证:2026-07 全部平台导出 300,707 行,差额列合计 1,354,719.44(与页面同值);
  只看未匹配 3,968 行,差额列合计 1,207,560.77
This commit is contained in:
yueyang 2026-10-10 15:38:31 +08:00
parent 158c5e1b23
commit 2da46a2a86

View File

@ -1207,8 +1207,9 @@ class Pages extends Controller
if ($key === 'remark') { if ($key === 'remark') {
$value = self::receiptDifferenceRemark($row) ?? ''; $value = self::receiptDifferenceRemark($row) ?? '';
} }
// 未匹配行(差额为空)按比对基准金额=0 计入差额,与页面口径一致 // 未匹配行(差额为空)按比对基准金额=0 计入差额,与页面口径一致。
if ($key === 'difference' && $value === null) { // 注意:上面取值用了 ?? '',空差值是空字符串而不是 null,这里两种都要认。
if ($key === 'difference' && ($value === null || $value === '')) {
$value = round( $value = round(
(float) ($row->income_amount ?? 0) + (float) ($row->discount_amount ?? 0) + (float) ($row->offset_amount ?? 0), (float) ($row->income_amount ?? 0) + (float) ($row->discount_amount ?? 0) + (float) ($row->offset_amount ?? 0),
2 2