From cfbd9a1693c0c852c372f5d0f3bcacd543350d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Tue, 10 Mar 2026 21:34:46 +0000 Subject: [PATCH] =?UTF-8?q?feat(platform-orders):=20=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A1=8C=E7=BA=A7=E5=9B=9E=E6=89=A7=E6=80=BB?= =?UTF-8?q?=E9=A2=9D=E4=B8=8E=E5=AF=B9=E8=B4=A6=E5=B7=AE=E9=A2=9D=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/PlatformOrderController.php | 27 +++++++++++++++++++ .../admin/platform_orders/index.blade.php | 20 ++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index cabaffa..54e4c35 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -146,6 +146,15 @@ class PlatformOrderController extends Controller ->paginate(10) ->withQueryString(); + // 列表行级对账视图:回执总额 / 差额(便于运营快速定位问题订单) + $orders->getCollection()->transform(function (PlatformOrder $o) { + $receiptTotal = (float) $this->receiptTotalForOrder($o); + $o->setAttribute('receipt_total', $receiptTotal); + $o->setAttribute('reconciliation_delta_row', $receiptTotal - (float) $o->paid_amount); + + return $o; + }); + $baseQuery = $this->applyFilters(PlatformOrder::query(), $filters); // 同步失败原因聚合(Top 5):用于运营快速判断“常见失败原因” @@ -1108,6 +1117,24 @@ class PlatformOrderController extends Controller }); } + + private function receiptTotalForOrder(PlatformOrder $order): float + { + // 优先读扁平字段 payment_summary.total_amount(更稳定、避免遍历 receipts) + $total = (float) (data_get($order->meta, 'payment_summary.total_amount') ?? 0); + if ($total > 0) { + return $total; + } + + // 回退:遍历 payment_receipts[].amount + $receipts = (array) (data_get($order->meta, 'payment_receipts', []) ?? []); + $sum = 0.0; + foreach ($receipts as $r) { + $sum += (float) (data_get($r, 'amount') ?? 0); + } + + return $sum; + } protected function sumReceiptAmount($orders): float { $total = 0.0; diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 139875d..891bb42 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -340,6 +340,8 @@ 失败原因 最近批量同步 最近批量生效 + 回执总额 + 对账差额 回执数 退款数 退款总额 @@ -463,6 +465,24 @@ - @endif + + @php + $receiptTotal = (float) ($order->receipt_total ?? 0); + @endphp + @if($receiptTotal > 0) + ¥{{ number_format($receiptTotal, 2) }} + @else + - + @endif + + + @php $rowDelta = (float) ($order->reconciliation_delta_row ?? 0); @endphp + @if(abs($rowDelta) >= 0.01) + ¥{{ number_format($rowDelta, 2) }} + @else + ¥0.00 + @endif + @php $receiptCount = count((array) (data_get($order->meta, 'payment_receipts', []) ?? []));