feat(admin): subscription show failed reason top3
This commit is contained in:
@@ -45,6 +45,25 @@ class SiteSubscriptionController extends Controller
|
|||||||
->count(),
|
->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', ''));
|
$orderSyncStatus = trim((string) $request->query('order_sync_status', ''));
|
||||||
|
|
||||||
@@ -93,6 +112,7 @@ class SiteSubscriptionController extends Controller
|
|||||||
'subscription' => $subscription,
|
'subscription' => $subscription,
|
||||||
'platformOrders' => $platformOrders,
|
'platformOrders' => $platformOrders,
|
||||||
'summaryStats' => $summaryStats,
|
'summaryStats' => $summaryStats,
|
||||||
|
'failedReasonStats' => $failedReasonStats,
|
||||||
'statusLabels' => $this->statusLabels(),
|
'statusLabels' => $this->statusLabels(),
|
||||||
'expiryLabel' => $expiryLabel,
|
'expiryLabel' => $expiryLabel,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -115,6 +115,20 @@
|
|||||||
<div class="num-md">{{ $summaryStats['unsynced_orders'] ?? 0 }}</div>
|
<div class="num-md">{{ $summaryStats['unsynced_orders'] ?? 0 }}</div>
|
||||||
<div class="muted muted-xs">无 activation 且无 error</div>
|
<div class="muted muted-xs">无 activation 且无 error</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<h3>失败原因Top3</h3>
|
||||||
|
@php $failedReasonStats = $failedReasonStats ?? []; @endphp
|
||||||
|
@if(count($failedReasonStats) > 0)
|
||||||
|
<div class="muted mt-6">
|
||||||
|
@foreach($failedReasonStats as $item)
|
||||||
|
<div>{{ $item['reason'] }} <span class="muted">({{ $item['count'] }})</span></div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="muted">暂无失败原因聚合数据</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ class AdminSiteSubscriptionShowTest extends TestCase
|
|||||||
->assertSee('关联订单总数')
|
->assertSee('关联订单总数')
|
||||||
->assertSee('可同步(已支付+已生效+未同步)')
|
->assertSee('可同步(已支付+已生效+未同步)')
|
||||||
->assertSee('未同步(无记录)')
|
->assertSee('未同步(无记录)')
|
||||||
|
->assertSee('失败原因Top3')
|
||||||
->assertSee('关联平台订单')
|
->assertSee('关联平台订单')
|
||||||
->assertSee('PO_SUB_SHOW_0001')
|
->assertSee('PO_SUB_SHOW_0001')
|
||||||
->assertSee('同步时间')
|
->assertSee('同步时间')
|
||||||
|
|||||||
Reference in New Issue
Block a user