first commit

This commit is contained in:
2026-09-21 19:21:35 +08:00
commit 6c944c4ffd
2733 changed files with 296956 additions and 0 deletions
+160
View File
@@ -0,0 +1,160 @@
-- ============================================================
-- 常州项目 数据库清理脚本(TRUNCATE 各类业务记录表)
-- 适用库:changzhou(127.0.0.1:23306,docker 容器 mysql_db;dev/pro 配置一致)
-- 对照时间:2026-09-17,库内共 163 张表,本脚本覆盖全部业务表
-- ⚠️ 高危操作!执行前务必完整备份数据库!
-- ⚠️ TRUNCATE 不可回滚,且会重置自增主键
-- ⚠️ 若某张表在你的环境中不存在,请注释掉对应行(TRUNCATE 无 IF EXISTS)
-- ============================================================
-- 关闭外键检查,避免因约束顺序报错
SET FOREIGN_KEY_CHECKS = 0;
-- ============================================================
-- Part 1: 系统日志表
-- ============================================================
TRUNCATE TABLE sys_logininfor; -- 登录日志
TRUNCATE TABLE sys_oper_log; -- 操作日志
TRUNCATE TABLE sys_job_log; -- 定时任务日志
-- 清用户
TRUNCATE TABLE tt_user;
-- ============================================================
-- Part 2: 财务流水
-- ============================================================
TRUNCATE TABLE tt_user_blend_ercash; -- 余额/积分变动主流水
TRUNCATE TABLE tt_user_blend_ercash_archive; -- 流水归档表
TRUNCATE TABLE tt_user_amount_records; -- 金币流水明细
TRUNCATE TABLE tt_user_credits_records; -- 积分流水明细
TRUNCATE TABLE tt_user_source_report; -- 用户来源日报表(累计流水统计)
TRUNCATE TABLE tt_user_daily_turnover; -- 用户每日流水统计(VIP 返利/排行榜口径)
TRUNCATE TABLE tt_recharge_record; -- 充值记录
TRUNCATE TABLE tt_recharge_card; -- 充值卡密
TRUNCATE TABLE tt_blank_card_key; -- 空白卡密(后台生成)
TRUNCATE TABLE promo_card_key; -- 卡商卡密
TRUNCATE TABLE promo_cdkey; -- 推广CDKEY创建记录表
TRUNCATE TABLE promo_cdkey_redeem; -- 推广CDKEY兑换记录表
TRUNCATE TABLE tt_order; -- 订单
TRUNCATE TABLE tianxin_order; -- 天心支付订单
TRUNCATE TABLE tt_loss_rebate; -- 亏损返水结算明细(回血红包)
TRUNCATE TABLE tt_comp_record; -- 补偿值记录(user_id + box_id + comp_amount)
TRUNCATE TABLE tt_promotion_update; -- 推广上下级关系变更记录
TRUNCATE TABLE tt_fight_ranking_reward; -- 对战排行榜奖励发放记录
TRUNCATE TABLE tt_recharge_ranking_reward; -- 充值排行榜奖励发放记录
TRUNCATE TABLE tt_user_sub_account; -- 主号-副号关联
TRUNCATE TABLE tt_user_avatar; -- 用户头像
-- ============================================================
-- Part 3: 游戏记录
-- ============================================================
-- 开箱
TRUNCATE TABLE tt_box_records;
TRUNCATE TABLE tt_user_box_open_chance; -- 用户开箱机会
TRUNCATE TABLE tt_box_third_explosive_user; -- 第三方爆率用户记录
-- 对战(tt_fight_round / tt_fight_result 为 DB 标注的废弃表,0 行)
TRUNCATE TABLE tt_fight;
ALTER TABLE tt_fight AUTO_INCREMENT = 1000001;
TRUNCATE TABLE tt_fight_user;
TRUNCATE TABLE tt_fight_round;
TRUNCATE TABLE tt_fight_result;
-- Roll房
TRUNCATE TABLE tt_roll;
TRUNCATE TABLE tt_roll_user;
TRUNCATE TABLE tt_roll_user_prize;
TRUNCATE TABLE tt_time_roll; -- 定时Roll房主表
TRUNCATE TABLE tt_time_roll_user; -- 定时Roll房参与记录
-- 幸运升级
TRUNCATE TABLE tt_upgrade_record;
-- 指数盲盒(tt_exponent 是指数期号历史,勿清空,见 Part 7)
TRUNCATE TABLE tt_exponent_user;
TRUNCATE TABLE tt_exponent_user_box;
-- 极速糖果(sweet)
TRUNCATE TABLE game_sweet_record; -- 对局记录
TRUNCATE TABLE game_sweet_user; -- 用户累计统计
TRUNCATE TABLE game_sweet_win; -- 每日盈亏统计
-- 疯狂转盘(wheel)
TRUNCATE TABLE game_wheel_round; -- 每期开奖
TRUNCATE TABLE game_wheel_round_bet; -- 下注明细
TRUNCATE TABLE game_wheel_user; -- 用户累计统计
TRUNCATE TABLE game_wheel_pool_adjustment; -- 奖池调节记录
-- 玫瑰女郎(olympus)
TRUNCATE TABLE game_olympus_record; -- 玩家游戏记录
TRUNCATE TABLE game_olympus_user; -- 用户累计统计
TRUNCATE TABLE game_olympus_win; -- 每日盈亏
TRUNCATE TABLE game_olympus_reward_log; -- 奖池水位调整日志
-- ============================================================
-- Part 4: 预生成回合池(默认注释)
-- ⚠️ 这些不是配置,是预生成回合池:清空后必须在后台重新生成/重算,
-- 否则对应玩法开局时取不到回合。数据量大(约 90 万行),
-- 要彻底重置磁盘占用再放开本段。
-- ============================================================
-- TRUNCATE TABLE game_sweet_round; -- 极速糖果预生成回合(约 8.4 万行)
-- TRUNCATE TABLE game_sweet_step; -- 极速糖果回合步骤(约 75 万行 / 626MB)
-- TRUNCATE TABLE game_olympus_round; -- 玫瑰女郎预生成回合(约 2.9 万行)
-- TRUNCATE TABLE game_olympus_step; -- 玫瑰女郎回合步骤(约 12.9 万行)
-- ============================================================
-- Part 5: 辅助数据
-- ============================================================
TRUNCATE TABLE tt_attendance_record; -- 签到记录
TRUNCATE TABLE tt_message; -- 用户消息
TRUNCATE TABLE tt_message_send; -- 消息下发记录
TRUNCATE TABLE tt_notice; -- 用户通知
TRUNCATE TABLE sys_notice; -- 系统公告
TRUNCATE TABLE tt_announcement_read; -- 公告已读记录
TRUNCATE TABLE tt_bonus_receive_record; -- 奖励包领取记录
TRUNCATE TABLE tt_red_packet; -- 红包
TRUNCATE TABLE tt_red_packet_record; -- 红包领取记录
TRUNCATE TABLE tt_commission_record; -- 佣金收益记录
TRUNCATE TABLE tt_promotion_record; -- 推广记录
TRUNCATE TABLE tt_task_center_user; -- 任务中心用户进度
TRUNCATE TABLE tt_welfare_record; -- 福利领取记录
TRUNCATE TABLE tt_welfare_box_inventory; -- 用户福利箱子库存
TRUNCATE TABLE tt_turnover_lottery_record; -- 流水抽奖记录
-- ============================================================
-- Part 6: 发货链路
-- ============================================================
TRUNCATE TABLE tt_delivery_record; -- 发货记录
TRUNCATE TABLE tt_box_transfer_record; -- 饰品转移记录
TRUNCATE TABLE tt_replacement_record; -- 饰品替换记录
TRUNCATE TABLE tt_transfer_apply; -- 转赠申请(按批次聚合审核)
TRUNCATE TABLE tt_user_transfer_daily; -- 用户每日转赠次数记录
-- ============================================================
-- Part 7: 明确【不要】清空的表(说明,勿放开)
-- ============================================================
-- game_wheel_reward_matrix 疯狂转盘 120 条固定奖励矩阵,删行会导致「命中缺行漏发」
-- tt_exponent 指数期号历史;TtExponentGenerateTask 的 @Scheduled 已注释停用,
-- 清空后当天无指数记录,指数盲盒无法开局
-- 宝箱 / 饰品 / 各玩法配置 tt_box*、tt_ornament*、tt_game_mould*、game_sweet_*、
-- game_olympus_*、game_wheel_prize_*、tt_roll_prize_template*、
-- tt_roll_jackpot*、tt_upgrade_ornaments*、tt_recharge_config/prod、
-- tt_vip_level、tt_welfare*、tt_task_center、tt_turnover_lottery*、
-- tt_robot_fight_*、tt_content*、tt_banner、tt_advertisement、
-- tt_announcement、promo_admin / promo_menu_config / promo_role_menu
-- 一律不清:清空后要重新导入配置,本脚本不负责恢复
-- qrtz_* 调度器运行状态(任务定义在 sys_job)
-- sys_user / sys_role / sys_menu / sys_config / sys_dict_* / gen_table*
-- 框架、权限、字典与代码生成器数据,清了后台就进不去
-- *_new / *_old 历史重建脚本(ruoyi-ui/main.py)遗留的影子表,确认无引用后直接 DROP,不必纳入本脚本
-- 恢复外键检查
SET FOREIGN_KEY_CHECKS = 1;
-- ============================================================
-- 维护提示:新增业务表后请同步本文件,可用下面两条反查差异
-- 1) 库内全部表:SELECT table_name FROM information_schema.tables
-- WHERE table_schema='changzhou' AND table_type='BASE TABLE' ORDER BY table_name;
-- 2) 本脚本已覆盖的表:在本文件中搜索 TRUNCATE TABLE
-- ============================================================