feat(platform-orders): 列表/导出退款统计优先读 refund_summary(含测试)

This commit is contained in:
萝卜
2026-03-11 00:27:58 +00:00
parent 9b136e6df8
commit 80b218bbfb
3 changed files with 91 additions and 7 deletions

View File

@@ -682,8 +682,9 @@ class PlatformOrderController extends Controller
$latestReceipt = $receiptCount > 0 ? end($receipts) : null;
$refunds = (array) (data_get($order->meta, 'refund_receipts', []) ?? []);
$refundCount = count($refunds);
$latestRefund = $refundCount > 0 ? end($refunds) : null;
$refundSummaryCount = data_get($order->meta, 'refund_summary.count');
$refundCount = $refundSummaryCount !== null ? (int) $refundSummaryCount : count($refunds);
$latestRefund = count($refunds) > 0 ? end($refunds) : null;
$row = [
$order->id,
@@ -715,7 +716,12 @@ class PlatformOrderController extends Controller
(string) (data_get($latestRefund, 'refunded_at') ?? ''),
(float) (data_get($latestRefund, 'amount') ?? 0),
(string) (data_get($latestRefund, 'channel') ?? ''),
(function () use ($refunds) {
(function () use ($order, $refunds) {
$summaryTotal = data_get($order->meta, 'refund_summary.total_amount');
if ($summaryTotal !== null) {
return (float) $summaryTotal;
}
$total = 0.0;
foreach ($refunds as $r) {
$total += (float) (data_get($r, 'amount') ?? 0);