Governance: block batch activate subscriptions when renewal missing subscription filter present

This commit is contained in:
萝卜
2026-03-17 01:24:47 +08:00
parent 8e93437748
commit 3cba715f01
2 changed files with 42 additions and 0 deletions

View File

@@ -1419,6 +1419,11 @@ class PlatformOrderController extends Controller
'refund_inconsistent' => (string) $request->input('refund_inconsistent', ''),
];
// 防误操作(治理优先):续费单未绑定订阅属于高风险治理集合,不允许直接批量同步。
if ($scope === 'filtered' && ((string) ($filters['renewal_missing_subscription'] ?? '') === '1')) {
return redirect()->back()->with('warning', '当前筛选为「续费单未绑定订阅」治理集合。为避免带病推进,请先完成订阅绑定/修复关联后再批量同步订阅。');
}
// 防误操作:批量同步默认要求先勾选“只看可同步”,避免无意识扩大处理范围
if ($scope === 'filtered' && ($filters['syncable_only'] ?? '') !== '1') {
return redirect()->back()->with('warning', '为避免误操作,请先在筛选条件中勾选「只看可同步」,再执行批量同步订阅。');

View File

@@ -0,0 +1,37 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderBatchActivateSubscriptionsShouldBlockWhenRenewalMissingSubscriptionTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_batch_activate_should_block_when_renewal_missing_subscription_present(): void
{
$this->loginAsPlatformAdmin();
$res = $this->post('/admin/platform-orders/batch-activate-subscriptions', [
'scope' => 'filtered',
'renewal_missing_subscription' => '1',
// syncable_only 即使传了,也应被治理集合优先阻断
'syncable_only' => '1',
'limit' => 50,
]);
$res->assertRedirect();
$res->assertSessionHas('warning');
}
}