feat(admin): 平台订单详情页展示回执/退款汇总并统一口径

This commit is contained in:
萝卜
2026-03-11 00:47:03 +00:00
parent eac782239a
commit e6626a54b3

View File

@@ -44,16 +44,36 @@
<tr><th>生效时间</th><td>{{ optional($order->activated_at)->format('Y-m-d H:i:s') ?: '-' }}</td></tr>
<tr><th>退款时间</th><td>{{ optional($order->refunded_at)->format('Y-m-d H:i:s') ?: '-' }}</td></tr>
@php
// 退款总额口径:优先读扁平字段 meta.refund_summary.total_amount(与列表/导出口径一致);缺省回退汇总 refund_receipts[].amount
// 统一口径:优先读扁平字段 payment_summary/refund_summary与列表/导出口径一致);缺省回退遍历 receipts
$paymentReceiptsRaw = (array) (data_get($order->meta, 'payment_receipts', []) ?? []);
$refundReceiptsRaw = (array) (data_get($order->meta, 'refund_receipts', []) ?? []);
$receiptCount = (int) (data_get($order->meta, 'payment_summary.count') ?? 0);
$receiptTotal = (float) (data_get($order->meta, 'payment_summary.total_amount') ?? 0);
if ($receiptCount <= 0) {
$receiptCount = count($paymentReceiptsRaw);
}
if ($receiptTotal <= 0) {
$receiptTotal = 0.0;
foreach ($paymentReceiptsRaw as $r) {
$receiptTotal += (float) (data_get($r, 'amount') ?? 0);
}
}
$refundCount = (int) (data_get($order->meta, 'refund_summary.count') ?? 0);
$refundTotal = (float) (data_get($order->meta, 'refund_summary.total_amount') ?? 0);
if ($refundCount <= 0) {
$refundCount = count($refundReceiptsRaw);
}
if ($refundTotal <= 0) {
$refundTotal = 0.0;
foreach ((array) (data_get($order->meta, 'refund_receipts', []) ?? []) as $r) {
foreach ($refundReceiptsRaw as $r) {
$refundTotal += (float) (data_get($r, 'amount') ?? 0);
}
}
@endphp
<tr><th>退款总额</th><td>¥{{ number_format($refundTotal, 2) }}</td></tr>
<tr><th>回执数 / 回执总额</th><td>{{ $receiptCount }} / ¥{{ number_format($receiptTotal, 2) }}</td></tr>
<tr><th>退款笔数 / 退款总额</th><td>{{ $refundCount }} / ¥{{ number_format($refundTotal, 2) }}</td></tr>
</tbody>
</table>