Admin subscriptions: expiring 7d add merchant+plan top10 and renewal CTA
This commit is contained in:
@@ -333,6 +333,7 @@ class SiteSubscriptionController extends Controller
|
||||
$baseQuery = $this->applyFilters(SiteSubscription::query(), $filters);
|
||||
|
||||
$expiryMerchantRows = [];
|
||||
$expiryMerchantPlanRows = [];
|
||||
if ((string) ($filters['expiry'] ?? '') === 'expiring_7d') {
|
||||
// 到期提醒清单:站点维度 Top10(用于运营快速触达/续费跟进)
|
||||
$expiryMerchantRows = $this->applyFilters(SiteSubscription::query(), $filters)
|
||||
@@ -354,6 +355,30 @@ class SiteSubscriptionController extends Controller
|
||||
})
|
||||
->values()
|
||||
->all();
|
||||
|
||||
// 到期提醒清单:站点+套餐维度 Top10(更精确的续费下单入口)
|
||||
$expiryMerchantPlanRows = $this->applyFilters(SiteSubscription::query(), $filters)
|
||||
->leftJoin('merchants', 'site_subscriptions.merchant_id', '=', 'merchants.id')
|
||||
->leftJoin('plans', 'site_subscriptions.plan_id', '=', 'plans.id')
|
||||
->whereNotNull('site_subscriptions.ends_at')
|
||||
->selectRaw('site_subscriptions.merchant_id as merchant_id, merchants.name as merchant_name, site_subscriptions.plan_id as plan_id, plans.name as plan_name, count(*) as cnt, min(site_subscriptions.ends_at) as min_ends_at')
|
||||
->groupBy('site_subscriptions.merchant_id', 'merchants.name', 'site_subscriptions.plan_id', 'plans.name')
|
||||
->orderByDesc('cnt')
|
||||
->orderBy('min_ends_at')
|
||||
->limit(10)
|
||||
->get()
|
||||
->map(function ($row) {
|
||||
return [
|
||||
'merchant_id' => (int) ($row->merchant_id ?? 0),
|
||||
'merchant_name' => (string) ($row->merchant_name ?? ''),
|
||||
'plan_id' => (int) ($row->plan_id ?? 0),
|
||||
'plan_name' => (string) ($row->plan_name ?? ''),
|
||||
'count' => (int) ($row->cnt ?? 0),
|
||||
'min_ends_at' => (string) ($row->min_ends_at ?? ''),
|
||||
];
|
||||
})
|
||||
->values()
|
||||
->all();
|
||||
}
|
||||
|
||||
return view('admin.site_subscriptions.index', [
|
||||
@@ -382,6 +407,7 @@ class SiteSubscriptionController extends Controller
|
||||
->count(),
|
||||
],
|
||||
'expiryMerchantRows' => $expiryMerchantRows,
|
||||
'expiryMerchantPlanRows' => $expiryMerchantPlanRows,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user