From 916796f58e8a2b454bfb72d7820ec21a7ac124a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 10:09:03 +0000 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8C=96=EF=BC=9A=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=A4=B1=E8=B4=A5=E5=8E=9F=E5=9B=A0TOPN=E4=B8=8E?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E6=88=AA=E6=96=AD=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Admin/PlatformOrderController.php | 5 ++++- config/saasshop.php | 10 ++++++++-- resources/views/admin/platform_orders/index.blade.php | 7 ++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index f8b03bb..0da9282 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -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) { diff --git a/config/saasshop.php b/config/saasshop.php index 2dd03c4..5b9a828 100644 --- a/config/saasshop.php +++ b/config/saasshop.php @@ -1,9 +1,15 @@ [ + // 平台订单列表中“同步失败原因”链接的最大长度阈值。 + // 失败原因过长时不生成 sync_error_keyword 链接,避免 URL 过长/特殊字符破坏 query。 'sync_error_keyword_link_max_len' => 200, + + // 平台订单列表“同步失败原因 TOPN”聚合条数。 + 'sync_failed_reason_top_n' => 5, + + // 同步失败原因展示截断长度(用于列表/聚合展示,避免撑坏布局)。 + 'sync_failed_reason_display_truncate_len' => 60, ], ]; diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index d06229e..a56530b 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -7,6 +7,7 @@ @php // 失败原因过长时不生成 sync_error_keyword 链接,避免 URL 过长/特殊字符破坏 query $SYNC_ERROR_KEYWORD_LINK_MAX_LEN = (int) config('saasshop.platform_orders.sync_error_keyword_link_max_len', 200); + $SYNC_FAILED_REASON_TRUNCATE_LEN = (int) config('saasshop.platform_orders.sync_failed_reason_display_truncate_len', 60); @endphp

这里是总台视角的平台收费主链骨架页,当前阶段先承接套餐订购 / 续费 / 生效跟踪。

@@ -250,7 +251,7 @@
@if($reason !== '' && $reason !== '(空)') @php - $reasonText = mb_substr($reason, 0, 60); + $reasonText = mb_substr($reason, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN); $reasonTooLong = mb_strlen($reason) > $SYNC_ERROR_KEYWORD_LINK_MAX_LEN; @endphp @@ -605,11 +606,11 @@ @endphp @if($syncErrMsg !== '') @if($syncErrTooLong) - {{ mb_substr($syncErrMsg, 0, 60) }} + {{ mb_substr($syncErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }}
原因过长,请复制到筛选框
进入同步失败集合 @else - {{ mb_substr($syncErrMsg, 0, 60) }} + {{ mb_substr($syncErrMsg, 0, $SYNC_FAILED_REASON_TRUNCATE_LEN) }} @endif @else -