From bb5fbfde4d70293427956d1e6623e03fe2d25198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 17:11:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E8=AE=A2=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=9F=A5=E6=89=BE=E8=AE=A2=E9=98=85=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=80=E9=94=AE=E7=BB=91=E5=AE=9A=EF=BC=88?= =?UTF-8?q?=E6=90=BA=E5=B8=A6=20attach=5Forder=5Fid=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/show.blade.php | 6 ++ ...iptionLinkShouldCarryAttachOrderIdTest.php | 73 +++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderShowFindSubscriptionLinkShouldCarryAttachOrderIdTest.php diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index 16ce666..4b94952 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -279,6 +279,9 @@ $missingSubscriptionHelpUrl = \App\Support\BackUrl::withBack('/admin/site-subscriptions?' . \Illuminate\Support\Arr::query([ 'merchant_id' => (int) ($order->merchant_id ?? 0) ?: null, 'plan_id' => (int) ($order->plan_id ?? 0) ?: null, + // 从订单详情跳过去挑订阅:在订阅列表行内提供“一键绑定到该订单”按钮 + 'attach_order_id' => (int) ($order->id ?? 0) ?: null, + 'attach_back' => $orderShowSelf, 'page' => null, ]), $orderShowSelf); } @@ -439,6 +442,9 @@ $missingSubHelpUrlForRelationBlock = \App\Support\BackUrl::withBack('/admin/site-subscriptions?' . \Illuminate\Support\Arr::query([ 'merchant_id' => (int) ($order->merchant_id ?? 0) ?: null, 'plan_id' => (int) ($order->plan_id ?? 0) ?: null, + // 从订单详情跳过去挑订阅:在订阅列表行内提供“一键绑定到该订单”按钮 + 'attach_order_id' => (int) ($order->id ?? 0) ?: null, + 'attach_back' => $orderShowSelf, 'page' => null, ]), $orderShowSelf); } diff --git a/tests/Feature/AdminPlatformOrderShowFindSubscriptionLinkShouldCarryAttachOrderIdTest.php b/tests/Feature/AdminPlatformOrderShowFindSubscriptionLinkShouldCarryAttachOrderIdTest.php new file mode 100644 index 0000000..9c13cbb --- /dev/null +++ b/tests/Feature/AdminPlatformOrderShowFindSubscriptionLinkShouldCarryAttachOrderIdTest.php @@ -0,0 +1,73 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_find_subscription_link_should_carry_attach_order_id_and_attach_back(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_show_find_sub_attach_order_plan', + 'name' => '订单详情 查找订阅链接携带 attach_order_id 测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 30, + 'list_price' => 30, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SHOW_FIND_SUB_ATTACH_ORDER_0001', + 'order_type' => 'renewal', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 30, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [], + ]); + + $res = $this->get('/admin/platform-orders/' . $order->id); + $res->assertOk(); + + $html = (string) $res->getContent(); + + // 仍应包含 merchant_id/plan_id/back + $this->assertStringContainsString('/admin/site-subscriptions?', $html); + $this->assertStringContainsString('merchant_id=' . $merchant->id, $html); + $this->assertStringContainsString('plan_id=' . $plan->id, $html); + $this->assertStringContainsString('back=' . urlencode('/admin/platform-orders/' . $order->id), $html); + + // 新增:应携带 attach_order_id/attach_back,支持订阅列表行内一键绑定并回跳 + $this->assertStringContainsString('attach_order_id=' . $order->id, $html); + $this->assertStringContainsString('attach_back=' . urlencode('/admin/platform-orders/' . $order->id), $html); + } +}