From cc6835e19ce68ddb5073c4c621034f2b73f23822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 00:33:02 +0000 Subject: [PATCH] =?UTF-8?q?feat(platform-orders):=20=E5=88=97=E8=A1=A8/?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=9B=9E=E6=89=A7=E6=95=B0=E4=BC=98=E5=85=88?= =?UTF-8?q?=E8=AF=BB=20payment=5Fsummary.count=EF=BC=88=E5=90=AB=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/PlatformOrderController.php | 5 +- .../admin/platform_orders/index.blade.php | 4 +- ...tformOrderReceiptSummaryRowColumnsTest.php | 72 +++++++++++++++++++ 3 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderReceiptSummaryRowColumnsTest.php diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index 1be1376..e954d78 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -678,8 +678,9 @@ class PlatformOrderController extends Controller } $receipts = (array) (data_get($order->meta, 'payment_receipts', []) ?? []); - $receiptCount = count($receipts); - $latestReceipt = $receiptCount > 0 ? end($receipts) : null; + $receiptSummaryCount = data_get($order->meta, 'payment_summary.count'); + $receiptCount = $receiptSummaryCount !== null ? (int) $receiptSummaryCount : count($receipts); + $latestReceipt = count($receipts) > 0 ? end($receipts) : null; $refunds = (array) (data_get($order->meta, 'refund_receipts', []) ?? []); $refundSummaryCount = data_get($order->meta, 'refund_summary.count'); diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 3bee9f3..a19f089 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -574,7 +574,9 @@ @php - $receiptCount = count((array) (data_get($order->meta, 'payment_receipts', []) ?? [])); + $receipts = (array) (data_get($order->meta, 'payment_receipts', []) ?? []); + $receiptSummaryCount = data_get($order->meta, 'payment_summary.count'); + $receiptCount = $receiptSummaryCount !== null ? (int) $receiptSummaryCount : count($receipts); @endphp @if($receiptCount > 0) {{ $receiptCount }} diff --git a/tests/Feature/AdminPlatformOrderReceiptSummaryRowColumnsTest.php b/tests/Feature/AdminPlatformOrderReceiptSummaryRowColumnsTest.php new file mode 100644 index 0000000..704f0c8 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderReceiptSummaryRowColumnsTest.php @@ -0,0 +1,72 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_platform_orders_row_receipt_count_prefers_payment_summary_when_receipts_missing(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'receipt_row_summary_test', + 'name' => '回执行级摘要测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_RECEIPT_ROW_SUMMARY_0001', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'meta' => [ + // 故意不给 payment_receipts,验证列表能从 payment_summary 读到回执数 + 'payment_summary' => [ + 'count' => 101, + 'total_amount' => 10.00, + ], + ], + ]); + + $this->get('/admin/platform-orders') + ->assertOk() + ->assertSee('PO_RECEIPT_ROW_SUMMARY_0001') + ->assertSee('101') + ->assertSee('¥10.00'); + } +}