feat(platform-orders): 清除全部失败标记增加 YES 确认护栏

This commit is contained in:
萝卜
2026-03-10 23:27:05 +00:00
parent 3b59a72d13
commit 429c84bfc2
3 changed files with 21 additions and 2 deletions

View File

@@ -984,10 +984,15 @@ class PlatformOrderController extends Controller
$this->ensurePlatformAdmin($request); $this->ensurePlatformAdmin($request);
// 支持两种模式: // 支持两种模式:
// - scope=all默认清理所有订单的失败标记 // - scope=all默认清理所有订单的失败标记(需要 confirm=YES
// - scope=filtered仅清理当前筛选结果命中的订单更安全 // - scope=filtered仅清理当前筛选结果命中的订单更安全
$scope = (string) $request->input('scope', 'all'); $scope = (string) $request->input('scope', 'all');
// 防误操作scope=all 需要二次确认
if ($scope === 'all' && (string) $request->input('confirm', '') !== 'YES') {
return redirect()->back()->with('warning', '为避免误操作,清除全部失败标记前请在确认框输入 YES。');
}
$filters = [ $filters = [
'status' => trim((string) $request->input('status', '')), 'status' => trim((string) $request->input('status', '')),
'payment_status' => trim((string) $request->input('payment_status', '')), 'payment_status' => trim((string) $request->input('payment_status', '')),

View File

@@ -332,9 +332,16 @@
<button type="submit">清除当前筛选范围的失败标记</button> <button type="submit">清除当前筛选范围的失败标记</button>
</form> </form>
<form method="post" action="/admin/platform-orders/clear-sync-errors" onsubmit="return confirm('确认清除全部订单的“同步失败”标记?');"> <form method="post" action="/admin/platform-orders/clear-sync-errors" onsubmit="return confirm('确认清除全部订单的“同步失败”标记?该操作不可逆(仅清理 meta 标记),请谨慎。');">
@csrf @csrf
<input type="hidden" name="scope" value="all"> <input type="hidden" name="scope" value="all">
<label class="muted form-inline-row mb-8">
<span>确认输入</span>
<input type="text" name="confirm" placeholder="YES" class="w-140">
<span>(必须输入 YES 才会执行)</span>
</label>
<button type="submit">清除全部失败标记</button> <button type="submit">清除全部失败标记</button>
</form> </form>
</div> </div>

View File

@@ -61,9 +61,16 @@ class AdminPlatformOrderClearSyncErrorsTest extends TestCase
], ],
]); ]);
// scope=all 需要二次确认
$this->post('/admin/platform-orders/clear-sync-errors', ['scope' => 'all']) $this->post('/admin/platform-orders/clear-sync-errors', ['scope' => 'all'])
->assertRedirect(); ->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(); $order->refresh();
$this->assertEmpty(data_get($order->meta, 'subscription_activation_error')); $this->assertEmpty(data_get($order->meta, 'subscription_activation_error'));
} }