From 3b5cb6ede7597bea364832f35c850d8a4e531348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 08:25:44 +0000 Subject: [PATCH] =?UTF-8?q?feat(admin):=20=E7=AB=99=E7=82=B9=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E8=A1=A5=E9=BD=90=E8=AE=A2=E9=98=85/?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95/=E7=BB=AD=E8=B4=B9?= =?UTF-8?q?=E7=BC=BA=E8=AE=A2=E9=98=85=E6=B2=BB=E7=90=86=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=20+=20back?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/admin/merchants/index.blade.php | 39 ++++++++++++++++- ...dIncludeRenewalMissingSubscriptionTest.php | 42 +++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/AdminMerchantIndexGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest.php diff --git a/resources/views/admin/merchants/index.blade.php b/resources/views/admin/merchants/index.blade.php index f4ba696..8044942 100644 --- a/resources/views/admin/merchants/index.blade.php +++ b/resources/views/admin/merchants/index.blade.php @@ -4,9 +4,41 @@ @section('page_title', '站点管理') @section('content') +@php + // back 安全护栏:用于可能从其它页面跳入站点管理时的回退 + $incomingBack = (string) request()->query('back', ''); + $safeBackForLinks = \App\Support\BackUrl::sanitizeForLinks($incomingBack); + + // 当前页自身(去掉 back),用于生成 back 回跳,避免 back 嵌套膨胀 + $selfWithoutBack = \App\Support\BackUrl::selfWithoutBack(); + + $merchantIndexUrlWithBack = \App\Support\BackUrl::withBack('/admin/merchants', $safeBackForLinks); + + $makePlatformOrdersUrl = function (int $merchantId, array $overrides = []) use ($selfWithoutBack) { + $q = array_merge(['merchant_id' => $merchantId], $overrides); + $url = '/admin/platform-orders?' . \Illuminate\Support\Arr::query($q); + + return \App\Support\BackUrl::withBack($url, $selfWithoutBack); + }; + + $makeSubscriptionsUrl = function (int $merchantId, array $overrides = []) use ($selfWithoutBack) { + $q = array_merge(['merchant_id' => $merchantId], $overrides); + $url = '/admin/site-subscriptions?' . \Illuminate\Support\Arr::query($q); + + return \App\Support\BackUrl::withBack($url, $selfWithoutBack); + }; +@endphp +

这里是总台视角的站点管理入口,用于开通、查看和维护 SaaS 站点主体。

当前站点列表已接入缓存:{{ $cacheMeta['store'] }} / TTL {{ $cacheMeta['ttl'] }}。

+ + @if($safeBackForLinks !== '') + + @endif +

新增站点

@csrf @@ -37,7 +69,12 @@ {{ $merchant->status }} {{ $merchant->contact_name }} / {{ $merchant->contact_phone }} - 进入站点后台 +
当前阶段请使用该站点管理员账号登录
diff --git a/tests/Feature/AdminMerchantIndexGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest.php b/tests/Feature/AdminMerchantIndexGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..a51a842 --- /dev/null +++ b/tests/Feature/AdminMerchantIndexGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest.php @@ -0,0 +1,42 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_merchants_index_should_include_governance_links_with_back(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + + $res = $this->get('/admin/merchants'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + // 站点治理入口:订阅/平台订单/续费缺订阅 + $this->assertStringContainsString('/admin/site-subscriptions?merchant_id=' . $merchant->id, $html); + $this->assertStringContainsString('/admin/platform-orders?merchant_id=' . $merchant->id, $html); + $this->assertStringContainsString('renewal_missing_subscription=1', $html); + + // back 应回到站点管理页 + $this->assertStringContainsString('back=' . urlencode('/admin/merchants'), $html); + } +}