From 3c185fa39258787f0d7558d51159204ecd96a962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Fri, 13 Mar 2026 19:49:03 +0000 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=9A=E5=9B=9E=E6=89=A7=E6=95=B0/=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E6=95=B0=E8=B7=B3=E8=AF=A6=E6=83=85=E6=90=BA=E5=B8=A6?= =?UTF-8?q?=20back+=E9=94=9A=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/index.blade.php | 10 ++- ...ReceiptRefundCountLinksContainBackTest.php | 88 +++++++++++++++++++ 2 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderIndexReceiptRefundCountLinksContainBackTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 043a0b2..cd45797 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -956,7 +956,10 @@ $receiptCount = $receiptSummaryCount !== null ? (int) $receiptSummaryCount : count($receipts); @endphp @if($receiptCount > 0) - {{ $receiptCount }} + @php + $receiptCountShowUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]) . '#payment-receipts'; + @endphp + {{ $receiptCount }} @else 0 @endif @@ -968,7 +971,10 @@ $refundCount = $refundSummaryCount !== null ? (int) $refundSummaryCount : count($refunds); @endphp @if($refundCount > 0) - {{ $refundCount }} + @php + $refundCountShowUrl = '/admin/platform-orders/' . $order->id . '?' . \Illuminate\Support\Arr::query(['back' => $selfWithoutBack]) . '#refund-receipts'; + @endphp + {{ $refundCount }} @else 0 @endif diff --git a/tests/Feature/AdminPlatformOrderIndexReceiptRefundCountLinksContainBackTest.php b/tests/Feature/AdminPlatformOrderIndexReceiptRefundCountLinksContainBackTest.php new file mode 100644 index 0000000..0d69369 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexReceiptRefundCountLinksContainBackTest.php @@ -0,0 +1,88 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_receipt_and_refund_count_links_should_carry_back_and_anchor(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_index_receipt_refund_count_back_plan', + 'name' => '平台订单列表回执/退款数 back 链接测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_INDEX_RC_BACK_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [ + 'payment_receipts' => [ + ['amount' => 10, 'paid_at' => now()->toDateTimeString(), 'channel' => 'offline', 'note' => 'test'], + ], + 'refund_receipts' => [ + ['amount' => 1, 'refunded_at' => now()->toDateTimeString(), 'channel' => 'offline', 'note' => 'test'], + ], + ], + ]); + + // 列表页带 back(模拟从其它页跳回),本页生成 selfWithoutBack 时会去掉 back + $res = $this->get('/admin/platform-orders?status=pending&back=' . urlencode('/admin/plans')); + $res->assertOk(); + + $indexSelfWithoutBack = '/admin/platform-orders?' . Arr::query([ + 'status' => 'pending', + ]); + + $receiptLink = '/admin/platform-orders/' . $order->id . '?' . Arr::query([ + 'back' => $indexSelfWithoutBack, + ]) . '#payment-receipts'; + + $refundLink = '/admin/platform-orders/' . $order->id . '?' . Arr::query([ + 'back' => $indexSelfWithoutBack, + ]) . '#refund-receipts'; + + $res->assertSee($receiptLink, false); + $res->assertSee($refundLink, false); + + // 不允许 back 嵌套 + $res->assertDontSee('back%3D', false); + } +}