CREATE TABLE ad (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(50) NOT NULL DEFAULT '' COMMENT '广告标题',
  channel varchar(20) NOT NULL DEFAULT '' COMMENT '频道页面',
  place varchar(20) NOT NULL DEFAULT '' COMMENT '位置',
  image varchar(255) NOT NULL DEFAULT '' COMMENT '广告图片',
  position int(11) unsigned NOT NULL DEFAULT '0' COMMENT '广告位置',
  link varchar(255) NOT NULL DEFAULT '' COMMENT '广告链接',
  start_time datetime DEFAULT NULL COMMENT '开始时间',
  end_time datetime DEFAULT NULL COMMENT '结束时间',
  PRIMARY KEY (id),
  KEY start_time (start_time,end_time),
  KEY channel (channel,place)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='广告';

CREATE TABLE comment (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  nickname varchar(50) NOT NULL DEFAULT '' COMMENT '昵称',
  avatar varchar(255) NOT NULL DEFAULT '' COMMENT '头像',
  channel varchar(20) NOT NULL DEFAULT '' COMMENT '频道',
  position int(11) unsigned NOT NULL DEFAULT '0' COMMENT '位置',
  content text,
  is_show tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否展示',
  is_special tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否用于展示',
  is_system tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否系统创建',
  sort int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY channel (channel,position,is_show)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='评价';

CREATE TABLE contract (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  `key` varchar(20) NOT NULL DEFAULT '' COMMENT '合同场景',
  title varchar(255) NOT NULL DEFAULT '' COMMENT '协议名称',
  content text,
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同';

INSERT INTO contract (id, `key`, title, content, create_time, update_time)
VALUES
	(1,'register','千行注册协议',NULL,NULL,'2019-09-03 01:08:57'),
	(2,'course','千行课程协议',NULL,NULL,NULL);

CREATE TABLE course (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  struct_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '节点id',
  parent_struct_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上级节点id，0为无上级',
  course_module varchar(20) NOT NULL DEFAULT '' COMMENT '课程模块',
  no_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课时数',
  time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课时时长',
  vs_type varchar(20) NOT NULL DEFAULT '' COMMENT '1vs1课程类型',
  video_type varchar(20) NOT NULL DEFAULT '' COMMENT '视频课程类型',
  extend varchar(20) NOT NULL DEFAULT '' COMMENT '从struct上继承extend',
  title varchar(20) NOT NULL DEFAULT '' COMMENT '课程名称',
  comment varchar(255) DEFAULT '' COMMENT '评价推荐',
  crowd varchar(20) NOT NULL DEFAULT '' COMMENT '适合人群',
  price decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',
  teacher varchar(20) NOT NULL DEFAULT '' COMMENT '授课老师',
  cover varchar(255) NOT NULL DEFAULT '' COMMENT '课程封面',
  min_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最小购买数量',
  max_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最大购买数量',
  expire_pre_days int(11) unsigned NOT NULL DEFAULT '0' COMMENT '1v1课时有效天数',
  expire_days int(11) unsigned NOT NULL DEFAULT '0' COMMENT '视频课程开通有效时长',
  ask_extend_days int(11) unsigned NOT NULL DEFAULT '0' COMMENT '提问扩展天数',
  use_expire_days int(11) unsigned NOT NULL DEFAULT '0' COMMENT '使用有效时长',
  wechat_avatar varchar(255) DEFAULT NULL COMMENT '微信头像',
  teacher_content text COMMENT '老师资质',
  base_content text COMMENT '基本参数',
  course_content text COMMENT '授课内容',
  point_content text COMMENT '授课重点',
  crowd_content text COMMENT '适合人群内容',
  syllabus_content text COMMENT '授课大纲',
  promote_content text COMMENT '优惠信息',
  service_content text COMMENT '服务介绍',
  message_content text COMMENT '推广语',
  process_content text COMMENT '授课流程',
  course_no_content text COMMENT '课时数',
  trail_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '试听人数',
  sale_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '销售数量',
  package_sale_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '套餐销售数量',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY course_module (course_module,struct_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='课程';

CREATE TABLE course_data (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(255) NOT NULL DEFAULT '' COMMENT '资料名称',
  comment varchar(255) NOT NULL DEFAULT '' COMMENT '评价推荐',
  struct_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '学科：节点id',
  parent_struct_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上级节点id，0为无上级',
  is_sentence tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否是长难句',
  data_type varchar(20) NOT NULL DEFAULT '' COMMENT '资料形式',
  is_novice tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '适合新手：1适合',
  is_original tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否原创：1原创',
  price decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '价格',
  pages int(11) unsigned NOT NULL DEFAULT '0' COMMENT '页数',
  link varchar(255) NOT NULL DEFAULT '' COMMENT '链接',
  cover varchar(255) NOT NULL DEFAULT '' COMMENT '封面图片',
  resource varchar(255) NOT NULL DEFAULT '' COMMENT '资料',
  trail_resource varchar(255) NOT NULL DEFAULT '' COMMENT '试用资料',
  trail_start int(11) unsigned NOT NULL DEFAULT '0' COMMENT '试用开始',
  trail_end int(11) unsigned NOT NULL DEFAULT '0' COMMENT '试用结束',
  description text COMMENT '摘要介绍',
  content text COMMENT '资料介绍',
  author_content text COMMENT '作者介绍',
  method_content text COMMENT '获取介绍',
  view_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '查看人数',
  sale_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '销售数量',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  latest_time datetime DEFAULT NULL,
  version varchar(20) DEFAULT NULL,
  PRIMARY KEY (id),
  KEY data_type (data_type,struct_id),
  KEY struct_id (struct_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='课程-资料';

CREATE TABLE course_data_history (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  data_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '资料id',
  version varchar(255) NOT NULL DEFAULT '' COMMENT '版本名称',
  time datetime DEFAULT NULL COMMENT '更新时间',
  position varchar(255) NOT NULL DEFAULT '' COMMENT '更新位置',
  origin_content text COMMENT '原文',
  content text COMMENT '更正',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY data_id (data_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='课程-资料-版本';

CREATE TABLE course_experience (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  nickname varchar(255) DEFAULT NULL COMMENT '用户昵称',
  title varchar(255) NOT NULL DEFAULT '' COMMENT '题目',
  content text COMMENT '正文',
  link varchar(255) NOT NULL DEFAULT '' COMMENT '问卷链接',
  prepare_status varchar(255) NOT NULL DEFAULT '' COMMENT '备考身份',
  experience_day int(11) unsigned NOT NULL DEFAULT '0' COMMENT '备考周期: 天',
  experience_score int(11) unsigned NOT NULL DEFAULT '0' COMMENT '分手成绩: 具体分数',
  experience_percent varchar(255) NOT NULL DEFAULT '' COMMENT '提分幅度',
  experience_time datetime DEFAULT NULL COMMENT '考试时间',
  view_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '阅读量',
  collect_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '收藏量',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY prepare_status (prepare_status),
  KEY experience_day (experience_day),
  KEY experience_score (experience_score),
  KEY experience_percent (experience_percent)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='课程-心经';

CREATE TABLE course_no (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  course_id int(11) unsigned NOT NULL COMMENT '课程id',
  no int(11) unsigned NOT NULL COMMENT '课时序号',
  title varchar(255) DEFAULT NULL COMMENT '标题',
  resource varchar(255) NOT NULL DEFAULT '' COMMENT '资源文件地址',
  content text COMMENT '课时描述',
  time int(11) unsigned NOT NULL COMMENT '课程时长',
  is_trail tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否试用',
  start_trail int(11) unsigned NOT NULL DEFAULT '0' COMMENT '试用区间：开始',
  end_trail int(11) unsigned NOT NULL DEFAULT '0' COMMENT '试用区间：结束',
  trail_resource varchar(255) NOT NULL DEFAULT '' COMMENT '试用视频',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY course_id (course_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='课程-视频课程课时';

CREATE TABLE course_package (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  struct_id int(20) NOT NULL COMMENT '学科',
  title varchar(255) NOT NULL DEFAULT '' COMMENT '套餐名称',
  description text COMMENT '套餐简介',
  price decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '套餐价格',
  course_ids text COMMENT '包含课程',
  is_special tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否精选：首页推荐',
  gift text COMMENT '赠品：json',
  sale_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '销售数量',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY struct_id (struct_id),
  KEY is_special (is_special)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='课程-套餐';

CREATE TABLE course_teacher (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  course_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课程id',
  realname varchar(20) DEFAULT NULL COMMENT '姓名',
  avatar varchar(255) DEFAULT NULL COMMENT '头像',
  wechat varchar(255) DEFAULT NULL COMMENT '微信号',
  qr varchar(255) DEFAULT NULL COMMENT '微信二维码',
  description text COMMENT '描述',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY course_id (course_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='课程-教师';

CREATE TABLE course_time (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  course_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课程id',
  start_time datetime DEFAULT NULL COMMENT '开始时间',
  end_time datetime DEFAULT NULL COMMENT '结束时间',
  status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '状态：0未开始，1进行，2结束',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY course_id (course_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='课程-课时';

CREATE TABLE examination_paper (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  struct_two int(11) unsigned NOT NULL COMMENT '试卷组',
  struct_three int(11) unsigned NOT NULL COMMENT '考卷',
  is_adapt tinyint(1) unsigned NOT NULL COMMENT '是否适应难度: 0非适应性，1适应性，2千行',
  title varchar(50) NOT NULL DEFAULT '' COMMENT '标题',
  status tinyint(1) unsigned NOT NULL COMMENT '开放状态：0关闭，1开启',
  total_score int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总分',
  total_times int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总做卷次数',
  quant_score int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总Q分',
  verbal_score int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总V分',
  ir_score int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总ir分',
  second_total_score int(11) unsigned NOT NULL DEFAULT '0' COMMENT '第二次总分',
  second_total_times int(11) unsigned NOT NULL DEFAULT '0' COMMENT '第二次总做卷次数',
  second_quant_score int(11) unsigned NOT NULL DEFAULT '0' COMMENT '第二次总Q分',
  second_verbal_score int(11) unsigned NOT NULL DEFAULT '0' COMMENT '第二次总V分',
  second_ir_score int(11) unsigned NOT NULL DEFAULT '0' COMMENT '第二次总ir分',
  PRIMARY KEY (id),
  KEY status (status,struct_three)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='模考-组卷';

CREATE TABLE examination_struct (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title_zh varchar(50) NOT NULL DEFAULT '' COMMENT '中文名称',
  title_en varchar(50) NOT NULL DEFAULT '' COMMENT '英文名称',
  parent_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '父级id',
  sort int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序：从大到小',
  level int(11) unsigned NOT NULL DEFAULT '0' COMMENT '层级：从1开始',
  is_adapt tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '难度适应性：0非难度适应性，1难度适应性',
  question_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '提问状态',
  extend varchar(25) DEFAULT NULL COMMENT '对应服务',
  description text COMMENT '说明',
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='模考结构-2+1层：种类-总卷-分卷（同时算paper）';

INSERT INTO examination_struct (id, title_zh, title_en, parent_id, sort, level, is_adapt, question_status, extend, description)
VALUES
	(1,'CAT 难度适应性','',0,0,1,1,0,'cat',NULL),
	(2,'非难度适应性','',0,0,1,0,0,'base',NULL),
	(3,'千行CAT','',1,0,2,2,0,'qx_cat',NULL),
	(4,'净化版PREP-CAT','',1,0,2,1,0,NULL,NULL),
	(5,'GWD-CAT','',1,0,2,1,0,NULL,NULL),
	(6,'净化版PREP-CAT','',1,0,2,0,0,'cat','净化版PREP-CAT');

CREATE TABLE exercise_paper (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  question_type varchar(20) NOT NULL DEFAULT '' COMMENT '题型：从struct上获取extend',
  title varchar(20) NOT NULL COMMENT '组卷名称',
  no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '组卷序号',
  logic varchar(20) NOT NULL DEFAULT '' COMMENT '组卷逻辑：order ，place，difficult，error',
  logic_extend varchar(20) NOT NULL DEFAULT '' COMMENT '逻辑',
  struct_three int(11) unsigned NOT NULL DEFAULT '0' COMMENT '教材',
  struct_four int(11) unsigned NOT NULL DEFAULT '0' COMMENT '分册',
  question_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目数量',
  question_no_ids text COMMENT '题目编号ids：json',
  status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '开放状态：0关闭，1开启',
  PRIMARY KEY (id),
  KEY logic (logic,logic_extend),
  KEY status (status,struct_four)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='练习-组卷-自动';

CREATE TABLE exercise_struct (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title_zh varchar(50) NOT NULL DEFAULT '' COMMENT '中文名称',
  title_en varchar(50) NOT NULL DEFAULT '' COMMENT '英文名称',
  parent_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '父级id',
  sort int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序：从大到小',
  level int(11) unsigned NOT NULL DEFAULT '0' COMMENT '层级：从1开始',
  question_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '提问状态：0关闭，1开启',
  is_course tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否是课程',
  is_data tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否是资料',
  is_sentence tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否是长难句：每一层都继承',
  is_examination tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否是考试：每一层都继承',
  description text COMMENT '描述',
  extend varchar(25) DEFAULT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='练习结构-4层：学科-门类-教材-分册';

INSERT INTO exercise_struct (id, title_zh, title_en, parent_id, sort, level, question_status, is_course, is_data, is_sentence, is_examination, description, extend)
VALUES
	(1,'长难句','',0,0,1,0,1,1,1,0,'','sentence'),
	(2,'语文','Verbal',0,0,1,0,1,1,0,1,'','verbal'),
	(3,'数学','Quant',0,0,1,0,1,1,0,1,'','quant'),
	(4,'综合推理','IR',0,0,1,0,0,0,0,1,'','ir'),
	(5,'作文','AWA',0,0,1,0,0,0,0,1,'','awa'),
	(6,'语法','SC',2,0,2,0,1,1,0,1,NULL,'sc'),
	(7,'阅读','RC',2,0,2,0,1,1,0,1,NULL,'rc'),
	(8,'逻辑','CR',2,0,2,0,1,1,0,1,NULL,'cr'),
	(9,'充分性分析','DS',3,0,2,0,0,0,0,1,NULL,'ds'),
	(10,'问题求解','PS',3,0,2,0,0,0,0,1,NULL,'ps'),
	(11,'综合推理','IR',4,0,2,0,0,0,0,1,NULL,'ir'),
	(12,'写作','AWA',5,0,2,0,0,0,0,1,NULL,'awa');

CREATE TABLE faq (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  email varchar(255) NOT NULL DEFAULT '' COMMENT '提问者邮箱',
  message tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '回复站内信',
  channel varchar(20) NOT NULL DEFAULT '' COMMENT '频道',
  position int(11) unsigned NOT NULL DEFAULT '0' COMMENT '位置',
  content text COMMENT '提问内容',
  manager_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '处理人',
  is_show tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否展示',
  is_special tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否用于展示',
  answer text COMMENT '回复内容',
  answer_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '问答状态：0未回答，1回答，忽略',
  answer_time datetime DEFAULT NULL COMMENT '回复时间',
  is_system tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否系统创建',
  sort int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY channel (channel,position,is_show)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='faq';

CREATE TABLE manager (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  username varchar(50) NOT NULL DEFAULT '' COMMENT '用户名',
  password varchar(64) NOT NULL DEFAULT '' COMMENT '密码',
  role_id int(11) unsigned NOT NULL COMMENT '角色id',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  delete_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  UNIQUE KEY username (username,delete_time)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理员';

INSERT INTO manager (id, username, password, role_id, create_time, update_time, delete_time)
VALUES
	(1,'admin','c3284d0f94606de1fd2af172aba15bf3',1,NULL,NULL,NULL);

CREATE TABLE manager_log (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  manager_id int(11) unsigned NOT NULL COMMENT '管理员ID',
  username varchar(50) NOT NULL DEFAULT '' COMMENT '用户名',
  ip varchar(20) NOT NULL DEFAULT '' COMMENT '当前ip',
  content text COMMENT '内容：json',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理日志';

CREATE TABLE manager_role (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(50) NOT NULL DEFAULT '' COMMENT '角色名称',
  permission_list text COMMENT '权限列表：json',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理角色';

INSERT INTO manager_role (id, title, permission_list, create_time, update_time)
VALUES
	(1,'超级管理员','[\"test\"]',NULL,NULL);

CREATE TABLE message_template (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(255) NOT NULL DEFAULT '' COMMENT '消息标题',
  message_method varchar(20) NOT NULL DEFAULT '' COMMENT '消息形式',
  message_category varchar(50) NOT NULL DEFAULT '' COMMENT '消息类型',
  content text COMMENT '消息内容',
  link varchar(255) NOT NULL DEFAULT '' COMMENT '消息链接',
  send_time datetime DEFAULT NULL COMMENT '发送时间',
  send_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '发送数量',
  send_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '发送状态：0未发送，1发送中，2发送完成',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY message_category (message_category)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='消息-模版配置';

INSERT INTO message_template (id, title, message_method, message_category, content, link, send_time, send_number, send_status, create_time)
VALUES
	(1, '登录异常', 'inside', 'login_abnormal', '您的账号于{time}发生异常登入，异常登入可能会影响您账号的正常使用，望知悉。', '', NULL, 0, 1, '2019-08-01 23:53:40'),
	(2, '换库', 'inside', 'textbook_library', '最新换库时间是{date}，上次换库时间是{prevDate}，间隔{period}天，库长{days}天。', '', NULL, 0, 1, NULL),
	(3, '预习作业提醒', 'inside', 'preview_notice', '您有{number}份“{title}”作业待完成', '', NULL, 0, 1, NULL),
	(4, '机经反馈', 'inside', 'textbook_feedback_handle', '您于{time}反馈如下问题：\r\n机经类别：{subject}\r\n反馈类型：{target}\r\n题号：{no}\r\n{result}：{answer}\r\n处理结果：{handle}。\r\n感谢您的反馈，{useExpireDays}天VIP权限已送至您的账户。', '', NULL, 11, 1, NULL),
	(5, '资料更新', 'inside', 'data_update_paper', '您购买的资料“{title}”已更新到版本{version}', '', NULL, 0, 1, NULL),
	(6, '提问回复', 'inside', 'ask_question_handle', '您在{date}对“{title}”的提问“{content}”已经被老师回答啦~', '', NULL, 0, 1, NULL),
	(7, '提问回复', 'inside', 'ask_course_handle', '您在{date}对“{title}-课时{no}”的提问“{content}”已经被老师回答啦~', '', NULL, 0, 1, NULL),
	(8, '咨询回复', 'inside', 'faq_handle', '咨询板块：{channel}\r\n您的问题：{content}\r\n回答：{answer}\r\n希望对您有帮助。', '', NULL, 0, 1, NULL),
	(9, '纠错回复', 'inside', 'feedback_error_handle', '您于{time}反馈如下问题：\r\n纠错对象：{title}-{position}\r\n错误内容是：{originContent}\r\n应该更改为：{content}\r\n处理结果：需要修改，已更正。\r\n感谢您的反馈，{useExpireDays}天VIP权限已送至您的账户。', '', NULL, 0, 1, NULL),
	(10, '[千行GMAT]登入异常', 'email', 'login_abnormal', '同学您好，\r\n您的账号于{time}发生异常登入，异常登入可能会影响您账号的正常使用，望知悉。\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(11, '[千行GMAT]换库消息', 'email', 'textbook_library', '同学您好，\r\n最新换库时间是{date}，上次换库时间是{prevDate}，间隔{period}天，库长{days}天。\r\n查看本年度换库情况: {linkSecondHtml}\r\n获取机经：{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(12, '[千行GMAT]注册成功', 'email', 'register', '同学您好，\r\n欢迎加入“千行GMAT”，您的账号已绑定该邮箱地址。\r\n愿您Waste Less, Learn More.\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(13, '[千行GMAT]作业提醒', 'email', 'preview_notice', '同学您好，\r\n您有{number}份“{title}”作业待完成，去做作业：{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(14, '[千行GMAT]购买成功', 'email', 'data_pay', '同学您好，\r\n您已成功购买“{title}”服务，祝您在 千行 学习愉快~\r\n\r\nBest\r\n千行团队', '', NULL, 8, 1, NULL),
	(15, '[千行GMAT]{nickname}发来的邀请', 'email', 'invited', '您的好友{nickname}邀请您加入“千行GMAT”，{linkHtml}\r\n\r\n{content}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(16, '[千行GMAT]绑定邮箱', 'email', 'email_change', '同学您好，\r\n您的“千行GMAT”账号更换绑定邮箱成功。\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(17, '[千行GMAT]资料更新', 'email', 'data_update_paper', '同学您好，\r\n您订阅的“{title}”已更新至版本{version}，\r\n更新日志：{description}\r\n您也可以：{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(18, '登录异常', 'sms', 'login_abnormal', NULL, '', NULL, 0, 1, NULL),
	(19, '新增换库', 'sms', 'textbook_library', NULL, '', NULL, 0, 1, NULL),
	(20, '[千行GMAT]解绑邮箱', 'email', 'email_unbind', '同学您好，\r\n您的“千行GMAT”账号不再绑定本邮箱，您更换的新邮箱地址为：{email}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(21, '[千行GMAT]实名认证成功', 'email', 'real', '同学您好，\r\n您已完成实名认证，{useExpireDays}天VIP权限已赠送至您的账户，VIP有效期至{expireTime}.\r\n我们将重视和保护您的隐私，祝您在 千行 学习愉快~\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(22, '[千行GMAT]购买成功', 'email', 'pay_multi', '同学您好，\r\n您已成功购买“{titleJoin}”共{number}个商品，祝您在 千行 学习愉快~\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(23, '[千行GMAT]开通提醒', 'email', 'course_open_expire', '同学您好，\r\n请于{expireDate}前开通“{title}”，过期后将无法正常开通使用。{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(24, '[千行GMAT]开通提醒', 'email', 'textbook_open_expire', '同学您好，\r\n请于{expireDate}前开通“{title}”，过期后将无法正常开通使用。{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(25, '[千行GMAT]开通提醒', 'email', 'qx_cat_open_expire', '同学您好，\r\n请于{expireDate}前开通“{title}”，过期后将无法正常开通使用。{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(26, '[千行GMAT]到期提醒', 'email', 'course_use_expire', '同学您好，\r\n您的“{title}”将于{days}天后过期，{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(27, '[千行GMAT]到期提醒', 'email', 'textbook_use_expire', '同学您好，\r\n您的“{title}”将于{days}天后过期，{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(28, '[千行GMAT]到期提醒', 'email', 'qx_cat_use_expire', '同学您好，\r\n您的“{title}”将于{days}天后过期，{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(29, '[千行GMAT]机经更新至{version}', 'email', 'textbook_update', '同学您好，\r\n数学机经{quantDescription}，更新至版本{quantVersion}；\r\n逻辑机经{irDescription}，更新至版本{irVersion}；\r\n阅读机经{rcDescription}，更新至版本{rcVersion}.\r\n您可以：{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(30, '[千行GMAT]资料更新', 'email', 'data_update_subscribe', '同学您好，\r\n您订阅的“{title}”已更新至版本{version}，\r\n更新日志：{description}\r\n附件为最新版资料，您也可以：{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(31, '[千行GMAT]资料更新', 'email', 'data_update_base', '同学您好，\r\n您订阅的“{title}”已更新至版本{version}，\r\n更新日志：{description}\r\n您也可以：{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(32, '课程到期', 'sms', 'course_use_expire', NULL, '', NULL, 0, 1, NULL),
	(33, '课程开通到期', 'sms', 'course_open_expire', NULL, '', NULL, 0, 1, NULL),
	(34, '机经开通到期', 'sms', 'textbook_open_expire', NULL, '', NULL, 0, 1, NULL),
	(35, '模考开通到期', 'sms', 'qx_cat_open_expire', NULL, '', NULL, 0, 1, NULL),
	(36, '购买成功', 'inside', 'vip_pay', '您已成功购买“{title}（{useExpireDays}天）”服务，有效期至{expireTime}', '', NULL, 0, 1, NULL),
	(37, '[千行GMAT]购买成功', 'email', 'vip_pay', '同学您好，\r\n您已成功购买“{title}”服务，祝您在 千行 学习愉快~\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(38, '[千行GMAT]购买成功', 'email', 'textbook_pay', '同学您好，\r\n您已成功购买“{title}”服务，祝您在 千行 学习愉快~\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(39, '[千行GMAT]购买成功', 'email', 'qx_cat_pay', '同学您好，\r\n您已成功购买“{title}”服务，祝您在 千行 学习愉快~\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(40, '到期提醒', 'inside', 'course_use_expire', '您的“{title}”将于{days}天后过期。', '', NULL, 0, 1, NULL),
	(41, '开通提醒', 'inside', 'course_open_expire', '请于{expireDate}前开通“{title}”，过期后将无法正常开通使用。', '', NULL, 0, 1, NULL),
	(42, '赠送', 'inside', 'invited_success', '您的第{number}位好友已加入”千行GMAT“，{useExpireDays}天VIP权限已赠送至您的账户，VIP有效期至{expireTime}', '', NULL, 0, 1, NULL),
	(43, '赠送', 'inside', 'real', '您已完成实名认证，{useExpireDays}天VIP权限已赠送至您的账户，VIP有效期至{expireTime}', '', NULL, 0, 1, NULL),
	(44, '赠送', 'inside', 'prepare', '您已完善备考信息，{useExpireDays}天VIP权限已赠送至您的账户，VIP有效期至{expireTime}', '', NULL, 0, 1, NULL),
	(45, '到期提醒', 'inside', 'vip_use_expire', '您的“{title}”将于{days}天后过期', '', NULL, 0, 1, NULL),
	(46, '购买成功', 'inside', 'qx_cat_pay', '您已成功购买\"{title}”服务，开通有效期为{expireDays}天，使用有效期为{useExpireDays}天。', '', NULL, 0, 1, NULL),
	(47, '开通提醒', 'inside', 'qx_cat_open_expire', '请于{expireDate}前开通“{title}”，过期后将无法正常开通使用。', '', NULL, 0, 1, NULL),
	(48, '到期提醒', 'inside', 'qx_cat_use_expire', '您的“{title}”将于{days}天后过期。', '', NULL, 0, 1, NULL),
	(49, '购买成功', 'inside', 'textbook_pay', '您已成功购买\"{title}”服务，开通有效期为{expireDays}天，使用有效期为{useExpireDays}天。', '', NULL, 0, 1, NULL),
	(50, '开通提醒', 'inside', 'textbook_open_expire', '请于{expireDate}前开通“{title}”，过期后将无法正常开通使用。', '', NULL, 0, 1, NULL),
	(51, '[千行GMAT]购买成功', 'email', 'course_pay', '同学您好，\r\n您已成功购买“{title}”服务，祝您在 千行 学习愉快~\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(52, '[千行GMAT]购买成功', 'email', 'course_pay_multi', '同学您好，\r\n您已成功购买“{titleJoin}”共{number}个商品，祝您在 千行 学习愉快~\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(53, '[千行GMAT]购买成功', 'email', 'data_pay_multi', '同学您好，\r\n您已成功购买“{titleJoin}”共{number}个商品，祝您在 千行 学习愉快~\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(54, '购买成功', 'inside', 'course_pay', '您已成功购买\"{title}”，开通有效期为{expireDays}天，使用有效期为{useExpireDays}天。', '', NULL, 0, 1, NULL),
	(55, '购买成功', 'inside', 'course_pay_multi', '您已成功购买\"{title}”等{number}个商品，查看开通有效期和使用有效期', '', NULL, 0, 1, NULL),
	(56, '购买成功', 'inside', 'pay_multi', '您已成功购买\"{title}”等{number}个商品，查看开通有效期和使用有效期', '', NULL, 0, 1, NULL),
	(57, '购买成功', 'inside', 'data_pay', '您已成功购买\"{title}”', '', NULL, 0, 1, NULL),
	(58, '购买成功', 'inside', 'data_pay_multi', '您已成功购买“{titleJoin}”', '', NULL, 0, 1, NULL),
	(59, '机经更新', 'inside', 'textbook_update', '数学机经{quantDescription}，更新至版本{quantVersion}；\r\n逻辑机经{irDescription}，更新至版本{irVersion}；\r\n阅读机经{rcDescription}，更新至版本{rcVersion}.', '', NULL, 0, 1, NULL),
	(60, '资料更新', 'inside', 'data_update_base', '您购买的资料“{title}”已更新到版本{version}', '', NULL, 0, 1, NULL),
	(61, '资料更新', 'inside', 'data_update_subscribe', '您购买的资料“{title}”已更新到版本{version}，最新版本已发送至您的邮箱{email}', '', NULL, 0, 1, NULL),
	(62, '纠错回复', 'inside', 'feedback_error_nohandle', '您于{time}反馈如下问题：\r\n纠错对象：{title}-{position}\r\n错误内容是：{originContent}\r\n应该更改为：{content}\r\n处理结果：无需修改。\r\n感谢您的反馈。', '', NULL, 0, 1, NULL),
	(63, '机经反馈', 'inside', 'textbook_feedback_nohandle', '您于{time}反馈如下问题：\r\n机经类别：{subject}\r\n反馈类型：{target}\r\n题号：{no}\r\n{result}：{content}\r\n处理结果：无需修改。\r\n感谢您的反馈。', '', NULL, 0, 1, NULL),
	(64, '提问回复', 'inside', 'ask_question_ignore', '您在{date}对“{title}”的提问“{content}”与本题无关，老师无法作出回答，敬请谅解。', '', NULL, 0, 1, NULL),
	(65, '提问回复', 'inside', 'ask_course_ignore', '您在{date}对“{title}-课时{no}”的提问“{content}”与课程内容无关，老师无法作出回答，敬请谅解。', '', NULL, 0, 1, NULL),
	(66, '赠送', 'inside', 'course_gift', '“{title}”已赠送至您的账户，开通有效期为{expireDays}天，使用有效期为{useExpireDays}天。', '', NULL, 0, 1, NULL),
	(67, '[千行GMAT]机经更新至{version}', 'email', 'textbook_update_subscribe', '同学您好，\r\n数学机经{quantDescription}，更新至版本{quantVersion}；\r\n逻辑机经{irDescription}，更新至版本{irVersion}；\r\n阅读机经{rcDescription}，更新至版本{rcVersion}.\r\n附件为最新版机经，您也可以：{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(68, '机经更新', 'inside', 'textbook_update_subscribe', '数学机经{quantDescription}，更新至版本{quantVersion}；\r\n逻辑机经{irDescription}，更新至版本{irVersion}；\r\n阅读机经{rcDescription}，更新至版本{rcVersion}.\r\n最新版本机经已发送至您的邮箱{email}', '', NULL, 0, 1, NULL),
	(69, '[千行GMAT]到期提醒', 'email', 'vip_use_expire', '同学您好，\r\n您的“{title}”将于{days}天后过期，{linkHtml}\r\n\r\nBest\r\n千行团队', '', NULL, 0, 1, NULL),
	(70, '提问回复', 'inside', 'ask_question_special', '您在{date}对“{title}”的提问“{content}”已经被老师回答并精选啦~', '', NULL, 0, 0, NULL),
	(71, '提问回复', 'inside', 'ask_course_special', '您在{date}对“{title}-课时{no}”的提问“{content}”已经被老师回答并精选啦~', '', NULL, 0, 0, NULL);


CREATE TABLE pay (
  id bigint(30) unsigned NOT NULL AUTO_INCREMENT,
  no varchar(32) NOT NULL DEFAULT '' COMMENT '支付流水id',
  user_id int(11) unsigned NOT NULL COMMENT '用户ID',
  channel varchar(32) NOT NULL COMMENT '支付渠道',
  pid varchar(32) NOT NULL COMMENT '商户号',
  client_ip varchar(30) NOT NULL COMMENT '支付端ip',
  money decimal(10,2) unsigned NOT NULL COMMENT '支付金额',
  module varchar(25) NOT NULL COMMENT '模块',
  module_extend int(11) unsigned NOT NULL COMMENT '模块扩展id',
  subject varchar(32) NOT NULL COMMENT '商品标题',
  body varchar(200) NOT NULL COMMENT '商品描述',
  transaction_no varchar(255) NOT NULL COMMENT '支付渠道交易流水号',
  currency varchar(3) NOT NULL COMMENT '3位iso货币代码，人民币为cny',
  trade_status tinyint(1) unsigned NOT NULL COMMENT '订单状态',
  pay_time datetime DEFAULT NULL COMMENT '支付时间',
  pay_info text COMMENT '支付传递的扩展参数',
  result_info text COMMENT '支付渠道最后的返回信息',
  pay_type varchar(20) NOT NULL DEFAULT '0' COMMENT '支付类型',
  create_time datetime NOT NULL COMMENT '创建时间',
  update_time datetime NOT NULL COMMENT '更新时间',
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='支付流水表';

CREATE TABLE preview_assign (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  paper_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '预习作业id',
  title varchar(255) NOT NULL DEFAULT '' COMMENT '独立的作业标题',
  course_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课程id',
  course_no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课程课时',
  course_module varchar(20) NOT NULL DEFAULT '' COMMENT '课程模块',
  course_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课程时间段',
  course_appointment int(11) unsigned NOT NULL DEFAULT '0' COMMENT '对应预约id',
  question_no_ids text COMMENT '题目编号id：json',
  start_time datetime DEFAULT NULL COMMENT '做题开始时间',
  end_time datetime DEFAULT NULL COMMENT '做题结束时间',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY paper_id (paper_id),
  KEY course_id (course_id,start_time,end_time)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='预习作业-分配';

CREATE TABLE preview_paper (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(50) NOT NULL DEFAULT '' COMMENT '作业标题',
  course_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课程id',
  course_module varchar(20) NOT NULL DEFAULT '' COMMENT '课程模块',
  course_no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课程课时',
  question_subject varchar(20) NOT NULL DEFAULT '' COMMENT '作业学科',
  question_type varchar(20) NOT NULL DEFAULT '' COMMENT '作业题型',
  question_no_ids text COMMENT '题目编号id：json',
  paper_module varchar(20) NOT NULL DEFAULT '' COMMENT '题目类型',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY course_id (course_id),
  KEY course_module (course_module)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='预习作业-试卷';

CREATE TABLE question (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  keyword varchar(255) DEFAULT NULL COMMENT '关键词，逗号分隔',
  question_module varchar(20) NOT NULL DEFAULT '',
  question_type varchar(20) NOT NULL DEFAULT '' COMMENT '题型',
  place varchar(20) NOT NULL DEFAULT '' COMMENT '考点: 读取setting',
  difficult varchar(20) NOT NULL DEFAULT '' COMMENT '难度',
  difficult_score float(11,2) DEFAULT '0.00' COMMENT '难度分',
  stem text COMMENT '题干',
  description varchar(1000) DEFAULT NULL COMMENT '简介：自动从题干提取',
  content text COMMENT '内容：json',
  answer text COMMENT '答案：json',
  question_time datetime DEFAULT NULL,
  qx_time datetime DEFAULT NULL,
  official_time datetime DEFAULT NULL,
  association_time datetime DEFAULT NULL,
  qx_content text,
  official_content text,
  association_content text COMMENT '题源联想：json',
  chinese_content text,
  total_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总作答时间',
  total_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总作答次数',
  total_correct int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总正确次数',
  collect_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '收藏数',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  answer_distributed text COMMENT '答案分布',
  PRIMARY KEY (id),
  KEY question_module (question_module),
  KEY question_type (question_type),
  FULLTEXT KEY description (description)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='题目';

CREATE TABLE question_no (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(50) DEFAULT NULL COMMENT '人工id',
  question_id int(11) unsigned NOT NULL COMMENT '题目id',
  no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '序号：人工',
  module varchar(50) NOT NULL DEFAULT '' COMMENT '模块：examination, exercise, sentence, textbook',
  module_struct varchar(255) NOT NULL DEFAULT '' COMMENT '对应模块结构信息，逗号分隔',
  total_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总作答时间',
  total_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总作答次数',
  total_correct int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总正确次数',
  collect_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总收藏数',
  delete_time datetime DEFAULT NULL,
  relation_question varchar(255) NOT NULL DEFAULT '' COMMENT '关联题目列表',
  relation_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '关联题目数量',
  PRIMARY KEY (id),
  KEY question_id (question_id),
  KEY module (module),
  FULLTEXT KEY title (title)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='题目-编号';

CREATE TABLE rank (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  total_score int(11) NOT NULL COMMENT '总分',
  total_rank int(11) NOT NULL COMMENT '总排行',
  quant_score int(11) NOT NULL COMMENT 'quant分数',
  quant_rank int(11) NOT NULL COMMENT 'quant排行',
  verbal_score int(11) NOT NULL COMMENT 'verbal分数',
  verbal_rank int(11) NOT NULL COMMENT 'verbal排行',
  ir_score int(11) NOT NULL COMMENT 'ir分数',
  ir_rank int(11) NOT NULL COMMENT 'ir排行',
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='排行信息';

CREATE TABLE ready_article (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
  category_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '二级标题',
  parent_category_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '一级标题',
  content text COMMENT '内容',
  view_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '访问量',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY category_id (category_id),
  KEY parent_category_id (parent_category_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ready-文章';

CREATE TABLE ready_article_category (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
  parent_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '父级id',
  is_data tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否资料节点',
  is_official tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否官方资料',
  is_room tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否考场节点',
  sort int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序：从大到小',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY parent_id (parent_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ready-文章分类';

CREATE TABLE ready_data (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(255) NOT NULL DEFAULT '' COMMENT '资料名称',
  cover varchar(255) NOT NULL DEFAULT '' COMMENT '资料封面',
  content text COMMENT '资料内容',
  is_official tinyint(1) unsigned NOT NULL DEFAULT '0',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY is_official (is_official)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ready-资料';

CREATE TABLE ready_read (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  plate varchar(255) NOT NULL DEFAULT '' COMMENT '板块',
  title varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
  content text COMMENT '内容',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY plate (plate)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ready-推荐阅读';

CREATE TABLE ready_room (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  position varchar(20) NOT NULL DEFAULT '' COMMENT '区域',
  area_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '省份id',
  is_overseas tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否海外',
  title varchar(255) NOT NULL DEFAULT '' COMMENT '考场名称',
  address varchar(255) NOT NULL DEFAULT '' COMMENT '考场地址',
  description text COMMENT '考场说明',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY position (position,area_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ready-考场';

CREATE TABLE ready_room_area (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  position_name varchar(20) DEFAULT NULL,
  position varchar(20) DEFAULT NULL,
  title varchar(20) DEFAULT NULL,
  pinyin varchar(20) DEFAULT NULL,
  PRIMARY KEY (id),
  KEY position_name (position_name),
  KEY pinyin (pinyin)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ready-考场-区域';

INSERT INTO ready_room_area (id, position_name, position, title, pinyin)
VALUES
	(1,'北部','north','北京','bei jing'),
	(2,'北部','north','天津','tian jin'),
	(3,'北部','north','河北','he bei'),
	(4,'北部','north','山西','shan xi'),
	(5,'北部','north','内蒙古','nei meng gu'),
	(6,'北部','north','辽宁','liao ning'),
	(7,'北部','north','吉林','ji lin'),
	(8,'北部','north','黑龙江','hei long jiang'),
	(9,'东部','east','上海','shang hai'),
	(10,'东部','east','江苏','jiang su'),
	(11,'东部','east','浙江','zhe jiang'),
	(12,'东部','east','安徽','an hui'),
	(13,'东部','east','福建','fu jian'),
	(14,'东部','east','江西','jiang xi'),
	(15,'东部','east','山东','shan dong'),
	(16,'中南','south_central','河南','he nan'),
	(17,'中南','south_central','湖北','hu bei'),
	(18,'中南','south_central','湖南','hu nan'),
	(19,'中南','south_central','广东','guang dong'),
	(20,'中南','south_central','广西','guang xi'),
	(21,'中南','south_central','海南','hai nan'),
	(22,'中南','south_central','香港','xiang gang'),
	(23,'中南','south_central','澳门','ao men'),
	(24,'中南','south_central','台湾','tai wan'),
	(25,'西部','west','重庆','chong qing'),
	(26,'西部','west','四川','si chuan'),
	(27,'西部','west','贵州','gui zhou'),
	(28,'西部','west','云南','yun nan'),
	(29,'西部','west','西藏','xi zang'),
	(30,'西部','west','陕西','shan xi'),
	(31,'西部','west','甘肃','gan su'),
	(32,'西部','west','青海','qing hai'),
	(33,'西部','west','宁夏','ning xia'),
	(34,'西部','west','新疆','xin jiang');

CREATE TABLE sentence_article (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(255) NOT NULL DEFAULT '' COMMENT '标题',
  chapter int(11) unsigned NOT NULL COMMENT '章节',
  part int(11) unsigned NOT NULL COMMENT '段落',
  content text NOT NULL COMMENT '内容',
  is_trail tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否试用：0非试用，1试用',
  trail_start int(11) unsigned NOT NULL DEFAULT '0' COMMENT '试看起始页',
  trail_end int(11) unsigned NOT NULL DEFAULT '0' COMMENT '试看结束页',
  pages int(11) unsigned NOT NULL DEFAULT '0' COMMENT '页数',
  PRIMARY KEY (id),
  KEY chapter (chapter,part)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='长难句-文章';

CREATE TABLE sentence_code (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  code varchar(50) NOT NULL DEFAULT '' COMMENT '激活code',
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '激活用户id',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY code (code),
  KEY user_id (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='长难句-激活码';

CREATE TABLE sentence_paper (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(50) NOT NULL DEFAULT '' COMMENT '标题',
  no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '组卷序号',
  logic varchar(20) NOT NULL DEFAULT '' COMMENT '组卷逻辑：no，trail',
  question_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目数量',
  question_no_ids text COMMENT '题目编号ids：json',
  question_s_ids text COMMENT '长难句ids：json',
  status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '开放状态：0关闭，1开启',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY logic (logic,status)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='长难句-练习册';

CREATE TABLE sentence_question (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(255) NOT NULL DEFAULT '' COMMENT '序号：手工录入',
  is_trail tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否试用：0非试用，1试用',
  is_paper tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否教材：1教材题，1用于作业',
  no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '组卷序号',
  subject varchar(255) NOT NULL COMMENT '根据序号生成的固定标题',
  question_id int(11) unsigned NOT NULL COMMENT '题目id',
  question_no_id int(11) unsigned NOT NULL COMMENT '题目编号id',
  total_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总作答时间',
  total_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总做题次数',
  total_correct int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总正确次数',
  collect_number int(11) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (id),
  KEY question_id (question_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='长难句-题目';

CREATE TABLE setting (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  `key` varchar(50) DEFAULT NULL COMMENT '配置key',
  value text COMMENT '内容：json',
  PRIMARY KEY (id),
  KEY `key` (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设置';

INSERT INTO setting (id, `key`, value)
VALUES
	(1,'index','{}'),
	(2,'sentence','{}'),
	(3,'prepare_info','{}'),
	(4,'place','{}'),
	(5,'exercise_time','{}'),
	(6,'exercise_paper_auto','{}'),
	(7,'examination_time','{\"verbal\":{\"number\":\"36\",\"time\":\"3900\"},\"ir\":{\"number\":\"12\",\"time\":\"1800\"},\"awa\":{\"number\":\"1\",\"time\":\"1800\"},\"quant\":{\"number\":\"31\",\"time\":\"3720\"}}'),
	(8,'filter_time','{}'),
	(9,'prepare_stat','{}'),
	(10,'tips','{}'),
	(11,'exercise_paper_status','{}'),
	(12,'sentence_paper_status','{}'),
	(13,'sentence_time','{\"time\":50}'),
	(14,'textbook_time','{\"time\":50}'),
	(15,'score_switch','{}'),
	(16,'service_qx_cat','{}'),
	(17,'service_textbook','{}'),
	(18,'service_vip','{}'),
	(19,'course_index','{}'),
	(20,'promote','{}'),
	(21,'experience_info','{}'),
	(22,'sentence_info','{}'),
	(23,'wechat_info','{}'),
	(24,'ready_read','{}'),
	(25,'base','{}'),
	(26,'textbook_config','{}');

CREATE TABLE textbook_library (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  start_date date NOT NULL COMMENT '库头',
  end_date date DEFAULT NULL COMMENT '库尾',
  quant varchar(255) NOT NULL DEFAULT '' COMMENT '数学',
  quant_version int(11) unsigned NOT NULL DEFAULT '0' COMMENT '数学版本',
  quant_time datetime DEFAULT NULL COMMENT '数学时间',
  quant_description varchar(255) DEFAULT NULL COMMENT '数学更新简介',
  quant_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '数学题目数',
  ir varchar(255) NOT NULL DEFAULT '' COMMENT '综合逻辑',
  ir_version int(11) unsigned NOT NULL DEFAULT '0' COMMENT '综合逻辑版本',
  ir_time datetime DEFAULT NULL COMMENT '综合逻辑时间',
  ir_description varchar(255) DEFAULT NULL COMMENT '综合逻辑更新简介',
  ir_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '综合逻辑题目数',
  rc varchar(255) NOT NULL DEFAULT '' COMMENT '阅读',
  rc_version int(10) unsigned NOT NULL DEFAULT '0' COMMENT '阅读版本',
  rc_time datetime DEFAULT NULL COMMENT '阅读时间',
  rc_description varchar(255) DEFAULT NULL COMMENT '阅读更新简介',
  rc_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '阅读题目数',
  history_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新次数',
  question_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '提问状态',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY start_date (start_date,end_date)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='换库表';

INSERT INTO textbook_library (id, start_date, end_date, quant, quant_version, quant_time, ir, ir_version, ir_time, rc, rc_version, rc_time, history_number, question_status, create_time, update_time)
VALUES
	(1,'2017-01-04','2017-01-23','',0,NULL,'',0,NULL,'',0,NULL,1,0,'2019-07-15 01:24:50','2019-07-15 01:33:42'),
	(2,'2017-01-23','2017-02-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(3,'2017-02-03','2017-02-23','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(4,'2017-02-23','2017-03-16','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(5,'2017-03-16','2017-04-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(6,'2017-04-03','2017-04-14','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(7,'2017-04-14','2017-05-05','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(8,'2017-05-05','2017-05-24','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(9,'2017-05-24','2017-06-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(10,'2017-06-03','2017-06-12','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(11,'2017-06-12','2017-07-01','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(12,'2017-07-01','2017-07-11','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(13,'2017-07-11','2017-08-01','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(14,'2017-08-01','2017-08-11','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(15,'2017-08-11','2017-08-24','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(16,'2017-08-24','2017-09-14','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(17,'2017-09-14','2017-09-25','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(18,'2017-09-25','2017-10-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(19,'2017-10-03','2017-10-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(20,'2017-10-15','2017-11-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(21,'2017-11-03','2017-11-13','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(22,'2017-11-13','2017-11-25','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(23,'2017-11-25','2017-12-13','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(24,'2017-12-13','2017-12-30','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(25,'2017-12-30','2018-01-19','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(26,'2018-01-19','2018-02-04','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(27,'2018-02-04','2018-02-16','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(28,'2018-02-16','2018-03-05','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(29,'2018-03-05','2018-03-19','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(30,'2018-03-19','2018-03-28','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(31,'2018-03-28','2018-04-07','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(32,'2018-04-07','2018-04-16','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(33,'2018-04-16','2018-05-05','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(34,'2018-05-05','2018-05-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(35,'2018-05-15','2018-05-28','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(36,'2018-05-28','2018-06-07','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(37,'2018-06-07','2018-06-22','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(38,'2018-06-22','2018-07-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(39,'2018-07-03','2018-07-16','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(40,'2018-07-16','2018-07-30','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(41,'2018-07-30','2018-08-10','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(42,'2018-08-10','2018-08-18','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(43,'2018-08-18','2018-08-30','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(44,'2018-08-30','2018-09-10','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(45,'2018-09-10','2018-09-23','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(46,'2018-09-23','2018-10-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(47,'2018-10-03','2018-10-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(48,'2018-10-15','2018-11-02','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(49,'2018-11-02','2018-11-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(50,'2018-11-15','2018-12-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(51,'2018-12-03','2018-12-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(52,'2018-12-15','2018-12-23','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(53,'2018-12-23','2019-01-04','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(54,'2019-01-04','2019-01-13','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(55,'2019-01-13','2019-01-24','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(56,'2019-01-24','2019-02-07','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(57,'2019-02-07','2019-02-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(58,'2019-02-15','2019-03-02','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(59,'2019-03-02','2019-03-10','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(60,'2019-03-10','2019-03-21','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(61,'2019-03-21','2019-04-07','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(62,'2019-04-07','2019-04-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(63,'2019-04-15','2019-04-29','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(64,'2019-04-29','2019-05-13','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(65,'2019-05-13','2019-05-22','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(66,'2019-05-22','2019-06-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(67,'2019-06-03','2019-06-11','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(68,'2019-06-11','2019-06-29','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(69,'2019-06-29','2019-07-06','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(70,'2019-07-06','2019-07-15','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(71,'2019-07-15','2019-07-25','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(72,'2019-07-25','2019-08-03','',0,NULL,'',0,NULL,'',0,NULL,0,0,NULL,NULL),
	(73,'2019-08-03',NULL,'',2,'2019-08-28 20:56:40','',0,NULL,'',0,NULL,2,1,NULL,'2019-08-28 20:56:40');

CREATE TABLE textbook_library_history (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  library_id int(11) unsigned NOT NULL COMMENT '换库id',
  quant varchar(255) DEFAULT NULL COMMENT '数学',
  quant_version int(11) unsigned NOT NULL DEFAULT '0' COMMENT '数学版本',
  quant_content text COMMENT '数学更新日志',
  quant_description varchar(255) DEFAULT NULL COMMENT '数学更新简介',
  rc varchar(255) DEFAULT NULL COMMENT '阅读',
  rc_version int(11) unsigned NOT NULL DEFAULT '0' COMMENT '阅读版本',
  rc_content text COMMENT '阅读更新日志',
  rc_description varchar(255) DEFAULT NULL COMMENT '阅读更新简介',
  ir varchar(255) DEFAULT NULL COMMENT '综合推理',
  ir_version int(11) unsigned NOT NULL DEFAULT '0' COMMENT '综合推理版本',
  ir_content text COMMENT '综合推理更新日志',
  ir_description varchar(255) DEFAULT NULL COMMENT '综合逻辑更新简介',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY library_id (library_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='换库-历史记录';

CREATE TABLE textbook_paper (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(50) DEFAULT NULL COMMENT '标题',
  logic varchar(20) NOT NULL DEFAULT '' COMMENT '组卷逻辑：ps、ds、ps+ds',
  no int(11) unsigned NOT NULL COMMENT '序号',
  library_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '换库id',
  question_no_ids text COMMENT '题目编号ids：json',
  question_t_ids text COMMENT '机经ids：json',
  question_number int(11) DEFAULT NULL,
  create_time datetime DEFAULT NULL,
  status tinyint(1) unsigned NOT NULL COMMENT '开放状态：0关闭，1开启',
  year varchar(20) DEFAULT NULL COMMENT '所属年份',
  PRIMARY KEY (id),
  KEY library_id (library_id,logic)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='机经-组卷';

CREATE TABLE textbook_question (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  title varchar(20) NOT NULL DEFAULT '' COMMENT '题目编号：人工',
  no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目序号',
  library_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '机经版本：关联换库表',
  question_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目id',
  question_no_id int(11) unsigned NOT NULL COMMENT '题目编号id',
  total_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总做题时间',
  total_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总做题次数',
  total_correct int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总正确次数',
  year varchar(20) DEFAULT NULL COMMENT '所属年份',
  collect_number int(11) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (id),
  KEY question_id (question_id),
  KEY library_id (library_id,year)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='机经-题目编号';

CREATE TABLE textbook_topic (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  library_id int(11) unsigned NOT NULL COMMENT '换库表',
  textbook_subject varchar(20) NOT NULL DEFAULT '' COMMENT '学科',
  no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目序号',
  keyword varchar(255) DEFAULT NULL COMMENT '关键词',
  quality varchar(20) DEFAULT NULL COMMENT '质量',
  is_old tinyint(1) unsigned NOT NULL COMMENT '是否考古题：1是，0否',
  detail text COMMENT '题目内容',
  content text COMMENT '题目解析',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY library_id (library_id,textbook_subject)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='机经-题目';

CREATE TABLE user (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  nickname varchar(50) NOT NULL DEFAULT '' COMMENT '昵称',
  avatar varchar(255) NOT NULL DEFAULT '',
  password varchar(50) NOT NULL DEFAULT '' COMMENT '密码',
  email varchar(64) NOT NULL DEFAULT '' COMMENT '邮箱',
  area varchar(10) NOT NULL DEFAULT '' COMMENT '手机-区号',
  mobile varchar(20) NOT NULL DEFAULT '' COMMENT '手机',
  wechat_openid_pc varchar(64) NOT NULL DEFAULT '' COMMENT '微信openid：pc端',
  wechat_openid_wechat varchar(64) NOT NULL DEFAULT '' COMMENT '微信openid: 公众号',
  wechat_unionid varchar(64) NOT NULL DEFAULT '' COMMENT '微信关联id',
  wechat_access_token varchar(255) NOT NULL DEFAULT '' COMMENT '微信公众号accessToken',
  wechat_refresh_token varchar(255) NOT NULL DEFAULT '' COMMENT '微信公众号refresh_token',
  wechat_expire_time datetime DEFAULT NULL COMMENT '微信公众号expireTime',
  real_time datetime DEFAULT NULL COMMENT '实名通过时间',
  real_name varchar(50) DEFAULT NULL COMMENT '实名：姓名',
  real_address varchar(255) DEFAULT NULL COMMENT '实名：地址',
  real_identity varchar(255) DEFAULT NULL COMMENT '实名：身份ID',
  real_photo_front varchar(255) DEFAULT NULL COMMENT '实名：身份证照片-正面',
  real_photo_back varchar(255) DEFAULT NULL COMMENT '实名：身份证照片-背面',
  real_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '实名状态：0未实名，1已实名',
  prepare_time datetime DEFAULT NULL COMMENT '备考设置时间',
  prepare_status varchar(20) NOT NULL DEFAULT '' COMMENT '备考：身份',
  prepare_goal int(5) NOT NULL DEFAULT '0' COMMENT '备考：目标分数',
  prepare_examination_time varchar(20) NOT NULL DEFAULT '' COMMENT '备考：考试时间',
  prepare_score_time datetime DEFAULT NULL COMMENT '备考：出分时间',
  latest_exercise int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上次做题',
  latest_error int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上一次错题组卷',
  latest_collect int(11) unsigned NOT NULL DEFAULT '0' COMMENT '上一次收藏组卷',
  origin_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '邀请用户',
  invite_code varchar(20) NOT NULL DEFAULT '' COMMENT '个人邀请码',
  total_money decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '消费金额',
  invite_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '邀请人数',
  textbook_half int(11) unsigned NOT NULL DEFAULT '0' COMMENT '半价机经券',
  qx_cat int(11) unsigned NOT NULL DEFAULT '0' COMMENT '千行cat次数',
  register_ip varchar(255) NOT NULL DEFAULT '' COMMENT '注册ip',
  register_city varchar(255) NOT NULL DEFAULT '' COMMENT '注册地信息',
  latest_login_ip varchar(255) NOT NULL DEFAULT '' COMMENT '最后一次登录ip',
  latest_login_time datetime DEFAULT NULL COMMENT '最后登录时间',
  is_frozen tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否冻结',
  create_time datetime DEFAULT NULL,
  data_email_subscribe tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '资料订阅',
  textbook_email_subscribe tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '机经邮箱订阅',
  total_alert int(11) unsigned NOT NULL DEFAULT '0' COMMENT '累计告警字数',
  export_question_error_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '导出错题次数',
  export_question_note_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '导出题目笔记次数',
  export_tips tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '导出提示：0展示，1关闭',
  textbook_tips tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '机经提示：0展示，1关闭',
  export_course_note_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '导出课时笔记次数',
  is_course tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否购买课程',
  PRIMARY KEY (id),
  KEY mobile (mobile),
  KEY wechat_unionid (wechat_unionid),
  KEY wechat_openid_pc (wechat_openid_pc),
  KEY wechat_openid_wechat (wechat_openid_wechat),
  KEY invite_code (invite_code)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户';

CREATE TABLE user_abnormal (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  is_alert tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否已警告',
  is_ignore tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否忽略该ip',
  login_ip varchar(255) NOT NULL DEFAULT '' COMMENT '登录ip',
  login_city varchar(255) NOT NULL DEFAULT '' COMMENT '登录地信息',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-异常登录';

CREATE TABLE user_ask_course (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  course_id int(11) unsigned NOT NULL COMMENT '课程id',
  course_no_id int(11) unsigned NOT NULL COMMENT '课时id',
  record_id int(11) unsigned NOT NULL COMMENT '记录id',
  position int(11) unsigned NOT NULL DEFAULT '0' COMMENT '位置',
  origin_content text COMMENT '老师讲解内容',
  content text COMMENT '提问',
  ask_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '提问优先回答时间',
  expire_time datetime DEFAULT NULL COMMENT '过期时间',
  answer text COMMENT '回答',
  answer_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '回答状态: 0未回答，1回答，2忽略',
  manager_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '回答人id',
  show_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '展示状态：0关闭，1打开',
  answer_time datetime DEFAULT NULL COMMENT '回答时间',
  sort int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序：从大到小',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id),
  KEY course_id (course_id),
  KEY record_id (record_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-课程-提问';

CREATE TABLE user_ask_question (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  user_question_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户做题id',
  ask_module varchar(20) DEFAULT NULL COMMENT '题目板块',
  question_module varchar(20) NOT NULL DEFAULT '' COMMENT '题目模块',
  question_id int(11) unsigned NOT NULL COMMENT '题目id',
  question_no_id int(11) unsigned NOT NULL COMMENT '题目编号id',
  record_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课程对应recordid',
  target varchar(11) NOT NULL DEFAULT '' COMMENT '问题对象：question，official，qx，association',
  origin_content text COMMENT '问题内容',
  content text COMMENT '提问',
  ask_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '提问优先回答时间',
  expire_time datetime DEFAULT NULL COMMENT '过期时间',
  answer text COMMENT '回答',
  answer_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '回答状态: 0未回答，1回答，2忽略',
  manager_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '回答人id',
  show_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '展示状态：0关闭，1打开',
  answer_time datetime DEFAULT NULL COMMENT '回答时间',
  sort int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排序：从大到小',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id),
  KEY question_id (question_id),
  KEY question_module (question_module,question_no_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-题目-提问';

CREATE TABLE user_collect_experience (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  experience_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '经验id',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,expericence_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-收藏-心经';

CREATE TABLE user_collect_question (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  question_module varchar(20) NOT NULL DEFAULT '' COMMENT '模块：base, sentence, textbook',
  question_id int(11) unsigned NOT NULL COMMENT '题目id',
  question_no_id int(11) unsigned NOT NULL COMMENT '题目编号id',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,question_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-收藏-题目';

CREATE TABLE user_course (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  course_id int(11) unsigned NOT NULL COMMENT '课程id',
  record_id int(11) unsigned NOT NULL COMMENT '当前课程记录id',
  start_time datetime DEFAULT NULL COMMENT '开通时间',
  expire_time datetime DEFAULT NULL COMMENT '到期时间',
  PRIMARY KEY (id),
  KEY user_id (user_id,course_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-课程';

CREATE TABLE user_course_appointment (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  no int(11) unsigned NOT NULL COMMENT '课时序号',
  title varchar(255) NOT NULL DEFAULT '' COMMENT '课程名称',
  record_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '关联购课记录',
  course_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '课程id',
  cctalk_channel varchar(255) NOT NULL DEFAULT '' COMMENT '频道号',
  question_file varchar(255) NOT NULL DEFAULT '' COMMENT '答疑文档',
  question_file_name varchar(255) NOT NULL DEFAULT '' COMMENT '答疑文档名称',
  start_time datetime DEFAULT NULL COMMENT '预约开始时间',
  end_time datetime DEFAULT NULL COMMENT '预约结束时间',
  is_finish tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否完成',
  supply_list text COMMENT '课后补充：json格式',
  note_list text COMMENT '笔记批阅：json格式',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,record_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户课程预约';

CREATE TABLE user_course_appointment_comment (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  record_id int(11) unsigned NOT NULL COMMENT '记录id',
  appointment_id int(11) unsigned NOT NULL COMMENT '预约id',
  type varchar(20) NOT NULL DEFAULT '',
  parent_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '引用id',
  content text,
  reply text,
  file varchar(255) DEFAULT NULL,
  name varchar(255) DEFAULT NULL,
  create_time datetime DEFAULT NULL,
  delete_time datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY record_id (record_id),
  KEY appointment_id (appointment_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-预约-聊天';

CREATE TABLE user_course_progress (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  course_id int(11) unsigned NOT NULL COMMENT '课程id',
  course_no_id int(11) unsigned NOT NULL COMMENT '课时id',
  record_id int(11) unsigned NOT NULL COMMENT '课程记录id',
  progress int(11) unsigned NOT NULL COMMENT '进度',
  times int(11) unsigned NOT NULL COMMENT '次数',
  PRIMARY KEY (id),
  KEY user_id (user_id,course_id,record_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户课程进度';

CREATE TABLE user_course_record (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  course_id int(11) unsigned NOT NULL COMMENT '课程id',
  record_id int(11) unsigned NOT NULL COMMENT '课程记录id',
  user_time int(11) unsigned NOT NULL COMMENT '访问时长',
  course_no_id int(11) unsigned NOT NULL COMMENT '课时id',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,course_id,record_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-课程-访问记录';

CREATE TABLE user_data_subscribe (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  data_id int(11) unsigned NOT NULL COMMENT '资料id',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY user_id (user_id),
  KEY data_id (data_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-资料-订阅';

CREATE TABLE user_export (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0',
  no int(11) unsigned NOT NULL DEFAULT '0',
  type varchar(20) NOT NULL DEFAULT '' COMMENT '导出类型',
  setting text COMMENT '导出设置',
  content longtext,
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-导出-记录';

CREATE TABLE user_feedback_error (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  module varchar(20) NOT NULL DEFAULT '' COMMENT '模块：question,data',
  module_id int(11) unsigned NOT NULL COMMENT '对应模块id',
  question_type varchar(20) DEFAULT NULL COMMENT '题目类型',
  question_module varchar(20) DEFAULT NULL COMMENT '题目模块',
  question_no_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目编号id',
  manager_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '处理人id',
  title varchar(255) NOT NULL DEFAULT '' COMMENT '内容名称',
  position varchar(20) DEFAULT NULL COMMENT '错误位置，逗号链接的字符串，服务端不解析',
  origin_content text COMMENT '错误内容',
  content text COMMENT '正确内容',
  create_time datetime DEFAULT NULL,
  status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '处理状态：0未处理，1已处理，2已忽略',
  handle_time datetime DEFAULT NULL COMMENT '处理时间',
  PRIMARY KEY (id),
  KEY user_id (user_id),
  KEY module (module,module_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='反馈-勘误';

CREATE TABLE user_invoice (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  order_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '订单id',
  record_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '记录id：独立课程id或套餐的记录id',
  invoice_type varchar(20) NOT NULL DEFAULT '' COMMENT '发票类型',
  title varchar(255) NOT NULL DEFAULT '' COMMENT '抬头',
  identity varchar(255) NOT NULL DEFAULT '' COMMENT '纳税人识别号',
  is_download tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否已下载',
  is_finish tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否已开票',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id),
  KEY is_download (is_download),
  KEY is_finish (is_finish)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-发票';

CREATE TABLE user_message (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) NOT NULL DEFAULT '0' COMMENT '用户id',
  type varchar(50) NOT NULL DEFAULT '' COMMENT '消息',
  relation_id int(11) NOT NULL DEFAULT '0' COMMENT '关联id',
  message_category varchar(50) NOT NULL DEFAULT '' COMMENT '消息类型',
  title varchar(50) NOT NULL DEFAULT '' COMMENT '标题',
  content text COMMENT '内容',
  link varchar(255) NOT NULL DEFAULT '' COMMENT '链接',
  link_title varchar(20) NOT NULL DEFAULT '' COMMENT '链接标题',
  link_second varchar(255) NOT NULL DEFAULT '' COMMENT '链接2',
  link_second_title varchar(255) NOT NULL DEFAULT '' COMMENT '链接2标题',
  is_read tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '已读状态：0未读，1已读',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,is_read),
  KEY user_id_2 (user_id,type)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-消息';

CREATE TABLE user_note_course (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  course_id int(11) unsigned NOT NULL COMMENT '课程ID',
  course_no_id int(11) unsigned NOT NULL COMMENT '课时id',
  content text,
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,course_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-笔记-课程';

CREATE TABLE user_note_question (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  question_module varchar(20) DEFAULT NULL COMMENT '模块：exercise, exaination, sentence, textbook',
  question_id int(11) unsigned NOT NULL COMMENT '题目id',
  question_no_id int(11) unsigned NOT NULL COMMENT '题目编号id',
  question_time datetime DEFAULT NULL,
  question_content text,
  content text COMMENT '笔记内容',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  official_time datetime DEFAULT NULL,
  official_content text,
  qx_time datetime DEFAULT NULL,
  qx_content text,
  association_time datetime DEFAULT NULL,
  association_content text,
  qa_time datetime DEFAULT NULL,
  qa_content text,
  PRIMARY KEY (id),
  KEY user_id (user_id,question_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-笔记-题目';

CREATE TABLE user_order (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  product_types varchar(255) NOT NULL DEFAULT '' COMMENT '包含的订单类型：json',
  pay_method varchar(20) NOT NULL DEFAULT '' COMMENT '支付方式',
  money decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '支付费用',
  origin_money decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '原价',
  invoice_money decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '开票费用',
  promote text COMMENT '优惠信息',
  gift text COMMENT '赠品信息',
  ask_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '回复时长',
  pay_id bigint(30) DEFAULT NULL COMMENT '支付id',
  pay_status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '支付状态',
  create_time datetime DEFAULT NULL,
  pay_time datetime DEFAULT NULL,
  is_speed tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '快速支付，不显示在后台',
  transaction_no varchar(255) DEFAULT NULL COMMENT '交易流水号',
  PRIMARY KEY (id),
  KEY user_id (user_id,pay_status),
  KEY pay_method (pay_method)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-支付记录';

CREATE TABLE user_order_checkout (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  order_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '关联订单',
  parent_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '套餐id',
  product_type varchar(255) NOT NULL DEFAULT '' COMMENT '产品类型',
  product_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '产品id',
  service varchar(20) NOT NULL DEFAULT '' COMMENT '服务',
  param varchar(20) NOT NULL DEFAULT '' COMMENT '服务参数',
  number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '数量：购买的课时数',
  money decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '购买金额',
  origin_money decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '原价',
  create_time datetime DEFAULT NULL,
  expire_days int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
  use_expire_days int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
  PRIMARY KEY (id),
  KEY user_id (user_id,order_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-购物车';

CREATE TABLE user_order_record (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  order_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '订单id',
  parent_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '套餐id',
  product_type varchar(20) NOT NULL DEFAULT '' COMMENT '产品类型',
  product_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '产品id',
  service varchar(20) NOT NULL DEFAULT '' COMMENT '服务',
  param varchar(20) NOT NULL DEFAULT '' COMMENT '服务参数',
  source varchar(20) NOT NULL DEFAULT '' COMMENT '开通方式',
  teacher_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '绑定教师',
  number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '购买的数量：vs课时数量',
  vs_no int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'vs课程编号',
  time_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '小班课时间段',
  ask_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '回复时长',
  cctalk_name varchar(255) NOT NULL DEFAULT '' COMMENT 'cctalk用户名',
  is_subscribe tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '订阅：千行、资料等',
  start_time datetime DEFAULT NULL COMMENT '开通开始时间',
  end_time datetime DEFAULT NULL COMMENT '开通结束时间',
  use_start_time datetime DEFAULT NULL COMMENT '使用开始时间',
  use_end_time datetime DEFAULT NULL COMMENT '使用结束时间',
  is_used tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否使用',
  use_time datetime DEFAULT NULL COMMENT '开通时间',
  is_stop tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否停用',
  stop_time datetime DEFAULT NULL COMMENT '停用时间',
  is_suspend tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否挂起：停课',
  suspend_time datetime DEFAULT NULL COMMENT '挂起时间',
  restore_time datetime DEFAULT NULL COMMENT '恢复时间',
  create_time datetime DEFAULT NULL,
  money decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
  origin_money decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
  course_award int(10) unsigned NOT NULL DEFAULT '0' COMMENT '奖励天数',
  comment_tips tinyint(10) unsigned NOT NULL DEFAULT '0' COMMENT '评价提醒：0显示，1关闭',
  expire_days int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
  use_expire_days int(10) unsigned NOT NULL DEFAULT '0' COMMENT '',
  PRIMARY KEY (id),
  KEY user_id (user_id,product_type),
  KEY order_id (order_id),
  KEY user_id_2 (user_id,service)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-订单购买记录';

CREATE TABLE user_paper (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  title varchar(50) NOT NULL DEFAULT '' COMMENT '组卷名称',
  paper_module varchar(20) NOT NULL DEFAULT '' COMMENT '组卷模块：examination，exercise, sentence',
  paper_origin varchar(20) NOT NULL DEFAULT '' COMMENT '组卷来源：examination, exercise, collect, error, preview',
  is_adapt tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '模考：是否适应难度: 0非适应性，1适应性，2千行',
  origin_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '对应来源id',
  record_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '关联记录id',
  paper_no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '相同试卷不同编号：对应千行cat次数',
  qx_cat int(11) unsigned NOT NULL DEFAULT '0' COMMENT '区分qx试卷0，1',
  question_no_ids text COMMENT '题目编号id列表：json',
  question_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目数量',
  times int(11) unsigned NOT NULL DEFAULT '0' COMMENT '练习次数',
  time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '单次时间：系统时间',
  latest_time date DEFAULT NULL COMMENT '最近一次做题时间',
  latest_report_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最近一次做题记录',
  total_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总作答时间',
  total_number int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总作答次数',
  total_correct int(11) unsigned NOT NULL DEFAULT '0' COMMENT '总正确次数',
  delete_time datetime DEFAULT NULL COMMENT '删除时间',
  is_reset tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '重置状态：0未重置，1重置',
  PRIMARY KEY (id),
  KEY user_id (user_id,paper_origin,origin_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-题目分组';

CREATE TABLE user_paper_question (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  paper_id int(11) unsigned NOT NULL COMMENT '分组id',
  question_module varchar(20) DEFAULT NULL COMMENT '题目模块：base, sentence, textbook',
  question_no_id int(11) unsigned DEFAULT 0 NOT NULL COMMENT '题目编号id',
  question_origin varchar(20) NOT NULL DEFAULT '' COMMENT '题目来源：collect,error,remove_error',
  PRIMARY KEY (id),
  KEY user_id (user_id,question_module)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-题目分组-题目关系';

CREATE TABLE user_question (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  report_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '报告id',
  question_module varchar(20) DEFAULT NULL COMMENT '题目模块',
  question_type varchar(20) DEFAULT NULL COMMENT '题型',
  question_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目id',
  question_no_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目编号id',
  no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '做题序号',
  stage varchar(20) DEFAULT '' COMMENT '子阶段',
  stage_no int(11) unsigned NOT NULL DEFAULT '0' COMMENT '子阶段序号',
  time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '系统定义时间',
  user_time int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户用时',
  user_answer text COMMENT '用户答案：json',
  is_correct tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '正确：0错误，1正确',
  setting text COMMENT '题目设置',
  detail text COMMENT '详细信息：长难句逻辑、结构，模考题分数',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,question_id),
  KEY report_id (report_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-做题记录';

CREATE TABLE user_ready_room_feedback (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  room_id int(11) unsigned NOT NULL COMMENT '考场id',
  content text COMMENT '补充内容',
  manager_id int(11) unsigned NOT NULL DEFAULT '0',
  status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '审核状态',
  create_time datetime DEFAULT NULL,
  handle_time datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-考场-补充';

CREATE TABLE user_report (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  paper_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户组卷id',
  paper_module varchar(20) NOT NULL DEFAULT '' COMMENT '组卷模块：exercise，examination，sentence',
  paper_origin varchar(20) NOT NULL DEFAULT '' COMMENT '组卷来源',
  origin_id int(11) unsigned NOT NULL DEFAULT '0',
  question_no_ids text COMMENT '题目编号id列表：json',
  question_number int(11) unsigned NOT NULL COMMENT '总题数',
  time int(11) unsigned NOT NULL COMMENT '预计时常/总时长',
  user_number int(11) unsigned NOT NULL COMMENT '已做题目数',
  user_time int(11) unsigned NOT NULL COMMENT '已用时长',
  user_correct int(11) DEFAULT NULL COMMENT '正确题目数',
  finish_time datetime DEFAULT NULL COMMENT '完成答题时间',
  setting text COMMENT '开考设置',
  score text COMMENT '考分：模考分值，json',
  detail text COMMENT '详细信息: json',
  is_finish tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否完成答卷：0未完成，1完成',
  is_stat tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否完成报告',
  create_time datetime DEFAULT NULL,
  update_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,paper_id),
  KEY paper_origin (paper_origin,origin_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-做题报告';

CREATE TABLE user_search_history (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  question_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目id',
  question_no_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '题目编号id',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (`id),
  KEY user_id (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-搜索题目-记录';

CREATE TABLE user_sentence_progress (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  chapter int(11) unsigned NOT NULL COMMENT '章节',
  part int(11) unsigned NOT NULL COMMENT '段落',
  progress int(11) unsigned NOT NULL COMMENT '进度：0-100',
  times int(11) unsigned NOT NULL COMMENT '次数',
  PRIMARY KEY (id),
  KEY user_id (user_id,chapter,part)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-长难句-进度';

CREATE TABLE user_sentence_record (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  chapter int(11) unsigned NOT NULL COMMENT '章节',
  part int(11) unsigned NOT NULL COMMENT '段落',
  user_time int(11) unsigned NOT NULL COMMENT '访问时长',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,chapter,part)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-长难句-访问记录';

CREATE TABLE user_service (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户id',
  service varchar(20) NOT NULL DEFAULT '' COMMENT '服务: vip, ',
  is_subscribe tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '机经是否邮箱订阅',
  is_reset tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '模考是否重置',
  start_time datetime DEFAULT NULL,
  expire_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,service,start_time,expire_time)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-服务';

CREATE TABLE user_textbook_enroll (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户ID',
  date datetime DEFAULT NULL COMMENT '报名日期',
  create_time datetime DEFAULT NULL,
  PRIMARY KEY (id),
  KEY user_id (user_id,month)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-机经-报名';

CREATE TABLE user_textbook_feedback (
  id int(11) unsigned NOT NULL AUTO_INCREMENT,
  user_id int(11) unsigned NOT NULL COMMENT '用户id',
  question_subject varchar(20) NOT NULL COMMENT '学科',
  no int(11) unsigned NOT NULL DEFAULT 0 COMMENT '序号',
  topic_id int(11) unsigned NOT NULL DEFAULT 0 COMMENT '机经问题',
  library_id int(11) unsigned NOT NULL COMMENT '换库表',
  manager_id int(11) unsigned NOT NULL DEFAULT 0 COMMENT '处理人id',
  target varchar(20) NOT NULL DEFAULT '' COMMENT '反馈类型',
  content text COMMENT '正确内容',
  create_time datetime DEFAULT NULL,
  status tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '处理状态',
  handle_time datetime DEFAULT NULL COMMENT '处理时间',
  PRIMARY KEY (id),
  KEY library_id (library_id),
  KEY topic_id (topic_id),
  KEY user_id (user_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户-机经-反馈';
