diff --git a/app/Support/PlatformOrderToolsGuard.php b/app/Support/PlatformOrderToolsGuard.php index 845b4f6..b9607db 100644 --- a/app/Support/PlatformOrderToolsGuard.php +++ b/app/Support/PlatformOrderToolsGuard.php @@ -122,6 +122,11 @@ class PlatformOrderToolsGuard */ public static function batchMarkActivatedReason(array $filters): string { + // 治理集合优先:续费单未绑定订阅属于高风险治理集合,不允许直接批量生效。 + if ((string) ($filters['renewal_missing_subscription'] ?? '') === '1') { + return '当前集合为「续费单未绑定订阅」治理集合:请先完成订阅绑定/修复关联后再批量仅标记为已生效。'; + } + if ((string) ($filters['payment_status'] ?? '') !== 'paid' || (string) ($filters['status'] ?? '') !== 'pending') { return '请先筛选「支付状态=已支付」且「订单状态=待处理」再执行批量生效。'; } diff --git a/tests/Feature/AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..15b3aaa --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexBatchMarkActivatedButtonShouldDisableWhenRenewalMissingSubscriptionTest.php @@ -0,0 +1,36 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_batch_mark_activated_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('续费单未绑定订阅', $html); + + $this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"')); + } +}