feat(plans): 列表显示关联订阅/订单数量并提供跳转

This commit is contained in:
萝卜
2026-03-10 22:18:55 +00:00
parent b27fd67347
commit aa5ec955cb
3 changed files with 113 additions and 6 deletions

View File

@@ -89,7 +89,7 @@ class PlanController extends Controller
'published' => trim((string) $request->query('published', '')),
];
$plansQuery = $this->applyFilters(Plan::query(), $filters);
$plansQuery = $this->applyFilters(Plan::query()->withCount(['subscriptions', 'platformOrders']), $filters);
$plans = (clone $plansQuery)
->orderBy('sort')
@@ -111,6 +111,9 @@ class PlanController extends Controller
'yearly_plans' => (clone $plansQuery)->where('billing_cycle', 'yearly')->count(),
'published_plans' => (clone $plansQuery)->whereNotNull('published_at')->count(),
'unpublished_plans' => (clone $plansQuery)->whereNull('published_at')->count(),
// 治理联动:当前筛选范围内关联订阅/订单总量
'subscriptions_count' => (clone $plansQuery)->sum('subscriptions_count'),
'platform_orders_count' => (clone $plansQuery)->sum('platform_orders_count'),
],
'statusLabels' => $this->statusLabels(),
'billingCycleLabels' => $this->billingCycleLabels(),