From 65b7b9058ff01f8f1094ad4ddeca046dad40a3c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sat, 14 Mar 2026 21:45:36 +0000 Subject: [PATCH] feat(platform_orders): add enter-failed-set links in reason top5 cards --- .../admin/platform_orders/index.blade.php | 4 + ...ReasonStatsHaveEnterFailedSetLinksTest.php | 106 ++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderFailedReasonStatsHaveEnterFailedSetLinksTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index d182f14..4213e19 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -438,6 +438,8 @@ ({{ $count }}) 切到可同步重试 + + 进入失败集合 @endif @else (空原因) @@ -480,6 +482,8 @@ ({{ $count }}) 切到可处理集合重试 + + 进入失败集合 @endif @else (空原因) diff --git a/tests/Feature/AdminPlatformOrderFailedReasonStatsHaveEnterFailedSetLinksTest.php b/tests/Feature/AdminPlatformOrderFailedReasonStatsHaveEnterFailedSetLinksTest.php new file mode 100644 index 0000000..c6d7146 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderFailedReasonStatsHaveEnterFailedSetLinksTest.php @@ -0,0 +1,106 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_failed_reason_stats_should_render_enter_failed_set_links(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_failed_reason_enter_failed_set', + 'name' => '失败原因统计进入失败集合链接测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $syncReason = '订单未生效'; + $bmpaReason = '回执缺失'; + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_FAILED_REASON_SYNC_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [ + 'subscription_activation_error' => [ + 'message' => $syncReason, + 'at' => now()->format('Y-m-d H:i:s'), + ], + ], + ]); + + PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_FAILED_REASON_BMPA_0001', + 'order_type' => 'new_purchase', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 10, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [ + 'batch_mark_paid_and_activate_error' => [ + 'message' => $bmpaReason, + 'at' => now()->format('Y-m-d H:i:s'), + ], + ], + ]); + + $res = $this->get('/admin/platform-orders'); + $res->assertOk(); + + $expectedSyncEnterFailedUrl = '/admin/platform-orders?' . Arr::query([ + 'sync_error_keyword' => $syncReason, + 'sync_status' => 'failed', + ]); + + $expectedBmpaEnterFailedUrl = '/admin/platform-orders?' . Arr::query([ + 'bmpa_failed_only' => '1', + 'bmpa_error_keyword' => $bmpaReason, + ]); + + $res->assertSee('进入失败集合', false); + $res->assertSee($expectedSyncEnterFailedUrl, false); + $res->assertSee($expectedBmpaEnterFailedUrl, false); + } +}