From dbb88f59f62477af31f8f6bc2510fe141d38dcf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Mon, 16 Mar 2026 19:04:40 +0800 Subject: [PATCH] chore(governance): batch mark activated requires unsynced scope --- app/Http/Controllers/Admin/PlatformOrderController.php | 6 +++++- app/Support/PlatformOrderToolsGuard.php | 5 +++++ tests/Feature/AdminPlatformOrderBatchMarkActivatedTest.php | 1 + ...derIndexBatchButtonsShouldEnableWhenFiltersMatchTest.php | 2 +- 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index 0d8c858..ee8518d 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -1818,11 +1818,15 @@ class PlatformOrderController extends Controller 'refund_inconsistent' => (string) $request->input('refund_inconsistent', ''), ]; - // 防误操作:批量“仅标记为已生效”默认要求当前筛选口径为「已支付 + 待处理(pending)」 + // 防误操作:批量“仅标记为已生效”默认要求当前筛选口径为「已支付 + 待处理(pending) + 未同步(unsynced)」 if ($scope === 'filtered') { if (($filters['payment_status'] ?? '') !== 'paid' || ($filters['status'] ?? '') !== 'pending') { return redirect()->back()->with('warning', '为避免误操作,请先筛选「支付状态=已支付」且「订单状态=待处理」,再执行批量仅标记为已生效。'); } + + if (($filters['sync_status'] ?? '') !== 'unsynced') { + return redirect()->back()->with('warning', '为避免把同步失败等异常单混入,请先锁定「同步状态=未同步(sync_status=unsynced)」(建议用快捷筛选「待生效」)再执行批量仅标记为已生效。'); + } } // 防误操作:scope=all 需要二次确认 diff --git a/app/Support/PlatformOrderToolsGuard.php b/app/Support/PlatformOrderToolsGuard.php index bb08606..c7d21a3 100644 --- a/app/Support/PlatformOrderToolsGuard.php +++ b/app/Support/PlatformOrderToolsGuard.php @@ -87,6 +87,11 @@ class PlatformOrderToolsGuard return '请先筛选「支付状态=已支付」且「订单状态=待处理」再执行批量生效。'; } + // 待生效口径一致:paid + pending + unsynced(排除同步失败等异常单),避免误把失败单“批量生效”导致治理链路混乱。 + if ((string) ($filters['sync_status'] ?? '') !== 'unsynced') { + return '为避免把同步失败等异常单混入,请先锁定「同步状态=未同步(sync_status=unsynced)」(建议用快捷筛选「待生效」)再执行批量生效。'; + } + return ''; } diff --git a/tests/Feature/AdminPlatformOrderBatchMarkActivatedTest.php b/tests/Feature/AdminPlatformOrderBatchMarkActivatedTest.php index d879cd8..fe81d00 100644 --- a/tests/Feature/AdminPlatformOrderBatchMarkActivatedTest.php +++ b/tests/Feature/AdminPlatformOrderBatchMarkActivatedTest.php @@ -97,6 +97,7 @@ class AdminPlatformOrderBatchMarkActivatedTest extends TestCase 'scope' => 'filtered', 'payment_status' => 'paid', 'status' => 'pending', + 'sync_status' => 'unsynced', 'limit' => 50, ])->assertRedirect(); diff --git a/tests/Feature/AdminPlatformOrderIndexBatchButtonsShouldEnableWhenFiltersMatchTest.php b/tests/Feature/AdminPlatformOrderIndexBatchButtonsShouldEnableWhenFiltersMatchTest.php index 114f932..a22e05e 100644 --- a/tests/Feature/AdminPlatformOrderIndexBatchButtonsShouldEnableWhenFiltersMatchTest.php +++ b/tests/Feature/AdminPlatformOrderIndexBatchButtonsShouldEnableWhenFiltersMatchTest.php @@ -156,7 +156,7 @@ class AdminPlatformOrderIndexBatchButtonsShouldEnableWhenFiltersMatchTest extend 'meta' => [], ]); - $res = $this->get('/admin/platform-orders?status=pending&payment_status=paid'); + $res = $this->get('/admin/platform-orders?status=pending&payment_status=paid&sync_status=unsynced'); $res->assertOk(); $html = (string) $res->getContent();