Governance: block batch mark activated when renewal missing subscription filter present

This commit is contained in:
萝卜
2026-03-17 01:34:51 +08:00
parent 387b18d32b
commit 89f79f5e90
2 changed files with 44 additions and 0 deletions

View File

@@ -1874,6 +1874,11 @@ class PlatformOrderController extends Controller
'refund_inconsistent' => (string) $request->input('refund_inconsistent', ''), 'refund_inconsistent' => (string) $request->input('refund_inconsistent', ''),
]; ];
// 防误操作(治理优先):续费单未绑定订阅属于高风险治理集合,不允许直接批量仅标记为已生效。
if ($scope === 'filtered' && ((string) ($filters['renewal_missing_subscription'] ?? '') === '1')) {
return redirect()->back()->with('warning', '当前筛选为「续费单未绑定订阅」治理集合。为避免带病推进,请先完成订阅绑定/修复关联后再批量仅标记为已生效。');
}
// 防误操作:批量“仅标记为已生效”默认要求当前筛选口径为「已支付 + 待处理(pending) + 未同步(unsynced)」 // 防误操作:批量“仅标记为已生效”默认要求当前筛选口径为「已支付 + 待处理(pending) + 未同步(unsynced)」
if ($scope === 'filtered') { if ($scope === 'filtered') {
if (($filters['payment_status'] ?? '') !== 'paid' || ($filters['status'] ?? '') !== 'pending') { if (($filters['payment_status'] ?? '') !== 'paid' || ($filters['status'] ?? '') !== 'pending') {

View File

@@ -0,0 +1,39 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderBatchMarkActivatedShouldBlockWhenRenewalMissingSubscriptionTest 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_mark_activated_should_block_when_renewal_missing_subscription_present(): void
{
$this->loginAsPlatformAdmin();
$res = $this->post('/admin/platform-orders/batch-mark-activated', [
'scope' => 'filtered',
'renewal_missing_subscription' => '1',
// 即便其它条件满足待生效口径,也应被治理集合优先阻断
'payment_status' => 'paid',
'status' => 'pending',
'sync_status' => 'unsynced',
'limit' => 50,
]);
$res->assertRedirect();
$res->assertSessionHas('warning');
}
}