feat(admin): subscription show failed reason top3
This commit is contained in:
@@ -45,6 +45,25 @@ class SiteSubscriptionController extends Controller
|
||||
->count(),
|
||||
];
|
||||
|
||||
// 同步失败原因聚合(Top3):订阅维度快速判断“常见失败原因”
|
||||
$failedReasonRows = (clone $baseOrdersQuery)
|
||||
->whereRaw("JSON_EXTRACT(meta, '$.subscription_activation_error.message') IS NOT NULL")
|
||||
->selectRaw("JSON_EXTRACT(meta, '$.subscription_activation_error.message') as reason, count(*) as cnt")
|
||||
->groupBy('reason')
|
||||
->orderByDesc('cnt')
|
||||
->limit(3)
|
||||
->get();
|
||||
|
||||
$failedReasonStats = $failedReasonRows->map(function ($row) {
|
||||
$reason = (string) ($row->reason ?? '');
|
||||
$reason = trim($reason, "\" ");
|
||||
|
||||
return [
|
||||
'reason' => $reason !== '' ? $reason : '(空)',
|
||||
'count' => (int) ($row->cnt ?? 0),
|
||||
];
|
||||
})->values()->all();
|
||||
|
||||
// 页面列表筛选:仅影响“关联平台订单”列表展示,不影响摘要统计
|
||||
$orderSyncStatus = trim((string) $request->query('order_sync_status', ''));
|
||||
|
||||
@@ -93,6 +112,7 @@ class SiteSubscriptionController extends Controller
|
||||
'subscription' => $subscription,
|
||||
'platformOrders' => $platformOrders,
|
||||
'summaryStats' => $summaryStats,
|
||||
'failedReasonStats' => $failedReasonStats,
|
||||
'statusLabels' => $this->statusLabels(),
|
||||
'expiryLabel' => $expiryLabel,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user