From 3ed4cb8112f66b73292f3c71c6b2fd01e5947e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 09:50:47 +0000 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=EF=BC=9A?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=A4=B1=E8=B4=A5=E5=8E=9F=E5=9B=A0=E8=BF=87?= =?UTF-8?q?=E9=95=BF=E6=97=B6=E4=B8=8D=E7=94=9F=E6=88=90=E7=AD=9B=E9=80=89?= =?UTF-8?q?=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/index.blade.php | 36 ++++++-- ...ncFailedReasonTop5LongReasonNoLinkTest.php | 83 +++++++++++++++++++ 2 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderSyncFailedReasonTop5LongReasonNoLinkTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 7aca100..10ed25e 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -245,11 +245,24 @@ @endphp
@if($reason !== '' && $reason !== '(空)') - @php $reasonText = mb_substr($reason, 0, 60); @endphp - {{ $reasonText }} - ({{ $count }}) - - 切到可同步重试 + @php + $reasonText = mb_substr($reason, 0, 60); + $reasonTooLong = mb_strlen($reason) > 200; + @endphp + + @if($reasonTooLong) + {{ $reasonText }} + ({{ $count }}) + + 原因过长,请复制到筛选框 + + 进入同步失败集合 + @else + {{ $reasonText }} + ({{ $count }}) + + 切到可同步重试 + @endif @else (空原因) ({{ $count }}) @@ -582,9 +595,18 @@ {{ optional($order->siteSubscription?->ends_at)->format('Y-m-d H:i:s') ?: '-' }} {{ data_get($order->meta, 'subscription_activation.synced_at') ?: '-' }} - @php $syncErrMsg = (string) (data_get($order->meta, 'subscription_activation_error.message') ?? ''); @endphp + @php + $syncErrMsg = (string) (data_get($order->meta, 'subscription_activation_error.message') ?? ''); + $syncErrTooLong = $syncErrMsg !== '' && mb_strlen($syncErrMsg) > 200; + @endphp @if($syncErrMsg !== '') - {{ mb_substr($syncErrMsg, 0, 60) }} + @if($syncErrTooLong) + {{ mb_substr($syncErrMsg, 0, 60) }} +
原因过长,请复制到筛选框
+ 进入同步失败集合 + @else + {{ mb_substr($syncErrMsg, 0, 60) }} + @endif @else - @endif diff --git a/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5LongReasonNoLinkTest.php b/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5LongReasonNoLinkTest.php new file mode 100644 index 0000000..d446837 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5LongReasonNoLinkTest.php @@ -0,0 +1,83 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_sync_failed_reason_top5_long_reason_should_not_render_keyword_links(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'sync_failed_reason_long_reason_no_link_test', + 'name' => '同步失败原因过长不渲染链接测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $reason = str_repeat('很长的失败原因', 30); // > 200 chars + $shown = mb_substr($reason, 0, 60); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SYNC_FAILED_LONG_REASON_0001', + 'order_type' => 'new_purchase', + 'status' => 'activated', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 10, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'meta' => [ + 'subscription_activation_error' => [ + 'message' => $reason, + 'at' => now()->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ]); + + $page = $this->get('/admin/platform-orders'); + $page->assertOk(); + + // 展示截断文本与“原因过长”提示 + $page->assertSee($shown); + $page->assertSee('原因过长,请复制到筛选框'); + + // 不应渲染 sync_error_keyword= 的链接(避免 URL 过长/特殊字符问题) + $page->assertDontSee('sync_error_keyword=', false); + + // 仍应给一个“进入同步失败集合”的入口 + $page->assertSee('进入同步失败集合'); + $page->assertSee('sync_status=failed', false); + } +}