diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php
index 8bdd9f8..19b6772 100644
--- a/resources/views/admin/platform_orders/show.blade.php
+++ b/resources/views/admin/platform_orders/show.blade.php
@@ -238,10 +238,11 @@
订阅管理 |
@php
- $subBack = '/admin/platform-orders/' . $order->id;
+ // 用 orderShowSelf 作为 back(已剔除 back query,避免嵌套膨胀)
+ $subBack = $orderShowSelf;
$openSubUrl = '/admin/site-subscriptions/' . $order->siteSubscription->id . '?' . \Illuminate\Support\Arr::query(['back' => $subBack]);
@endphp
- 打开订阅详情
+ 打开订阅详情
|
@php
$openSubSyncableUrl = '/admin/site-subscriptions/' . $order->siteSubscription->id . '?' . \Illuminate\Support\Arr::query([
@@ -249,11 +250,23 @@
'order_sync_status' => 'syncable',
]) . '#syncable-batch';
@endphp
- 查看可同步订单
+ 查看可同步订单
|
- 同站点订阅
+ @php
+ $sameMerchantSubsUrl = '/admin/site-subscriptions?' . \Illuminate\Support\Arr::query([
+ 'merchant_id' => $order->siteSubscription->merchant_id,
+ 'back' => $orderShowSelf,
+ ]);
+ @endphp
+ 同站点订阅
|
- 同套餐订阅
+ @php
+ $samePlanSubsUrl = '/admin/site-subscriptions?' . \Illuminate\Support\Arr::query([
+ 'plan_id' => $order->siteSubscription->plan_id,
+ 'back' => $orderShowSelf,
+ ]);
+ @endphp
+ 同套餐订阅
|
| 状态 | {{ $order->siteSubscription->status }} |
diff --git a/tests/Feature/AdminPlatformOrderShowRelatedSubscriptionLinksAreNotEscapedTest.php b/tests/Feature/AdminPlatformOrderShowRelatedSubscriptionLinksAreNotEscapedTest.php
new file mode 100644
index 0000000..6f2a836
--- /dev/null
+++ b/tests/Feature/AdminPlatformOrderShowRelatedSubscriptionLinksAreNotEscapedTest.php
@@ -0,0 +1,82 @@
+seed();
+
+ $this->post('/admin/login', [
+ 'email' => 'platform.admin@demo.local',
+ 'password' => 'Platform@123456',
+ ])->assertRedirect('/admin');
+ }
+
+ public function test_related_subscription_links_should_not_render_amp_escaped_query_delimiter(): void
+ {
+ $this->loginAsPlatformAdmin();
+
+ $merchant = Merchant::query()->firstOrFail();
+ $plan = Plan::query()->create([
+ 'code' => 'po_show_related_sub_no_escape_plan',
+ 'name' => '平台订单详情关联订阅链接不转义测试套餐',
+ 'billing_cycle' => 'monthly',
+ 'price' => 10,
+ 'list_price' => 10,
+ 'status' => 'active',
+ 'sort' => 10,
+ 'published_at' => now(),
+ ]);
+
+ $sub = SiteSubscription::query()->create([
+ 'merchant_id' => $merchant->id,
+ 'plan_id' => $plan->id,
+ 'status' => 'activated',
+ 'source' => 'manual',
+ 'subscription_no' => 'SUB_PO_SHOW_RELATED_NO_ESCAPE_0001',
+ 'plan_name' => $plan->name,
+ 'billing_cycle' => $plan->billing_cycle,
+ 'period_months' => 1,
+ 'amount' => 10,
+ 'starts_at' => now()->subDay(),
+ 'ends_at' => now()->addMonth(),
+ 'activated_at' => now()->subDay(),
+ ]);
+
+ $order = PlatformOrder::query()->create([
+ 'merchant_id' => $merchant->id,
+ 'plan_id' => $plan->id,
+ 'site_subscription_id' => $sub->id,
+ 'order_no' => 'PO_SHOW_RELATED_NO_ESCAPE_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' => [],
+ ]);
+
+ $res = $this->get('/admin/platform-orders/' . $order->id);
+ $res->assertOk();
+
+ // 关键点:openSubSyncableUrl 带两个 query 参数,不能被渲染成 &
+ $res->assertDontSee('order_sync_status=syncable&', false);
+ $res->assertDontSee('back=%2Fadmin%2Fplatform-orders%2F' . $order->id . '&', false);
+ }
+}
diff --git a/tests/Feature/AdminPlatformOrderShowRelatedSubscriptionLinksContainBackTest.php b/tests/Feature/AdminPlatformOrderShowRelatedSubscriptionLinksContainBackTest.php
new file mode 100644
index 0000000..3bb820a
--- /dev/null
+++ b/tests/Feature/AdminPlatformOrderShowRelatedSubscriptionLinksContainBackTest.php
@@ -0,0 +1,105 @@
+seed();
+
+ $this->post('/admin/login', [
+ 'email' => 'platform.admin@demo.local',
+ 'password' => 'Platform@123456',
+ ])->assertRedirect('/admin');
+ }
+
+ public function test_related_subscription_links_should_carry_back_to_platform_order_show(): void
+ {
+ $this->loginAsPlatformAdmin();
+
+ $merchant = Merchant::query()->firstOrFail();
+ $plan = Plan::query()->create([
+ 'code' => 'po_show_related_sub_back_plan',
+ 'name' => '平台订单详情关联订阅 back 链接测试套餐',
+ 'billing_cycle' => 'monthly',
+ 'price' => 10,
+ 'list_price' => 10,
+ 'status' => 'active',
+ 'sort' => 10,
+ 'published_at' => now(),
+ ]);
+
+ $sub = SiteSubscription::query()->create([
+ 'merchant_id' => $merchant->id,
+ 'plan_id' => $plan->id,
+ 'status' => 'activated',
+ 'source' => 'manual',
+ 'subscription_no' => 'SUB_PO_SHOW_RELATED_BACK_0001',
+ 'plan_name' => $plan->name,
+ 'billing_cycle' => $plan->billing_cycle,
+ 'period_months' => 1,
+ 'amount' => 10,
+ 'starts_at' => now()->subDay(),
+ 'ends_at' => now()->addMonth(),
+ 'activated_at' => now()->subDay(),
+ ]);
+
+ $order = PlatformOrder::query()->create([
+ 'merchant_id' => $merchant->id,
+ 'plan_id' => $plan->id,
+ 'site_subscription_id' => $sub->id,
+ 'order_no' => 'PO_SHOW_RELATED_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' => [],
+ ]);
+
+ $res = $this->get('/admin/platform-orders/' . $order->id);
+ $res->assertOk();
+
+ $back = '/admin/platform-orders/' . $order->id;
+
+ $openSubUrl = '/admin/site-subscriptions/' . $sub->id . '?' . Arr::query([
+ 'back' => $back,
+ ]);
+
+ $openSubSyncableUrl = '/admin/site-subscriptions/' . $sub->id . '?' . Arr::query([
+ 'back' => $back,
+ 'order_sync_status' => 'syncable',
+ ]) . '#syncable-batch';
+
+ $sameMerchantSubsUrl = '/admin/site-subscriptions?' . Arr::query([
+ 'merchant_id' => $merchant->id,
+ 'back' => $back,
+ ]);
+
+ $samePlanSubsUrl = '/admin/site-subscriptions?' . Arr::query([
+ 'plan_id' => $plan->id,
+ 'back' => $back,
+ ]);
+
+ $res->assertSee($openSubUrl, false);
+ $res->assertSee($openSubSyncableUrl, false);
+ $res->assertSee($sameMerchantSubsUrl, false);
+ $res->assertSee($samePlanSubsUrl, false);
+ }
+}
diff --git a/tests/Feature/AdminPlatformOrderShowRelatedSubscriptionLinksShouldNotNestBackTest.php b/tests/Feature/AdminPlatformOrderShowRelatedSubscriptionLinksShouldNotNestBackTest.php
new file mode 100644
index 0000000..670ff4b
--- /dev/null
+++ b/tests/Feature/AdminPlatformOrderShowRelatedSubscriptionLinksShouldNotNestBackTest.php
@@ -0,0 +1,82 @@
+seed();
+
+ $this->post('/admin/login', [
+ 'email' => 'platform.admin@demo.local',
+ 'password' => 'Platform@123456',
+ ])->assertRedirect('/admin');
+ }
+
+ public function test_related_subscription_links_back_should_not_contain_nested_back(): void
+ {
+ $this->loginAsPlatformAdmin();
+
+ $merchant = Merchant::query()->firstOrFail();
+ $plan = Plan::query()->create([
+ 'code' => 'po_show_related_sub_no_nested_back_plan',
+ 'name' => '平台订单详情关联订阅 back 不嵌套测试套餐',
+ 'billing_cycle' => 'monthly',
+ 'price' => 10,
+ 'list_price' => 10,
+ 'status' => 'active',
+ 'sort' => 10,
+ 'published_at' => now(),
+ ]);
+
+ $sub = SiteSubscription::query()->create([
+ 'merchant_id' => $merchant->id,
+ 'plan_id' => $plan->id,
+ 'status' => 'activated',
+ 'source' => 'manual',
+ 'subscription_no' => 'SUB_PO_SHOW_NO_NEST_0001',
+ 'plan_name' => $plan->name,
+ 'billing_cycle' => $plan->billing_cycle,
+ 'period_months' => 1,
+ 'amount' => 10,
+ 'starts_at' => now()->subDay(),
+ 'ends_at' => now()->addMonth(),
+ 'activated_at' => now()->subDay(),
+ ]);
+
+ $order = PlatformOrder::query()->create([
+ 'merchant_id' => $merchant->id,
+ 'plan_id' => $plan->id,
+ 'site_subscription_id' => $sub->id,
+ 'order_no' => 'PO_SHOW_NO_NEST_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' => [],
+ ]);
+
+ // 带 back 访问订单详情页(模拟从列表进入)
+ $res = $this->get('/admin/platform-orders/' . $order->id . '?back=' . urlencode('/admin/platform-orders?status=pending'));
+ $res->assertOk();
+
+ // 关联订阅的 back 应该回到“订单详情(去掉 back)”,不应出现 back=...back= 的嵌套
+ $res->assertDontSee('back%3D', false);
+ }
+}