chore(governance): block batch BMPA when sync-governance filters present
This commit is contained in:
@@ -1632,6 +1632,17 @@ class PlatformOrderController extends Controller
|
||||
return redirect()->back()->with('warning', '为避免误操作,请先筛选「订单状态=待处理」且「支付状态=未支付」,再执行批量标记支付并生效。');
|
||||
}
|
||||
|
||||
// 互斥筛选阻断:BMPA 面向“待处理+未支付”推进链路;若叠加同步治理筛选,语义会混乱,且可能误伤治理集合。
|
||||
$hasSyncGovernanceFilters = ((string) ($filters['syncable_only'] ?? '') === '1')
|
||||
|| ((string) ($filters['synced_only'] ?? '') === '1')
|
||||
|| (trim((string) ($filters['sync_status'] ?? '')) !== '')
|
||||
|| ((string) ($filters['fail_only'] ?? '') === '1')
|
||||
|| (trim((string) ($filters['sync_error_keyword'] ?? '')) !== '');
|
||||
|
||||
if ($hasSyncGovernanceFilters) {
|
||||
return redirect()->back()->with('warning', '当前筛选包含「订阅同步治理」相关条件(同步状态/同步失败/失败原因/只看可同步等)。本动作仅用于推进待处理未支付订单,请先清空同步治理筛选后再执行。');
|
||||
}
|
||||
|
||||
// 治理优先:若当前筛选已包含“对账不一致/退款不一致”等治理集合,则先治理再执行批量推进
|
||||
if ((string) ($filters['reconcile_mismatch'] ?? '') === '1' || (string) ($filters['refund_inconsistent'] ?? '') === '1') {
|
||||
return redirect()->back()->with('warning', '当前筛选包含「对账不一致/退款不一致」治理集合,请先完成回执/退款治理后,再执行批量标记支付并生效。');
|
||||
|
||||
@@ -80,6 +80,21 @@ class PlatformOrderToolsGuard
|
||||
if ((string) ($filters['status'] ?? '') !== 'pending' || (string) ($filters['payment_status'] ?? '') !== 'unpaid') {
|
||||
return '请先筛选「订单状态=待处理」且「支付状态=未支付」再执行批量 BMPA。';
|
||||
}
|
||||
|
||||
// 互斥筛选阻断:BMPA 面向“待处理+未支付”推进链路;若叠加同步治理筛选,语义会混乱,且可能误伤治理集合。
|
||||
if ((string) ($filters['syncable_only'] ?? '') === '1') {
|
||||
return '当前已勾选「只看可同步」:该集合语义为“已生效+未同步”,与 BMPA(待处理+未支付)互斥。请先取消只看可同步后再执行。';
|
||||
}
|
||||
|
||||
$hasSyncGovernanceFilters = ((string) ($filters['synced_only'] ?? '') === '1')
|
||||
|| (trim((string) ($filters['sync_status'] ?? '')) !== '')
|
||||
|| ((string) ($filters['fail_only'] ?? '') === '1')
|
||||
|| (trim((string) ($filters['sync_error_keyword'] ?? '')) !== '');
|
||||
|
||||
if ($hasSyncGovernanceFilters) {
|
||||
return '当前筛选包含「订阅同步治理」相关条件(同步状态/同步失败/失败原因等)。BMPA 动作仅用于推进待处理未支付订单,请先清空同步治理筛选后再执行。';
|
||||
}
|
||||
|
||||
if (((string) ($filters['reconcile_mismatch'] ?? '') === '1') || ((string) ($filters['refund_inconsistent'] ?? '') === '1')) {
|
||||
return '当前集合包含「对账不一致/退款不一致」治理集合:建议先完成回执/退款治理后再批量推进。';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformOrderIndexBatchBmpaButtonShouldDisableWhenSyncGovernanceFiltersPresentTest 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_bmpa_button_should_disable_when_sync_governance_filters_present_even_if_pending_unpaid(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
// status=pending&payment_status=unpaid 是 BMPA 的基本口径;但叠加“同步失败”治理筛选应禁用(与后端阻断一致)。
|
||||
$res = $this->get('/admin/platform-orders?status=pending&payment_status=unpaid&fail_only=1');
|
||||
$res->assertOk();
|
||||
|
||||
$html = (string) $res->getContent();
|
||||
|
||||
$this->assertStringContainsString('批量标记支付并生效(含订阅同步)(当前筛选范围)', $html);
|
||||
$this->assertStringContainsString('data-role="batch-bmpa-blocked-hint"', $html);
|
||||
$this->assertStringContainsString('同步', $html);
|
||||
|
||||
// 按钮 disabled(宽松断言)
|
||||
$this->assertTrue(str_contains($html, 'type="submit" disabled') || str_contains($html, 'disabled="disabled"'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user