-- Repair the first LIKEI cumulative-recharge reward snapshots whose Snowflake IDs were
-- rounded by an early JavaScript Number boundary.
--
-- Performance review:
-- 1. Every UPDATE is bounded by one config_id, one cycle_key, and one status set. MySQL can
--    enter through idx_recharge_reward_grant_config_cycle (config_id, cycle_key, status).
-- 2. The production preflight estimates 129 matching rows out of 776 total rows, so the
--    transaction does not scan or lock unrelated recharge cycles.
-- 3. Keeping FAILED/PENDING unchanged lets the existing idempotent cron dispatcher retry the
--    repaired records with their original track IDs; successful records are never touched.

START TRANSACTION;

UPDATE `recharge_reward_grant_record` FORCE INDEX (`idx_recharge_reward_grant_config_cycle`)
SET `reward_group_id` = 2056981527522242561,
    `reward_group_name` = '累计充值10美金',
    `update_time` = CURRENT_TIMESTAMP(3)
WHERE `config_id` = 2050113883955269632
  AND `sys_origin` = 'LIKEI'
  AND `cycle_key` = '20260521'
  AND `status` IN ('PENDING', 'FAILED')
  AND `reward_group_status` IN ('PENDING', 'FAILED')
  AND `level` = 1
  AND `reward_group_id` = 2056981527522242600;

UPDATE `recharge_reward_grant_record` FORCE INDEX (`idx_recharge_reward_grant_config_cycle`)
SET `reward_group_id` = 2056723577461338114,
    `reward_group_name` = '累充活动$50',
    `update_time` = CURRENT_TIMESTAMP(3)
WHERE `config_id` = 2050113883955269632
  AND `sys_origin` = 'LIKEI'
  AND `cycle_key` = '20260521'
  AND `status` IN ('PENDING', 'FAILED')
  AND `reward_group_status` IN ('PENDING', 'FAILED')
  AND `level` = 2
  AND `reward_group_id` = 2056723577461338000;

UPDATE `recharge_reward_grant_record` FORCE INDEX (`idx_recharge_reward_grant_config_cycle`)
SET `reward_group_id` = 2056980937278816257,
    `reward_group_name` = '累充活动$100',
    `update_time` = CURRENT_TIMESTAMP(3)
WHERE `config_id` = 2050113883955269632
  AND `sys_origin` = 'LIKEI'
  AND `cycle_key` = '20260521'
  AND `status` IN ('PENDING', 'FAILED')
  AND `reward_group_status` IN ('PENDING', 'FAILED')
  AND `level` = 3
  AND `reward_group_id` = 2056980937278816300;

COMMIT;
