diff --git a/app/Http/Controllers/Admin/PlatformOrderController.php b/app/Http/Controllers/Admin/PlatformOrderController.php index 555a95a..a424763 100644 --- a/app/Http/Controllers/Admin/PlatformOrderController.php +++ b/app/Http/Controllers/Admin/PlatformOrderController.php @@ -984,10 +984,15 @@ class PlatformOrderController extends Controller $this->ensurePlatformAdmin($request); // 支持两种模式: - // - scope=all(默认):清理所有订单的失败标记 + // - scope=all(默认):清理所有订单的失败标记(需要 confirm=YES) // - scope=filtered:仅清理当前筛选结果命中的订单(更安全) $scope = (string) $request->input('scope', 'all'); + // 防误操作:scope=all 需要二次确认 + if ($scope === 'all' && (string) $request->input('confirm', '') !== 'YES') { + return redirect()->back()->with('warning', '为避免误操作,清除全部失败标记前请在确认框输入 YES。'); + } + $filters = [ 'status' => trim((string) $request->input('status', '')), 'payment_status' => trim((string) $request->input('payment_status', '')), diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index ae49cdc..94b4398 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -332,9 +332,16 @@ -
diff --git a/tests/Feature/AdminPlatformOrderClearSyncErrorsTest.php b/tests/Feature/AdminPlatformOrderClearSyncErrorsTest.php index ef21d14..b92bfab 100644 --- a/tests/Feature/AdminPlatformOrderClearSyncErrorsTest.php +++ b/tests/Feature/AdminPlatformOrderClearSyncErrorsTest.php @@ -61,9 +61,16 @@ class AdminPlatformOrderClearSyncErrorsTest extends TestCase ], ]); + // scope=all 需要二次确认 $this->post('/admin/platform-orders/clear-sync-errors', ['scope' => 'all']) ->assertRedirect(); + $order->refresh(); + $this->assertNotEmpty(data_get($order->meta, 'subscription_activation_error.message')); + + $this->post('/admin/platform-orders/clear-sync-errors', ['scope' => 'all', 'confirm' => 'YES']) + ->assertRedirect(); + $order->refresh(); $this->assertEmpty(data_get($order->meta, 'subscription_activation_error')); }