From 810c4894fd6eb9ff8fc1f03ae290b63ca4ae4309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Tue, 17 Mar 2026 01:37:32 +0800 Subject: [PATCH] Governance UI: block batch BMPA in renewal missing subscription scope --- app/Support/PlatformOrderToolsGuard.php | 5 +++ ...ableWhenRenewalMissingSubscriptionTest.php | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/Feature/AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenRenewalMissingSubscriptionTest.php diff --git a/app/Support/PlatformOrderToolsGuard.php b/app/Support/PlatformOrderToolsGuard.php index b9607db..84851d4 100644 --- a/app/Support/PlatformOrderToolsGuard.php +++ b/app/Support/PlatformOrderToolsGuard.php @@ -88,6 +88,11 @@ class PlatformOrderToolsGuard */ public static function batchBmpaReason(array $filters): string { + // 治理集合优先:续费单未绑定订阅属于高风险治理集合,不允许执行 BMPA(会产生大量失败标记,掩盖问题)。 + if ((string) ($filters['renewal_missing_subscription'] ?? '') === '1') { + return '当前集合为「续费单未绑定订阅」治理集合:请先完成订阅绑定/修复关联后再执行 BMPA。'; + } + if ((string) ($filters['status'] ?? '') !== 'pending' || (string) ($filters['payment_status'] ?? '') !== 'unpaid') { return '请先筛选「订单状态=待处理」且「支付状态=未支付」再执行批量 BMPA。'; } diff --git a/tests/Feature/AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..2198749 --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenRenewalMissingSubscriptionTest.php @@ -0,0 +1,37 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_batch_bmpa_button_should_disable_when_renewal_missing_subscription_present(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin/platform-orders?renewal_missing_subscription=1'); + $res->assertOk(); + + $html = (string) $res->getContent(); + + $this->assertStringContainsString('批量标记支付并生效(含订阅同步)(当前筛选范围)', $html); + $this->assertStringContainsString('data-role="batch-bmpa-blocked-hint"', $html); + $this->assertStringContainsString('续费单未绑定订阅', $html); + + $this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"')); + } +}