From decd653ad805e3eb0eef2b75c437d390218b35d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Wed, 18 Mar 2026 00:10:40 +0800 Subject: [PATCH] =?UTF-8?q?admin:=20=E5=88=97=E8=A1=A8=E8=A1=8C=E7=BA=A7?= =?UTF-8?q?=E4=BB=85=E6=A0=87=E8=AE=B0=E7=94=9F=E6=95=88=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E6=B2=BB=E7=90=86=E5=AE=89=E5=85=A8=E9=98=80=EF=BC=88=E7=BB=AD?= =?UTF-8?q?=E8=B4=B9=E7=BC=BA=E8=AE=A2=E9=98=85=E7=A6=81=E7=94=A8=E5=B9=B6?= =?UTF-8?q?=E5=BC=95=E5=AF=BC=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/index.blade.php | 14 +++- ...ableWhenRenewalMissingSubscriptionTest.php | 75 +++++++++++++++++++ 2 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderIndexRowMarkActivatedButtonShouldDisableWhenRenewalMissingSubscriptionTest.php diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index 07c7974..938e057 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -1831,11 +1831,21 @@ @php $canMarkActivatedOnly = ($order->payment_status === 'paid') && ($order->status !== 'activated'); + // 安全阀对齐后端:续费单未绑定订阅时,不允许“仅标记为已生效”(后端 markActivated 也会阻断) + $markActivatedBlockedByMissingSubscriptionOnRenewalRow = ((string) ($order->order_type ?? '') === 'renewal') + && ((int) ($order->site_subscription_id ?? 0) <= 0); @endphp
@csrf - +
+ @if($markActivatedBlockedByMissingSubscriptionOnRenewalRow) +
+ 续费缺订阅不可直接标记生效 + + 去关联订阅 +
+ @endif @php $syncBlockedByGovernanceRow = (bool) ($order->isReconcileMismatch() || $order->isRefundInconsistent()); @@ -1861,7 +1871,7 @@ 需先完成治理后再同步 @if($syncBlockedByMissingSubscriptionOnRenewalRow) - 去关联订阅 + 去关联订阅 @endif @endif diff --git a/tests/Feature/AdminPlatformOrderIndexRowMarkActivatedButtonShouldDisableWhenRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderIndexRowMarkActivatedButtonShouldDisableWhenRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..24c6ea8 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexRowMarkActivatedButtonShouldDisableWhenRenewalMissingSubscriptionTest.php @@ -0,0 +1,75 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_row_mark_activated_button_should_be_disabled_when_renewal_missing_subscription(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_index_row_mark_activated_disable_renewal_missing_sub_plan', + 'name' => '平台订单列表行级仅标记生效禁用(续费缺订阅)测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 30, + 'list_price' => 30, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + // 构造:已支付 + 待处理,但续费缺订阅;该场景后端 markActivated 会阻断,列表页也应禁用。 + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_INDEX_ROW_MARK_ACTIVATED_DISABLE_RENEW_MISS_SUB_0001', + 'order_type' => 'renewal', + 'site_subscription_id' => null, + 'status' => 'pending', + 'payment_status' => 'paid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 30, + 'paid_amount' => 30, + 'placed_at' => now(), + 'paid_at' => now(), + 'meta' => [], + ]); + + $res = $this->get('/admin/platform-orders'); + $res->assertOk(); + + $html = (string) $res->getContent(); + $this->assertStringContainsString($order->order_no, $html); + + // 断言:该订单所在行的“仅标记为已生效”按钮应被禁用 + $pattern = '#/admin/platform-orders/' . $order->id . '/mark-activated.*?]*disabled#s'; + $this->assertMatchesRegularExpression($pattern, $html); + + // 并且应给出最短治理入口(去关联订阅) + $this->assertStringContainsString('去关联订阅', $html); + $this->assertStringContainsString('#relation-subscription', $html); + } +}