diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index 87e9960..ff57a4f 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -51,6 +51,10 @@ class DashboardController extends Controller 'platform_orders_sync_failed' => PlatformOrder::query() ->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation_error.message') IS NOT NULL") ->count(), + 'platform_orders_renewal_missing_subscription' => PlatformOrder::query() + ->where('order_type', 'renewal') + ->whereNull('site_subscription_id') + ->count(), // 站点治理 'active_merchants' => Merchant::query()->where('status', 'active')->count(), diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index de93281..798e274 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -103,6 +103,7 @@ 待生效({{ (int) ($stats['platform_orders_paid_pending'] ?? 0) }}) 可同步 同步失败({{ (int) ($stats['platform_orders_sync_failed'] ?? 0) }}) + 续费缺订阅({{ (int) ($stats['platform_orders_renewal_missing_subscription'] ?? 0) }}) diff --git a/tests/Feature/AdminDashboardBillingWorkbenchShouldIncludeRenewalMissingSubscriptionQuickLinkTest.php b/tests/Feature/AdminDashboardBillingWorkbenchShouldIncludeRenewalMissingSubscriptionQuickLinkTest.php new file mode 100644 index 0000000..1dd627d --- /dev/null +++ b/tests/Feature/AdminDashboardBillingWorkbenchShouldIncludeRenewalMissingSubscriptionQuickLinkTest.php @@ -0,0 +1,35 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_dashboard_billing_workbench_should_include_renewal_missing_subscription_quick_link(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin'); + $res->assertOk(); + + // 链接应携带 back 回到仪表盘,并且 & 不应被 escape + $res->assertSee('href="/admin/platform-orders?renewal_missing_subscription=1&back=%2Fadmin"', false); + $res->assertDontSee('&back=', false); + + $res->assertSee('续费缺订阅', false); + } +}