-- 日常记录游戏化：稳糖分、勋章、每日任务领奖记录（按诊单+用户）

CREATE TABLE IF NOT EXISTS `zyt_tcm_daily_gamify` (
    `id` int unsigned NOT NULL AUTO_INCREMENT,
    `diagnosis_id` int unsigned NOT NULL COMMENT '诊单ID',
    `user_id` int unsigned NOT NULL COMMENT '小程序用户ID',
    `points` int unsigned NOT NULL DEFAULT 0 COMMENT '稳糖分累计',
    `badges` text COMMENT '已解锁勋章ID列表 JSON',
    `task_awards` mediumtext COMMENT '每日任务领奖记录 JSON，键为日期',
    `create_time` int unsigned NOT NULL DEFAULT 0,
    `update_time` int unsigned NOT NULL DEFAULT 0,
    PRIMARY KEY (`id`),
    UNIQUE KEY `uk_diagnosis_user` (`diagnosis_id`, `user_id`),
    KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='日常记录稳糖分与勋章';
