From d0b7f9ad61acab725842bc50054702422c5bc456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 09:33:34 +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=A0TOP5?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E5=A2=9E=E5=BC=BA(=E6=88=AA=E6=96=AD?= =?UTF-8?q?=E5=B1=95=E7=A4=BA+URL=E7=BC=96=E7=A0=81=E6=B5=8B=E8=AF=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/index.blade.php | 19 +++-- ...derSyncFailedReasonTop5UrlEncodingTest.php | 82 +++++++++++++++++++ 2 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderSyncFailedReasonTop5UrlEncodingTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index c8514fc..25ade77 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -239,12 +239,21 @@ @if(count($failedReasonStats) > 0)
@foreach($failedReasonStats as $item) - @php $reason = (string) ($item['reason'] ?? ''); @endphp + @php + $reason = (string) ($item['reason'] ?? ''); + $count = (int) ($item['count'] ?? 0); + @endphp
- {{ $reason }} - ({{ $item['count'] }}) - - 切到可同步重试 + @if($reason !== '') + @php $reasonText = mb_substr($reason, 0, 60); @endphp + {{ $reasonText }} + ({{ $count }}) + + 切到可同步重试 + @else + (空原因) + ({{ $count }}) + @endif
@endforeach
diff --git a/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5UrlEncodingTest.php b/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5UrlEncodingTest.php new file mode 100644 index 0000000..1da9700 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5UrlEncodingTest.php @@ -0,0 +1,82 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_sync_failed_reason_top5_links_url_encode_reason(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'sync_failed_reason_top5_url_encode_test', + 'name' => '同步失败原因URL编码测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $reason = 'A&B=1 中文'; + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SYNC_FAILED_REASON_ENCODE_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, + ], + ], + ]); + + // RFC3986 编码:& -> %26,= -> %3D,空格 -> %20 + $encoded = 'A%26B%3D1%20%E4%B8%AD%E6%96%87'; + + $page = $this->get('/admin/platform-orders'); + $page->assertOk(); + + $page->assertSee('sync_status=failed', false); + $page->assertSee('sync_error_keyword=' . $encoded, false); + + // retry link 也应包含同一编码,并包含 syncable_only=1 + $page->assertSee('切到可同步重试', false); + $page->assertSee('syncable_only=1', false); + $page->assertSee('sync_error_keyword=' . $encoded, false); + } +}