-- 修复对对碰次数卡订单的幽灵 discount_amount
-- 问题：matching_game_app.go 中次数卡下单时，DiscountAmount 被错误地设为活动全价
--       实际上次数卡支付不涉及优惠券，discount_amount 应该为 0
-- 影响：所有 discount_amount 汇总统计会虚高
-- 代码修复：matching_game_app.go L175 DiscountAmount: activity.PriceDraw → 0

-- Step 1: 先查看受影响的数据量（DRY RUN）
-- SELECT COUNT(*) as affected_count,
--        SUM(discount_amount) as total_phantom_discount_cents,
--        SUM(discount_amount) / 100.0 as total_phantom_discount_yuan
-- FROM orders
-- WHERE source_type = 3
--   AND actual_amount = 0
--   AND discount_amount > 0
--   AND (order_no LIKE 'GP%' OR remark LIKE '%game_pass%');

-- Step 2: 执行修复
UPDATE orders
SET discount_amount = 0,
    updated_at = NOW(3)
WHERE source_type = 3
  AND actual_amount = 0
  AND discount_amount > 0
  AND (order_no LIKE 'GP%' OR remark LIKE '%game_pass%');
