feat(admin): 仪表盘补齐订阅到期治理入口(7天内到期/已过期)

This commit is contained in:
萝卜
2026-03-15 19:34:32 +08:00
parent b7471026ef
commit dc7b7b395c
3 changed files with 53 additions and 2 deletions

View File

@@ -38,6 +38,15 @@ class DashboardController extends Controller
// 收费中心(平台侧)
'plans' => Plan::count(),
'site_subscriptions' => SiteSubscription::count(),
'site_subscriptions_expired' => SiteSubscription::query()
->whereNotNull('ends_at')
->where('ends_at', '<', now())
->count(),
'site_subscriptions_expiring_7d' => SiteSubscription::query()
->whereNotNull('ends_at')
->where('ends_at', '>=', now())
->where('ends_at', '<', now()->addDays(7))
->count(),
'platform_orders' => PlatformOrder::count(),
'platform_orders_unpaid_pending' => PlatformOrder::query()
->where('payment_status', 'unpaid')

View File

@@ -97,7 +97,7 @@
<div class="muted">聚焦收费闭环的日常治理入口:订单 订阅 套餐。</div>
<div class="mt-12">
<div class="muted">快捷筛选:</div>
<div class="muted">平台订单快捷筛选:</div>
<div class="actions mt-8">
<a class="btn btn-secondary btn-sm" href="{!! $platformOrdersQuickLinks['unpaid_pending'] !!}">待支付({{ (int) ($stats['platform_orders_unpaid_pending'] ?? 0) }}</a>
<a class="btn btn-secondary btn-sm" href="{!! $platformOrdersQuickLinks['paid_pending'] !!}">待生效({{ (int) ($stats['platform_orders_paid_pending'] ?? 0) }}</a>
@@ -107,7 +107,15 @@
</div>
</div>
<div class="muted muted-xs mt-10">说明:这里先落“入口与布局骨架”,后续会把 KPI/趋势/排行 接入真实聚合指标。</div>
<div class="mt-12">
<div class="muted">订阅到期治理:</div>
<div class="actions mt-8">
<a class="btn btn-secondary btn-sm" href="{!! \App\Support\BackUrl::withBack('/admin/site-subscriptions?expiry=expiring_7d', $selfWithoutBack) !!}">7天内到期({{ (int) ($stats['site_subscriptions_expiring_7d'] ?? 0) }}</a>
<a class="btn btn-secondary btn-sm" href="{!! \App\Support\BackUrl::withBack('/admin/site-subscriptions?expiry=expired', $selfWithoutBack) !!}">已过期({{ (int) ($stats['site_subscriptions_expired'] ?? 0) }}</a>
</div>
</div>
<div class="muted muted-xs mt-10">说明:这里先把收费主链的高频治理入口收敛到仪表盘;后续再补趋势/排行的真实聚合。</div>
</div>
<div class="card">

View File

@@ -0,0 +1,34 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminDashboardSubscriptionExpiryQuickLinksShouldRenderTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_dashboard_subscription_expiry_quick_links_should_render(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin');
$res->assertOk();
$res->assertSee('订阅到期治理');
$res->assertSee('href="/admin/site-subscriptions?expiry=expiring_7d&back=%2Fadmin"', false);
$res->assertSee('href="/admin/site-subscriptions?expiry=expired&back=%2Fadmin"', false);
$res->assertDontSee('&amp;back=', false);
}
}