From 61e615efacebfe18cbf7eeac03a5b36e8a623c44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Sun, 15 Mar 2026 04:50:36 +0000 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E8=AE=A2=E5=8D=95=E8=AF=A6?= =?UTF-8?q?=E6=83=85=20BMPA=20=E6=B2=BB=E7=90=86=EF=BC=9A=E7=BB=AD?= =?UTF-8?q?=E8=B4=B9=E5=8D=95=E6=9C=AA=E7=BB=91=E8=AE=A2=E9=98=85=E6=97=B6?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E6=8C=89=E9=92=AE=E5=B9=B6=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=EF=BC=88=E5=90=AB=E6=B5=8B=E8=AF=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/platform_orders/show.blade.php | 15 +++- ...bledWhenRenewalMissingSubscriptionTest.php | 70 +++++++++++++++++++ 2 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 tests/Feature/AdminPlatformOrderShowMarkPaidAndActivateButtonDisabledWhenRenewalMissingSubscriptionTest.php diff --git a/resources/views/admin/platform_orders/show.blade.php b/resources/views/admin/platform_orders/show.blade.php index bb2d30d..353300b 100644 --- a/resources/views/admin/platform_orders/show.blade.php +++ b/resources/views/admin/platform_orders/show.blade.php @@ -205,6 +205,10 @@ $expectedCents = (int) round($expectedPaid * 100); $markPaidBlockedByRefund = $refundTotal > 0; + // 安全阀:续费单必须绑定订阅(后端已阻断,这里做前端提示/禁用) + $markPaidBlockedByMissingSubscriptionOnRenewal = ((string) ($order->order_type ?? '') === 'renewal') + && ((int) ($order->site_subscription_id ?? 0) <= 0); + $tol = (float) config('saasshop.amounts.tolerance', 0.01); $tolCents = (int) round($tol * 100); $tolCents = max(1, $tolCents); @@ -215,10 +219,10 @@
@csrf - +
- @if($markPaidBlockedByRefund || $markPaidBlockedByReceiptMismatch) + @if($markPaidBlockedByRefund || $markPaidBlockedByReceiptMismatch || $markPaidBlockedByMissingSubscriptionOnRenewal)
BMPA 治理提示(当前不建议/不可直接标记支付并生效)
@@ -229,6 +233,13 @@ 去核对退款
@endif + @if($markPaidBlockedByMissingSubscriptionOnRenewal) +
+ 原因:当前订单类型为「续费」,但未绑定订阅(site_subscription_id 为空)。 + + 请先补齐订阅关联后再处理。 +
+ @endif @if($markPaidBlockedByReceiptMismatch)
原因:当前订单已存在支付回执,但回执总额与订单金额不一致。 diff --git a/tests/Feature/AdminPlatformOrderShowMarkPaidAndActivateButtonDisabledWhenRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderShowMarkPaidAndActivateButtonDisabledWhenRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..59d92bf --- /dev/null +++ b/tests/Feature/AdminPlatformOrderShowMarkPaidAndActivateButtonDisabledWhenRenewalMissingSubscriptionTest.php @@ -0,0 +1,70 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_show_should_disable_mark_paid_and_activate_button_when_renewal_order_missing_subscription(): void + { + $this->loginAsPlatformAdmin(); + + $merchant = Merchant::query()->firstOrFail(); + $plan = Plan::query()->create([ + 'code' => 'po_show_bmpa_disable_renewal_no_sub_plan', + 'name' => '订单详情 BMPA 按钮禁用(续费无订阅)测试套餐', + 'billing_cycle' => 'monthly', + 'price' => 30, + 'list_price' => 30, + 'status' => 'active', + 'sort' => 10, + 'published_at' => now(), + ]); + + $order = PlatformOrder::query()->create([ + 'merchant_id' => $merchant->id, + 'plan_id' => $plan->id, + 'order_no' => 'PO_SHOW_BMPA_DISABLE_RENEW_NO_SUB_0001', + 'order_type' => 'renewal', + 'status' => 'pending', + 'payment_status' => 'unpaid', + 'plan_name' => $plan->name, + 'billing_cycle' => $plan->billing_cycle, + 'period_months' => 1, + 'quantity' => 1, + 'payable_amount' => 30, + 'paid_amount' => 0, + 'placed_at' => now(), + 'meta' => [], + ]); + + $res = $this->get('/admin/platform-orders/' . $order->id); + $res->assertOk(); + + // 按钮应被禁用(disabled) + $res->assertSee('标记支付并生效', false); + $res->assertSee('disabled', false); + + // 治理提示应出现 + $res->assertSee('续费', false); + $res->assertSee('未绑定订阅', false); + $res->assertSee('BMPA 治理提示', false); + } +}