From e06fa9bd9a45cc26e4243f5e894df19da6b7afbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 14:25:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2:=20=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E6=B2=BB=E7=90=86=E5=85=A5=E5=8F=A3=E4=BF=9D=E7=95=99=E6=97=A5?= =?UTF-8?q?=E6=9C=9F=E8=8C=83=E5=9B=B4=E4=B8=8A=E4=B8=8B=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/index.blade.php | 3 +- ...nceLinksShouldKeepDateRangeContextTest.php | 76 +++++++++++++++++++ 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/AdminPlatformOrderIndexSubscriptionGovernanceLinksShouldKeepDateRangeContextTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index b1a0b87..af8d6b7 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -243,7 +243,8 @@ // 订阅治理快捷入口:保留订阅上下文(site_subscription_id + 其它业务上下文),但不继承 syncable_only/fail_only/page 等工具型开关。 $buildSubGovernUrl = function (array $overrides) use ($safeBackForLinks) { return \App\Support\BackUrl::currentPathQuickFilter( - ['merchant_id', 'plan_id', 'site_subscription_id', 'keyword', 'lead_id'], + // 订阅锁定治理入口:除订阅ID外,也保留时间范围(便于运营在“近7天/某段时间窗口”内治理) + ['merchant_id', 'plan_id', 'site_subscription_id', 'keyword', 'lead_id', 'created_from', 'created_to'], $overrides, $safeBackForLinks ); diff --git a/tests/Feature/AdminPlatformOrderIndexSubscriptionGovernanceLinksShouldKeepDateRangeContextTest.php b/tests/Feature/AdminPlatformOrderIndexSubscriptionGovernanceLinksShouldKeepDateRangeContextTest.php new file mode 100644 index 0000000..97a7c41 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexSubscriptionGovernanceLinksShouldKeepDateRangeContextTest.php @@ -0,0 +1,76 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_subscription_governance_links_should_keep_date_range_context(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_idx_sub_gov_keep_date_range_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_IDX_GOV_KEEP_DATE_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(), + ]); + + $from = '2026-03-01'; + $to = '2026-03-18'; + + $res = $this->get('/admin/platform-orders?site_subscription_id=' . $sub->id . '&created_from=' . $from . '&created_to=' . $to); + $res->assertOk(); + + $html = (string) $res->getContent(); + + // 订阅治理入口:查看同步失败(该订阅)应保留 created_from/to + $this->assertMatchesRegularExpression('/href="([^"]+)"[^>]*>查看同步失败(该订阅)<\/a>/', $html); + preg_match('/href="([^"]+)"[^>]*>查看同步失败(该订阅)<\/a>/', $html, $m); + $href = html_entity_decode($m[1] ?? ''); + + $query = parse_url($href, PHP_URL_QUERY) ?: ''; + parse_str($query, $q); + + $this->assertSame($from, (string) ($q['created_from'] ?? '')); + $this->assertSame($to, (string) ($q['created_to'] ?? '')); + $this->assertSame((string) $sub->id, (string) ($q['site_subscription_id'] ?? '')); + } +}