CREATE TABLE IF NOT EXISTS `recharge_reward_config` (
  `id` bigint NOT NULL COMMENT '主键ID',
  `sys_origin` varchar(32) NOT NULL COMMENT '来源系统',
  `enabled` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否启用',
  `timezone` varchar(64) NOT NULL DEFAULT 'Asia/Riyadh' COMMENT '活动时区',
  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_recharge_reward_sys_origin` (`sys_origin`),
  KEY `idx_recharge_reward_enabled` (`enabled`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='充值奖励主配置';

CREATE TABLE IF NOT EXISTS `recharge_reward_level` (
  `id` bigint NOT NULL COMMENT '主键ID',
  `config_id` bigint NOT NULL COMMENT '主配置ID',
  `level` int NOT NULL COMMENT '奖励档位',
  `recharge_amount_cents` bigint NOT NULL COMMENT '充值金额门槛，单位为分',
  `reward_gold` bigint NOT NULL DEFAULT '0' COMMENT '金币奖励数量',
  `reward_group_id` bigint DEFAULT NULL COMMENT '奖励组ID',
  `reward_group_name` varchar(255) NOT NULL DEFAULT '' COMMENT '奖励组名称快照',
  `enabled` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否启用',
  `create_time` datetime(3) DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(3) DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_recharge_reward_level` (`config_id`, `level`),
  UNIQUE KEY `uk_recharge_reward_amount` (`config_id`, `recharge_amount_cents`),
  KEY `idx_recharge_reward_level_config` (`config_id`),
  KEY `idx_recharge_reward_group` (`reward_group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='充值奖励档位配置';
