diff --git a/app/Support/PlatformOrderToolsGuard.php b/app/Support/PlatformOrderToolsGuard.php index a4f0ae4..845b4f6 100644 --- a/app/Support/PlatformOrderToolsGuard.php +++ b/app/Support/PlatformOrderToolsGuard.php @@ -50,6 +50,11 @@ class PlatformOrderToolsGuard */ public static function batchActivateSubscriptionsReason(array $filters): string { + // 治理集合优先:续费单未绑定订阅属于“先治理再推进”的高风险集合,不允许执行批量同步。 + if ((string) ($filters['renewal_missing_subscription'] ?? '') === '1') { + return '当前集合为「续费单未绑定订阅」治理集合:请先完成订阅绑定/修复关联后再批量同步订阅。'; + } + if ((string) ($filters['syncable_only'] ?? '') !== '1') { return '请先勾选「只看可同步」再执行批量同步。'; } diff --git a/tests/Feature/AdminPlatformOrderIndexBatchActivateButtonShouldDisableWhenRenewalMissingSubscriptionTest.php b/tests/Feature/AdminPlatformOrderIndexBatchActivateButtonShouldDisableWhenRenewalMissingSubscriptionTest.php new file mode 100644 index 0000000..f2030fd --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexBatchActivateButtonShouldDisableWhenRenewalMissingSubscriptionTest.php @@ -0,0 +1,37 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_batch_activate_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-activate-subscriptions-blocked-hint"', $html); + $this->assertStringContainsString('续费单未绑定订阅', $html); + + $this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"')); + } +}