From 6dc2e5947751009bf6aae89c084fbc65a1037a91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 01:18:57 +0000 Subject: [PATCH] PlatformOrder create: add renewal target governance block --- .../admin/platform_orders/form.blade.php | 13 +++ ...mOrderCreateRenewalGovernanceBlockTest.php | 108 ++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderCreateRenewalGovernanceBlockTest.php diff --git a/resources/views/admin/platform_orders/form.blade.php b/resources/views/admin/platform_orders/form.blade.php index ac6e84c..e3406b0 100644 --- a/resources/views/admin/platform_orders/form.blade.php +++ b/resources/views/admin/platform_orders/form.blade.php @@ -45,6 +45,19 @@
提示:该订单类型为「续费」。在订单完成「标记支付并生效 → 同步订阅」后,将会对该订阅执行续期/延长到期时间(以系统同步结果为准)。
+ +
+

续费对象确认

+
+
订阅号:{{ $siteSubscription->subscription_no }}(订阅ID:{{ $siteSubscription->id }})
+
站点:{{ optional($siteSubscription->merchant)->name ?: ('#' . (int) $siteSubscription->merchant_id) }}
+
套餐:{{ $siteSubscription->plan_name ?: optional($siteSubscription->plan)->name ?: ('#' . (int) $siteSubscription->plan_id) }}
+
到期时间:{{ optional($siteSubscription->ends_at)->format('Y-m-d H:i:s') ?: '-' }}
+
+
+ 建议流程:创建订单 → 在订单详情执行「标记支付并生效」→ 再执行「同步订阅」。请在提交前确认续费对象无误,避免误给其它订阅续期。 +
+
@endif @endif diff --git a/tests/Feature/AdminPlatformOrderCreateRenewalGovernanceBlockTest.php b/tests/Feature/AdminPlatformOrderCreateRenewalGovernanceBlockTest.php new file mode 100644 index 0000000..fb59605 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderCreateRenewalGovernanceBlockTest.php @@ -0,0 +1,108 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_create_form_should_render_renewal_governance_block_when_order_type_is_renewal_and_subscription_present(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_create_renewal_gov_plan', + 'name' => '创建订单续费治理提示测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $sub = SiteSubscription::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'status' => 'activated', + 'source' => 'manual', + 'subscription_no' => 'SUB_RENEW_GOV_0001', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 10, + 'starts_at' => now()->subDay(), + 'ends_at' => now()->addDays(10), + 'activated_at' => now()->subDay(), + ]); + + $url = '/admin/platform-orders/create?site_subscription_id=' . $sub->id . '&order_type=renewal'; + + $res = $this->get($url); + $res->assertOk(); + + $res->assertSee('续费对象确认', false); + $res->assertSee('SUB_RENEW_GOV_0001', false); + $res->assertSee('订阅ID:' . $sub->id, false); + + // 使用统一的治理提示块样式类(避免 inline style 漂移) + $res->assertSee('class="governance-block', false); + } + + public function test_create_form_should_not_render_governance_block_when_order_type_is_not_renewal(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_create_non_renewal_gov_plan', + 'name' => '创建订单非续费不展示治理提示测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 10, + 'list_price' => 10, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $sub = SiteSubscription::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'status' => 'activated', + 'source' => 'manual', + 'subscription_no' => 'SUB_RENEW_GOV_0002', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'amount' => 10, + 'starts_at' => now()->subDay(), + 'ends_at' => now()->addDays(10), + 'activated_at' => now()->subDay(), + ]); + + $url = '/admin/platform-orders/create?site_subscription_id=' . $sub->id . '&order_type=new_purchase'; + + $res = $this->get($url); + $res->assertOk(); + + $res->assertDontSee('续费对象确认', false); + $res->assertDontSee('class="governance-block', false); + } +}