From bd9d007ce070bdfd4284e9de5655f253301aa7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 11 Mar 2026 09:44:53 +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?=E7=A9=BA=E5=8E=9F=E5=9B=A0=E9=99=8D=E7=BA=A7=E4=B8=8D=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=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 | 2 +- ...ailedReasonTop5EmptyReasonFallbackTest.php | 76 +++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/AdminPlatformOrderSyncFailedReasonTop5EmptyReasonFallbackTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 25ade77..7aca100 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -244,7 +244,7 @@ $count = (int) ($item['count'] ?? 0); @endphp
- @if($reason !== '') + @if($reason !== '' && $reason !== '(空)') @php $reasonText = mb_substr($reason, 0, 60); @endphp {{ $reasonText }} ({{ $count }}) diff --git a/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5EmptyReasonFallbackTest.php b/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5EmptyReasonFallbackTest.php new file mode 100644 index 0000000..31035c3 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderSyncFailedReasonTop5EmptyReasonFallbackTest.php @@ -0,0 +1,76 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_sync_failed_reason_top5_empty_reason_should_fallback_and_not_render_link(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'sync_failed_reason_empty_reason_test', + 'name' => '同步失败原因空字符串降级测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // 构造空失败原因(message 为空字符串),确保 TOP5 渲染时走降级展示 + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SYNC_FAILED_EMPTY_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' => '', + 'at' => now()->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ]); + + $page = $this->get('/admin/platform-orders'); + $page->assertOk(); + + $page->assertSee('(空原因)'); + + // 空原因不应生成“失败原因链接”或“切到可同步重试”链接 + $page->assertDontSee('切到可同步重试', false); + $page->assertDontSee('sync_error_keyword=', false); + } +}