fix(platform-orders): make bmpa_success_only and bmpa_failed_only mutually exclusive

This commit is contained in:
萝卜
2026-03-18 03:47:25 +08:00
parent 5ee3052280
commit 17e78c2ab2
2 changed files with 59 additions and 0 deletions

View File

@@ -251,6 +251,17 @@ class PlatformOrderController extends Controller
// 只看批量“标记支付并生效”成功:存在 run_id 且 error.message 为空
'bmpa_success_only' => (string) $request->query('bmpa_success_only', ''),
'synced_only' => (string) $request->query('synced_only', ''),
];
// 治理口径bmpa_failed_only 与 bmpa_success_only 互斥(两者同时勾选会导致空集合)。
// 优先级:失败优先(更贴近“需要处理”的治理语义)。
if (($filters['bmpa_failed_only'] ?? '') === '1') {
$filters['bmpa_success_only'] = '';
} elseif (($filters['bmpa_success_only'] ?? '') === '1') {
$filters['bmpa_failed_only'] = '';
}
$filters += [
'sync_status' => trim((string) $request->query('sync_status', '')),
'keyword' => trim((string) $request->query('keyword', '')),
// 同步失败原因关键词:用于快速定位同原因失败订单(可治理)
@@ -1324,6 +1335,17 @@ class PlatformOrderController extends Controller
// 只看批量“标记支付并生效”成功:存在 run_id 且 error.message 为空
'bmpa_success_only' => (string) $request->query('bmpa_success_only', ''),
'synced_only' => (string) $request->query('synced_only', ''),
];
// 治理口径bmpa_failed_only 与 bmpa_success_only 互斥(两者同时勾选会导致空集合)。
// 优先级:失败优先(更贴近“需要处理”的治理语义)。
if (($filters['bmpa_failed_only'] ?? '') === '1') {
$filters['bmpa_success_only'] = '';
} elseif (($filters['bmpa_success_only'] ?? '') === '1') {
$filters['bmpa_failed_only'] = '';
}
$filters += [
'sync_status' => trim((string) $request->query('sync_status', '')),
'keyword' => trim((string) $request->query('keyword', '')),
// 同步失败原因关键词:用于快速定位同原因失败订单(可治理)

View File

@@ -0,0 +1,37 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderBmpaFailedAndSuccessFiltersShouldBeMutuallyExclusiveTest 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_platform_orders_bmpa_failed_and_success_filters_should_be_mutually_exclusive(): void
{
$this->loginAsPlatformAdmin();
// 同时传 success + failedController 侧应执行互斥清洗(失败优先),避免落入空集合。
$html = $this->get('/admin/platform-orders?bmpa_failed_only=1&bmpa_success_only=1')
->assertOk()
->getContent();
// UIsuccess checkbox 不应保持 checked已被清洗掉
$this->assertStringNotContainsString('name="bmpa_success_only" value="1" checked', $html);
// UIfailed checkbox 仍应 checked
$this->assertStringContainsString('name="bmpa_failed_only" value="1" checked', $html);
}
}