From fa9090f4d836543456217ba1d1cc5bcf1e992d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sat, 14 Mar 2026 13:49:58 +0000 Subject: [PATCH] platform_orders show: show retry activate-subscription label when sync error exists --- .../admin/platform_orders/show.blade.php | 8 +- ...howRetryActivateSubscriptionButtonTest.php | 73 +++++++++++++++++++ 2 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 tests/Feature/AdminPlatformOrderShowRetryActivateSubscriptionButtonTest.php diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index 047aa49..211930b 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -250,7 +250,13 @@ @endphp
@csrf - + @php + $hasSyncErrorMeta = (bool) ($syncError ?? false); + $activateBtnLabel = $alreadySynced + ? '已同步' + : ($hasSyncErrorMeta ? '重试同步订阅' : '同步订阅'); + @endphp +
@if($syncBlockedByGovernance) diff --git a/tests/Feature/AdminPlatformOrderShowRetryActivateSubscriptionButtonTest.php b/tests/Feature/AdminPlatformOrderShowRetryActivateSubscriptionButtonTest.php new file mode 100644 index 0000000..68a9ad1 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderShowRetryActivateSubscriptionButtonTest.php @@ -0,0 +1,73 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_show_page_renders_retry_sync_button_when_sync_error_exists_and_order_is_syncable(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'retry_sync_btn_test', + 'name' => '重试同步订阅按钮测试', + 'billing_cycle' => 'monthly', + 'price' => 9, + 'list_price' => 9, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_RETRY_SYNC_BTN_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' => 9, + 'paid_amount' => 9, + 'placed_at' => now(), + 'paid_at' => now(), + 'activated_at' => now(), + 'meta' => [ + 'subscription_activation_error' => [ + 'message' => '历史同步失败', + 'at' => now()->subMinutes(3)->toDateTimeString(), + 'admin_id' => 1, + ], + ], + ]); + + $back = '/admin/platform-orders?' . Arr::query(['status' => 'activated']); + + $this->get('/admin/platform-orders/' . $order->id . '?back=' . urlencode($back)) + ->assertOk() + ->assertSee('重试同步订阅'); + } +}