配置化:同步失败原因TOPN与展示截断长度
This commit is contained in:
@@ -178,12 +178,15 @@ class PlatformOrderController extends Controller
|
||||
|
||||
// 同步失败原因聚合(Top 5):用于运营快速判断“常见失败原因”
|
||||
// 注意:这里用 JSON_EXTRACT 做 group by,MySQL 会返回带引号的 JSON 字符串,展示时做一次 trim 处理。
|
||||
$topN = (int) config('saasshop.platform_orders.sync_failed_reason_top_n', 5);
|
||||
$topN = max(1, min(20, $topN));
|
||||
|
||||
$failedReasonRows = (clone $baseQuery)
|
||||
->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(5)
|
||||
->limit($topN)
|
||||
->get();
|
||||
|
||||
$failedReasonStats = $failedReasonRows->map(function ($row) {
|
||||
|
||||
Reference in New Issue
Block a user