diff --git a/app/Http/Controllers/Admin/DashboardController.php b/app/Http/Controllers/Admin/DashboardController.php index 573805a..87e9960 100644 --- a/app/Http/Controllers/Admin/DashboardController.php +++ b/app/Http/Controllers/Admin/DashboardController.php @@ -10,6 +10,7 @@ use App\Models\Product; use App\Models\Merchant; use App\Models\Plan; use App\Models\PlatformOrder; +use App\Models\SiteSubscription; use App\Models\User; use App\Support\CacheKeys; use Illuminate\Http\Request; @@ -35,6 +36,8 @@ class DashboardController extends Controller 'orders' => Order::count(), // 收费中心(平台侧) + 'plans' => Plan::count(), + 'site_subscriptions' => SiteSubscription::count(), 'platform_orders' => PlatformOrder::count(), 'platform_orders_unpaid_pending' => PlatformOrder::query() ->where('payment_status', 'unpaid') diff --git a/resources/views/admin/dashboard.blade.php b/resources/views/admin/dashboard.blade.php index a899b62..1e706d0 100644 --- a/resources/views/admin/dashboard.blade.php +++ b/resources/views/admin/dashboard.blade.php @@ -53,19 +53,19 @@
全站点数量(总台视角)
-
管理员
-
{{ $stats['admins'] }}
-
平台/站点后台账号
+
套餐
+
{{ (int) ($stats['plans'] ?? 0) }}
+
可售套餐目录
-
用户
-
{{ $stats['users'] }}
-
买家端用户累计
+
订阅
+
{{ (int) ($stats['site_subscriptions'] ?? 0) }}
+
站点订阅总量(收费主链)
-
订单
-
{{ $stats['orders'] }}
-
站点订单累计(非平台订单)
+
平台订单
+
{{ (int) ($stats['platform_orders'] ?? 0) }}
+
平台收费订单总量
diff --git a/tests/Feature/AdminDashboardKpiShouldIncludeBillingChainStatsTest.php b/tests/Feature/AdminDashboardKpiShouldIncludeBillingChainStatsTest.php new file mode 100644 index 0000000..309cc1e --- /dev/null +++ b/tests/Feature/AdminDashboardKpiShouldIncludeBillingChainStatsTest.php @@ -0,0 +1,34 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_dashboard_kpi_should_include_billing_chain_stats(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin'); + $res->assertOk(); + + // 收费主链 KPI:套餐/订阅/平台订单 + $res->assertSee('套餐'); + $res->assertSee('订阅'); + $res->assertSee('平台订单'); + } +}