-- 系统配置表
-- INPUT_TYPE: 1.TEXT 2.SELECT. 3.CHECKBOX 4.YEAR_PICKER 5.DATE_TIME_PICKER 6.DATE_PICKER 7.TIME_PICKER 8.SWITCH
-- OPTIONS: STRING类型的关于上面的需要附加参数的选项
DROP TABLE IF EXISTS `AR_CONFIG`;
CREATE TABLE `AR_CONFIG` (
  CONFIG_NAME     varchar(32)                     NOT NULL COMMENT '配置参数名',
  TITLE           varchar (48)                    NOT NULL COMMENT '标题',
  UNIT            varchar(32) COMMENT '单位',
  INPUT_TYPE      int(2) DEFAULT 1             NOT NULL COMMENT '表单类型',
  OPTIONS         text COMMENT '参数配置的选项',
  VALUE           text NOT NULL COMMENT '配置值',
  TYPE            varchar(32)                    NOT NULL COMMENT '类型',
  SORT            int(10) DEFAULT 1            NOT NULL COMMENT '排序',
  CREATED_AT      int(10)                      NOT NULL COMMENT '创建时间',
  UPDATED_AT      int(10) DEFAULT 0            NOT NULL COMMENT '更新时间'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='系统配置表';


LOCK TABLES `AR_CONFIG` WRITE;
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('siteTitle', '网站标题', null, 1, null, '会员管理系统', 'base', 1, 1521085263, 1524013893);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('decPercent', '报单奖比例', '%', 1, null, '3', 'bonus', 1, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('transferOpen', '是否开启转账功能', null, 8, null, '1', 'transfer', 1, 1521085263, 1581816562);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('smsOpen', '是否开启短信通知', null, 8, null, '1', 'sms', 1, 1521085263, 1522396087);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('calcYear', '期数计算至年份', '年', 4, null, '2021', 'period', 1, 1521085263, 1580998939);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('siteClose', '是否关闭网站', null, 8, null, '0', 'base', 2, 1521085263, 1524013893);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('allowWallet', '转出转入配置', null, 10, null, '[{"out":"bonus","in":"cash","outMin":"0","outMax":"500","fee":"0","feeMin":"0","feeMax":"0","weekMax":"0","monthMax":"0","isSystem":true,"isBind":true,"isOpen":true},{"out":"bonus","in":"bonus","outMin":"0","outMax":"1000","fee":"0","feeMin":"0","feeMax":"0","weekMax":"2000","monthMax":"5000","isSystem":true,"isBind":true,"isOpen":true}]', 'transfer', 2, 1521085263, 1581816562);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('smsFee', '短信月费用', '元/月', 1, null, '10', 'sms', 2, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('closeWeekDate', '自动封期星期', null, 2, '[{"label":"星期一","value":"1"},{"label":"星期二","value":"2"},{"label":"星期三","value":"3"},{"label":"星期四","value":"4"},{"label":"星期五","value":"5"},{"label":"星期六","value":"6"},{"label":"星期日","value":"0"}]', '1', 'period', 2, 1521085263, 1580998939);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('recPercent', '推广奖比例', '%', 1, null, '15', 'bonus', 2, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('siteCloseInfo', '关闭提示信息', null, 1, null, '网站正在维护中...', 'base', 3, 1521085263, 1524013893);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('pointsLayer', '业绩奖偶数层数', '层', 1, null, '10', 'bonus', 3, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('smsWallet', '短信费用扣除钱包', null, 2, '[{"label":"奖金钱包","value":"1"},{"label":"现金钱包","value":"2"}]', '1,2', 'sms', 3, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('closeTime', '自动封期时间', null, 7, '{"start":"00:00","end":"23:59","step":"00:30"}', '00:00', 'period', 3, 1521085263, 1580998939);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('smsContent', '短信内容', null, 9, null, '尊敬的会员{%REAL_NAME%}！您的最迟复销充值日期是{%LAST_RECHARGE_DATE%}、您{%MONTH%}{%IS_PASS%}，请留意您的复销状态；如已交复销请忽略此短信。', 'sms', 4, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('pointsPercent', '业绩奖比例', '%', 1, null, '1', 'bonus', 4, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('shareRegPerson', '共享奖注册时间人数', '人', 1, null, '7', 'bonus', 5, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('sharePercent', '共享奖比例', '%', 1, null, '5', 'bonus', 6, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('parentOddPercent_0', '管理奖1/3/5代比例', '%', 1, null, '5', 'bonus', 7, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('parentOddPercent_1', '管理奖7/9/11代比例', '%', 1, null, '4', 'bonus', 8, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('parentOddPercent_2', '管理奖13/15/17代比例', '%', 1, null, '2', 'bonus', 9, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('smsEmpOpen', '是否开启首次达到聘级短信通知', null, 8, null, '1', 'sms', 10, 1521085263, 1522396087);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('parentOddPercent_3', '管理奖19/21/23代比例', '%', 1, null, '3', 'bonus', 10, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('smsEmp', '达到的聘级', null, 2, '[{"label":"高级经理","value":"1"},{"label":"合格高级经理","value":"2"},{"label":"一钻经理","value":"3"},{"label":"二钻经理","value":"4"},{"label":"三钻经理","value":"5"},{"label":"四钻经理","value":"6"},{"label":"五钻经理","value":"7"},{"label":"六钻经理","value":"8"},{"label":"七钻经理","value":"9"},{"label":"七星董事","value":"10"},{"label":"六星董事","value":"11"},{"label":"三星董事","value":"12"}]', '1,2,3,4,5,6,7,8,9,10,11,12', 'sms', 11, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('reConsumePointsPercent', '重复消费积分比例', '%', 1, null, '10', 'bonus', 11, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('smsEmpContent', '聘级短信内容', null, 9, null, '尊敬的会员{%REAL_NAME%}！恭喜您于{%EMP_LV_DATE%}升级到{%EMP_LV%}。', 'sms', 12, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('reConsumePointsMonthCap', '重复消费积分每月上限', '积分', 1, null, '1000', 'bonus', 12, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('showBonusPeriodNum', '前台可见往期奖金期数', '期', 1, null, '10', 'other', 13, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('manageTaxPercent', '管理费比例', '%', 1, null, '5', 'bonus', 13, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('showFlowPeriodNum', '前台可见交易记录期数', '期', 1, null, '10', 'other', 14, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('bonusTotalZeroLimit', '总收入限制(推荐0人)', '倍', 1, null, '1', 'bonus', 14, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('showTransferPeriodNum', '前台可见转账记录期数', '期', 1, null, '10', 'other', 15, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('bonusTotalOneLimit', '总收入限制(推荐1人)', '倍', 1, null, '2', 'bonus', 15, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('showWithdrawPeriodNum', '前台可见提现记录期数', '期', 1, null, '10', 'other', 16, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('bonusTotalTwoLimit', '总收入限制(推荐2人)', '倍', 1, null, '4', 'bonus', 16, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('sameEmpLevelPercent', '相同聘级荣衔奖比例', '%', 1, null, '10', 'bonus', 17, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('openQY', '是否开启团队奖', null, 8, null, '1', 'bonus', 20, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('openYC', '是否开启荣衔奖', null, 8, null, '1', 'bonus', 21, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('openBD', '是否开启报单奖', null, 8, null, '1', 'bonus', 23, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('manualWithdrawMinAmount', '手动提现最低金额', '元', 1, null, '100', 'other', 23, 1521085263, 1541830796);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('openTG', '是否开启推广奖', null, 8, null, '1', 'bonus', 24, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('openYJ', '是否开启业绩奖', null, 8, null, '1', 'bonus', 25, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('openGX', '是否开启共享奖', null, 8, null, '1', 'bonus', 26, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('withdrawFreezeDays', '提现预付款天数', '天', 1, null, '30', 'other', 26, 1521085263, 1541830796);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('openGL', '是否开启管理奖', null, 8, null, '1', 'bonus', 27, 1521085263, 1581836154);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('isCanWithdrawBack', '是否开启前台提现退回功能', null, 8, null, '1', 'other', 27, 1521085263, 1522396087);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('autoClosePeriod', '自动封期', null, 8, null, '1', 'other', 41, 1521085263, 1541830796);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('autoCalcPeriod', '自动结算', null, 8, null, '1', 'other', 42, 1521085263, 1541830796);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('isCanTransferProp', '是否开启单笔转账比例', null, 8, null, '1', 'other', 43, 1521085263, 1541830796);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('backupWeekDate', '备份星期', null, 2, '[{"label":"星期一","value":"1"},{"label":"星期二","value":"2"},{"label":"星期三","value":"3"},{"label":"星期四","value":"4"},{"label":"星期五","value":"5"},{"label":"星期六","value":"6"},{"label":"星期日","value":"0"}]', '6', 'other', 44, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('backupTime', '备份时间', null, 7, '{"start":"00:00","end":"23:59","step":"00:30"}', '03:30', 'other', 45, 1521085263, 1524116298);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('historyBonusLimit', '奖金余额备份近几周', '周', 1, null, '5', 'other', 46, 1521085263, 1541830796);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('payPasswordRule', '支付密码规则', null, 2, '[{"label":"无","value":"0"},{"label":"身份证后6位","value":"id_s_6"},{"label":"身份证前8位","value":"id_p_8"},{"label":"用户名","value":"user_name"}]', 'user_name', 'other', 47, 1521085263, 1541830796);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('passwordRule', '密码规则', null, 2, '[{"label":"无","value":"0"},{"label":"身份证后6位","value":"id_s_6"},{"label":"身份证前8位","value":"id_p_8"},{"label":"用户名","value":"user_name"}]', '0', 'other', 48, 1521085263, 1541830796);
INSERT INTO AR_CONFIG (CONFIG_NAME, TITLE, UNIT, INPUT_TYPE, OPTIONS, VALUE, TYPE, SORT, CREATED_AT, UPDATED_AT) VALUES ('pvRatio', 'PV比例', null, 1, null, '0.7', 'other', 49, 1521085263, 1541830796);
UNLOCK TABLES;

-- 管理员表
DROP TABLE IF EXISTS `AR_ADMIN`;
CREATE TABLE `AR_ADMIN` (
  ID          varchar(32) NOT NULL COMMENT 'ID',
  ADMIN_NAME    varchar(255)                   NOT NULL COMMENT '用户名',
  REAL_NAME    varchar(128)                   NOT NULL COMMENT '会员姓名',
  REMARK    varchar(255) COMMENT '备注',
  ROLE_ID    varchar(32)         NOT NULL COMMENT '角色ID',
  IS_ENABLE tinyint(1) DEFAULT 1 NOT NULL COMMENT '是否启用',
  AUTH_KEY    varchar(255) COMMENT '认证KEY',
  PASSWORD_HASH    varchar(255)                   NOT NULL COMMENT '密码',
  PASSWORD_RESET_TOKEN varchar(255) COMMENT '重设密码TOKEN',
  DONT_DEL    tinyint(1) DEFAULT 0             NOT NULL COMMENT '不可删除',
  IS_DEL    tinyint(1) DEFAULT 0             NOT NULL COMMENT '是否删除',
  LOGIN_NUMS int(10) DEFAULT 0            NOT NULL COMMENT '登录次数',
  FAIL_NUMS int(10) DEFAULT 0            NOT NULL COMMENT '登录失败次数',
  LAST_LOGIN_IP varchar(16) DEFAULT '0.0.0.0' NOT NULL  COMMENT '上次登录IP',
  LAST_LOGIN_AT  int(10) DEFAULT 0                     NOT NULL COMMENT '上次登录时间',
  BIND_IP text COMMENT '绑定IP',
  CREATE_ADMIN  varchar(32)                  NOT NULL COMMENT '创建管理员',
  UPDATE_ADMIN   varchar(32) COMMENT '更新管理员',
  CREATED_AT  int(10)                      NOT NULL COMMENT '创建时间',
  UPDATED_AT  int(10) DEFAULT 0            NOT NULL COMMENT '更新时间',
  DELETED_AT  int(10) DEFAULT 0            NOT NULL COMMENT '删除时间',
	PRIMARY KEY (`ID`),
  UNIQUE KEY `ADMIN_NAME` (`ADMIN_NAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员表';

INSERT INTO AR_ADMIN (ID, ADMIN_NAME, REAL_NAME, REMARK, ROLE_ID, IS_ENABLE, AUTH_KEY, PASSWORD_HASH, DONT_DEL, LOGIN_NUMS, FAIL_NUMS, LAST_LOGIN_IP, LAST_LOGIN_AT, BIND_IP, CREATE_ADMIN, CREATED_AT) VALUES (REPLACE(UUID(),'-',''), 'admin', 'admin', '', '666A7F102B8D6C66E055736AECE8644D', 1, 'asdsad', '$2y$13$ZTJsT7UpOiaebII1ex3vV.boCW9hTJseV3/pbuYJ2lQQltcKq/hcG', 1, 0, 0, '0.0.0.0', 0, '', '65F27BCE7FD278FFE055736AECE8644D', 1519978161);

-- 管理员角色表
DROP TABLE IF EXISTS `AR_ADMIN_ROLE`;
CREATE TABLE `AR_ADMIN_ROLE` (
  ID          varchar(32)  NOT NULL COMMENT 'ID',
  ROLE_NAME    varchar(255)                   NOT NULL COMMENT '角色名',
  REMARK    varchar(255) COMMENT '描述',
  PERMISSION    text DEFAULT NULL COMMENT '权限',
  COLUMN_PERMISSION    text DEFAULT NULL COMMENT '列表字段权限',
  DONT_DEL     tinyint(1)  DEFAULT 0           NOT NULL COMMENT '不可删除',
  CREATE_ADMIN  varchar(32)                  COMMENT '创建管理员',
  UPDATE_ADMIN   varchar(32) COMMENT '更新管理员',
  CREATED_AT  int(10)                      NOT NULL COMMENT '创建时间',
  UPDATED_AT  int(10) DEFAULT 0            NOT NULL COMMENT '更新时间',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `ROLE_NAME` (`ROLE_NAME`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员角色表';

INSERT INTO AR_ADMIN_ROLE (ID, ROLE_NAME, REMARK, DONT_DEL, CREATE_ADMIN, CREATED_AT) VALUES ('666A7F102B8D6C66E055736AECE8644D', '超级管理员', '全局管理', 1, '65F27BCE7FD278FFE055736AECE8644D', 1519978161);


-- 管理员TOKEN表
DROP TABLE IF EXISTS `AR_ADMIN_TOKEN`;
CREATE TABLE `AR_ADMIN_TOKEN` (
  ID          varchar(32) NOT NULL COMMENT 'ID',
  ADMIN_ID     varchar(32)                    NOT NULL COMMENT '管理员ID',
  PC_ACCESS_TOKEN  varchar(255) COMMENT 'PC认证TOKEN',
  APP_ACCESS_TOKEN     varchar(255) COMMENT 'APP认证TOKEN',
  PC_REFRESH_TOKEN     varchar(255) COMMENT 'PC刷新TOKEN',
  APP_REFRESH_TOKEN  varchar(255) COMMENT 'APP刷新TOKEN',
  CREATED_AT  int(10)                      NOT NULL COMMENT '创建时间',
  PAT_UPDATED_AT  int(10) DEFAULT 0            NOT NULL COMMENT 'PCACCESSTOKEN更新时间',
  AAT_UPDATED_AT  int(10) DEFAULT 0            NOT NULL COMMENT 'APPACCESSTOKEN更新时间',
  PRT_UPDATED_AT  int(10) DEFAULT 0            NOT NULL COMMENT 'PCREFRESHTOKEN更新时间',
  ART_UPDATED_AT  int(10) DEFAULT 0            NOT NULL COMMENT 'PCREFRESHTOKEN更新时间',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `PC_ACCESS_TOKEN` (`PC_ACCESS_TOKEN`),
  UNIQUE KEY `APP_ACCESS_TOKEN` (`APP_ACCESS_TOKEN`),
  UNIQUE KEY `PC_REFRESH_TOKEN` (`PC_REFRESH_TOKEN`),
  UNIQUE KEY `APP_REFRESH_TOKEN` (`APP_REFRESH_TOKEN`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理员TOKEN表';

INSERT INTO AR_ADMIN_TOKEN (ID, ADMIN_ID, PC_ACCESS_TOKEN, APP_ACCESS_TOKEN, PC_REFRESH_TOKEN, APP_REFRESH_TOKEN, CREATED_AT, PAT_UPDATED_AT, AAT_UPDATED_AT, PRT_UPDATED_AT, ART_UPDATED_AT) VALUES ('6642C11AD4A66F07E055736AECE8644D', '65F27BCE7FD278FFE055736AECE8644D', '08ff6856c6ff0c8289a4958921221e05', null, '7875e4c5eff79308d4ce2af7ed5ecd0c', null, 1519807464, 1521508188, 0, 1521508188, 0);

-- 会员TOKEN表
DROP TABLE IF EXISTS `AR_USER_TOKEN`;
CREATE TABLE `AR_USER_TOKEN`(
  ID          varchar(32) NOT NULL COMMENT 'ID',
  USER_ID     varchar(32)                    NOT NULL COMMENT '会员ID',
  PC_ACCESS_TOKEN  varchar(255) COMMENT 'PC端TOKEN',
  APP_ACCESS_TOKEN varchar(255) COMMENT 'APP端TOKEN',
  PC_REFRESH_TOKEN varchar(255) COMMENT 'PC刷新TOKEN',
  APP_REFRESH_TOKEN varchar(255) COMMENT 'APP刷新TOKEN',
  CREATED_AT  int(10)                      NOT NULL COMMENT '创建时间',
  PAT_UPDATED_AT  int(10) DEFAULT 0        NOT NULL COMMENT 'PC端TOKEN更新时间',
  AAT_UPDATED_AT  int(10) DEFAULT 0        NOT NULL COMMENT 'APP端TOKEN更新时间',
  PRT_UPDATED_AT  int(10) DEFAULT 0        NOT NULL COMMENT 'PC刷新TOKEN更新时间',
  ART_UPDATED_AT  int(10) DEFAULT 0        NOT NULL COMMENT 'APP刷新TOKEN更新时间',
  PRIMARY KEY (`ID`),
  UNIQUE KEY `PC_ACCESS_TOKEN` (`PC_ACCESS_TOKEN`),
  UNIQUE KEY `APP_ACCESS_TOKEN` (`APP_ACCESS_TOKEN`),
  UNIQUE KEY `PC_REFRESH_TOKEN` (`PC_REFRESH_TOKEN`),
  UNIQUE KEY `APP_REFRESH_TOKEN` (`APP_REFRESH_TOKEN`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员TOKEN表';

-- 期业绩表
DROP TABLE IF EXISTS `AR_PERF_PERIOD`;
CREATE TABLE `AR_PERF_PERIOD`(
  ID          varchar(32) NOT NULL COMMENT 'ID',
  USER_ID     varchar(32)                    NOT NULL COMMENT '会员ID',
  LAST_DEC_LV   varchar(32)                    DEFAULT '' COMMENT '结算时会员级别',
  LAST_EMP_LV   varchar(32)                    DEFAULT '' COMMENT '结算时会员聘级',
  LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL COMMENT '结算时会有状态',
  PV_PCS      decimal(16,3) DEFAULT 0        NOT NULL COMMENT '个人消费',
  PV_PCS_ZC   decimal(16,3) DEFAULT 0        NOT NULL COMMENT '个人消费注册单',
  PV_PCS_YH   decimal(16,3) DEFAULT 0        NOT NULL COMMENT '个人消费优惠单',
  PV_PCS_ZG   decimal(16,3) DEFAULT 0        NOT NULL COMMENT '个人消费增购单',
  PV_PCS_LS   decimal(16,3) DEFAULT 0        NOT NULL COMMENT '个人消费零售单',
  PV_PCS_FX   decimal(16,3) DEFAULT 0        NOT NULL COMMENT '个人消费复销单',
  PV_1L       decimal(16,3) DEFAULT 0        NOT NULL COMMENT '一市场业绩',
  PV_1L_TOUCH  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '一市场对碰业绩',
  PV_1L_ZC    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '一市场注册单业绩',
  PV_1L_YH    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '一市场优惠单业绩',
  PV_1L_ZG    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '一市场增购单业绩',
  PV_1L_LS    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '一市场零售单业绩',
  PV_1L_FX    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '一市场复销单业绩',
  PV_2L       decimal(16,3) DEFAULT 0        NOT NULL COMMENT '二市场业绩',
  PV_2L_TOUCH  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '二市场对碰业绩',
  PV_2L_ZC    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '二市场注册单业绩',
  PV_2L_YH    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '二市场优惠单业绩',
  PV_2L_ZG    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '二市场增购单业绩',
  PV_2L_LS    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '二市场零售单业绩',
  PV_2L_FX    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '二市场复销单业绩',
  PV_3L       decimal(16,3) DEFAULT 0        NOT NULL COMMENT '三市场业绩',
  PV_3L_TOUCH  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '三市场对碰业绩',
  PV_3L_ZC    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '三市场优惠单业绩',
  PV_3L_YH    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '三市场优惠单业绩',
  PV_3L_ZG    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '三市场增购单业绩',
  PV_3L_LS    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '三市场零售单业绩',
  PV_3L_FX    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '三市场复销单业绩',
  PV_4L       decimal(16,3) DEFAULT 0        NOT NULL COMMENT '四市场业绩',
  PV_4L_TOUCH  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '四市场对碰业绩',
  PV_4L_ZC    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '四市场优惠单业绩',
  PV_4L_YH    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '四市场优惠单业绩',
  PV_4L_ZG    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '四市场增购单业绩',
  PV_4L_LS    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '四市场零售单业绩',
  PV_4L_FX    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '四市场复销单业绩',
  PV_5L       decimal(16,3) DEFAULT 0        NOT NULL COMMENT '五市场业绩',
  PV_5L_TOUCH  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '五市场对碰业绩',
  PV_5L_ZC    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '五市场优惠单业绩',
  PV_5L_YH    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '五市场优惠单业绩',
  PV_5L_ZG    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '五市场增购单业绩',
  PV_5L_LS    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '五市场零售单业绩',
  PV_5L_FX    decimal(16,3) DEFAULT 0        NOT NULL COMMENT '五市场复销单业绩',
  PV_LS_TOUCH  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '隐藏零售区业绩30%后的',
  SURPLUS_1L  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '一市场结余业绩',
  SURPLUS_2L  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '二市场结余业绩',
  SURPLUS_3L  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '三市场结余业绩',
  SURPLUS_4L  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '四市场结余业绩',
  SURPLUS_5L  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '五市场结余业绩',
  SURPLUS_LS  decimal(16,3) DEFAULT 0        NOT NULL COMMENT '零售隐藏区结余业绩',
  PERIOD_NUM  int(10)                      NOT NULL COMMENT '期数',
  CALC_MONTH  int(10)                      NOT NULL COMMENT '结算月YYYYMM',
  P_CALC_MONTH DATE                           NOT NULL COMMENT '表分区日期索引',
  CREATED_AT  int(10)                      NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`ID`),
  KEY `USER_ID` (`USER_ID`),
  KEY `PERIOD_NUM` (`PERIOD_NUM`),
  KEY `CALC_MONTH` (`CALC_MONTH`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='业绩记录';

-- 月度业绩表
DROP TABLE IF EXISTS `AR_PERF_MONTH`;
CREATE TABLE `AR_PERF_MONTH`(
  ID          varchar(32) NOT NULL COMMENT 'ID',
  USER_ID         varchar(32)                    NOT NULL COMMENT '会员ID',
  LAST_DEC_LV   varchar(32)                    DEFAULT '' COMMENT '结算时会员级别',
  LAST_EMP_LV   varchar(32)                    DEFAULT '' COMMENT '结算时会员聘级',
  LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL COMMENT '个人消费',
  PV_PCS          decimal(16,3) DEFAULT 0         NOT NULL COMMENT '一市场业绩',
  PV_1L           decimal(16,3) DEFAULT 0         NOT NULL COMMENT '二市场业绩',
  PV_2L           decimal(16,3) DEFAULT 0         NOT NULL COMMENT '三市场业绩',
  PV_3L           decimal(16,3) DEFAULT 0         NOT NULL COMMENT '四市场业绩',
  PV_4L           decimal(16,3) DEFAULT 0         NOT NULL COMMENT '五市场业绩',
  PV_5L           decimal(16,3) DEFAULT 0         NOT NULL COMMENT '一市场历史累计加该月业绩',
  PV_1L_TOTAL     decimal(16,3) DEFAULT 0         NOT NULL COMMENT '二市场历史累计加该月业绩',
  PV_2L_TOTAL     decimal(16,3) DEFAULT 0         NOT NULL COMMENT '三市场历史累计加该月业绩',
  PV_3L_TOTAL     decimal(16,3) DEFAULT 0         NOT NULL COMMENT '四市场历史累计加该月业绩',
  PV_4L_TOTAL     decimal(16,3) DEFAULT 0         NOT NULL COMMENT '五市场历史累计加该月业绩',
  PV_5L_TOTAL     decimal(16,3) DEFAULT 0         NOT NULL COMMENT '五市场历史累计加该月业绩',
  CF_PERCENT      int(10) DEFAULT 0            NOT NULL COMMENT '车房养老奖分工系数',
  LX_PERCENT      int(10) DEFAULT 0            NOT NULL COMMENT '领袖分红分工系数',
  FX_STATUS       tinyint(1) DEFAULT 0             NOT NULL COMMENT '本月复销状态作为下月发奖资格',
  CALC_MONTH      int(10)                      NOT NULL COMMENT '结算月',
  P_CALC_MONTH    DATE                            NOT NULL COMMENT '表分区日期索引',
  CREATED_AT      int(10)                      NOT NULL COMMENT '创建时间',
  PRIMARY KEY (`ID`),
  KEY `USER_ID` (`USER_ID`),
  KEY `LAST_EMP_LV` (`LAST_EMP_LV`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='月业绩记录';
COMMENT ON COLUMN AR_PERF_MONTH.PV_1L IS '一市场业绩';
COMMENT ON COLUMN AR_PERF_MONTH.PV_2L IS '二市场业绩';
COMMENT ON COLUMN AR_PERF_MONTH.PV_3L IS '三市场业绩';
COMMENT ON COLUMN AR_PERF_MONTH.PV_4L IS '四市场业绩';
COMMENT ON COLUMN AR_PERF_MONTH.PV_5L IS '五市场业绩';
COMMENT ON COLUMN AR_PERF_MONTH.PV_1L_TOTAL IS '一市场历史累计加该月业绩';
COMMENT ON COLUMN AR_PERF_MONTH.PV_2L_TOTAL IS '二市场历史累计加该月业绩';
COMMENT ON COLUMN AR_PERF_MONTH.PV_3L_TOTAL IS '三市场历史累计加该月业绩';
COMMENT ON COLUMN AR_PERF_MONTH.PV_4L_TOTAL IS '四市场历史累计加该月业绩';
COMMENT ON COLUMN AR_PERF_MONTH.PV_5L_TOTAL IS '五市场历史累计加该月业绩';
COMMENT ON COLUMN AR_PERF_MONTH.CF_PERCENT  IS '车房养老奖分工系数';
COMMENT ON COLUMN AR_PERF_MONTH.LX_PERCENT  IS '领袖分红分工系数';
COMMENT ON COLUMN AR_PERF_MONTH.FX_STATUS  IS '本月复销状态作为下月发奖资格';
COMMENT ON COLUMN AR_PERF_MONTH.CALC_MONTH IS '结算月';
COMMENT ON COLUMN AR_PERF_MONTH.P_CALC_MONTH IS '表分区日期索引';
COMMENT ON COLUMN AR_PERF_MONTH.CREATED_AT IS '创建时间';

-- 公司总业绩
DROP TABLE IF EXISTS `AR_PERF_COMPANY`;
CREATE TABLE AR_PERF_COMPANY
(
  ID          varchar(32) NOT NULL COMMENT 'ID',
  PV          decimal(16,3) DEFAULT 0          NOT NULL COMMENT '月总业绩',
  CALC_YEAR   int(10)                      NOT NULL COMMENT '结算年',
  CALC_MONTH  int(10)                      NOT NULL COMMENT '结算月',
  CREATED_AT  int(10)                      NOT NULL COMMENT '创建时间',
  KEY `CALC_YEAR` (`CALC_YEAR`),
  KEY `CALC_MONTH` (`CALC_MONTH`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='公司总业绩';

-- 报单级别
DROP TABLE IF EXISTS `AR_DECLARATION_LEVEL`;
CREATE TABLE AR_DECLARATION_LEVEL
(
	ID         varchar(32) NOT NULL COMMENT 'ID',
	LEVEL_NAME varchar(48)                    NOT NULL COMMENT '级别名称',
	PERF       float(16, 2) DEFAULT 0.00      NOT NULL COMMENT '累计业绩',
	QY_PERCENT float(16, 2) DEFAULT 0.00      NOT NULL COMMENT '区域津贴百分比',
	QY_TOUCH_CAP float(16, 2) DEFAULT 0.00    NOT NULL COMMENT '对碰封顶',
	QY_BIG_CAP float(16, 2) DEFAULT 0.00      NOT NULL COMMENT '大区封顶',
	FX_MIN_DEEP int(10) DEFAULT 1           NOT NULL COMMENT '复销奖拿奖最小层数',
	FX_MAX_DEEP int(10) DEFAULT 1           NOT NULL COMMENT '复销奖拿奖最大层数',
	FX_PERCENT float(16, 2) DEFAULT 0.00      NOT NULL COMMENT '复销奖百分比',
	IS_ADJUST_GIFT tinyint(1) DEFAULT 0         NOT NULL COMMENT '是否可调整礼包',
	IS_DEC     tinyint(1) DEFAULT 0             NOT NULL COMMENT '是否可以报单',
	SORT       int(10) DEFAULT 0            NOT NULL COMMENT '级别排序',
	CREATE_ADMIN varchar(32)                  NOT NULL COMMENT '创建管理员',
	UPDATE_ADMIN varchar(32) COMMENT '更新管理员',
	UPDATE_PERIOD float(10,0) DEFAULT 0       NOT NULL COMMENT '更新期数',
	ORDER_PERMISSION text COMMENT '订单权限',
	CREATED_AT int(10)                      NOT NULL COMMENT '创建时间',
	UPDATED_AT int(10) DEFAULT 0            NOT NULL COMMENT '更新时间',
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='报单级别';
ALTER TABLE `AR_DECLARATION_LEVEL` ADD UNIQUE INDEX `LEVEL_NAME`(`LEVEL_NAME`) USING BTREE;

-- AR_DECLARATION_LEVEL 表字段修改
ALTER TABLE AR_DECLARATION_LEVEL ADD GL_ODD_DEEP_ONE int(10) DEFAULT 1 NOT NULL COMMENT '共享奖推荐1人拿的代数';
ALTER TABLE AR_DECLARATION_LEVEL ADD GL_ODD_DEEP_TWO int(10) DEFAULT 1 NOT NULL COMMENT'共享奖推荐2人拿的代数';
ALTER TABLE AR_DECLARATION_LEVEL ADD GL_ODD_DEEP_THREE int(10) DEFAULT 1 NOT NULL COMMENT '共享奖推荐3人拿的代数';
ALTER TABLE AR_DECLARATION_LEVEL ADD INCOME_CAP decimal(16,2) DEFAULT 0.00 NOT NULL COMMENT '收入上限';

-- INSERT INTO AR_DECLARATION_LEVEL("ID", "LEVEL_NAME", "PERF", "QY_PERCENT", "QY_TOUCH_CAP", "QY_BIG_CAP", "FX_MIN_DEEP", "FX_MAX_DEEP", "FX_PERCENT", "IS_ADJUST_GIFT", "IS_DEC", "SORT", "CREATE_ADMIN", "UPDATE_ADMIN", "UPDATE_PERIOD", "ORDER_PERMISSION", "CREATED_AT", "UPDATED_AT") VALUES ('67AB99FDC4B6501CE055736AECE8644D', '普通会员', '600', '8', '4000', '100000', '1', '12', '3', '0', '1', '1', 'admin', 'wangqi', '154', '', '1521357308', '1571879753');
-- INSERT INTO AR_DECLARATION_LEVEL("ID", "LEVEL_NAME", "PERF", "QY_PERCENT", "QY_TOUCH_CAP", "QY_BIG_CAP", "FX_MIN_DEEP", "FX_MAX_DEEP", "FX_PERCENT", "IS_ADJUST_GIFT", "IS_DEC", "SORT", "CREATE_ADMIN", "UPDATE_ADMIN", "UPDATE_PERIOD", "ORDER_PERMISSION", "CREATED_AT", "UPDATED_AT") VALUES ('67ABCB8C1F7D5519E055736AECE8644D', '银卡会员', '3000', '10', '15000', '280000', '1', '13', '3', '1', '1', '2', 'admin', 'adminty', '158', '', '1521358140', '1572317628');
-- INSERT INTO AR_DECLARATION_LEVEL("ID", "LEVEL_NAME", "PERF", "QY_PERCENT", "QY_TOUCH_CAP", "QY_BIG_CAP", "FX_MIN_DEEP", "FX_MAX_DEEP", "FX_PERCENT", "IS_ADJUST_GIFT", "IS_DEC", "SORT", "CREATE_ADMIN", "UPDATE_ADMIN", "UPDATE_PERIOD", "ORDER_PERMISSION", "CREATED_AT", "UPDATED_AT") VALUES ('67ABCCE20A9F5553E055736AECE8644D', '金卡会员', '6000', '12', '30000', '550000', '1', '14', '3', '1', '1', '3', 'admin', NULL, '140', '', '1521358162', '1563504126');
-- INSERT INTO AR_DECLARATION_LEVEL("ID", "LEVEL_NAME", "PERF", "QY_PERCENT", "QY_TOUCH_CAP", "QY_BIG_CAP", "FX_MIN_DEEP", "FX_MAX_DEEP", "FX_PERCENT", "IS_ADJUST_GIFT", "IS_DEC", "SORT", "CREATE_ADMIN", "UPDATE_ADMIN", "UPDATE_PERIOD", "ORDER_PERMISSION", "CREATED_AT", "UPDATED_AT") VALUES ('67ABCE0ECE705575E055736AECE8644D', 'VIP会员', '12000', '16', '80000', '1050000', '1', '17', '3', '1', '1', '4', 'admin', 'wangqi', '158', '', '1521358182', '1572257546');
INSERT INTO AR_DECLARATION_LEVEL (ID, LEVEL_NAME, PERF, QY_PERCENT, QY_TOUCH_CAP, QY_BIG_CAP, FX_MIN_DEEP, FX_MAX_DEEP, FX_PERCENT, IS_ADJUST_GIFT, IS_DEC, SORT, CREATE_ADMIN, UPDATE_ADMIN, UPDATE_PERIOD, ORDER_PERMISSION, CREATED_AT, UPDATED_AT, GL_ODD_DEEP_ONE, GL_ODD_DEEP_TWO, GL_ODD_DEEP_THREE, INCOME_CAP) VALUES ('67ABCB8C1F7D5519E055736AECE8644D', '银钻会员', 980.00, 2.00, 15000.00, 280000.00, 1, 13, 3.00, 1, 1, 2, 'admin', 'adminx', 158, null, 1521358140, 1581996445, 1, 2, 6, 10000.00);
INSERT INTO AR_DECLARATION_LEVEL (ID, LEVEL_NAME, PERF, QY_PERCENT, QY_TOUCH_CAP, QY_BIG_CAP, FX_MIN_DEEP, FX_MAX_DEEP, FX_PERCENT, IS_ADJUST_GIFT, IS_DEC, SORT, CREATE_ADMIN, UPDATE_ADMIN, UPDATE_PERIOD, ORDER_PERMISSION, CREATED_AT, UPDATED_AT, GL_ODD_DEEP_ONE, GL_ODD_DEEP_TWO, GL_ODD_DEEP_THREE, INCOME_CAP) VALUES ('67ABCCE20A9F5553E055736AECE8644D', '金钻会员', 2980.00, 2.00, 30000.00, 550000.00, 1, 14, 3.00, 1, 1, 3, 'admin', 'adminx', 140, null, 1521358162, 1581996462, 2, 4, 9, 100000.00);
INSERT INTO AR_DECLARATION_LEVEL (ID, LEVEL_NAME, PERF, QY_PERCENT, QY_TOUCH_CAP, QY_BIG_CAP, FX_MIN_DEEP, FX_MAX_DEEP, FX_PERCENT, IS_ADJUST_GIFT, IS_DEC, SORT, CREATE_ADMIN, UPDATE_ADMIN, UPDATE_PERIOD, ORDER_PERMISSION, CREATED_AT, UPDATED_AT, GL_ODD_DEEP_ONE, GL_ODD_DEEP_TWO, GL_ODD_DEEP_THREE, INCOME_CAP) VALUES ('67ABCE0ECE705575E055736AECE8644D', 'VIP会员', 9800.00, 2.00, 80000.00, 1050000.00, 1, 17, 3.00, 1, 1, 4, 'admin', 'adminx', 158, null, 1521358182, 1581996473, 3, 6, 12, 200000.00);


-- 聘级
DROP TABLE IF EXISTS `AR_EMPLOY_LEVEL`;
CREATE TABLE AR_EMPLOY_LEVEL
(
	ID          varchar(32) NOT NULL COMMENT 'ID',
	LEVEL_NAME  varchar(48)                    NOT NULL COMMENT '级别名称',
	LOCATION_NUM int(10) DEFAULT 0           NOT NULL COMMENT '区数量',
	LOCATION_PERF float(16, 2) DEFAULT 0.00    NOT NULL COMMENT '单区业绩',
	NEW_PERF    float(16, 2) DEFAULT 0.00      NOT NULL COMMENT '新增业绩',
	MIN_EMPLOY_LEVEL varchar(32) COMMENT '几个区域内分别有几个最低什么聘级的会员',
	YC_PERCENT_ARR  text COMMENT '育成津贴比例集合',
	CF_BASE_NUM float(16, 2) DEFAULT 0.00      NOT NULL COMMENT '车房奖基数',
	CF_PERCENT  float(16, 2) DEFAULT 0.00      NOT NULL COMMENT '车房奖系数',
	LX_BASE_NUM float(16, 2) DEFAULT 0.00      NOT NULL COMMENT '领袖奖奖基数',
	LX_PERCENT  float(16, 2) DEFAULT 0.00      NOT NULL COMMENT '领袖奖系数',
	SORT        int(10)  DEFAULT 0           NOT NULL COMMENT '排序',
	CREATED_AT  int(10)                      NOT NULL COMMENT '创建时间',
	UPDATED_AT  int(10) DEFAULT 0            NOT NULL COMMENT '更新时间',
	CREATE_ADMIN varchar(32)                   NOT NULL COMMENT '创建管理员',
	UPDATE_ADMIN varchar(32) COMMENT '更新管理员',
	ICON_TYPE  	tinyint(1) DEFAULT 0             NOT NULL COMMENT '图表类型',
	ICON_NUM  	tinyint(2) DEFAULT 0             NOT NULL COMMENT '图标个数',
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='聘级';
ALTER TABLE `AR_EMPLOY_LEVEL` ADD UNIQUE INDEX `LEVEL_NAME`(`LEVEL_NAME`) USING BTREE;

ALTER TABLE AR_EMPLOY_LEVEL ADD RX_PERCENT decimal(16,2) DEFAULT 0.00 NOT NULL COMMENT '荣衔奖比例';
ALTER TABLE AR_EMPLOY_LEVEL ADD OTHER_DEPART_PERF decimal(16,2) DEFAULT 0.00 NOT NULL COMMENT '去除最大部门，其它部门的累计推荐业绩';
ALTER TABLE AR_EMPLOY_LEVEL ADD MIN_EMPLOY_NUM int(10) DEFAULT 0 NOT NULL COMMENT '最小聘级的数量';

-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE1C6C21F81B32E055736AECE8644D', '无聘级', '0', '0', '0', NULL, '[0,0,0,0,0,0,0,0,0,0]', '0', '0', '0', '0', '0', '1521436806', '1547104919', 'admin', NULL, '0', '0');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE5FE7857C216AE055736AECE8644D', '高级经理', '2', '70000', '0', NULL, '[0,0,0,0,0,0,0,0,0,0]', '0', '0', '0', '0', '1', '1521437938', '1548221354', 'admin', NULL, '1', '1');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE6A4D03C52288E055736AECE8644D', '合格高级经理', '2', '70000', '14000', NULL, '[0,0,0,0,0,0,0,0,0,0]', '0', '0', '0', '0', '2', '1521438113', '1547103900', 'admin', NULL, '1', '2');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE6EA2070D22EBE055736AECE8644D', '一钻经理', '1', '70000', '14000', '67BE6A4D03C52288E055736AECE8644D', '["10",0,0,0,0,0,0,0,0,0]', '0', '0', '0', '0', '3', '1521438185', '1547104065', 'admin', NULL, '2', '1');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE742A336F2370E055736AECE8644D', '二钻经理', '2', '0', '0', '67BE6A4D03C52288E055736AECE8644D', '["10","10",0,0,0,0,0,0,0,0]', '0', '0', '0', '0', '4', '1521438278', '1547104073', 'admin', NULL, '2', '2');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE805032C22492E055736AECE8644D', '三钻经理', '3', '0', '0', '67BE6A4D03C52288E055736AECE8644D', '["10","10","10",0,0,0,0,0,0,0]', '0', '0', '0', '0', '5', '1521438482', '1547104081', 'admin', NULL, '2', '3');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE82019BE524CAE055736AECE8644D', '四钻经理', '3', '0', '0', '67BE6EA2070D22EBE055736AECE8644D', '["10","10","10","5",0,0,0,0,0,0]', '0', '0', '0', '0', '6', '1521438510', '1547104088', 'admin', NULL, '2', '4');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE84991AF22509E055736AECE8644D', '五钻经理', '3', '0', '0', '67BE742A336F2370E055736AECE8644D', '["10","10","10","5","5",0,0,0,0,0]', '1', '1', '1', '1', '7', '1521438554', '1547104095', 'admin', NULL, '2', '5');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE866A22C6252FE055736AECE8644D', '六钻经理', '3', '0', '0', '67BE84991AF22509E055736AECE8644D', '["10","10","10","5","5","5",0,0,0,0]', '2', '3', '2', '3', '8', '1521438584', '1547104102', 'admin', NULL, '2', '6');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE88C8F55F2582E055736AECE8644D', '七钻经理', '3', '0', '0', '67BE866A22C6252FE055736AECE8644D', '["10","10","10","5","5","5","5",0,0,0]', '3', '6', '3', '6', '9', '1521438624', '1547104110', 'admin', NULL, '2', '7');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE8A92393225B1E055736AECE8644D', '七星董事', '3', '0', '0', '67BE88C8F55F2582E055736AECE8644D', '["10","10","10","5","5","5","5","5",0,0]', '4', '10', '4', '10', '10', '1521438654', '1547111868', 'admin', NULL, '3', '1');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE8BF76AD925E5E055736AECE8644D', '六星董事', '3', '0', '0', '67BE8A92393225B1E055736AECE8644D', '["10","10","10","5","5","5","5","5","5",0]', '5', '15', '5', '15', '11', '1521438677', '1547104142', 'admin', NULL, '3', '2');
-- INSERT INTO "AR_EMPLOY_LEVEL"("ID", "LEVEL_NAME", "LOCATION_NUM", "LOCATION_PERF", "NEW_PERF", "MIN_EMPLOY_LEVEL", "YC_PERCENT_ARR", "CF_BASE_NUM", "CF_PERCENT", "LX_BASE_NUM", "LX_PERCENT", "SORT", "CREATED_AT", "UPDATED_AT", "CREATE_ADMIN", "UPDATE_ADMIN", "ICON_TYPE", "ICON_NUM") VALUES ('67BE8E20BE1A260FE055736AECE8644D', '三星董事', '3', '0', '0', '67BE8BF76AD925E5E055736AECE8644D', '["10","10","10","5","5","5","5","5","5","5"]', '6', '21', '6', '21', '12', '1521438714', '1547104149', 'admin', NULL, '3', '3');
INSERT INTO AR_EMPLOY_LEVEL (ID, LEVEL_NAME, LOCATION_NUM, LOCATION_PERF, NEW_PERF, MIN_EMPLOY_LEVEL, YC_PERCENT_ARR, CF_BASE_NUM, CF_PERCENT, LX_BASE_NUM, LX_PERCENT, SORT, CREATED_AT, UPDATED_AT, CREATE_ADMIN, UPDATE_ADMIN, ICON_TYPE, ICON_NUM, RX_PERCENT, OTHER_DEPART_PERF, MIN_EMPLOY_NUM) VALUES ('67BE1C6C21F81B32E055736AECE8644D', '无聘级', 0, 0.00, 0.00, null, '[0,0,0,0,0,0,0,0,0,0]', 0.00, 0.00, 0.00, 0.00, 0, 1521436806, 1547104919, 'admin', null, 0, 0, 0.00, 0.00, 0);
INSERT INTO AR_EMPLOY_LEVEL (ID, LEVEL_NAME, LOCATION_NUM, LOCATION_PERF, NEW_PERF, MIN_EMPLOY_LEVEL, YC_PERCENT_ARR, CF_BASE_NUM, CF_PERCENT, LX_BASE_NUM, LX_PERCENT, SORT, CREATED_AT, UPDATED_AT, CREATE_ADMIN, UPDATE_ADMIN, ICON_TYPE, ICON_NUM, RX_PERCENT, OTHER_DEPART_PERF, MIN_EMPLOY_NUM) VALUES ('67BE5FE7857C216AE055736AECE8644D', '主任', 0, 70000.00, 0.00, null, '[0,0,0,0,0,0,0,0,0,0]', 0.00, 0.00, 0.00, 0.00, 1, 1521437938, 1548221354, 'admin', null, 1, 1, 2.00, 500000.00, 0);
INSERT INTO AR_EMPLOY_LEVEL (ID, LEVEL_NAME, LOCATION_NUM, LOCATION_PERF, NEW_PERF, MIN_EMPLOY_LEVEL, YC_PERCENT_ARR, CF_BASE_NUM, CF_PERCENT, LX_BASE_NUM, LX_PERCENT, SORT, CREATED_AT, UPDATED_AT, CREATE_ADMIN, UPDATE_ADMIN, ICON_TYPE, ICON_NUM, RX_PERCENT, OTHER_DEPART_PERF, MIN_EMPLOY_NUM) VALUES ('67BE6A4D03C52288E055736AECE8644D', '经理', 2, 70000.00, 14000.00, '67BE5FE7857C216AE055736AECE8644D', '[0,0,0,0,0,0,0,0,0,0]', 0.00, 0.00, 0.00, 0.00, 2, 1521438113, 1581997760, 'admin', 'adminx', 2, 1, 3.00, 0.00, 1);
INSERT INTO AR_EMPLOY_LEVEL (ID, LEVEL_NAME, LOCATION_NUM, LOCATION_PERF, NEW_PERF, MIN_EMPLOY_LEVEL, YC_PERCENT_ARR, CF_BASE_NUM, CF_PERCENT, LX_BASE_NUM, LX_PERCENT, SORT, CREATED_AT, UPDATED_AT, CREATE_ADMIN, UPDATE_ADMIN, ICON_TYPE, ICON_NUM, RX_PERCENT, OTHER_DEPART_PERF, MIN_EMPLOY_NUM) VALUES ('67BE6EA2070D22EBE055736AECE8644D', '高级经理', 2, 70000.00, 14000.00, '67BE6A4D03C52288E055736AECE8644D', '["10",0,0,0,0,0,0,0,0,0]', 0.00, 0.00, 0.00, 0.00, 3, 1521438185, 1581997773, 'admin', 'adminx', 2, 2, 4.00, 0.00, 1);
INSERT INTO AR_EMPLOY_LEVEL (ID, LEVEL_NAME, LOCATION_NUM, LOCATION_PERF, NEW_PERF, MIN_EMPLOY_LEVEL, YC_PERCENT_ARR, CF_BASE_NUM, CF_PERCENT, LX_BASE_NUM, LX_PERCENT, SORT, CREATED_AT, UPDATED_AT, CREATE_ADMIN, UPDATE_ADMIN, ICON_TYPE, ICON_NUM, RX_PERCENT, OTHER_DEPART_PERF, MIN_EMPLOY_NUM) VALUES ('67BE742A336F2370E055736AECE8644D', '总监', 3, 0.00, 0.00, '67BE6EA2070D22EBE055736AECE8644D', '["10","10",0,0,0,0,0,0,0,0]', 0.00, 0.00, 0.00, 0.00, 4, 1521438278, 1581997787, 'admin', 'adminx', 3, 1, 4.50, 0.00, 1);
INSERT INTO AR_EMPLOY_LEVEL (ID, LEVEL_NAME, LOCATION_NUM, LOCATION_PERF, NEW_PERF, MIN_EMPLOY_LEVEL, YC_PERCENT_ARR, CF_BASE_NUM, CF_PERCENT, LX_BASE_NUM, LX_PERCENT, SORT, CREATED_AT, UPDATED_AT, CREATE_ADMIN, UPDATE_ADMIN, ICON_TYPE, ICON_NUM, RX_PERCENT, OTHER_DEPART_PERF, MIN_EMPLOY_NUM) VALUES ('67BE805032C22492E055736AECE8644D', '高级总监', 3, 0.00, 0.00, '67BE742A336F2370E055736AECE8644D', '["10","10","10",0,0,0,0,0,0,0]', 0.00, 0.00, 0.00, 0.00, 5, 1521438482, 1581997806, 'admin', 'adminx', 3, 2, 5.00, 0.00, 1);
INSERT INTO AR_EMPLOY_LEVEL (ID, LEVEL_NAME, LOCATION_NUM, LOCATION_PERF, NEW_PERF, MIN_EMPLOY_LEVEL, YC_PERCENT_ARR, CF_BASE_NUM, CF_PERCENT, LX_BASE_NUM, LX_PERCENT, SORT, CREATED_AT, UPDATED_AT, CREATE_ADMIN, UPDATE_ADMIN, ICON_TYPE, ICON_NUM, RX_PERCENT, OTHER_DEPART_PERF, MIN_EMPLOY_NUM) VALUES ('67BE82019BE524CAE055736AECE8644D', '首席总监', 3, 0.00, 0.00, '67BE742A336F2370E055736AECE8644D', '["10","10","10","5",0,0,0,0,0,0]', 0.00, 0.00, 0.00, 0.00, 6, 1521438510, 1581997817, 'admin', 'adminx', 3, 3, 0.00, 0.00, 2);



-- 报单中心级别表
DROP TABLE IF EXISTS `AR_DEC_ROLE`;
CREATE TABLE AR_DEC_ROLE
(
    ID varchar(32) NOT NULL,
    ROLE_NAME varchar(255) NOT NULL,
    ORDER_PERMISSION text NOT NULL,
    STORE_SUBSIDY decimal(16,2) NOT NULL,
    GOODS_SUBSIDY decimal(16,2) NOT NULL,
    CREATED_AT int(10) NOT NULL,
    UPDATED_AT int(10) NOT NULL,
    UPDATER varchar(16),
    ADM_NAME varchar(16) NOT NULL,
    GOODS_TO_USER_PROP decimal(16,2) NOT NULL,
    D_STORE_PERF_PROP decimal(16,2) NOT NULL,
    FLOW_SUBSIDY_PROP float(10,2),
    NEED_SET_AREA tinyint(1) NOT NULL,
    UPDATE_PERIOD int(10) NOT NULL,
    CREATE_ORDER_FORM tinyint(1) NOT NULL,
    PRIMARY KEY (`ID`)
);

ALTER TABLE `AR_DEC_ROLE` ADD UNIQUE INDEX `ROLE_NAME`(`ROLE_NAME`) USING BTREE;

INSERT INTO AR_DEC_ROLE (ID, ROLE_NAME, ORDER_PERMISSION, STORE_SUBSIDY, GOODS_SUBSIDY, CREATED_AT, UPDATED_AT, UPDATER, ADM_NAME, GOODS_TO_USER_PROP, D_STORE_PERF_PROP, FLOW_SUBSIDY_PROP, NEED_SET_AREA, UPDATE_PERIOD, CREATE_ORDER_FORM) VALUES ('8976C62F40064D8AB357BE07C8A3CA8F', '店铺', '["ZC","ZG","LS","FX","DH"]', 4.00, 0.00, 1534748970, 1571380687, 'ADMINZ', 'ADMIN', 2.00, 0.00, 2.00, 1, 153, 1);
INSERT INTO AR_DEC_ROLE (ID, ROLE_NAME, ORDER_PERMISSION, STORE_SUBSIDY, GOODS_SUBSIDY, CREATED_AT, UPDATED_AT, UPDATER, ADM_NAME, GOODS_TO_USER_PROP, D_STORE_PERF_PROP, FLOW_SUBSIDY_PROP, NEED_SET_AREA, UPDATE_PERIOD, CREATE_ORDER_FORM) VALUES ('466CB7E1F32349C196B88ECBDE51C059', '形象店', '["ZC","ZG","FX","LS","DH"]', 4.00, 3.00, 1534749202, 1571380500, 'ADMINZ', 'ADMIN', 2.00, 0.00, 2.00, 1, 153, 1);
INSERT INTO AR_DEC_ROLE (ID, ROLE_NAME, ORDER_PERMISSION, STORE_SUBSIDY, GOODS_SUBSIDY, CREATED_AT, UPDATED_AT, UPDATER, ADM_NAME, GOODS_TO_USER_PROP, D_STORE_PERF_PROP, FLOW_SUBSIDY_PROP, NEED_SET_AREA, UPDATE_PERIOD, CREATE_ORDER_FORM) VALUES ('16B96B8D910E44EA86C89CC80F6BC76C', '报单中心', '["ZC","ZG","LS","FX","DH"]', 0.00, 0.00, 1534749214, 1571380490, 'ADMINZ', 'ADMIN', 0.00, 0.00, 0.00, 1, 153, 0);
INSERT INTO AR_DEC_ROLE (ID, ROLE_NAME, ORDER_PERMISSION, STORE_SUBSIDY, GOODS_SUBSIDY, CREATED_AT, UPDATED_AT, UPDATER, ADM_NAME, GOODS_TO_USER_PROP, D_STORE_PERF_PROP, FLOW_SUBSIDY_PROP, NEED_SET_AREA, UPDATE_PERIOD, CREATE_ORDER_FORM) VALUES ('85B65542FCC341FAAFFAD0FA625CF9B8', '服务点', '["ZC","ZG","LS","FX","DH"]', 2.00, 0.00, 1534749225, 1571380719, 'ADMINZ', 'ADMIN', 2.00, 0.00, 1.00, 1, 153, 1);
INSERT INTO AR_DEC_ROLE (ID, ROLE_NAME, ORDER_PERMISSION, STORE_SUBSIDY, GOODS_SUBSIDY, CREATED_AT, UPDATED_AT, UPDATER, ADM_NAME, GOODS_TO_USER_PROP, D_STORE_PERF_PROP, FLOW_SUBSIDY_PROP, NEED_SET_AREA, UPDATE_PERIOD, CREATE_ORDER_FORM) VALUES ('810916A06B304162902408A6B9E5D177', '区级店', '["ZC","ZG","LS","FX","DH"]', 4.00, 0.00, 1534749236, 1571380696, 'ADMINZ', 'ADMIN', 2.00, 1.00, 2.00, 1, 153, 1);



-- 银行表
DROP TABLE IF EXISTS `AR_OPEN_BANK`;
CREATE TABLE AR_OPEN_BANK
(
    ID varchar(32) NOT NULL COMMENT 'ID',
    BANK_NAME varchar(64) NOT NULL COMMENT '银行名称',
    BANK_CODE varchar(32) NOT NULL COMMENT '银行代码',
    LIST_ORDER int(5) DEFAULT 0 NOT NULL COMMENT '排序',
    CREATED_AT int(10) DEFAULT 0 NOT NULL COMMENT '创建时间',
    UPDATED_AT int(10) DEFAULT 0 NOT NULL COMMENT '修改时间',
    ADM_NAME varchar(16) NOT NULL COMMENT '操作人',
    MIN_CHARGE float(10,2) DEFAULT 0.00 NOT NULL COMMENT '最低手续费',
    MAX_CHARGE float(10,2) DEFAULT 0.00 NOT NULL COMMENT '最高手续费',
    CHARGE_PROP float(10,2) DEFAULT 0.00 NOT NULL COMMENT '手续费比例',
    UPDATER varchar(16) DEFAULT '' COMMENT '修改人',
    STATUS tinyint(1) DEFAULT 1 NOT NULL COMMENT '状态',
    PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='开户行';
ALTER TABLE `AR_OPEN_BANK` ADD UNIQUE INDEX `BANK_CODE`(`BANK_CODE`) USING BTREE;

INSERT INTO AR_OPEN_BANK (ID, BANK_NAME, BANK_CODE, LIST_ORDER, CREATED_AT, UPDATED_AT, ADM_NAME, MIN_CHARGE, MAX_CHARGE, CHARGE_PROP, UPDATER, STATUS) VALUES ('960B4D9367C776B7E053693418ACFCC1', '中国银行', '4566999', 0, 1572345878, 1573182295, 'ADMIN', 0.00, 0.00, 0.00, 'LIMIN', 1);
INSERT INTO AR_OPEN_BANK (ID, BANK_NAME, BANK_CODE, LIST_ORDER, CREATED_AT, UPDATED_AT, ADM_NAME, MIN_CHARGE, MAX_CHARGE, CHARGE_PROP, UPDATER, STATUS) VALUES ('960B6BDE22667B67E053693418ACF2B7', '招商银行', '789666', 0, 1572346386, 0, 'ADMIN', 0.00, 0.00, 0.00, NULL, 1);
INSERT INTO AR_OPEN_BANK (ID, BANK_NAME, BANK_CODE, LIST_ORDER, CREATED_AT, UPDATED_AT, ADM_NAME, MIN_CHARGE, MAX_CHARGE, CHARGE_PROP, UPDATER, STATUS) VALUES ('960B4CAB7C07769CE053693418ACF6F7', '农业银行', '123456', 0, 1572345863, 0, 'ADMIN', 0.00, 0.00, 0.00, NULL, 1);
INSERT INTO AR_OPEN_BANK (ID, BANK_NAME, BANK_CODE, LIST_ORDER, CREATED_AT, UPDATED_AT, ADM_NAME, MIN_CHARGE, MAX_CHARGE, CHARGE_PROP, UPDATER, STATUS) VALUES ('960B6924E1527B02E053693418AC2B0A', '民生银行', '456789', 0, 1572346341, 0, 'ADMIN', 0.00, 0.00, 0.00, NULL, 1);
INSERT INTO AR_OPEN_BANK (ID, BANK_NAME, BANK_CODE, LIST_ORDER, CREATED_AT, UPDATED_AT, ADM_NAME, MIN_CHARGE, MAX_CHARGE, CHARGE_PROP, UPDATER, STATUS) VALUES ('95A71AF5E4D55466E053693418ACED88', '123', '11111111', 0, 1571915532, 1572345780, 'CN0006', 0.00, 0.00, 0.00, 'ADMIN', 1);
INSERT INTO AR_OPEN_BANK (ID, BANK_NAME, BANK_CODE, LIST_ORDER, CREATED_AT, UPDATED_AT, ADM_NAME, MIN_CHARGE, MAX_CHARGE, CHARGE_PROP, UPDATER, STATUS) VALUES ('960B7BDF35E67F01E053693418AC3102', '上海银行', '88585585', 0, 1572346655, 0, 'ADMIN', 0.00, 0.00, 0.00, NULL, 1);
INSERT INTO AR_OPEN_BANK (ID, BANK_NAME, BANK_CODE, LIST_ORDER, CREATED_AT, UPDATED_AT, ADM_NAME, MIN_CHARGE, MAX_CHARGE, CHARGE_PROP, UPDATER, STATUS) VALUES ('9632D2ECCB120E33E053693418AC891C', '建设银行', '11111112', 0, 1572515619, 0, 'ADMINZ', 0.00, 0.00, 0.00, NULL, 1);



-- 会员表
DROP TABLE IF EXISTS `AR_USER`;
CREATE TABLE AR_USER
(
    ID varchar(32) NOT NULL,
    USER_NAME varchar(16) NOT NULL,
    PASSWORD_HASH varchar(255) NOT NULL,
    PAY_PASSWORD varchar(255) NOT NULL,
    NATION tinyint(2) DEFAULT 0 NOT NULL,
    REAL_NAME varchar(128) NOT NULL,
    ID_CARD varchar(18) NOT NULL,
    ID_TYPE tinyint(1) DEFAULT 0 NOT NULL,
    MOBILE varchar(11) DEFAULT '',
    ADDRESS varchar(2000) DEFAULT '',
    ID_IMAGE varchar(255) DEFAULT '',
    OPEN_BANK varchar(32) DEFAULT '',
    BANK_ADDRESS varchar(255) DEFAULT '',
    BANK_NO varchar(32) DEFAULT '',
    BANK_PROVINCE int(6) DEFAULT 0,
    BANK_CITY int(6) DEFAULT 0,
    BANK_COUNTY int(6) DEFAULT 0,
    SPOUSE_NAME varchar(16) DEFAULT '',
    SPOUSE_IDCARD varchar(18) DEFAULT '',
    CREATED_AT int(10) DEFAULT 0 NOT NULL,
    UPDATED_AT int(10) DEFAULT 0 NOT NULL,
    STATUS tinyint(1) DEFAULT 1 NOT NULL,
    DEC_CLOSED tinyint(1) DEFAULT 0 NOT NULL,
    DEC_CLOSED_AT int(10) DEFAULT 0 NOT NULL,
    DEC_LV varchar(32) DEFAULT '',
    EMP_LV varchar(32) DEFAULT '',
    PROVINCE int(6) DEFAULT 0 NOT NULL,
    CITY int(6) DEFAULT 0 NOT NULL,
    COUNTY int(6) DEFAULT 0 NOT NULL,
    TEL varchar(16) DEFAULT '',
    LOGIN_TIMES int(10) DEFAULT 0 NOT NULL,
    LOGIN_IP varchar(15) DEFAULT '',
    LOGIN_AT int(10) DEFAULT 0 NOT NULL,
    PULL_MESSAGE_AT int(10) DEFAULT 0 NOT NULL,
    SUB_COM_ID varchar(32) DEFAULT '',
    AVATAR varchar(255) NOT NULL,
    DELETED tinyint(1) DEFAULT 0 NOT NULL,
    DELETED_AT int(10) DEFAULT 0 NOT NULL,
    ALLOW_TRANSFER tinyint(1) DEFAULT 1 NOT NULL,
    TRANSFER_PROP float(10,2) DEFAULT 0.00 NOT NULL,
    PARTITION_DATE DATE  NOT NULL,
    IS_DEC tinyint(1) DEFAULT 0 NOT NULL,
    DEC_ID varchar(32) DEFAULT 1 NOT NULL,
    BIRTHDAY DATE DEFAULT '1990-09-09',
    DEC_ROLE_ID varchar(32) DEFAULT '',
    PERIOD_AT int(10) DEFAULT 0 NOT NULL,
    DEC_PROVINCE int(6) DEFAULT 0 NOT NULL,
    DEC_CITY int(6) DEFAULT 0 NOT NULL,
    DEC_COUNTY int(6) DEFAULT 0 NOT NULL,
    IS_UNION tinyint(1) DEFAULT 0 NOT NULL,
    STATUS_AT int(10) DEFAULT 0 NOT NULL,
    VERIFIED tinyint(1) DEFAULT 0 NOT NULL,
    VERIFIED_AT int(10) DEFAULT 0 NOT NULL,
    ALLOW_LOGIN tinyint(1) DEFAULT 1 NOT NULL,
    NOT_OPERATING tinyint(1) DEFAULT 0 NOT NULL,
    REG_FROM tinyint(1) DEFAULT 1 NOT NULL,
    ID_CARD_PREFIX varchar(32) DEFAULT '',
    ALLOW_BONUS_LOGIN tinyint(1) DEFAULT 1 NOT NULL,
    SEX varchar(32) DEFAULT '',
    DEC_ACCOUNT_OLD varchar(64) DEFAULT '',
    BANK_UPDATED_AT int(10) DEFAULT 0 NOT NULL,
    IS_DIRECT_SELLER tinyint(1) DEFAULT 0 NOT NULL,
    DEC_LV_UPDATED_AT int(10) DEFAULT 0 NOT NULL,
    DEC_LV_UPDATED_PERIOD int(10) DEFAULT 0 NOT NULL,
    DEC_ADDRESS varchar(2000) DEFAULT '',
    DEC_PHONE varchar(32) DEFAULT '',
    GUARANTOR varchar(32) DEFAULT '',
    GUARANTOR_NAME varchar(64) DEFAULT '',
    PART_FUNC_CLOSED tinyint(1) DEFAULT 0 NOT NULL,
    LAST_DEC_LV_UPDATED_PERIOD int(10) DEFAULT 0 NOT NULL,
    USER_CREATOR varchar(32) DEFAULT '',
    USER_UPDATER varchar(32) DEFAULT '',
    LAST_DEC_LV_UPDATED_AT int(10) DEFAULT 0 NOT NULL,
    DEC_CREATED_AT int(10) DEFAULT 0 NOT NULL,
    PART_FUNC_CLOSED_REMARK text,
    DEC_CREATED_PERIOD int(10) DEFAULT 0 NOT NULL,
    PASSWORD_CHANGED tinyint(1) DEFAULT 0 NOT NULL,
    SUB_COM_LEADER tinyint(1) DEFAULT 0 NOT NULL,
    LOGIN_FAIL_TIMES int(10) DEFAULT 0 NOT NULL,
    ZG_UPGRADE_PV decimal(16,2) DEFAULT 0.00 NOT NULL,
    APP_CLIENT_ID varchar(128) DEFAULT '',
    READ_AGREEMENT tinyint(1) DEFAULT 1 NOT NULL,
    LAST_DEC_LV varchar(32) DEFAULT '',
    BONUS_APP_CLIENT_ID varchar(128) DEFAULT '',
    IS_FIRST_OPEN tinyint(1) DEFAULT 1,
	  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户';
COMMENT ON COLUMN AR_USER.USER_NAME IS '帐号';
COMMENT ON COLUMN AR_USER.PASSWORD_HASH IS '登录密码';
COMMENT ON COLUMN AR_USER.PAY_PASSWORD IS '支付密码';
COMMENT ON COLUMN AR_USER.NATION IS '民族';
COMMENT ON COLUMN AR_USER.REAL_NAME IS '姓名';
COMMENT ON COLUMN AR_USER.ID_CARD IS '身份证号';
COMMENT ON COLUMN AR_USER.ID_TYPE IS '证件类型';
COMMENT ON COLUMN AR_USER.MOBILE IS '手机号';
COMMENT ON COLUMN AR_USER.ADDRESS IS '身份证地址';
COMMENT ON COLUMN AR_USER.ID_IMAGE IS '证件图片';
COMMENT ON COLUMN AR_USER.OPEN_BANK IS '开户行';
COMMENT ON COLUMN AR_USER.BANK_ADDRESS IS '银行地址';
COMMENT ON COLUMN AR_USER.BANK_NO IS '银行卡号';
COMMENT ON COLUMN AR_USER.BANK_PROVINCE IS '银行省份';
COMMENT ON COLUMN AR_USER.BANK_CITY IS '银行城市';
COMMENT ON COLUMN AR_USER.BANK_COUNTY IS '银行县区';
COMMENT ON COLUMN AR_USER.SPOUSE_NAME IS '配偶姓名';
COMMENT ON COLUMN AR_USER.SPOUSE_IDCARD IS '配偶证件号';
COMMENT ON COLUMN AR_USER.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_USER.UPDATED_AT IS '更新时间';
COMMENT ON COLUMN AR_USER.STATUS IS '状态';
COMMENT ON COLUMN AR_USER.DEC_CLOSED IS '是否关闭报单功能';
COMMENT ON COLUMN AR_USER.DEC_CLOSED_AT IS '关闭时间';
COMMENT ON COLUMN AR_USER.DEC_LV IS '报单级别';
COMMENT ON COLUMN AR_USER.EMP_LV IS '聘级';
COMMENT ON COLUMN AR_USER.PROVINCE IS '省份';
COMMENT ON COLUMN AR_USER.CITY IS '城市';
COMMENT ON COLUMN AR_USER.COUNTY IS '县区';
COMMENT ON COLUMN AR_USER.TEL IS '座机';
COMMENT ON COLUMN AR_USER.LOGIN_TIMES IS '登录次数';
COMMENT ON COLUMN AR_USER.LOGIN_IP IS '登录IP';
COMMENT ON COLUMN AR_USER.LOGIN_AT IS '登录时间';
COMMENT ON COLUMN AR_USER.PULL_MESSAGE_AT IS '拉取消息的时间';
COMMENT ON COLUMN AR_USER.SUB_COM_ID IS '子公司ID';
COMMENT ON COLUMN AR_USER.AVATAR IS '头像';
COMMENT ON COLUMN AR_USER.DELETED IS '是否删除';
COMMENT ON COLUMN AR_USER.DELETED_AT IS '删除时间';
COMMENT ON COLUMN AR_USER.ALLOW_TRANSFER IS '开启转帐功能';
COMMENT ON COLUMN AR_USER.TRANSFER_PROP IS '转帐比例';
COMMENT ON COLUMN AR_USER.PARTITION_DATE IS '分区时间';
COMMENT ON COLUMN AR_USER.IS_DEC IS '是否为报单中心';
COMMENT ON COLUMN AR_USER.DEC_ID IS '报单中心ID';
COMMENT ON COLUMN AR_USER.BIRTHDAY IS '生日';
COMMENT ON COLUMN AR_USER.DEC_ROLE_ID IS '报单中心级别';
COMMENT ON COLUMN AR_USER.PERIOD_AT IS '期数';
COMMENT ON COLUMN AR_USER.DEC_PROVINCE IS '报单中心所属的省份';
COMMENT ON COLUMN AR_USER.DEC_CITY IS '报单中心所属的城市';
COMMENT ON COLUMN AR_USER.DEC_COUNTY IS '报单中心所属的县区';
COMMENT ON COLUMN AR_USER.IS_UNION IS '是否为点位合作';
COMMENT ON COLUMN AR_USER.STATUS_AT IS '状态更改时间';
COMMENT ON COLUMN AR_USER.VERIFIED IS '是否认证';
COMMENT ON COLUMN AR_USER.VERIFIED_AT IS '认证时间';
COMMENT ON COLUMN AR_USER.ALLOW_LOGIN IS '允许登录';
COMMENT ON COLUMN AR_USER.NOT_OPERATING IS '不运作';
COMMENT ON COLUMN AR_USER.REG_FROM IS '注册类型';
COMMENT ON COLUMN AR_USER.ID_CARD_PREFIX IS '身份证前缀';
COMMENT ON COLUMN AR_USER.ALLOW_BONUS_LOGIN IS '允许结算登录';
COMMENT ON COLUMN AR_USER.SEX IS '性别';
COMMENT ON COLUMN AR_USER.DEC_ACCOUNT_OLD IS '老系统中的报单中心编号';
COMMENT ON COLUMN AR_USER.BANK_UPDATED_AT IS '银行信息更新时间';
COMMENT ON COLUMN AR_USER.IS_DIRECT_SELLER IS '是否为直销员';
COMMENT ON COLUMN AR_USER.DEC_LV_UPDATED_AT IS '报单级别更新时间';
COMMENT ON COLUMN AR_USER.DEC_LV_UPDATED_PERIOD IS '报单级别更新期数';
COMMENT ON COLUMN AR_USER.DEC_ADDRESS IS '报单中心详细地址';
COMMENT ON COLUMN AR_USER.DEC_PHONE IS '报单中心电话';
COMMENT ON COLUMN AR_USER.GUARANTOR IS '担保人编号';
COMMENT ON COLUMN AR_USER.GUARANTOR_NAME IS '担保人姓名';
COMMENT ON COLUMN AR_USER.PART_FUNC_CLOSED IS '部分功能开启';
COMMENT ON COLUMN AR_USER.LAST_DEC_LV_UPDATED_PERIOD IS '上次报单级别更新期数';
COMMENT ON COLUMN AR_USER.USER_CREATOR IS '创建人';
COMMENT ON COLUMN AR_USER.USER_UPDATER IS '修改人';
COMMENT ON COLUMN AR_USER.LAST_DEC_LV_UPDATED_AT IS '上次报单级别更新时间';
COMMENT ON COLUMN AR_USER.DEC_CREATED_AT IS '成为报单中心时间';
COMMENT ON COLUMN AR_USER.PART_FUNC_CLOSED_REMARK IS '部分功能关闭原因';
COMMENT ON COLUMN AR_USER.DEC_CREATED_PERIOD IS '成为报单中心期数';
COMMENT ON COLUMN AR_USER.PASSWORD_CHANGED IS '是否修改过密码';
COMMENT ON COLUMN AR_USER.SUB_COM_LEADER IS '是否为分公司领导';
COMMENT ON COLUMN AR_USER.LOGIN_FAIL_TIMES IS '登录失败次数';
COMMENT ON COLUMN AR_USER.ZG_UPGRADE_PV IS '增购升级PV';
COMMENT ON COLUMN AR_USER.APP_CLIENT_ID IS 'APP设备ID';
COMMENT ON COLUMN AR_USER.READ_AGREEMENT IS '已读协议';
COMMENT ON COLUMN AR_USER.LAST_DEC_LV IS '上次的报单级别';
COMMENT ON COLUMN AR_USER.BONUS_APP_CLIENT_ID IS '结算APP设备ID';
COMMENT ON COLUMN AR_USER.IS_FIRST_OPEN IS '首次开通';
ALTER TABLE `AR_USER` ADD UNIQUE INDEX `USER_NAME`(`USER_NAME`) USING BTREE;

INSERT INTO AR_USER (ID, USER_NAME, PASSWORD_HASH, PAY_PASSWORD, NATION, REAL_NAME, ID_CARD, ID_TYPE, MOBILE, ADDRESS, ID_IMAGE, OPEN_BANK, BANK_ADDRESS, BANK_NO, BANK_PROVINCE, BANK_CITY, BANK_COUNTY, SPOUSE_NAME, SPOUSE_IDCARD, CREATED_AT, UPDATED_AT, STATUS, DEC_CLOSED, DEC_CLOSED_AT, DEC_LV, EMP_LV, PROVINCE, CITY, COUNTY, TEL, LOGIN_TIMES, LOGIN_IP, LOGIN_AT, PULL_MESSAGE_AT, SUB_COM_ID, AVATAR, DELETED, DELETED_AT, ALLOW_TRANSFER, TRANSFER_PROP, PARTITION_DATE, IS_DEC, DEC_ID, BIRTHDAY, DEC_ROLE_ID, PERIOD_AT, DEC_PROVINCE, DEC_CITY, DEC_COUNTY, IS_UNION, STATUS_AT, VERIFIED, VERIFIED_AT, ALLOW_LOGIN, NOT_OPERATING, REG_FROM, ID_CARD_PREFIX, ALLOW_BONUS_LOGIN, SEX, DEC_ACCOUNT_OLD, BANK_UPDATED_AT, IS_DIRECT_SELLER, DEC_LV_UPDATED_AT, DEC_LV_UPDATED_PERIOD, DEC_ADDRESS, DEC_PHONE, GUARANTOR, GUARANTOR_NAME, PART_FUNC_CLOSED, LAST_DEC_LV_UPDATED_PERIOD, USER_CREATOR, USER_UPDATER, LAST_DEC_LV_UPDATED_AT, DEC_CREATED_AT, PART_FUNC_CLOSED_REMARK, DEC_CREATED_PERIOD, PASSWORD_CHANGED, SUB_COM_LEADER, LOGIN_FAIL_TIMES, ZG_UPGRADE_PV, APP_CLIENT_ID, READ_AGREEMENT, LAST_DEC_LV, BONUS_APP_CLIENT_ID, IS_FIRST_OPEN) VALUES ('670B84FD7C216D4EE055736AECE8644D', 'tester001', '$2y$10$26RZqjbcKbKmeLn5JZtqYON2CBCiGT76TX2cxyjT10eNjZ7CZBfTW', '$2y$10$P1m//xxOA1JP4aJ.7ZfqVe8de8Of1XJDnGBn3OfPVB.vUGcJX4OxS', 1, '新周静', '32038119770810152X', 0, '13333333333', '秦皇岛市东山街1000001号', 'http://upload.ar.wqcms.com/files/2018/0606/e0013022694b11e8b1af10ddb1d0e3fd', '0010000', '鸽子窝110号', '6222222222222220131', 130000, 130300, 130304, '瞬瞬', '130324198808081235', 1528770496, 1575450033, 1, 0, 0, '67ABCE0ECE705575E055736AECE8644D', '67BE1C6C21F81B32E055736AECE8644D', 110000, 110100, 110101, '13826545212', 2659, '106.118.113.61', 1578879390, 0, '953BF18AE3694BC4E053693418ACAC98', 'http://upload.ar.wqcms.com/cdn/avatar/1.png', 0, 0, 1, 1.01, '2018-06-12', 1, '670B84FD7C216D4EE055736AECE8644D', '1977-08-10', '810916A06B304162902408A6B9E5D177', 117, 130000, 130200, 130203, 0, 1565921409, 1, 1571797394, 1, 0, 0, null, 1, '女', null, 0, 0, 1573003331, 158, '123', '15098156582', null, null, 0, 0, 'adminty', 'adminty', 0, 1572337842, '报单中心货款/会员货款余额15132.00,600010.00高于参数"100.00"关闭', 158, 3, 0, 5, 12000.00, null, 1, '67ABCE0ECE705575E055736AECE8644D', null, 1);



-- 结算系统用到的会员其他资料
DROP TABLE IF EXISTS `AR_USER_INFO`;
CREATE TABLE AR_USER_INFO
(
  USER_ID     varchar(32)                    NOT NULL,
  USER_NAME   varchar(16)                    NOT NULL,
  ZC_PV       decimal(16,3) DEFAULT 0          NOT NULL,
  CON_UID     varchar(32)                    NOT NULL,
  REC_UID     varchar(32)                    NOT NULL,
  CON_NUM     int(10) DEFAULT 0            NOT NULL,
  REC_NUM     int(10) DEFAULT 0            NOT NULL,
  NETWORK_DEEP    int(10) DEFAULT 0        NOT NULL,
  RELATION_DEEP   int(10) DEFAULT 0        NOT NULL,
  SYSTEM_ID   varchar(32) ,
  IS_GROUP_LEADER  tinyint(1) DEFAULT 0        NOT NULL,
  IS_SYSTEM_LEADER  tinyint(1) DEFAULT 0       NOT NULL,
  IS_TEAM     tinyint(1) DEFAULT 0             NOT NULL,
  IS_BIND     tinyint(1) DEFAULT 0             NOT NULL,
  IS_TEAM_MAIN tinyint(1) DEFAULT 0            NOT NULL,
  IS_BIND_MAIN tinyint(1) DEFAULT 0            NOT NULL,
  IS_AUTO_WITHDRAW tinyint(1) DEFAULT 0        NOT NULL,
  CLOSE_LOGIN tinyint(1) DEFAULT 0             NOT NULL,
  REG_TYPE    varchar(32) DEFAULT '56D9181C0F5D428FA2DBD4CAB263BF2F' NOT NULL,
  SHOULD_REG_TYPE varchar(32) DEFAULT '56D9181C0F5D428FA2DBD4CAB263BF2F',
  REG_NAME    varchar(255) ,
  CREDIT_CODE varchar(255) ,
  PREMISES    varchar(255) ,
  LEGAL_PERSON varchar(255) ,
  REG_EXPIRES int(10) ,
  STORE_TYPE  tinyint(1) DEFAULT 0             NOT NULL,
  INVOICE_BALANCE  decimal(16,2) DEFAULT 0.00  NOT NULL,
  HIGHEST_EMP_LV varchar(32) ,
  CREATED_AT  int(10)                      NOT NULL,
  UPDATED_AT  int(10) DEFAULT 0            NOT NULL,
  CLOSE_LOGIN_AT  int(10) DEFAULT 0        NOT NULL,
  PULLED_AT   int(10) DEFAULT 0            NOT NULL,
  DELETED   tinyint(1) DEFAULT 0               NOT NULL,
  DELETED_AT   int(10) DEFAULT 0           NOT NULL,
  GROUP_LEADER_AT   int(10) DEFAULT 0      NOT NULL,
  ALLOW_TRANSFER tinyint(1) DEFAULT 1          NOT NULL,
  ALLOW_RECONSUME_SMS tinyint(1) DEFAULT 0          NOT NULL,
  ALLOW_RECONSUME_SMS_TO  int(10) DEFAULT 0        NOT NULL,
  HIGHEST_EMP_LV_PERIOD int(10) DEFAULT 1   NOT NULL,
  TRANSFER_PROP float(10,2) DEFAULT 100.00     NOT NULL,
  LOGIN_NUMS int(10) DEFAULT 0            NOT NULL,
  FAIL_NUMS int(10) DEFAULT 0            NOT NULL,
  LAST_LOGIN_IP varchar(16) DEFAULT '0.0.0.0' NOT NULL ,
  LAST_LOGIN_AT  int(10) DEFAULT 0                     NOT NULL,
  SHOW_EMP_LV     varchar(32) DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员资料表';
COMMENT ON COLUMN AR_USER_INFO.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_INFO.USER_NAME IS '会员名';
COMMENT ON COLUMN AR_USER_INFO.ZC_PV IS '注册单PV';
COMMENT ON COLUMN AR_USER_INFO.CON_UID IS '接点人ID';
COMMENT ON COLUMN AR_USER_INFO.REC_UID IS '推荐人ID';
COMMENT ON COLUMN AR_USER_INFO.CON_NUM IS '下级节点数量';
COMMENT ON COLUMN AR_USER_INFO.REC_NUM IS '开拓会员数量';
COMMENT ON COLUMN AR_USER_INFO.NETWORK_DEEP IS '安置网络深度';
COMMENT ON COLUMN AR_USER_INFO.RELATION_DEEP IS '开拓网络深度';
COMMENT ON COLUMN AR_USER_INFO.SYSTEM_ID IS '体系ID';
COMMENT ON COLUMN AR_USER_INFO.IS_GROUP_LEADER IS '是否团队领导人';
COMMENT ON COLUMN AR_USER_INFO.IS_SYSTEM_LEADER IS '是否体系领导人';
COMMENT ON COLUMN AR_USER_INFO.IS_TEAM IS '是否点位合作';
COMMENT ON COLUMN AR_USER_INFO.IS_BIND IS '是否点位绑定';
COMMENT ON COLUMN AR_USER_INFO.IS_TEAM_MAIN IS '是否点位合作主点';
COMMENT ON COLUMN AR_USER_INFO.IS_BIND_MAIN IS '是否点位绑定主点';
COMMENT ON COLUMN AR_USER_INFO.IS_AUTO_WITHDRAW IS '是否开启自动提现';
COMMENT ON COLUMN AR_USER_INFO.CLOSE_LOGIN IS '关闭结算系统登录';
COMMENT ON COLUMN AR_USER_INFO.REG_TYPE IS '注册类型';
COMMENT ON COLUMN AR_USER_INFO.SHOULD_REG_TYPE IS '应注册类型';
COMMENT ON COLUMN AR_USER_INFO.REG_NAME IS '注册名称';
COMMENT ON COLUMN AR_USER_INFO.CREDIT_CODE IS '信用代码';
COMMENT ON COLUMN AR_USER_INFO.PREMISES IS '经营场所';
COMMENT ON COLUMN AR_USER_INFO.LEGAL_PERSON IS '法人';
COMMENT ON COLUMN AR_USER_INFO.REG_EXPIRES IS '注册有效期';
COMMENT ON COLUMN AR_USER_INFO.STORE_TYPE IS '店铺类型';
COMMENT ON COLUMN AR_USER_INFO.INVOICE_BALANCE IS '发票余额';
COMMENT ON COLUMN AR_USER_INFO.HIGHEST_EMP_LV IS '历史最高聘级';
COMMENT ON COLUMN AR_USER_INFO.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_USER_INFO.UPDATED_AT IS '更新时间';
COMMENT ON COLUMN AR_USER_INFO.CLOSE_LOGIN_AT IS '禁止登录时间';
COMMENT ON COLUMN AR_USER_INFO.PULLED_AT IS '站内信拉取时间';
COMMENT ON COLUMN AR_USER_INFO.DELETED IS '是否删除';
COMMENT ON COLUMN AR_USER_INFO.DELETED_AT IS '删除时间';
COMMENT ON COLUMN AR_USER_INFO.GROUP_LEADER_AT IS '成为团队领导人的时间';
COMMENT ON COLUMN AR_USER_INFO.ALLOW_TRANSFER is '开启转账功能';
COMMENT ON COLUMN AR_USER_INFO.ALLOW_RECONSUME_SMS is '开启复销短信通知';
COMMENT ON COLUMN AR_USER_INFO.ALLOW_RECONSUME_SMS_TO is '开启复销短信通知有效期';
COMMENT ON COLUMN AR_USER_INFO.HIGHEST_EMP_LV_PERIOD is '首次达到最高聘级期数';
COMMENT ON COLUMN AR_USER_INFO.TRANSFER_PROP is '单笔转账比例';
COMMENT ON COLUMN AR_USER_INFO.LOGIN_NUMS IS '登录次数';
COMMENT ON COLUMN AR_USER_INFO.FAIL_NUMS IS '登录失败次数';
COMMENT ON COLUMN AR_USER_INFO.LAST_LOGIN_IP IS '上次登录IP';
COMMENT ON COLUMN AR_USER_INFO.LAST_LOGIN_AT IS '上次登录时间';
COMMENT ON COLUMN AR_USER_INFO.SHOW_EMP_LV IS '展示聘级';


ALTER TABLE `AR_USER_INFO` ADD UNIQUE INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_USER_INFO` ADD INDEX `USER_NAME_DELETED`(`USER_NAME`, `DELETED`) USING BTREE;
ALTER TABLE `AR_USER_INFO` ADD INDEX `NETWORK_DEEP`(`NETWORK_DEEP`) USING BTREE;
ALTER TABLE `AR_USER_INFO` ADD INDEX `RELATION_DEEP`(`RELATION_DEEP`) USING BTREE;
ALTER TABLE `AR_USER_INFO` ADD INDEX `REG_TYPE`(`REG_TYPE`) USING BTREE;

INSERT INTO AR_USER_INFO (USER_ID, USER_NAME, ZC_PV, CON_UID, REC_UID, CON_NUM, REC_NUM, NETWORK_DEEP, RELATION_DEEP, SYSTEM_ID, IS_AUTO_WITHDRAW, STORE_TYPE, CREATED_AT, UPDATED_AT) VALUES ('670B84FD7C216D4EE055736AECE8644D', 'tester001', 600.000, '0', '0', 11, 11, 0, 0, null, 1, 0, 1520667339, 0);


-- 点位合作
DROP TABLE IF EXISTS `AR_USER_TEAMWORK`;
CREATE TABLE AR_USER_TEAMWORK
(
  ID          varchar(32) NOT NULL,
  USER_ID     varchar(32)                    NOT NULL,
  MAIN_UID    varchar(32)                    NOT NULL,
  DIVIDE_PERCENT decimal(16,2) DEFAULT 0.00    NOT NULL,
  PERIOD_NUM  int(10)                      NOT NULL,
  IS_DEL      int(10) DEFAULT 0            NOT NULL,
  CREATE_ADMIN varchar(32)                   NOT NULL,
  UPDATE_ADMIN varchar(32),
  CREATE_REMARK text ,
  UPDATE_REMARK text ,
  CREATED_AT  int(10)                      NOT NULL,
  UPDATED_AT  int(10) DEFAULT 0            NOT NULL,
  UPDATED_PERIOD int(10) ,
  DELETED_AT  int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='点位合作';
COMMENT ON COLUMN AR_USER_TEAMWORK.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_TEAMWORK.MAIN_UID IS '主会员ID';
COMMENT ON COLUMN AR_USER_TEAMWORK.DIVIDE_PERCENT IS '分成比例';
COMMENT ON COLUMN AR_USER_TEAMWORK.PERIOD_NUM IS '加入时期数';
COMMENT ON COLUMN AR_USER_TEAMWORK.IS_DEL IS '是否删除';
COMMENT ON COLUMN AR_USER_TEAMWORK.CREATE_ADMIN IS '创建人';
COMMENT ON COLUMN AR_USER_TEAMWORK.UPDATE_ADMIN IS '修改人';
COMMENT ON COLUMN AR_USER_TEAMWORK.CREATE_REMARK IS '创建备注';
COMMENT ON COLUMN AR_USER_TEAMWORK.UPDATE_REMARK IS '修改备注';
COMMENT ON COLUMN AR_USER_TEAMWORK.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_USER_TEAMWORK.UPDATED_AT IS '修改时间';
COMMENT ON COLUMN AR_USER_TEAMWORK.UPDATED_PERIOD IS '修改期数';
COMMENT ON COLUMN AR_USER_TEAMWORK.DELETED_AT IS '已删除';

ALTER TABLE `AR_USER_TEAMWORK` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_USER_TEAMWORK` ADD INDEX `MAIN_UID`(`MAIN_UID`) USING BTREE;

-- 点位绑定
DROP TABLE IF EXISTS `AR_USER_BIND`;
CREATE TABLE AR_USER_BIND
(
  ID          varchar(32) NOT NULL,
  USER_ID     varchar(32)                    NOT NULL,
  MAIN_UID    varchar(32)                    NOT NULL,
  PERIOD_NUM  int(10)                      NOT NULL,
  IS_DEL      int(10) DEFAULT 0            NOT NULL,
  CREATE_ADMIN varchar(32),
  UPDATE_ADMIN varchar(32),
  CREATE_USER varchar(32),
  UPDATE_USER varchar(32),
  CREATED_AT  int(10)                      NOT NULL,
  UPDATED_AT  int(10) DEFAULT 0            NOT NULL,
  DELETED_AT  int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='点位合作';
COMMENT ON COLUMN AR_USER_BIND.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_BIND.MAIN_UID IS '主会员ID';
COMMENT ON COLUMN AR_USER_BIND.PERIOD_NUM IS '加入时期数';
COMMENT ON COLUMN AR_USER_BIND.IS_DEL IS '是否删除';
COMMENT ON COLUMN AR_USER_BIND.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_USER_BIND.DELETED_AT IS '已删除';

ALTER TABLE `AR_USER_BIND` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_USER_BIND` ADD INDEX `MAIN_UID`(`MAIN_UID`) USING BTREE;

-- 会员奖金表
DROP TABLE IF EXISTS `AR_USER_BONUS`;
CREATE TABLE AR_USER_BONUS
(
  USER_ID     varchar(32)                    NOT NULL,
  BONUS       decimal(16,2) DEFAULT 0          NOT NULL,
  BONUS_FREEZE decimal(16,2) DEFAULT 0         NOT NULL,
  CF          decimal(16,2) DEFAULT 0          NOT NULL,
  LX          decimal(16,2) DEFAULT 0          NOT NULL,
  QY_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  YC_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  FX_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  LS_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  FW_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  BT_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  BT_PROD_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  BT_TOOL_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  CF_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  LX_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  DEDUCT_ZR_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  FL_TOTAL    decimal(16,2) DEFAULT 0          NOT NULL,
  VER         int(10) DEFAULT 0            NOT NULL,
  CREATED_AT  int(10)                      NOT NULL,
	KEY `USER_ID`(`USER_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员奖金表';
COMMENT ON COLUMN AR_USER_BONUS.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_BONUS.BONUS IS '奖金总额';
COMMENT ON COLUMN AR_USER_BONUS.BONUS_FREEZE IS '奖金冻结部分';
COMMENT ON COLUMN AR_USER_BONUS.CF IS '车房养老奖';
COMMENT ON COLUMN AR_USER_BONUS.LX IS '领袖分红奖';
COMMENT ON COLUMN AR_USER_BONUS.QY_TOTAL IS '区域津贴累计';
COMMENT ON COLUMN AR_USER_BONUS.YC_TOTAL IS '育成津贴累计';
COMMENT ON COLUMN AR_USER_BONUS.FX_TOTAL IS '复销奖累计';
COMMENT ON COLUMN AR_USER_BONUS.LS_TOTAL IS '零售奖累计';
COMMENT ON COLUMN AR_USER_BONUS.FW_TOTAL IS '区级店业绩提成累计';
COMMENT ON COLUMN AR_USER_BONUS.BT_TOTAL IS '店补累计';
COMMENT ON COLUMN AR_USER_BONUS.BT_PROD_TOTAL IS '产品补贴累计';
COMMENT ON COLUMN AR_USER_BONUS.BT_TOOL_TOTAL IS '工具流补贴累计';
COMMENT ON COLUMN AR_USER_BONUS.CF_TOTAL IS '车房养老奖累计';
COMMENT ON COLUMN AR_USER_BONUS.LX_TOTAL IS '领袖分红累计';
COMMENT ON COLUMN AR_USER_BONUS.DEDUCT_ZR_TOTAL IS '责任业绩扣除累计';
COMMENT ON COLUMN AR_USER_BONUS.FL_TOTAL IS '形象店货补累计';
COMMENT ON COLUMN AR_USER_BONUS.VER IS '乐观锁标识';
COMMENT ON COLUMN AR_USER_BONUS.CREATED_AT IS '创建时间';

-- 会员关停和停发表
DROP TABLE IF EXISTS `AR_USER_CLOSE`;
CREATE TABLE AR_USER_CLOSE
(
  ID          varchar(32) NOT NULL,
  USER_ID     varchar(32)                    NOT NULL,
  TYPE        tinyint(1) DEFAULT 1             NOT NULL,
  IS_MANUAL   tinyint(1) DEFAULT 0             NOT NULL,
  PERIOD_NUM  int(10)                      NOT NULL,
  IS_CLOSE    tinyint(1) DEFAULT 1             NOT NULL,
  REMARK      varchar(255)                   NOT NULL,
  AUDIT_STATUS tinyint(1) DEFAULT 0            NOT NULL,
  ADMIN_ID    varchar(32) ,
  AUDIT_ADMIN_ID varchar(32) ,
  AUDITED_AT  int(10) ,
  CREATED_AT  int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员关停和停发表';
COMMENT ON COLUMN AR_USER_CLOSE.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_CLOSE.TYPE IS '类型';
COMMENT ON COLUMN AR_USER_CLOSE.IS_MANUAL IS '是否手动操作';
COMMENT ON COLUMN AR_USER_CLOSE.PERIOD_NUM IS '期数';
COMMENT ON COLUMN AR_USER_CLOSE.IS_CLOSE IS '停|开';
COMMENT ON COLUMN AR_USER_CLOSE.REMARK IS '备注';
COMMENT ON COLUMN AR_USER_CLOSE.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_USER_CLOSE.ADMIN_ID IS '操作管理员';
COMMENT ON COLUMN AR_USER_CLOSE.AUDIT_ADMIN_ID IS '审核管理员';
COMMENT ON COLUMN AR_USER_CLOSE.AUDITED_AT IS '审核时间';
COMMENT ON COLUMN AR_USER_CLOSE.CREATED_AT IS '创建时间';

ALTER TABLE `AR_USER_CLOSE` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_USER_CLOSE` ADD INDEX `TYPE`(`TYPE`) USING BTREE;
ALTER TABLE `AR_USER_CLOSE` ADD INDEX `PERIOD_NUM`(`PERIOD_NUM`) USING BTREE;
ALTER TABLE `AR_USER_CLOSE` ADD INDEX `IS_CLOSE`(`IS_CLOSE`) USING BTREE;
ALTER TABLE `AR_USER_CLOSE` ADD INDEX `AUDIT_STATUS`(`AUDIT_STATUS`) USING BTREE;

-- 会员安置关系表
DROP TABLE IF EXISTS `AR_USER_NETWORK`;
CREATE TABLE AR_USER_NETWORK
(
  ID          varchar(32) NOT NULL,
  USER_ID         varchar(32)                    NOT NULL,
  PARENT_UID  varchar(32)                    NOT NULL,
  LOCATION    tinyint(1)                       NOT NULL,
  TOP_UID     varchar(32)                    NOT NULL,
  TOP_DEEP    int(10)                      NOT NULL,
  PERIOD_NUM      int(10)                      NOT NULL,
  CREATED_AT  int(10)                      NOT NULL,
  UPDATED_AT  int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='安置关系表';
COMMENT ON COLUMN AR_USER_NETWORK.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_NETWORK.PARENT_UID IS '相对上级会员ID';
COMMENT ON COLUMN AR_USER_NETWORK.LOCATION IS '相对上级会员区位';
COMMENT ON COLUMN AR_USER_NETWORK.TOP_UID IS '顶端会员ID';
COMMENT ON COLUMN AR_USER_NETWORK.TOP_DEEP IS '距离顶端会员深度';
COMMENT ON COLUMN AR_USER_NETWORK.PERIOD_NUM IS '加入时的期数';
COMMENT ON COLUMN AR_USER_NETWORK.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_USER_NETWORK.UPDATED_AT IS '更新时间';

ALTER TABLE `AR_USER_NETWORK` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_USER_NETWORK` ADD INDEX `PARENT_UID`(`PARENT_UID`) USING BTREE;
ALTER TABLE `AR_USER_NETWORK` ADD INDEX `LOCATION`(`LOCATION`) USING BTREE;
ALTER TABLE `AR_USER_NETWORK` ADD INDEX `TOP_DEEP`(`TOP_DEEP`) USING BTREE;
ALTER TABLE `AR_USER_NETWORK` ADD INDEX `PERIOD_NUM`(`PERIOD_NUM`) USING BTREE;

INSERT INTO AR_USER_NETWORK (ID, USER_ID, PARENT_UID, LOCATION, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('8F793577F2A44947A5918852976AE290', '670B84FD7C216D4EE055736AECE8644D', '0', 0, '670B84FD7C216D4EE055736AECE8644D', 0, 100, 1522378282, 0);


-- 会员开拓关系
DROP TABLE IF EXISTS `AR_USER_RELATION`;
CREATE TABLE AR_USER_RELATION
(
  ID          varchar(32) NOT NULL,
  USER_ID         varchar(32)                    NOT NULL,
  PARENT_UID  varchar(32)                    NOT NULL,
  TOP_UID     varchar(32)                    NOT NULL,
  TOP_DEEP    int(10)                      NOT NULL,
  PERIOD_NUM      int(10)                      NOT NULL,
  CREATED_AT  int(10)                      NOT NULL,
  UPDATED_AT  int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='开拓关系表';
COMMENT ON COLUMN AR_USER_RELATION.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_RELATION.PARENT_UID IS '相对上级会员ID';
COMMENT ON COLUMN AR_USER_RELATION.TOP_UID IS '顶端会员ID';
COMMENT ON COLUMN AR_USER_RELATION.TOP_DEEP IS '距离顶端会员深度';
COMMENT ON COLUMN AR_USER_RELATION.PERIOD_NUM IS '加入时的期数';
COMMENT ON COLUMN AR_USER_RELATION.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_USER_RELATION.UPDATED_AT IS '更新时间';

ALTER TABLE `AR_USER_RELATION` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_USER_RELATION` ADD INDEX `PARENT_UID`(`PARENT_UID`) USING BTREE;
ALTER TABLE `AR_USER_RELATION` ADD INDEX `TOP_DEEP`(`TOP_DEEP`) USING BTREE;
ALTER TABLE `AR_USER_RELATION` ADD INDEX `PERIOD_NUM`(`PERIOD_NUM`) USING BTREE;

INSERT INTO AR_USER_RELATION (ID, USER_ID, PARENT_UID, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('EF010C38C7144BD0844593A1FF8AC7AD', '670B84FD7C216D4EE055736AECE8644D', '0', '670B84FD7C216D4EE055736AECE8644D', 0, 100, 1522378282, 0);


-- 会员体系
DROP TABLE IF EXISTS `AR_USER_SYSTEM`;
CREATE TABLE AR_USER_SYSTEM
(
  ID          varchar(32) NOT NULL,
  SYSTEM_NAME varchar(32)                    NOT NULL,
  LEADER_UID  varchar(32)                    NOT NULL,
  PERIOD_NUM  int(10)                      NOT NULL,
  UPDATE_PERIOD_NUM  int(10) ,
  CREATE_ADMIN varchar(32)                   NOT NULL,
  UPDATE_ADMIN varchar(32) ,
  CREATE_REMARK  text ,
  UPDATE_REMARK  text ,
  IS_DEL      tinyint(1) DEFAULT 0             NOT NULL,
  CREATED_AT  int(10)                      NOT NULL,
  UPDATED_AT  int(10) DEFAULT 0            NOT NULL,
  DELETED_AT  int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员体系';
COMMENT ON COLUMN AR_USER_SYSTEM.SYSTEM_NAME IS '体系名称';
COMMENT ON COLUMN AR_USER_SYSTEM.LEADER_UID IS '领导人ID';
COMMENT ON COLUMN AR_USER_SYSTEM.PERIOD_NUM IS '加入时的期数';
COMMENT ON COLUMN AR_USER_SYSTEM.UPDATE_PERIOD_NUM IS '修改期数';
COMMENT ON COLUMN AR_USER_SYSTEM.CREATE_ADMIN IS '创建人';
COMMENT ON COLUMN AR_USER_SYSTEM.UPDATE_ADMIN IS '修改人';
COMMENT ON COLUMN AR_USER_SYSTEM.CREATE_REMARK IS '备注';
COMMENT ON COLUMN AR_USER_SYSTEM.UPDATE_REMARK IS '备注';
COMMENT ON COLUMN AR_USER_SYSTEM.IS_DEL IS '是否删除';
COMMENT ON COLUMN AR_USER_SYSTEM.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_USER_SYSTEM.UPDATED_AT IS '更新时间';
COMMENT ON COLUMN AR_USER_SYSTEM.DELETED_AT IS '删除时间';

ALTER TABLE `AR_USER_SYSTEM` ADD UNIQUE INDEX `SYSTEM_NAME`(`SYSTEM_NAME`) USING BTREE;
ALTER TABLE `AR_USER_SYSTEM` ADD UNIQUE INDEX `LEADER_UID`(`LEADER_UID`) USING BTREE;


-- 会员移网记录
DROP TABLE IF EXISTS `AR_USER_MOVE`;
CREATE TABLE AR_USER_MOVE
(
  ID          varchar(32) NOT NULL,
  USER_ID     varchar(32)                    NOT NULL,
  FROM_UID    varchar(32)                    NOT NULL,
  TO_UID      varchar(32)                    NOT NULL,
  LOCATION    tinyint(1) DEFAULT 0             NOT NULL,
  TYPE        varchar(48)                    NOT NULL,
  IS_MOVING   tinyint(1) DEFAULT 0             NOT NULL,
  MOVE_PERCENT  tinyint(3) DEFAULT 0           NOT NULL,
  AUDIT_STATUS tinyint(1) DEFAULT 0            NOT NULL,
  PERIOD_NUM  int(10)                      NOT NULL,
  UPDATE_PERIOD_NUM  int(10),
  AUDIT_PERIOD_NUM  int(10),
  MOVE_ADMIN_ID varchar(32)                  NOT NULL,
  AUDIT_ADMIN_ID varchar(32) ,
  NET_TABLE_NAME varchar(32) ,
  CREATE_REMARK  text ,
  AUDIT_REMARK  text ,
  CREATED_AT  int(10)                      NOT NULL,
  STARTED_AT  int(10) DEFAULT 0            NOT NULL,
  ENDED_AT    int(10) DEFAULT 0            NOT NULL,
  AUDITED_AT  int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员移网记录';
COMMENT ON COLUMN AR_USER_MOVE.USER_ID IS '移动的会员ID';
COMMENT ON COLUMN AR_USER_MOVE.FROM_UID IS '移动前接点UID';
COMMENT ON COLUMN AR_USER_MOVE.TO_UID IS '移动后接点UID';
COMMENT ON COLUMN AR_USER_MOVE.LOCATION IS '移动到位置';
COMMENT ON COLUMN AR_USER_MOVE.TYPE IS '移网类型';
COMMENT ON COLUMN AR_USER_MOVE.IS_MOVING IS '是否正在移动';
COMMENT ON COLUMN AR_USER_MOVE.MOVE_PERCENT IS '移动百分比';
COMMENT ON COLUMN AR_USER_MOVE.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_USER_MOVE.PERIOD_NUM IS '移动时的期数';
COMMENT ON COLUMN AR_USER_MOVE.UPDATE_PERIOD_NUM IS '修改期数';
COMMENT ON COLUMN AR_USER_MOVE.AUDIT_PERIOD_NUM IS '修改期数';
COMMENT ON COLUMN AR_USER_MOVE.MOVE_ADMIN_ID IS '移网管理员';
COMMENT ON COLUMN AR_USER_MOVE.AUDIT_ADMIN_ID IS '审核管理员';
COMMENT ON COLUMN AR_USER_MOVE.NET_TABLE_NAME IS '移点备份表名';
COMMENT ON COLUMN AR_USER_MOVE.CREATE_REMARK IS '创建备注';
COMMENT ON COLUMN AR_USER_MOVE.AUDIT_REMARK IS '审核备注';
COMMENT ON COLUMN AR_USER_MOVE.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_USER_MOVE.STARTED_AT IS '移网开始时间';
COMMENT ON COLUMN AR_USER_MOVE.ENDED_AT IS '移网结束时间';
COMMENT ON COLUMN AR_USER_MOVE.AUDITED_AT IS '审核时间';

-- 会员累计业绩
DROP TABLE IF EXISTS `AR_USER_PERF`;
CREATE TABLE AR_USER_PERF
(
  USER_ID       varchar(32)                    NOT NULL,
  PV_PCS_ZC     decimal(16,2) DEFAULT 0          NOT NULL,
  PV_PCS_YH     decimal(16,2) DEFAULT 0          NOT NULL,
  PV_PCS_ZG     decimal(16,2) DEFAULT 0          NOT NULL,
  PV_PCS_LS     decimal(16,2) DEFAULT 0          NOT NULL,
  PV_PCS_FX     decimal(16,2) DEFAULT 0          NOT NULL,
  PV_1L         decimal(16,2) DEFAULT 0          NOT NULL,
  PV_2L         decimal(16,2) DEFAULT 0          NOT NULL,
  PV_3L         decimal(16,2) DEFAULT 0          NOT NULL,
  PV_4L         decimal(16,2) DEFAULT 0          NOT NULL,
  PV_5L         decimal(16,2) DEFAULT 0          NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
	KEY `USER_ID`(`USER_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员累计业绩表';
COMMENT ON COLUMN AR_USER_PERF.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_PERF.PV_PCS_ZC IS '个人注册单累计';
COMMENT ON COLUMN AR_USER_PERF.PV_PCS_YH IS '个人优惠单累计';
COMMENT ON COLUMN AR_USER_PERF.PV_PCS_ZG IS '个人增购单累计';
COMMENT ON COLUMN AR_USER_PERF.PV_PCS_LS IS '个人零售单累计';
COMMENT ON COLUMN AR_USER_PERF.PV_PCS_FX IS '个人复销单累计';
COMMENT ON COLUMN AR_USER_PERF.PV_1L IS '一市场累计业绩';
COMMENT ON COLUMN AR_USER_PERF.PV_2L IS '二市场累计业绩';
COMMENT ON COLUMN AR_USER_PERF.PV_3L IS '三市场累计业绩';
COMMENT ON COLUMN AR_USER_PERF.PV_4L IS '四市场累计业绩';
COMMENT ON COLUMN AR_USER_PERF.PV_5L IS '五市场累计业绩';
COMMENT ON COLUMN AR_USER_PERF.CREATED_AT IS '创建时间';

-- 会员累计业绩更新期数
DROP TABLE IF EXISTS `AR_USER_PERF_UPDATE`;
CREATE TABLE AR_USER_PERF_UPDATE
(
    ID          varchar(32) NOT NULL,
    USER_ID       varchar(32)              NOT NULL,
    PERIOD_NUM    int(10) DEFAULT 0      NOT NULL,
    P_CALC_MONTH  DATE                      NOT NULL,
    CREATED_AT    int(10)                NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员累计业绩更新期数';
COMMENT ON COLUMN AR_USER_PERF_UPDATE.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_PERF_UPDATE.PERIOD_NUM IS '更新时的期数';
COMMENT ON COLUMN AR_USER_PERF_UPDATE.P_CALC_MONTH IS '更新时的结算月';
COMMENT ON COLUMN AR_USER_PERF_UPDATE.CREATED_AT IS '创建时间';
ALTER TABLE `AR_USER_PERF_UPDATE` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;

-- 报单级别变动
DROP TABLE IF EXISTS `AR_DEC_LEVEL_LOG`;
CREATE TABLE AR_DEC_LEVEL_LOG
(
  ID         varchar(32) NOT NULL,
  USER_ID    varchar(32)                    NOT NULL,
  FROM_ID    varchar(32)                    NOT NULL,
  TO_ID      varchar(32)                    NOT NULL,
  PERIOD_NUM int(10)                      NOT NULL,
  CALC_MONTH int(10)                      NOT NULL,
  REMARK     text                  NOT NULL,
  ADMIN_ID   varchar(32)  DEFAULT ''        NOT NULL,
  STATUS     tinyint(1) DEFAULT 0             NOT NULL,
  CREATED_AT int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='报单级别变动记录';
COMMENT ON COLUMN AR_DEC_LEVEL_LOG.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_DEC_LEVEL_LOG.FROM_ID IS '变动前的级别';
COMMENT ON COLUMN AR_DEC_LEVEL_LOG.TO_ID IS '变动后的级别';
COMMENT ON COLUMN AR_DEC_LEVEL_LOG.PERIOD_NUM IS '变动的期数';
COMMENT ON COLUMN AR_DEC_LEVEL_LOG.CALC_MONTH IS '变动的结算月';
COMMENT ON COLUMN AR_DEC_LEVEL_LOG.REMARK IS '备注';
COMMENT ON COLUMN AR_DEC_LEVEL_LOG.ADMIN_ID IS '管理员ID';
COMMENT ON COLUMN AR_DEC_LEVEL_LOG.STATUS IS '状态';
COMMENT ON COLUMN AR_DEC_LEVEL_LOG.CREATED_AT IS '创建时间';

ALTER TABLE `AR_DEC_LEVEL_LOG` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_DEC_LEVEL_LOG` ADD INDEX `PERIOD_NUM`(`PERIOD_NUM`) USING BTREE;
ALTER TABLE `AR_DEC_LEVEL_LOG` ADD INDEX `STATUS`(`STATUS`) USING BTREE;


-- 聘级变动记录表
DROP TABLE IF EXISTS `AR_EMPLOY_LEVEL_LOG`;
CREATE TABLE AR_EMPLOY_LEVEL_LOG
(
  ID         varchar(32) NOT NULL,
  USER_ID    varchar(32)                    NOT NULL,
  FROM_ID    varchar(32)                    NOT NULL,
  TO_ID      varchar(32)                    NOT NULL,
  PERIOD_NUM int(10)                      NOT NULL,
  CALC_MONTH int(10)                      NOT NULL,
  P_CALC_MONTH DATE                          NOT NULL,
  REMARK     text ,
  CREATED_AT int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='聘级变动记录表';
COMMENT ON COLUMN AR_EMPLOY_LEVEL_LOG.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_EMPLOY_LEVEL_LOG.FROM_ID IS '变动前的级别';
COMMENT ON COLUMN AR_EMPLOY_LEVEL_LOG.TO_ID IS '变动后的级别';
COMMENT ON COLUMN AR_EMPLOY_LEVEL_LOG.PERIOD_NUM IS '变动时的期数';
COMMENT ON COLUMN AR_EMPLOY_LEVEL_LOG.CALC_MONTH IS '变动时的结算月';
COMMENT ON COLUMN AR_EMPLOY_LEVEL_LOG.P_CALC_MONTH IS '表分区标识';
COMMENT ON COLUMN AR_EMPLOY_LEVEL_LOG.REMARK IS '备注';
COMMENT ON COLUMN AR_EMPLOY_LEVEL_LOG.CREATED_AT IS '创建时间';

-- 注册类型
DROP TABLE IF EXISTS `AR_REG_TYPE`;
CREATE TABLE AR_REG_TYPE
(
  ID          varchar(32) NOT NULL,
  TYPE_NAME   varchar(48)                    NOT NULL,
  IS_PACT     tinyint(1)  DEFAULT 1            NOT NULL,
  MONTH_LIMIT_AMOUNT   decimal(16,2)  DEFAULT 0           NOT NULL,
  YEAR_LIMIT_AMOUNT   decimal(16,2)  DEFAULT 0           NOT NULL,
  SORT        int(10)  DEFAULT 0           NOT NULL,
  CREATE_ADMIN varchar(32) ,
  UPDATE_ADMIN varchar(32) ,
  REMARK      varchar(255) ,
  CREATED_AT  int(10)                      NOT NULL,
  UPDATED_AT  int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='聘级';
COMMENT ON COLUMN AR_REG_TYPE.TYPE_NAME IS '类型名称';
COMMENT ON COLUMN AR_REG_TYPE.IS_PACT IS '是否启用协议';
COMMENT ON COLUMN AR_REG_TYPE.MONTH_LIMIT_AMOUNT IS '达到月提现金额升级应注册类型';
COMMENT ON COLUMN AR_REG_TYPE.YEAR_LIMIT_AMOUNT IS '达到年提现金额升级应注册类型';
COMMENT ON COLUMN AR_REG_TYPE.SORT IS '排序';
COMMENT ON COLUMN AR_REG_TYPE.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_REG_TYPE.UPDATED_AT IS '更新时间';

ALTER TABLE `AR_REG_TYPE` ADD UNIQUE INDEX `TYPE_NAME`(`TYPE_NAME`) USING BTREE;

INSERT INTO AR_REG_TYPE (ID, TYPE_NAME, SORT, CREATED_AT, UPDATED_AT) VALUES ('56D9181C0F5D428FA2DBD4CAB263BF2F', '个人', 1, 1521438677, 0);
INSERT INTO AR_REG_TYPE (ID, TYPE_NAME, SORT, CREATED_AT, UPDATED_AT) VALUES ('28359A005A3E44C6816A4A7E994B7789', '个体工商户', 2, 1521438677, 0);
INSERT INTO AR_REG_TYPE (ID, TYPE_NAME, SORT, CREATED_AT, UPDATED_AT) VALUES ('758BF69C25C3422AA7743936BC77EE64', '公司', 3, 1521438677, 0);


-- 期数
DROP TABLE IF EXISTS `AR_PERIOD`;
CREATE TABLE AR_PERIOD
(
  ID            varchar(32) NOT NULL,
  PERIOD_NUM    int(10)                      NOT NULL,
  CALC_MONTH    tinyint(2)                       NOT NULL,
  CALC_YEAR     tinyint(4)                       NOT NULL,
  START_TIME    int(10)                      NOT NULL,
  END_TIME      int(10)                      NOT NULL,
  IS_MONTH      tinyint(1) DEFAULT 0             NOT NULL,
  IS_YEAR       tinyint(1) DEFAULT 0             NOT NULL,
  IS_CLOSED     tinyint(1) DEFAULT 0             NOT NULL,
  IS_PERFED     tinyint(1) DEFAULT 0             NOT NULL,
  IS_CALCULATED tinyint(1) DEFAULT 0             NOT NULL,
  IS_SENT       tinyint(1) DEFAULT 0             NOT NULL,
  IS_PERFING    tinyint(1) DEFAULT 0             NOT NULL,
  IS_CALCING    tinyint(1) DEFAULT 0             NOT NULL,
  IS_SENDING    tinyint(1) DEFAULT 0             NOT NULL,
  PERF_PERCENT  tinyint(3) DEFAULT 0             NOT NULL,
  CALC_PERCENT  tinyint(3) DEFAULT 0             NOT NULL,
  SENT_PERCENT  tinyint(3) DEFAULT 0             NOT NULL,
  PERF_ADMIN_ID varchar(32) ,
  CLOSE_ADMIN_ID varchar(32) ,
  CALC_ADMIN_ID varchar(32) ,
  SENT_ADMIN_ID varchar(32) ,
  CLOSED_AT     int(10) ,
  PERF_STARTED_AT int(10) DEFAULT 0          NOT NULL,
  PERFED_AT     int(10) DEFAULT 0            NOT NULL,
  CALCULATE_STARTED_AT int(10) DEFAULT 0     NOT NULL,
  CALCULATED_AT int(10) DEFAULT 0            NOT NULL,
  SEND_STARTED_AT int(10) DEFAULT 0          NOT NULL,
  SENT_AT       int(10) DEFAULT 0            NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='期数';
COMMENT ON COLUMN AR_PERIOD.PERIOD_NUM IS '期数';
COMMENT ON COLUMN AR_PERIOD.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_PERIOD.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_PERIOD.START_TIME IS '期数开始时间戳';
COMMENT ON COLUMN AR_PERIOD.END_TIME IS '期数结束时间戳';
COMMENT ON COLUMN AR_PERIOD.IS_MONTH IS '是否结算月节点';
COMMENT ON COLUMN AR_PERIOD.IS_YEAR IS '是否结算年节点';
COMMENT ON COLUMN AR_PERIOD.IS_CLOSED IS '是否已封期';
COMMENT ON COLUMN AR_PERIOD.IS_PERFED IS '是否已生成业绩单';
COMMENT ON COLUMN AR_PERIOD.IS_CALCULATED IS '是否已结算';
COMMENT ON COLUMN AR_PERIOD.IS_SENT IS '是否已发放';
COMMENT ON COLUMN AR_PERIOD.IS_PERFING IS '是否正在生成业绩单';
COMMENT ON COLUMN AR_PERIOD.IS_CALCING IS '是否正在计算状态';
COMMENT ON COLUMN AR_PERIOD.IS_SENDING IS '是否正在挂网状态';
COMMENT ON COLUMN AR_PERIOD.PERF_PERCENT IS '生成业绩单进度';
COMMENT ON COLUMN AR_PERIOD.CALC_PERCENT IS '结算进度';
COMMENT ON COLUMN AR_PERIOD.SENT_PERCENT IS '发放进度';
COMMENT ON COLUMN AR_PERIOD.PERF_ADMIN_ID IS '生成业绩单管理员';
COMMENT ON COLUMN AR_PERIOD.CLOSE_ADMIN_ID IS '手动封期管理员ID';
COMMENT ON COLUMN AR_PERIOD.CALC_ADMIN_ID IS '结算管理员ID';
COMMENT ON COLUMN AR_PERIOD.SENT_ADMIN_ID IS '发放管理员ID';
COMMENT ON COLUMN AR_PERIOD.CLOSED_AT IS '发放管理员ID';
COMMENT ON COLUMN AR_PERIOD.PERF_STARTED_AT IS '生成业绩单开始时间';
COMMENT ON COLUMN AR_PERIOD.PERFED_AT IS '生成业绩单结束时间';
COMMENT ON COLUMN AR_PERIOD.CALCULATE_STARTED_AT IS '结算开始时间';
COMMENT ON COLUMN AR_PERIOD.CALCULATED_AT IS '结算完成时间';
COMMENT ON COLUMN AR_PERIOD.SEND_STARTED_AT IS '发放开始时间';
COMMENT ON COLUMN AR_PERIOD.SENT_AT IS '发放完成时间';
COMMENT ON COLUMN AR_PERIOD.CREATED_AT IS '创建时间';

ALTER TABLE `AR_PERIOD` ADD UNIQUE INDEX `PERIOD_NUM`(`PERIOD_NUM`) USING BTREE;
ALTER TABLE `AR_PERIOD` ADD INDEX `IS_CLOSED`(`IS_CLOSED`) USING BTREE;
ALTER TABLE `AR_PERIOD` ADD INDEX `IS_PERFED`(`IS_PERFED`) USING BTREE;
ALTER TABLE `AR_PERIOD` ADD INDEX `IS_CALCULATED`(`IS_CALCULATED`) USING BTREE;
ALTER TABLE `AR_PERIOD` ADD INDEX `IS_SENT`(`IS_SENT`) USING BTREE;
ALTER TABLE `AR_PERIOD` ADD INDEX `IS_PERFING`(`IS_PERFING`) USING BTREE;
ALTER TABLE `AR_PERIOD` ADD INDEX `IS_CALCING`(`IS_CALCING`) USING BTREE;
ALTER TABLE `AR_PERIOD` ADD INDEX `IS_SENDING`(`IS_SENDING`) USING BTREE;

-- 会员提供的税票
DROP TABLE IF EXISTS `AR_BILL`;
CREATE TABLE AR_BILL
(
  ID            varchar(32) NOT NULL,
  USER_ID           varchar(32)                    NOT NULL,
  BILL_NO       varchar(255)                   NOT NULL,
  BILL_AMOUNT   float(16, 2) DEFAULT 0.00      NOT NULL,
  USED_AMOUNT   float(16, 2) DEFAULT 0.00      NOT NULL,
  EXPIRY_DATE   int(10)                      NOT NULL,
  INPUT_ADMIN_ID varchar(32),
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员提供的税票';
COMMENT ON COLUMN AR_BILL.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_BILL.BILL_NO IS '发票号';
COMMENT ON COLUMN AR_BILL.BILL_AMOUNT IS '发票金额';
COMMENT ON COLUMN AR_BILL.USED_AMOUNT IS '已用金额';
COMMENT ON COLUMN AR_BILL.EXPIRY_DATE IS '有效期';
COMMENT ON COLUMN AR_BILL.INPUT_ADMIN_ID IS '录入管理员ID';
COMMENT ON COLUMN AR_BILL.CREATED_AT IS '创建时间';

-- 提现申请
DROP TABLE IF EXISTS `AR_WITHDRAW`;
CREATE TABLE AR_WITHDRAW
(
  ID              varchar(32) NOT NULL,
  SN              varchar(32),
  USER_ID         varchar(32)                    NOT NULL,
  ID_CARD         varchar(20) ,
  WITHDRAW_PERIOD_NUM int(10),
  WITHDRAW_YEAR   tinyint(4),
  WITHDRAW_MONTH  tinyint(2),
  PAY_TYPE        tinyint(1)  DEFAULT 1            NOT NULL,
  IS_AUTO_WITHDRAW tinyint(1) DEFAULT 0            NOT NULL,
  AMOUNT          float(16, 2) DEFAULT 0.00      NOT NULL,
  INVOICE_ID      varchar(32),
  REAL_NAME       varchar(255),
  OPEN_BANK       varchar(32),
  BANK_ADDRESS    varchar(255),
  BANK_NO         varchar(32),
  BANK_PROVINCE   int(6),
  BANK_CITY       int(6),
  BANK_COUNTY     int(6),
  P_MONTH         DATE                            NOT NULL,
  AUDIT_STATUS    tinyint(1) DEFAULT 0             NOT NULL,
  REMARK          text,
  UPDATE_ADMIN    varchar(32),
  UPDATE_REMARK   text,
  AUDIT_ADMIN     varchar(32),
  CREATED_AT      int(10)                      NOT NULL,
  UPDATED_AT      int(10) DEFAULT 0            NOT NULL,
  AUDITED_AT      int(10) DEFAULT 0            NOT NULL,
  PLAN_PAID_AT    int(10)                      NOT NULL,
  PAID_AT         int(10) DEFAULT 0            NOT NULL,
  PAID_FAIL_REMARK text,
  PAID_FAIL_AT    int(10) DEFAULT 0            NOT NULL,
  BACK_REMARK text,
  BACK_FAIL_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='提现申请';
COMMENT ON COLUMN AR_WITHDRAW.SN IS '单号';
COMMENT ON COLUMN AR_WITHDRAW.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_WITHDRAW.ID_CARD IS '身份证号';
COMMENT ON COLUMN AR_WITHDRAW.WITHDRAW_PERIOD_NUM IS '提现期数';
COMMENT ON COLUMN AR_WITHDRAW.WITHDRAW_YEAR IS '提现年份';
COMMENT ON COLUMN AR_WITHDRAW.WITHDRAW_MONTH IS '提现月份';
COMMENT ON COLUMN AR_WITHDRAW.PAY_TYPE IS '付款类型';
COMMENT ON COLUMN AR_WITHDRAW.IS_AUTO_WITHDRAW IS '是否自动提现';
COMMENT ON COLUMN AR_WITHDRAW.AMOUNT IS '提现金额';
COMMENT ON COLUMN AR_WITHDRAW.INVOICE_ID IS '发票ID';
COMMENT ON COLUMN AR_WITHDRAW.REAL_NAME IS '会员姓名';
COMMENT ON COLUMN AR_WITHDRAW.OPEN_BANK IS '开户行';
COMMENT ON COLUMN AR_WITHDRAW.BANK_ADDRESS IS '银行地址';
COMMENT ON COLUMN AR_WITHDRAW.BANK_NO IS '银行账号';
COMMENT ON COLUMN AR_WITHDRAW.BANK_PROVINCE IS '银行省份';
COMMENT ON COLUMN AR_WITHDRAW.BANK_CITY IS '银行城市';
COMMENT ON COLUMN AR_WITHDRAW.BANK_COUNTY IS '银行地区';
COMMENT ON COLUMN AR_WITHDRAW.P_MONTH IS '表分区标识';
COMMENT ON COLUMN AR_WITHDRAW.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_WITHDRAW.REMARK IS '备注';
COMMENT ON COLUMN AR_WITHDRAW.UPDATE_ADMIN IS '修改管理员';
COMMENT ON COLUMN AR_WITHDRAW.UPDATE_REMARK IS '修改备注';
COMMENT ON COLUMN AR_WITHDRAW.AUDIT_ADMIN IS '审核管理员';
COMMENT ON COLUMN AR_WITHDRAW.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_WITHDRAW.UPDATED_AT IS '修改时间';
COMMENT ON COLUMN AR_WITHDRAW.AUDITED_AT IS '审核时间';
COMMENT ON COLUMN AR_WITHDRAW.PLAN_PAID_AT IS '预计付款时间';
COMMENT ON COLUMN AR_WITHDRAW.PAID_AT IS '付款时间';
COMMENT ON COLUMN AR_WITHDRAW.PAID_FAIL_REMARK IS '付款失败备注';
COMMENT ON COLUMN AR_WITHDRAW.PAID_FAIL_AT IS '付款失败时间';
COMMENT ON COLUMN AR_WITHDRAW.BACK_REMARK IS '提现退回备注';
COMMENT ON COLUMN AR_WITHDRAW.BACK_FAIL_AT IS '提现退回时间';

ALTER TABLE `AR_WITHDRAW` ADD UNIQUE INDEX `SN`(`SN`) USING BTREE;

-- 转账记录
DROP TABLE IF EXISTS `AR_TRANSFER`;
CREATE TABLE AR_TRANSFER
(
  ID            varchar(32) NOT NULL,
  TRANSFER_SN      varchar(32)                    NOT NULL,
  OUT_UID      varchar(32)                    NOT NULL,
  LAST_OUT_USER_NAME      varchar(16)                    NOT NULL,
  LAST_OUT_REAL_NAME      varchar(128)                    NOT NULL,
  LAST_OUT_DEC_LV   varchar(32)                    DEFAULT '',
  LAST_OUT_DEC_ROLE_ID   varchar(32)               DEFAULT '',
  OUT_WALLET   varchar(128) DEFAULT 'bonus'   NOT NULL,
  LAST_OUT_SYSTEM_ID       varchar(32)                    NOT NULL,
  IN_UID      varchar(32)                    NOT NULL,
  LAST_IN_USER_NAME      varchar(16)                    NOT NULL,
  LAST_IN_REAL_NAME      varchar(128)                    NOT NULL,
  LAST_IN_DEC_LV   varchar(32)                    DEFAULT '',
  IN_WALLET   varchar(128) DEFAULT 'bonus'   NOT NULL,
  LAST_IN_SYSTEM_ID       varchar(32)                    NOT NULL,
  ORI_AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
  FEE        decimal(16,3) DEFAULT 0.000     NOT NULL,
  AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
  REMARK        text ,
  PERIOD_NUM    int(10)                      NOT NULL,
  CALC_MONTH    int(10)                      NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='转账记录';
COMMENT ON COLUMN AR_TRANSFER.TRANSFER_SN IS '转账记录流水号';
COMMENT ON COLUMN AR_TRANSFER.OUT_UID IS '转出会员ID';
COMMENT ON COLUMN AR_TRANSFER.LAST_OUT_USER_NAME IS '转账时转出会员编号';
COMMENT ON COLUMN AR_TRANSFER.LAST_OUT_REAL_NAME IS '转账时转出会员姓名';
COMMENT ON COLUMN AR_TRANSFER.LAST_OUT_DEC_LV IS '转账时转出会员级别';
COMMENT ON COLUMN AR_TRANSFER.LAST_OUT_DEC_ROLE_ID IS '转账时转出会员报单中心级别';
COMMENT ON COLUMN AR_TRANSFER.OUT_WALLET IS '转出账户';
COMMENT ON COLUMN AR_TRANSFER.LAST_OUT_SYSTEM_ID IS '转账时转出会员体系';
COMMENT ON COLUMN AR_TRANSFER.IN_UID IS '转入会员ID';
COMMENT ON COLUMN AR_TRANSFER.LAST_IN_USER_NAME IS '转账时转入会员编号';
COMMENT ON COLUMN AR_TRANSFER.LAST_IN_REAL_NAME IS '转账时转入会员姓名';
COMMENT ON COLUMN AR_TRANSFER.LAST_IN_DEC_LV IS '转账时转入会员级别';
COMMENT ON COLUMN AR_TRANSFER.IN_WALLET IS '转入账户';
COMMENT ON COLUMN AR_TRANSFER.LAST_IN_SYSTEM_ID IS '转账时转入会员体系';
COMMENT ON COLUMN AR_TRANSFER.ORI_AMOUNT IS '转账金额';
COMMENT ON COLUMN AR_TRANSFER.FEE IS '手续费';
COMMENT ON COLUMN AR_TRANSFER.AMOUNT IS '实际转入金额';
COMMENT ON COLUMN AR_TRANSFER.REMARK IS '备注';
COMMENT ON COLUMN AR_TRANSFER.PERIOD_NUM IS '所在期数';
COMMENT ON COLUMN AR_TRANSFER.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_TRANSFER.CREATED_AT IS '创建时间';

-- 钱包变更审核记录
DROP TABLE IF EXISTS `AR_BALANCE_AUDIT`;
CREATE TABLE AR_BALANCE_AUDIT
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  LAST_DEC_LV   varchar(32)                    DEFAULT '',
  LAST_EMP_LV   varchar(32)                    DEFAULT '',
  LAST_DEC_ROLE_ID   varchar(32)                    DEFAULT '',
  TYPE          varchar(48)                    NOT NULL,
  DEAL_TYPE     varchar(32)                    NOT NULL,
  AMOUNT        float(16, 2) DEFAULT 0.00      NOT NULL,
  AUDIT_STATUS  tinyint(1) DEFAULT 0             NOT NULL,
  UPDATE_ADMIN_ID varchar(32),
  AUDIT_ADMIN_ID varchar(32),
  CREATE_REMARK text,
  AUDIT_REMARK text,
  REMARK_IS_SHOW tinyint(1) DEFAULT 0            NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
  AUDITED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='钱包变更审核记录';
COMMENT ON COLUMN AR_BALANCE_AUDIT.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_BALANCE_AUDIT.LAST_DEC_LV IS '申请时会员级别';
COMMENT ON COLUMN AR_BALANCE_AUDIT.LAST_EMP_LV IS '申请时会员聘级';
COMMENT ON COLUMN AR_BALANCE_AUDIT.LAST_DEC_ROLE_ID IS '申请时报单中心级别';
COMMENT ON COLUMN AR_BALANCE_AUDIT.TYPE IS '余额类型';
COMMENT ON COLUMN AR_BALANCE_AUDIT.DEAL_TYPE IS '交易类型';
COMMENT ON COLUMN AR_BALANCE_AUDIT.AMOUNT IS '金额';
COMMENT ON COLUMN AR_BALANCE_AUDIT.AUDIT_STATUS IS '状态';
COMMENT ON COLUMN AR_BALANCE_AUDIT.UPDATE_ADMIN_ID IS '变更管理员';
COMMENT ON COLUMN AR_BALANCE_AUDIT.AUDIT_ADMIN_ID IS '审核管理员';
COMMENT ON COLUMN AR_BALANCE_AUDIT.CREATE_REMARK IS '创建备注';
COMMENT ON COLUMN AR_BALANCE_AUDIT.AUDIT_REMARK IS '审核备注';
COMMENT ON COLUMN AR_BALANCE_AUDIT.REMARK_IS_SHOW IS '前台是否展示';
COMMENT ON COLUMN AR_BALANCE_AUDIT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_BALANCE_AUDIT.AUDITED_AT IS ' 审核时间';

ALTER TABLE `AR_BALANCE_AUDIT` ADD INDEX `TYPE`(`TYPE`) USING BTREE;
ALTER TABLE `AR_BALANCE_AUDIT` ADD INDEX `AUDIT_STATUS`(`AUDIT_STATUS`) USING BTREE;

-- 总奖金流水
DROP TABLE IF EXISTS `AR_FLOW_BONUS`;
CREATE TABLE AR_FLOW_BONUS
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  LAST_DEC_LV   varchar(32)                    DEFAULT '',
  LAST_EMP_LV   varchar(32)                    DEFAULT '',
  LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
  CALC_ID       varchar(32),
  AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
  TOTAL         decimal(16,3) DEFAULT 0.000     NOT NULL,
  IS_INCR       tinyint(1) DEFAULT 1             NOT NULL,
  REMARK        varchar(255)                   NOT NULL,
  REMARK_IS_SHOW tinyint(1) DEFAULT 1            NOT NULL,
  DEAL_TYPE_ID varchar(32),
  DEAL_TYPE_IS_PRESET    tinyint(1) DEFAULT 1            NOT NULL,
  ADMIN_NAME    varchar(32),
  PERIOD_NUM    int(10)                      NOT NULL,
  CALC_MONTH    int(10)                      NOT NULL,
  P_MONTH       DATE                            NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
  DELETED       tinyint(1) DEFAULT 0             NOT NULL,
  DELETED_AT    int(10) DEFAULT 0            NOT NULL,
  TRANSFER_SN   varchar(32) DEFAULT '',
  SORT    int(10) DEFAULT 0            NOT NULL,
  AUTO_SORT int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='总奖金流水';
COMMENT ON COLUMN AR_FLOW_BONUS.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_FLOW_BONUS.LAST_DEC_LV IS '记录时会员级别';
COMMENT ON COLUMN AR_FLOW_BONUS.LAST_EMP_LV IS '记录时会员聘级';
COMMENT ON COLUMN AR_FLOW_BONUS.LAST_STATUS IS '记录时状态';
COMMENT ON COLUMN AR_FLOW_BONUS.CALC_ID IS '奖金结算表ID';
COMMENT ON COLUMN AR_FLOW_BONUS.AMOUNT IS '金额';
COMMENT ON COLUMN AR_FLOW_BONUS.TOTAL IS '当前总金额';
COMMENT ON COLUMN AR_FLOW_BONUS.IS_INCR IS '是否增加';
COMMENT ON COLUMN AR_FLOW_BONUS.REMARK IS '备注';
COMMENT ON COLUMN AR_FLOW_BONUS.REMARK_IS_SHOW IS '备注是否显示';
COMMENT ON COLUMN AR_FLOW_BONUS.DEAL_TYPE_ID IS '交易类型ID';
COMMENT ON COLUMN AR_FLOW_BONUS.DEAL_TYPE_IS_PRESET IS '交易类型是否预置';
COMMENT ON COLUMN AR_FLOW_BONUS.ADMIN_NAME IS '操作人名称';
COMMENT ON COLUMN AR_FLOW_BONUS.PERIOD_NUM IS '所在期数';
COMMENT ON COLUMN AR_FLOW_BONUS.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_FLOW_BONUS.P_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_FLOW_BONUS.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_FLOW_BONUS.DELETED IS '是否删除';
COMMENT ON COLUMN AR_FLOW_BONUS.DELETED_AT IS '删除时间';
COMMENT ON COLUMN AR_FLOW_BONUS.TRANSFER_SN IS '转账流水号';
COMMENT ON COLUMN AR_FLOW_BONUS.SORT IS '排序';
COMMENT ON COLUMN AR_FLOW_BONUS.AUTO_SORT IS '自增排序';

-- 车房奖流水
DROP TABLE IF EXISTS `AR_FLOW_CF`;
CREATE TABLE AR_FLOW_CF
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  LAST_DEC_LV   varchar(32)                    DEFAULT '',
  LAST_EMP_LV   varchar(32)                    DEFAULT '',
  LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
  AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
  TOTAL         decimal(16,3) DEFAULT 0.000     NOT NULL,
  IS_INCR       tinyint(1) DEFAULT 1             NOT NULL,
  REMARK        varchar(255)                   NOT NULL,
  REMARK_IS_SHOW tinyint(1) DEFAULT 1            NOT NULL,
  DEAL_TYPE_ID varchar(32),
  DEAL_TYPE_IS_PRESET    tinyint(1) DEFAULT 1            NOT NULL,
  ADMIN_NAME    varchar(32),
  PERIOD_NUM    int(10)                      NOT NULL,
  CALC_MONTH    int(10)                      NOT NULL,
  P_MONTH       DATE                            NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
  DELETED       tinyint(1) DEFAULT 0             NOT NULL,
  DELETED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='车房养老奖流水';
COMMENT ON COLUMN AR_FLOW_CF.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_FLOW_CF.LAST_DEC_LV IS '记录时会员级别';
COMMENT ON COLUMN AR_FLOW_CF.LAST_EMP_LV IS '记录时会员聘级';
COMMENT ON COLUMN AR_FLOW_CF.LAST_STATUS IS '记录时状态';
COMMENT ON COLUMN AR_FLOW_CF.AMOUNT IS '金额';
COMMENT ON COLUMN AR_FLOW_CF.TOTAL IS '当前总金额';
COMMENT ON COLUMN AR_FLOW_CF.IS_INCR IS '是否增加';
COMMENT ON COLUMN AR_FLOW_CF.REMARK IS '备注';
COMMENT ON COLUMN AR_FLOW_CF.REMARK_IS_SHOW IS '备注是否显示';
COMMENT ON COLUMN AR_FLOW_CF.DEAL_TYPE_ID IS '交易类型ID';
COMMENT ON COLUMN AR_FLOW_CF.DEAL_TYPE_IS_PRESET IS '交易类型是否预置';
COMMENT ON COLUMN AR_FLOW_CF.ADMIN_NAME IS '操作人名称';
COMMENT ON COLUMN AR_FLOW_CF.PERIOD_NUM IS '所在期数';
COMMENT ON COLUMN AR_FLOW_CF.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_FLOW_CF.P_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_FLOW_CF.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_FLOW_CF.DELETED IS '是否删除';
COMMENT ON COLUMN AR_FLOW_CF.DELETED_AT IS '删除时间';

ALTER TABLE `AR_FLOW_CF` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;

-- 领袖分红奖流水
DROP TABLE IF EXISTS `AR_FLOW_LX`;
CREATE TABLE AR_FLOW_LX
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  LAST_DEC_LV   varchar(32)                    DEFAULT '',
  LAST_EMP_LV   varchar(32)                    DEFAULT '',
  LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
  AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
  TOTAL         decimal(16,3) DEFAULT 0.000     NOT NULL,
  IS_INCR       tinyint(1) DEFAULT 1             NOT NULL,
  REMARK        varchar(255)                   NOT NULL,
  REMARK_IS_SHOW tinyint(1) DEFAULT 1            NOT NULL,
  DEAL_TYPE_ID varchar(32),
  DEAL_TYPE_IS_PRESET    tinyint(1) DEFAULT 1            NOT NULL,
  ADMIN_NAME    varchar(32),
  PERIOD_NUM    int(10)                      NOT NULL,
  CALC_MONTH    int(10)                      NOT NULL,
  P_MONTH       DATE                            NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
  DELETED       tinyint(1) DEFAULT 0             NOT NULL,
  DELETED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='领袖分红奖流水';
COMMENT ON COLUMN AR_FLOW_LX.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_FLOW_LX.LAST_DEC_LV IS '记录时会员级别';
COMMENT ON COLUMN AR_FLOW_LX.LAST_EMP_LV IS '记录时会员聘级';
COMMENT ON COLUMN AR_FLOW_LX.LAST_STATUS IS '记录时状态';
COMMENT ON COLUMN AR_FLOW_LX.AMOUNT IS '金额';
COMMENT ON COLUMN AR_FLOW_LX.TOTAL IS '当前总金额';
COMMENT ON COLUMN AR_FLOW_LX.IS_INCR IS '是否增加';
COMMENT ON COLUMN AR_FLOW_LX.REMARK IS '备注';
COMMENT ON COLUMN AR_FLOW_LX.REMARK_IS_SHOW IS '备注是否显示';
COMMENT ON COLUMN AR_FLOW_LX.DEAL_TYPE_ID IS '交易类型ID';
COMMENT ON COLUMN AR_FLOW_LX.DEAL_TYPE_IS_PRESET IS '交易类型是否预置';
COMMENT ON COLUMN AR_FLOW_LX.ADMIN_NAME IS '操作人名称';
COMMENT ON COLUMN AR_FLOW_LX.PERIOD_NUM IS '所在期数';
COMMENT ON COLUMN AR_FLOW_LX.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_FLOW_LX.P_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_FLOW_LX.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_FLOW_LX.DELETED IS '是否删除';
COMMENT ON COLUMN AR_FLOW_LX.DELETED_AT IS '删除时间';

ALTER TABLE `AR_FLOW_LX` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;

-- 历史奖金余额
DROP TABLE IF EXISTS `AR_HISTORY_BONUS`;
CREATE TABLE AR_HISTORY_BONUS
(
    ID        varchar(32) NOT NULL,
    USER_ID varchar(32) NOT NULL,
    USER_NAME varchar(32) NOT NULL,
    REAL_NAME varchar(32) NOT NULL,
    DEC_LV varchar(32) NOT NULL,
    EMP_LV varchar(32) NOT NULL,
    IS_DEC tinyint(1) DEFAULT 0 NOT NULL,
    DEC_ROLE_ID varchar(32) DEFAULT '',
    SYSTEM_NAME varchar(32) DEFAULT '',
    BONUS decimal(16,2) DEFAULT 0.00 NOT NULL,
    CF decimal(16,2) DEFAULT 0.00 NOT NULL,
    LX decimal(16,2) DEFAULT 0.00 NOT NULL,
    WITHDRAW decimal(16,2) DEFAULT 0.00 NOT NULL,
    WITHDRAW_TAX decimal(16,2) DEFAULT 0.00 NOT NULL,
    WITHDRAW_DEDUCT decimal(16,2) DEFAULT 0.00 NOT NULL,
    WITHDRAW_REAL decimal(16,2) DEFAULT 0.00 NOT NULL,
    WITHDRAW_FAIL decimal(16,2) DEFAULT 0.00 NOT NULL,
    USER_STATUS tinyint(1) DEFAULT 0 NOT NULL,
    USER_STATUS_AT int(10) DEFAULT 0 NOT NULL,
    HIGHEST_EMP_LV varchar(32) DEFAULT '',
    PERIOD_AT varchar(32) DEFAULT '',
    DEC_DEC_ROLE_ID varchar(32) DEFAULT '',
    DEC_USER_NAME varchar(32) DEFAULT '',
    DEC_REAL_NAME varchar(32) DEFAULT '',
    MOBILE varchar(11) DEFAULT '',
    TEL varchar(11) DEFAULT '',
    PROVINCE int(10) DEFAULT 0 NOT NULL,
    CITY int(10) DEFAULT 0 NOT NULL,
    COUNTY int(10) DEFAULT 0 NOT NULL,
    SUB_COM_ID varchar(32) DEFAULT '',
    IS_DIRECT_SELLER tinyint(1) DEFAULT 0 NOT NULL,
    BACKUP_AT int(10) DEFAULT 0 NOT NULL,
    PARTITION_DATE        DATE            NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='历史奖金余额';
ALTER TABLE `AR_HISTORY_BONUS` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
COMMENT ON COLUMN AR_HISTORY_BONUS.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_HISTORY_BONUS.USER_NAME IS '会员编号';
COMMENT ON COLUMN AR_HISTORY_BONUS.REAL_NAME IS '会员姓名';
COMMENT ON COLUMN AR_HISTORY_BONUS.DEC_LV IS '会员级别';
COMMENT ON COLUMN AR_HISTORY_BONUS.EMP_LV IS '聘级';
COMMENT ON COLUMN AR_HISTORY_BONUS.IS_DEC IS '是否报单中心';
COMMENT ON COLUMN AR_HISTORY_BONUS.DEC_ROLE_ID IS '报单中心级别';
COMMENT ON COLUMN AR_HISTORY_BONUS.SYSTEM_NAME IS '体系名称';
COMMENT ON COLUMN AR_HISTORY_BONUS.BONUS IS '奖金';
COMMENT ON COLUMN AR_HISTORY_BONUS.CF IS '车房养老余额';
COMMENT ON COLUMN AR_HISTORY_BONUS.LX IS '领袖分红余额';
COMMENT ON COLUMN AR_HISTORY_BONUS.WITHDRAW IS '提现金额';
COMMENT ON COLUMN AR_HISTORY_BONUS.WITHDRAW_TAX IS '个税';
COMMENT ON COLUMN AR_HISTORY_BONUS.WITHDRAW_DEDUCT IS '扣款';
COMMENT ON COLUMN AR_HISTORY_BONUS.WITHDRAW_REAL IS '实付金额';
COMMENT ON COLUMN AR_HISTORY_BONUS.WITHDRAW_FAIL IS '实付失败金额';
COMMENT ON COLUMN AR_HISTORY_BONUS.USER_STATUS IS '会员状态';
COMMENT ON COLUMN AR_HISTORY_BONUS.USER_STATUS_AT IS '会员状态变更时间';
COMMENT ON COLUMN AR_HISTORY_BONUS.HIGHEST_EMP_LV IS '历史最高聘级';
COMMENT ON COLUMN AR_HISTORY_BONUS.PERIOD_AT IS '加入期数';
COMMENT ON COLUMN AR_HISTORY_BONUS.DEC_DEC_ROLE_ID IS '所属报单中心级别';
COMMENT ON COLUMN AR_HISTORY_BONUS.DEC_USER_NAME IS '所属报单中心编号';
COMMENT ON COLUMN AR_HISTORY_BONUS.DEC_REAL_NAME IS '所属报单中心姓名';
COMMENT ON COLUMN AR_HISTORY_BONUS.MOBILE IS '手机号';
COMMENT ON COLUMN AR_HISTORY_BONUS.TEL IS '备用手机号码';
COMMENT ON COLUMN AR_HISTORY_BONUS.PROVINCE IS '省份';
COMMENT ON COLUMN AR_HISTORY_BONUS.CITY IS '城市';
COMMENT ON COLUMN AR_HISTORY_BONUS.COUNTY IS '地区';
COMMENT ON COLUMN AR_HISTORY_BONUS.SUB_COM_ID IS '所属分公司';
COMMENT ON COLUMN AR_HISTORY_BONUS.IS_DIRECT_SELLER IS '是否直销员';
COMMENT ON COLUMN AR_HISTORY_BONUS.BACKUP_AT IS '备份时间';
COMMENT ON COLUMN AR_HISTORY_BONUS.PARTITION_DATE IS '分区日期';


-- 全部奖金结算记录
DROP TABLE IF EXISTS `AR_CALC_BONUS`;
CREATE TABLE AR_CALC_BONUS
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_USER_NAME        varchar(16)                    NOT NULL,
    LAST_REAL_NAME        varchar(128)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    LAST_MOBILE           varchar(11) DEFAULT '',
    LAST_PERIOD_AT int(10) DEFAULT 0 NOT NULL,
    LAST_CREATED_AT int(10) DEFAULT 0 NOT NULL,
    LAST_SUB_COM_ID       varchar(32) DEFAULT '',
    LAST_PROVINCE    int(6) DEFAULT 0,
    LAST_CITY        int(6) DEFAULT 0,
    LAST_COUNTY      int(6) DEFAULT 0,
    LAST_SYSTEM_ID       varchar(32)                    NOT NULL,
    LAST_IS_DIRECT_SELLER tinyint(1) DEFAULT 0 NOT NULL,
    LAST_REC_USER_NAME        varchar(16) DEFAULT '',
    LAST_REC_REAL_NAME        varchar(128) DEFAULT '',
    LAST_CON_USER_NAME        varchar(16) DEFAULT '',
    LAST_CON_REAL_NAME        varchar(128) DEFAULT '',
    LAST_LOCATION    tinyint(1)                       NOT NULL,
    BONUS_QY      decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_YC      decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_FX      decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_LS      decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_FW      decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_BT      decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_BT_PROD      decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_BT_TOOL      decimal(16,3) DEFAULT 0.000     NOT NULL,
    DEDUCT_ZR     decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_FL      decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_CF      decimal(16,3) DEFAULT 0.000     NOT NULL,
    BONUS_LX      decimal(16,3) DEFAULT 0.000     NOT NULL,
    SHOULD_QY     decimal(16,3) DEFAULT 0.000     NOT NULL,
    SHOULD_DEDUCT_ZR     decimal(16,3) DEFAULT 0.000     NOT NULL,
    PV_1L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_1L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_1L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_2L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_2L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_2L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_3L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_3L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_3L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_4L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_4L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_4L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_5L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_5L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_5L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_PCS        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_LS_TOUCH        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_LS        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_LS        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_TOUCH        decimal(16,3) DEFAULT 0.000       NOT NULL,
    BONUS_TOTAL        decimal(16,3) DEFAULT 0.000       NOT NULL,
    BONUS_INCOME        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_YEAR     int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    CALCULATED_AT int(10)                      NOT NULL,
    IS_SENT       tinyint(1) DEFAULT 0             NOT NULL,
    SENT_AT       int(10) DEFAULT 0            NOT NULL,
    P_CALC_MONTH  DATE                            NOT NULL,
    CREATED_AT    int(10)                      NOT NULL,
    BONUS_QY_MONTH        decimal(16,3) DEFAULT 0.000       NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='总奖金结算记录';
COMMENT ON COLUMN AR_CALC_BONUS.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_USER_NAME IS '结算时会员编号';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_REAL_NAME IS '结算时会员姓名';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_MOBILE IS '结算时手机号码';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_PERIOD_AT IS '结算时加入期数';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_CREATED_AT IS '结算时加入时间';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_SUB_COM_ID IS '结算时所属分公司';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_PROVINCE IS '结算时所属省份';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_CITY IS '结算时所属城市';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_COUNTY IS '结算时所属地区';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_SYSTEM_ID IS '结算时体系';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_IS_DIRECT_SELLER IS '结算时是否直销员';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_REC_USER_NAME IS '结算时开拓者编号';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_REC_REAL_NAME IS '结算时开拓者姓名';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_CON_USER_NAME IS '结算时上级编号';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_CON_REAL_NAME IS '结算时上级姓名';
COMMENT ON COLUMN AR_CALC_BONUS.LAST_LOCATION IS '结算时市场';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_QY IS '区域津贴';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_YC IS '育成津贴';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_FX IS '复销奖';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_LS IS '零售奖';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_FW IS '区级店业绩提成';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_BT IS '店补';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_BT_PROD IS '产品补贴';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_BT_TOOL IS '工具流补贴';
COMMENT ON COLUMN AR_CALC_BONUS.DEDUCT_ZR IS '责任业绩扣除';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_FL IS '形象店货补';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_CF IS '车房养老奖';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_LX IS '领袖分红';
COMMENT ON COLUMN AR_CALC_BONUS.SHOULD_QY IS '应发区域津贴';
COMMENT ON COLUMN AR_CALC_BONUS.SHOULD_DEDUCT_ZR IS '应扣责任业绩';
COMMENT ON COLUMN AR_CALC_BONUS.PV_1L IS '一市场新增业绩';
COMMENT ON COLUMN AR_CALC_BONUS.QY_1L IS '一市场区域业绩';
COMMENT ON COLUMN AR_CALC_BONUS.SURPLUS_1L IS '一市场结余业绩';
COMMENT ON COLUMN AR_CALC_BONUS.PV_2L IS '二市场新增业绩';
COMMENT ON COLUMN AR_CALC_BONUS.QY_2L IS '二市场区域业绩';
COMMENT ON COLUMN AR_CALC_BONUS.SURPLUS_2L IS '二市场结余业绩';
COMMENT ON COLUMN AR_CALC_BONUS.PV_3L IS '三市场新增业绩';
COMMENT ON COLUMN AR_CALC_BONUS.QY_3L IS '三市场区域业绩';
COMMENT ON COLUMN AR_CALC_BONUS.SURPLUS_3L IS '三市场结余业绩';
COMMENT ON COLUMN AR_CALC_BONUS.PV_4L IS '四市场新增业绩';
COMMENT ON COLUMN AR_CALC_BONUS.QY_4L IS '四市场区域业绩';
COMMENT ON COLUMN AR_CALC_BONUS.SURPLUS_4L IS '四市场结余业绩';
COMMENT ON COLUMN AR_CALC_BONUS.PV_5L IS '五市场新增业绩';
COMMENT ON COLUMN AR_CALC_BONUS.QY_5L IS '五市场区域业绩';
COMMENT ON COLUMN AR_CALC_BONUS.SURPLUS_5L IS '五市场结余业绩';
COMMENT ON COLUMN AR_CALC_BONUS.PV_PCS IS '当期零售';
COMMENT ON COLUMN AR_CALC_BONUS.PV_LS_TOUCH IS '虚拟零售区新增业绩';
COMMENT ON COLUMN AR_CALC_BONUS.SURPLUS_LS IS '虚拟零售区结余';
COMMENT ON COLUMN AR_CALC_BONUS.QY_LS IS '虚拟零售区区域业绩';
COMMENT ON COLUMN AR_CALC_BONUS.PV_TOUCH IS '新增业绩累计';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_TOTAL IS '总奖金';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_INCOME IS '总收入';
COMMENT ON COLUMN AR_CALC_BONUS.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS.CALCULATED_AT IS '结算时间';
COMMENT ON COLUMN AR_CALC_BONUS.IS_SENT IS '是否挂网';
COMMENT ON COLUMN AR_CALC_BONUS.SENT_AT IS '挂网时间';
COMMENT ON COLUMN AR_CALC_BONUS.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_QY_MONTH IS '月区域津贴累计';

ALTER TABLE `AR_CALC_BONUS` ADD INDEX `IS_SENT`(`IS_SENT`) USING BTREE;

-- 报单中心店补补贴记录
DROP TABLE IF EXISTS `AR_CALC_BONUS_BT`;
CREATE TABLE AR_CALC_BONUS_BT
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    FROM_USER_ID  varchar(32)                    NOT NULL,
    LAST_FROM_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_FROM_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_FROM_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    LAST_DEC_ROLE_ID      varchar(32)                 DEFAULT '',
    BT_TYPE varchar(8)     NOT NULL,
    FROM_ORDER_SN   varchar(32)                    DEFAULT '',
    ORDER_TIME    int(10)   DEFAULT 0            NOT NULL,
    ORDER_PERIOD    int(10) DEFAULT 0            NOT NULL,
    DELIVERY_AT    int(10)   DEFAULT 0            NOT NULL,
    DELIVERY_PERIOD    int(10) DEFAULT 0          NOT NULL,
    PAY_AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
    PAY_PV        decimal(16,3) DEFAULT 0.000     NOT NULL,
    TRANSFER_SN   varchar(32)                    DEFAULT '',
    TRANSFER_AMOUNT   decimal(16,3) DEFAULT 0.000     NOT NULL,
    TRANSFER_AT   int(10)   DEFAULT 0            NOT NULL,
    TRANSFER_PERIOD   int(10)   DEFAULT 0            NOT NULL,
    AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_YEAR     int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    P_CALC_MONTH  DATE                            NOT NULL,
    CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='报单中心店补补贴记录';
COMMENT ON COLUMN AR_CALC_BONUS_BT.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_BT.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_BT.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_BT.LAST_STATUS IS '结算时会员状态';
COMMENT ON COLUMN AR_CALC_BONUS_BT.LAST_DEC_ROLE_ID IS '结算时会员报单级别';
COMMENT ON COLUMN AR_CALC_BONUS_BT.FROM_USER_ID IS '来源会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_BT.LAST_FROM_DEC_LV IS '结算时来源会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_BT.LAST_FROM_EMP_LV IS '结算时来源会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_BT.LAST_FROM_STATUS IS '结算时来源会员状态';
COMMENT ON COLUMN AR_CALC_BONUS_BT.BT_TYPE IS '补贴类型';
COMMENT ON COLUMN AR_CALC_BONUS_BT.FROM_ORDER_SN IS '来源订单编号';
COMMENT ON COLUMN AR_CALC_BONUS_BT.ORDER_TIME IS '订货时间';
COMMENT ON COLUMN AR_CALC_BONUS_BT.ORDER_PERIOD IS '订货期数';
COMMENT ON COLUMN AR_CALC_BONUS_BT.DELIVERY_AT IS '发货时间';
COMMENT ON COLUMN AR_CALC_BONUS_BT.DELIVERY_PERIOD IS '发货期数';
COMMENT ON COLUMN AR_CALC_BONUS_BT.PAY_AMOUNT IS '订货金额';
COMMENT ON COLUMN AR_CALC_BONUS_BT.PAY_PV IS '订货积分';
COMMENT ON COLUMN AR_CALC_BONUS_BT.TRANSFER_SN IS '转账记录流水号';
COMMENT ON COLUMN AR_CALC_BONUS_BT.TRANSFER_AMOUNT IS '转账金额';
COMMENT ON COLUMN AR_CALC_BONUS_BT.TRANSFER_AT IS '转账时间';
COMMENT ON COLUMN AR_CALC_BONUS_BT.TRANSFER_PERIOD IS '转账期数';
COMMENT ON COLUMN AR_CALC_BONUS_BT.AMOUNT IS '店补金额';
COMMENT ON COLUMN AR_CALC_BONUS_BT.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_BT.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_BT.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_BT.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_BT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_BT.LOGS IS '日志';

-- 车房养老结算记录
DROP TABLE IF EXISTS `AR_CALC_BONUS_CF`;
CREATE TABLE AR_CALC_BONUS_CF
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_YEAR     int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    P_CALC_MONTH  DATE                            NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='车房养老结算记录';
COMMENT ON COLUMN AR_CALC_BONUS_CF.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_CF.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_CF.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_CF.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_CF.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_CF.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_CF.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_CF.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_CF.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_CF.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_CF.LOGS IS '日志';

-- 货补记录
DROP TABLE IF EXISTS `AR_CALC_BONUS_FL`;
CREATE TABLE AR_CALC_BONUS_FL
(
    ID           varchar(32)  NOT NULL,
    USER_ID      varchar(32)                     NOT NULL,
    LAST_DEC_ROLE_ID      varchar(32)                     NOT NULL,
    DEC_SN     varchar(32)                     NOT NULL,
    TO_USER_ID varchar(32)                     NOT NULL,
    DEC_AT       int(10) DEFAULT 0      NOT NULL,
    DEC_PERIOD       int(10) DEFAULT 0      NOT NULL,
    DEC_AMOUNT       decimal(16,3) DEFAULT 0.000      NOT NULL,
    DEC_PV       decimal(16,3) DEFAULT 0.000      NOT NULL,
    AMOUNT       decimal(16,3) DEFAULT 0.000      NOT NULL,
    PERIOD_NUM   int(10)                       NOT NULL,
    CALC_YEAR    int(10)                       NOT NULL,
    CALC_MONTH   int(10)                       NOT NULL,
    P_CALC_MONTH DATE                             NOT NULL,
    ORDER_PV     decimal(16,3) DEFAULT 0.000      NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    CREATED_AT   int(10)                       NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='货补记录';
COMMENT ON COLUMN AR_CALC_BONUS_FL.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_FL.LAST_DEC_ROLE_ID IS '结算时报单级别';
COMMENT ON COLUMN AR_CALC_BONUS_FL.DEC_SN IS '报单编号';
COMMENT ON COLUMN AR_CALC_BONUS_FL.TO_USER_ID IS '被报单会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_FL.DEC_AT IS '报单时间';
COMMENT ON COLUMN AR_CALC_BONUS_FL.DEC_PERIOD IS '报单期数';
COMMENT ON COLUMN AR_CALC_BONUS_FL.DEC_AMOUNT IS '报单金额';
COMMENT ON COLUMN AR_CALC_BONUS_FL.DEC_PV IS '报单PV';
COMMENT ON COLUMN AR_CALC_BONUS_FL.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_FL.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_FL.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_FL.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_FL.ORDER_PV IS '区域业绩';
COMMENT ON COLUMN AR_CALC_BONUS_FL.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_FL.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_FL.LOGS IS '日志';

-- 区级店业绩提成结算记录
DROP TABLE IF EXISTS `AR_CALC_BONUS_FW`;
CREATE TABLE AR_CALC_BONUS_FW
(
    ID           varchar(32)  NOT NULL,
    USER_ID      varchar(32)                     NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    LAST_DEC_ROLE_ID   varchar(32)                    DEFAULT '',
    FROM_USER_ID varchar(32)                     NOT NULL,
    LAST_FROM_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_FROM_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_FROM_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    LAST_FROM_DEC_ROLE_ID   varchar(32)                    DEFAULT '',
    LAST_FROM_PROVINCE    int(6) DEFAULT 0,
    LAST_FROM_CITY        int(6) DEFAULT 0,
    LAST_FROM_COUNTY      int(6) DEFAULT 0,
    FROM_ORDER_SN   varchar(32)                    DEFAULT '',
    ORDER_TIME    int(10)   DEFAULT 0            NOT NULL,
    ORDER_PERIOD    int(10) DEFAULT 0            NOT NULL,
    DELIVERY_AT    int(10)   DEFAULT 0            NOT NULL,
    DELIVERY_PERIOD    int(10) DEFAULT 0          NOT NULL,
    PAY_AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
    PAY_PV        decimal(16,3) DEFAULT 0.000     NOT NULL,
    ORDER_PV     decimal(16,3) DEFAULT 0.000      NOT NULL,
    AMOUNT       decimal(16,3) DEFAULT 0.000      NOT NULL,
    PERIOD_NUM   int(10)                       NOT NULL,
    CALC_YEAR    int(10)                       NOT NULL,
    CALC_MONTH   int(10)                       NOT NULL,
    P_CALC_MONTH DATE                             NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    CREATED_AT   int(10)                       NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='区级店业绩提成结算记录';
COMMENT ON COLUMN AR_CALC_BONUS_FW.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_DEC_ROLE_ID IS '结算时会员报单中心级别';
COMMENT ON COLUMN AR_CALC_BONUS_FW.FROM_USER_ID IS '来源会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_FROM_DEC_LV IS '结算时来源会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_FROM_EMP_LV IS '结算时来源会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_FROM_STATUS IS '结算时来源状态';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_FROM_DEC_ROLE_ID IS '结算时来源会员报单中心级别';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_FROM_PROVINCE IS '结算时来源省市';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_FROM_CITY IS '结算时来源城市';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LAST_FROM_COUNTY IS '结算时来源地区';
COMMENT ON COLUMN AR_CALC_BONUS_FW.FROM_ORDER_SN IS '来源订单编号';
COMMENT ON COLUMN AR_CALC_BONUS_FW.ORDER_TIME IS '订货时间';
COMMENT ON COLUMN AR_CALC_BONUS_FW.ORDER_PERIOD IS '订货期数';
COMMENT ON COLUMN AR_CALC_BONUS_FW.DELIVERY_AT IS '发货时间';
COMMENT ON COLUMN AR_CALC_BONUS_FW.DELIVERY_PERIOD IS '发货期数';
COMMENT ON COLUMN AR_CALC_BONUS_FW.PAY_AMOUNT IS '订货金额';
COMMENT ON COLUMN AR_CALC_BONUS_FW.PAY_PV IS '订货积分';
COMMENT ON COLUMN AR_CALC_BONUS_FW.ORDER_PV IS '提供区域业绩';
COMMENT ON COLUMN AR_CALC_BONUS_FW.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_FW.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_FW.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_FW.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_FW.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_FW.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_FW.LOGS IS '日志';

-- 复销奖结算记录
DROP TABLE IF EXISTS `AR_CALC_BONUS_FX`;
CREATE TABLE AR_CALC_BONUS_FX
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    FROM_USER_ID  varchar(32)                    NOT NULL,
    LAST_FROM_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_FROM_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_FROM_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    DEEP          int(10)                      NOT NULL,
    AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    P_CALC_MONTH  DATE                            NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='复销奖结算记录';
COMMENT ON COLUMN AR_CALC_BONUS_FX.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_FX.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_FX.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_FX.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_FX.FROM_USER_ID IS '来源会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_FX.LAST_FROM_DEC_LV IS '结算时来源会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_FX.LAST_FROM_EMP_LV IS '结算时来源会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_FX.LAST_FROM_STATUS IS '结算时来源状态';
COMMENT ON COLUMN AR_CALC_BONUS_FX.DEEP IS '深度';
COMMENT ON COLUMN AR_CALC_BONUS_FX.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_FX.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_FX.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_FX.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_FX.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_FX.LOGS IS '日志';

-- 零售结算记录
DROP TABLE IF EXISTS `AR_CALC_BONUS_LS`;
CREATE TABLE AR_CALC_BONUS_LS
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_YEAR     int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    P_CALC_MONTH  DATE                            NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='零售结算记录';
COMMENT ON COLUMN AR_CALC_BONUS_LS.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_LS.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_LS.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_LS.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_LS.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_LS.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_LS.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_LS.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_LS.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_LS.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_LS.LOGS IS '日志';

-- 领袖分红结算记录
DROP TABLE IF EXISTS `AR_CALC_BONUS_LX`;
CREATE TABLE AR_CALC_BONUS_LX
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_YEAR     int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    P_CALC_MONTH  DATE                            NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='领袖分红结算记录';
COMMENT ON COLUMN AR_CALC_BONUS_LX.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_LX.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_LX.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_LX.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_LX.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_LX.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_LX.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_LX.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_LX.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_LX.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_LX.LOGS IS '日志';

-- 区域津贴结算记录
DROP TABLE IF EXISTS `AR_CALC_BONUS_QY`;
CREATE TABLE AR_CALC_BONUS_QY
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_YEAR     int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    P_CALC_MONTH  DATE                            NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    CREATED_AT    int(10)                      NOT NULL,
    ORI_BONUS decimal(16,3) DEFAULT 0 NOT NULL,
    RECONSUME_POINTS decimal(16,3) DEFAULT 0 NOT NULL,
    MANAGE_TAX decimal(16,3) DEFAULT 0 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='区域津贴结算记录';
COMMENT ON COLUMN AR_CALC_BONUS_QY.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_QY.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_QY.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_QY.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_QY.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_QY.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_QY.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_QY.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_QY.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_QY.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_QY.LOGS IS '日志';

-- 育成津贴结算记录
DROP TABLE IF EXISTS `AR_CALC_BONUS_YC`;
CREATE TABLE AR_CALC_BONUS_YC
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    FROM_USER_ID  varchar(32)                    NOT NULL,
    LAST_FROM_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_FROM_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_FROM_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    DEEP          int(10)                      NOT NULL,
    AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    P_CALC_MONTH  DATE                            NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    CREATED_AT    int(10)                      NOT NULL,
    ORI_BONUS decimal(16,3) DEFAULT 0 NOT NULL,
    RECONSUME_POINTS decimal(16,3) DEFAULT 0 NOT NULL,
    MANAGE_TAX decimal(16,3) DEFAULT 0 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='育成津贴结算记录';
COMMENT ON COLUMN AR_CALC_BONUS_YC.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_YC.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_YC.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_YC.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_YC.FROM_USER_ID IS '来源会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_YC.LAST_FROM_DEC_LV IS '结算时来源会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_YC.LAST_FROM_EMP_LV IS '结算时来源会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_YC.LAST_FROM_STATUS IS '结算时来源状态';
COMMENT ON COLUMN AR_CALC_BONUS_YC.DEEP IS '深度';
COMMENT ON COLUMN AR_CALC_BONUS_YC.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_YC.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_YC.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_YC.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_YC.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_YC.LOGS IS '日志';



-- 责任业绩扣除记录
DROP TABLE IF EXISTS `AR_FLOW_DEDUCT_ZR`;
CREATE TABLE AR_FLOW_DEDUCT_ZR
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    ZR  decimal(16,3) DEFAULT 0.000     NOT NULL,
    LOGS   varchar(2000)   DEFAULT '',
    SURPLUS_BONUS        decimal(16,3) DEFAULT 0.000     NOT NULL,
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_YEAR     int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    P_CALC_MONTH  DATE                            NOT NULL,
    CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='责任业绩扣除记录';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.LAST_DEC_LV IS '记录时会员级别';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.LAST_EMP_LV IS '记录时会员聘级';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.LAST_STATUS IS '记录时状态';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.ZR IS '责任业绩';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.SURPLUS_BONUS IS '剩余奖金';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_FLOW_DEDUCT_ZR.LOGS IS '日志';

-- 短信模板
DROP TABLE IF EXISTS `AR_SMS_TEMPLATE`;
CREATE TABLE AR_SMS_TEMPLATE
(
  ID            varchar(32) NOT NULL,
  TITLE         varchar(32)                    NOT NULL,
  DESCRIPTION   varchar(255)                   NOT NULL,
  FIELD         varchar(255)                   NOT NULL,
  DEC_LEVEL     varchar(32),
  EMP_LEVEL     varchar(32),
  CONTENT       varchar(255)                   NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='短信模板';
COMMENT ON COLUMN AR_SMS_TEMPLATE.TITLE IS '标题';
COMMENT ON COLUMN AR_SMS_TEMPLATE.DESCRIPTION IS '描述';
COMMENT ON COLUMN AR_SMS_TEMPLATE.FIELD IS '标题英文字段';
COMMENT ON COLUMN AR_SMS_TEMPLATE.DEC_LEVEL IS '报单级别';
COMMENT ON COLUMN AR_SMS_TEMPLATE.EMP_LEVEL IS '聘级';
COMMENT ON COLUMN AR_SMS_TEMPLATE.CONTENT IS '模板内容';
COMMENT ON COLUMN AR_SMS_TEMPLATE.CREATED_AT IS '创建时间';

INSERT INTO AR_SMS_TEMPLATE (ID, TITLE, DESCRIPTION, FIELD, DEC_LEVEL, EMP_LEVEL, CONTENT, CREATED_AT) VALUES ('A8563B1832CB4B1B95145974B60574C5', '注册成功', '首购报单完成后给新注册的会员发送注册成功短信', 'REG_SUCCESS','67AB99FDC4B6501CE055736AECE8644D', null, '尊敬的{REAL_NAME}，您已注册成功，用户名：{USER_NAME}，报单金额{AMOUNT}', 1526002387);
INSERT INTO AR_SMS_TEMPLATE (ID, TITLE, DESCRIPTION, FIELD, DEC_LEVEL, EMP_LEVEL, CONTENT, CREATED_AT) VALUES ('651074FEE2804DE695CDB00EDED342B0', '注册成功', '首购报单完成后给新注册的会员发送注册成功短信', 'REG_SUCCESS', '67ABCB8C1F7D5519E055736AECE8644D', null, '尊敬的{REAL_NAME}，您已注册成功，用户名：{USER_NAME}，报单金额{AMOUNT}', 1526002387);
INSERT INTO AR_SMS_TEMPLATE (ID, TITLE, DESCRIPTION, FIELD, DEC_LEVEL, EMP_LEVEL, CONTENT, CREATED_AT) VALUES ('F8A46347B7014701B61B77034A7AE3BA', '注册成功', '首购报单完成后给新注册的会员发送注册成功短信', 'REG_SUCCESS', '67ABCCE20A9F5553E055736AECE8644D', null, '尊敬的{REAL_NAME}，您已注册成功，用户名：{USER_NAME}，报单金额{AMOUNT}', 1526002387);
INSERT INTO AR_SMS_TEMPLATE (ID, TITLE, DESCRIPTION, FIELD, DEC_LEVEL, EMP_LEVEL, CONTENT, CREATED_AT) VALUES ('FEA004EDB52347D99869B2E8B61C7C3D', '注册成功', '首购报单完成后给新注册的会员发送注册成功短信', 'REG_SUCCESS', '67ABCE0ECE705575E055736AECE8644D', null, '尊敬的{REAL_NAME}，您已注册成功，用户名：{USER_NAME}，报单金额{AMOUNT}', 1526002387);


-- 提现金额等级设置
DROP TABLE IF EXISTS `AR_WITHDRAW_LEVEL`;
CREATE TABLE AR_WITHDRAW_LEVEL
(
  ID            varchar(32) NOT NULL,
  TYPE          varchar(32)                    NOT NULL,
  MIN_AMOUNT    decimal(16,2) DEFAULT 0.00       NOT NULL,
  MAX_AMOUNT    decimal(16,2),
  TAX_PERCENT   decimal(16,2) DEFAULT 0.00       NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='提现金额等级';
COMMENT ON COLUMN AR_WITHDRAW_LEVEL.TYPE IS '注册类型';
COMMENT ON COLUMN AR_WITHDRAW_LEVEL.MIN_AMOUNT IS '最小金额';
COMMENT ON COLUMN AR_WITHDRAW_LEVEL.MAX_AMOUNT IS '最大金额';
COMMENT ON COLUMN AR_WITHDRAW_LEVEL.TAX_PERCENT IS '税金比率';
COMMENT ON COLUMN AR_WITHDRAW_LEVEL.CREATED_AT IS '创建时间';

INSERT INTO AR_WITHDRAW_LEVEL (ID, TYPE, MIN_AMOUNT, MAX_AMOUNT, TAX_PERCENT, CREATED_AT) VALUES ('BE062D2EDA204B16B31DF8B06189AD07', '56D9181C0F5D428FA2DBD4CAB263BF2F', 0.00, 2000.00, 5.00, 1523435526);
INSERT INTO AR_WITHDRAW_LEVEL (ID, TYPE, MIN_AMOUNT, MAX_AMOUNT, TAX_PERCENT, CREATED_AT) VALUES ('7671AA8CA8DE4BF39C00BB5558416EAB', '56D9181C0F5D428FA2DBD4CAB263BF2F', 2001.00, 5000.00, 2.00, 1523435514);
INSERT INTO AR_WITHDRAW_LEVEL (ID, TYPE, MIN_AMOUNT, MAX_AMOUNT, TAX_PERCENT, CREATED_AT) VALUES ('89CFFF1D53464165B173ED9B48AEC0C3', '56D9181C0F5D428FA2DBD4CAB263BF2F', 5001.00, null, 1.00, 1523437783);


-- 上传文件列表
DROP TABLE IF EXISTS `AR_UPLOADS`;
CREATE TABLE AR_UPLOADS
(
  ID            varchar(32) NOT NULL,
  FILE_NAME     varchar(255)                   NOT NULL,
  CATEGORY      varchar(255)                   NOT NULL,
  REMARK        varchar(255),
  URL           varchar(1000)                  NOT NULL,
  FILE_SIZE     varchar(255),
  MD5           varchar(32),
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='上传文件表';
COMMENT ON COLUMN AR_UPLOADS.FILE_NAME IS '文件名称';
COMMENT ON COLUMN AR_UPLOADS.CATEGORY IS '分类';
COMMENT ON COLUMN AR_UPLOADS.REMARK IS '备注';
COMMENT ON COLUMN AR_UPLOADS.URL IS '文件路径';
COMMENT ON COLUMN AR_UPLOADS.FILE_SIZE IS '文件大小';
COMMENT ON COLUMN AR_UPLOADS.MD5 IS 'MD5值';
COMMENT ON COLUMN AR_UPLOADS.CREATED_AT IS '创建时间';

ALTER TABLE `AR_UPLOADS` ADD INDEX `CATEGORY`(`CATEGORY`) USING BTREE;

-- 导出文件管理表
DROP TABLE IF EXISTS `AR_EXPORT`;
CREATE TABLE AR_EXPORT
(
  ID            varchar(32) NOT NULL,
  EXPORT_NAME   varchar(255)                   NOT NULL,
  MODULE_NAME   varchar(255)                   NOT NULL,
  REMARK        varchar(255),
  IS_EXPORTING  tinyint(1) DEFAULT 0             NOT NULL,
  ADMIN_ID      varchar(32),
  EXPORT_PERCENT decimal(16,2) DEFAULT 0.00      NOT NULL,
  STARTED_AT    int(10) DEFAULT 0            NOT NULL,
  ENDED_AT      int(10) DEFAULT 0            NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
  FILE_NAME     varchar(255) DEFAULT '',
  REMOTE_URL    varchar(2000) DEFAULT  '',
  FILE_SIZE     bigint(16) DEFAULT 0 NOT NULL,
  UPDATER      varchar(16),
  UPDATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='导出表';
COMMENT ON COLUMN AR_EXPORT.EXPORT_NAME IS '导出名称';
COMMENT ON COLUMN AR_EXPORT.MODULE_NAME IS '模块名称';
COMMENT ON COLUMN AR_EXPORT.REMARK IS '备注';
COMMENT ON COLUMN AR_EXPORT.IS_EXPORTING IS '正在导出';
COMMENT ON COLUMN AR_EXPORT.ADMIN_ID IS '管理员ID';
COMMENT ON COLUMN AR_EXPORT.EXPORT_PERCENT IS '导出进度';
COMMENT ON COLUMN AR_EXPORT.STARTED_AT IS '导出开始时间';
COMMENT ON COLUMN AR_EXPORT.ENDED_AT IS '导出完成时间';
COMMENT ON COLUMN AR_EXPORT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_EXPORT.UPDATER IS '更新人';
COMMENT ON COLUMN AR_EXPORT.UPDATED_AT IS '更新时间';
COMMENT ON COLUMN AR_EXPORT.FILE_SIZE IS '文件大小';
COMMENT ON COLUMN AR_EXPORT.REMOTE_URL IS '远程url';
COMMENT ON COLUMN AR_EXPORT.FILE_NAME IS '文件名称';

ALTER TABLE `AR_EXPORT` ADD UNIQUE INDEX `EXPORT_NAME`(`EXPORT_NAME`) USING BTREE;
ALTER TABLE `AR_EXPORT` ADD INDEX `MODULE_NAME`(`MODULE_NAME`) USING BTREE;

-- 导出对应的文件表
DROP TABLE IF EXISTS `AR_EXPORT_FILE`;
CREATE TABLE AR_EXPORT_FILE
(
  ID            varchar(32) NOT NULL,
  FILE_NAME     varchar(255)                   NOT NULL,
  EXPORT_ID     varchar(32)                    NOT NULL,
  URL           varchar(1000) ,
  FILE_SIZE     varchar(255),
  MD5           varchar(32),
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='导出文件表';
COMMENT ON COLUMN AR_EXPORT_FILE.FILE_NAME IS '文件名称';
COMMENT ON COLUMN AR_EXPORT_FILE.EXPORT_ID IS '对应导出的ID';
COMMENT ON COLUMN AR_EXPORT_FILE.URL IS '文件路径';
COMMENT ON COLUMN AR_EXPORT_FILE.FILE_SIZE IS '文件大小';
COMMENT ON COLUMN AR_EXPORT_FILE.MD5 IS 'MD5值';
COMMENT ON COLUMN AR_EXPORT_FILE.CREATED_AT IS '创建时间';

ALTER TABLE `AR_EXPORT_FILE` ADD UNIQUE INDEX `FILE_NAME`(`FILE_NAME`) USING BTREE;

-- OCR识别接口表
DROP TABLE IF EXISTS `AR_OCR_API`;
CREATE TABLE AR_OCR_API
(
  ID            varchar(32) NOT NULL,
  API_NAME      varchar(48)                   NOT NULL,
  DESCRIPTION   varchar(255)                   NOT NULL,
  CONFIG        text,
  STATUS        tinyint(1) DEFAULT 0             NOT NULL,
  CREATE_ADMIN  varchar(32)                    NOT NULL,
  UPDATE_ADMIN   varchar(32),
  CREATED_AT    int(10)                      NOT NULL,
  UPDATED_AT    int(10) DEFAULT 0,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='OCR识别接口表';
COMMENT ON COLUMN AR_OCR_API.API_NAME IS '文件名称';
COMMENT ON COLUMN AR_OCR_API.DESCRIPTION IS '分类';
COMMENT ON COLUMN AR_OCR_API.CONFIG IS '备注';
COMMENT ON COLUMN AR_OCR_API.STATUS IS '文件路径';
COMMENT ON COLUMN AR_OCR_API.CREATE_ADMIN IS '创建管理员';
COMMENT ON COLUMN AR_OCR_API.UPDATE_ADMIN IS '更新管理员';
COMMENT ON COLUMN AR_OCR_API.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_OCR_API.UPDATED_AT IS '更新时间';

ALTER TABLE `AR_OCR_API` ADD UNIQUE INDEX `API_NAME`(`API_NAME`) USING BTREE;

INSERT INTO AR_OCR_API (ID, API_NAME, DESCRIPTION, CONFIG, STATUS, CREATE_ADMIN, CREATED_AT) VALUES ('5955B56B0C0E465E8F0E65FBF86E5D44', 'baidu', '百度OCR识别', null, 1, '65F27BCE7FD278FFE055736AECE8644D', 1526960820);


-- SMS短信接口表
DROP TABLE IF EXISTS `AR_SMS_API`;
CREATE TABLE AR_SMS_API
(
    ID            varchar(32) NOT NULL,
    API_NAME      varchar(48)                   NOT NULL,
    DESCRIPTION   varchar(255)                   NOT NULL,
    CONFIG        text,
    STATUS        tinyint(1) DEFAULT 0             NOT NULL,
    CREATE_ADMIN  varchar(32)                    NOT NULL,
    UPDATE_ADMIN   varchar(32),
    CREATED_AT    int(10)                      NOT NULL,
    UPDATED_AT    int(10) DEFAULT 0,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='SMS短信接口表';
COMMENT ON COLUMN AR_SMS_API.API_NAME IS '接口名称';
COMMENT ON COLUMN AR_SMS_API.DESCRIPTION IS '描述';
COMMENT ON COLUMN AR_SMS_API.CONFIG IS '设置内容';
COMMENT ON COLUMN AR_SMS_API.STATUS IS '状态';
COMMENT ON COLUMN AR_SMS_API.CREATE_ADMIN IS '创建管理员';
COMMENT ON COLUMN AR_SMS_API.UPDATE_ADMIN IS '更新管理员';
COMMENT ON COLUMN AR_SMS_API.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_SMS_API.UPDATED_AT IS '更新时间';

ALTER TABLE `AR_SMS_API` ADD UNIQUE INDEX `API_NAME`(`API_NAME`) USING BTREE;



-- 文章表
DROP TABLE IF EXISTS `AR_ARTICLE`;
CREATE TABLE AR_ARTICLE
(
  ID            varchar(32) NOT NULL,
  TITLE         varchar(255)                   NOT NULL,
  CID           varchar(32)                   NOT NULL,
  CONTENT       text,
  STATUS        tinyint(1) DEFAULT 1             NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文章表';
COMMENT ON COLUMN AR_ARTICLE.TITLE IS '标题';
COMMENT ON COLUMN AR_ARTICLE.CID IS '分类ID';
COMMENT ON COLUMN AR_ARTICLE.CONTENT IS '内容';
COMMENT ON COLUMN AR_ARTICLE.STATUS IS '状态';
COMMENT ON COLUMN AR_ARTICLE.CREATED_AT IS '创建时间';

ALTER TABLE `AR_ARTICLE` ADD UNIQUE INDEX `TITLE`(`TITLE`) USING BTREE;

-- 文章分类表
DROP TABLE IF EXISTS `AR_ARTICLE_CATEGORY`;
CREATE TABLE AR_ARTICLE_CATEGORY
(
  ID            varchar(32) NOT NULL,
  CATE_NAME     varchar(48)                    NOT NULL,
  SORT          tinyint(2) DEFAULT 10            NOT NULL,
  STATUS        tinyint(1) DEFAULT 1             NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='文章分类表';
COMMENT ON COLUMN AR_ARTICLE_CATEGORY.CATE_NAME IS '分类名';
COMMENT ON COLUMN AR_ARTICLE_CATEGORY.STATUS IS '状态';
COMMENT ON COLUMN AR_ARTICLE_CATEGORY.CREATED_AT IS '创建时间';

ALTER TABLE `AR_ARTICLE_CATEGORY` ADD UNIQUE INDEX `CATE_NAME`(`CATE_NAME`) USING BTREE;

-- 广告位
DROP TABLE IF EXISTS `AR_AD_LOCATION`;
CREATE TABLE AR_AD_LOCATION
(
  ID            varchar(32) NOT NULL,
  LOCATION_NAME varchar(48)                    NOT NULL,
  REMARK        varchar(255)                   NOT NULL,
  TYPE          tinyint(1)                       NOT NULL,
  CREATE_ADMIN  varchar(32)                    NOT NULL,
  UPDATE_ADMIN   varchar(32),
  CREATED_AT    int(10)                      NOT NULL,
  UPDATED_AT    int(10) DEFAULT 0,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='广告位';
COMMENT ON COLUMN AR_AD_LOCATION.LOCATION_NAME IS '分类名';
COMMENT ON COLUMN AR_AD_LOCATION.REMARK IS '状态';
COMMENT ON COLUMN AR_AD_LOCATION.TYPE IS '类型';
COMMENT ON COLUMN AR_AD_LOCATION.CREATE_ADMIN IS '创建管理员';
COMMENT ON COLUMN AR_AD_LOCATION.UPDATE_ADMIN IS '更新管理员';
COMMENT ON COLUMN AR_AD_LOCATION.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_AD_LOCATION.UPDATED_AT IS '更新时间';

ALTER TABLE `AR_AD_LOCATION` ADD UNIQUE INDEX `LOCATION_NAME`(`LOCATION_NAME`) USING BTREE;

INSERT INTO AR_AD_LOCATION (ID, LOCATION_NAME, REMARK, TYPE, CREATE_ADMIN, CREATED_AT) VALUES ('CF4D22A9BB6147AC8A4A655166B40827', '手机APP首页顶部广告', '手机APP首页导航栏下方的幻灯广告位', 1, '65F27BCE7FD278FFE055736AECE8644D', 1523245926);
INSERT INTO AR_AD_LOCATION (ID, LOCATION_NAME, REMARK, TYPE, CREATE_ADMIN, CREATED_AT) VALUES ('44AC521CCA2E4E21B05E131EE54A259A', '手机APP首页底部广告', '手机APP首页底部图片广告', 2, '65F27BCE7FD278FFE055736AECE8644D', 1523245926);


-- 广告
DROP TABLE IF EXISTS `AR_AD`;
CREATE TABLE AR_AD
(
  ID            varchar(32) NOT NULL,
  TITLE         varchar(48)                    NOT NULL,
  IMAGE         varchar(1000)                  NOT NULL,
  TYPE          tinyint(1)                       NOT NULL,
  LID           varchar(32)                    NOT NULL,
  CONTENT       varchar(1000),
  SORT          tinyint(2) DEFAULT 10            NOT NULL,
  STATUS        tinyint(1) DEFAULT 1             NOT NULL,
  CREATE_ADMIN  varchar(32)                    NOT NULL,
  UPDATE_ADMIN   varchar(32),
  CREATED_AT    int(10)                      NOT NULL,
  UPDATED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='广告';
COMMENT ON COLUMN AR_AD.TITLE IS '标题';
COMMENT ON COLUMN AR_AD.IMAGE IS '图片地址';
COMMENT ON COLUMN AR_AD.TYPE IS '类型';
COMMENT ON COLUMN AR_AD.LID IS '广告位ID';
COMMENT ON COLUMN AR_AD.CONTENT IS '内容';
COMMENT ON COLUMN AR_AD.SORT IS '排序';
COMMENT ON COLUMN AR_AD.STATUS IS '状态';
COMMENT ON COLUMN AR_AD.CREATE_ADMIN IS '创建管理员';
COMMENT ON COLUMN AR_AD.UPDATE_ADMIN IS '更新管理员';
COMMENT ON COLUMN AR_AD.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_AD.UPDATED_AT IS '更新时间';

ALTER TABLE `AR_AD` ADD UNIQUE INDEX `TITLE`(`TITLE`) USING BTREE;

-- 站内信内容
DROP TABLE IF EXISTS `AR_MESSAGE_TEXT`;
CREATE TABLE AR_MESSAGE_TEXT
(
  ID            varchar(32) NOT NULL,
  TITLE         varchar(48)                    NOT NULL,
  CONTENT       text                  NOT NULL,
  TO_UID        varchar(32) DEFAULT '0'        NOT NULL,
  IS_DEL        tinyint(1) DEFAULT 0             NOT NULL,
  ADMIN_ID      varchar(32)                    NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
  DELETED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='站内信内容';
COMMENT ON COLUMN AR_MESSAGE_TEXT.TITLE IS '标题';
COMMENT ON COLUMN AR_MESSAGE_TEXT.CONTENT IS '内容';
COMMENT ON COLUMN AR_MESSAGE_TEXT.TO_UID IS '发给某个会员';
COMMENT ON COLUMN AR_MESSAGE_TEXT.IS_DEL IS '是否删除';
COMMENT ON COLUMN AR_MESSAGE_TEXT.ADMIN_ID IS '管理员ID';
COMMENT ON COLUMN AR_MESSAGE_TEXT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_MESSAGE_TEXT.DELETED_AT IS '删除时间';

ALTER TABLE `AR_MESSAGE_TEXT` ADD INDEX `TO_UID`(`TO_UID`) USING BTREE;

-- 站内信收件人拉取
DROP TABLE IF EXISTS `AR_MESSAGE`;
CREATE TABLE AR_MESSAGE
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  TEXT_ID       varchar(32)                    NOT NULL,
  IS_READ       tinyint(1) DEFAULT 0             NOT NULL,
  IS_DEL        tinyint(1) DEFAULT 0             NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
  READ_AT     int(10) DEFAULT 0            NOT NULL,
  DELETED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='站内信';
COMMENT ON COLUMN AR_MESSAGE.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_MESSAGE.TEXT_ID IS '站内信内容ID';
COMMENT ON COLUMN AR_MESSAGE.IS_READ IS '是否已读';
COMMENT ON COLUMN AR_MESSAGE.IS_DEL IS '是否删除';
COMMENT ON COLUMN AR_MESSAGE.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_MESSAGE.READ_AT IS '已读时间';
COMMENT ON COLUMN AR_MESSAGE.DELETED_AT IS '删除时间';

ALTER TABLE `AR_MESSAGE` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_MESSAGE` ADD INDEX `IS_READ`(`IS_READ`) USING BTREE;
ALTER TABLE `AR_MESSAGE` ADD INDEX `IS_DEL`(`IS_DEL`) USING BTREE;

-- 业绩单
DROP TABLE IF EXISTS `AR_PERF_ORDER`;
CREATE TABLE AR_PERF_ORDER
(
  ID          varchar(32) NOT NULL,
  SN    			varchar(32)                    NOT NULL,
  DEC_SN      varchar(32),
  DEC_TYPE        varchar(32)                    NOT NULL,
  DEC_STATUS        tinyint(1),
  USER_ID     varchar(32)                    NOT NULL,
  LAST_DEC_LV   varchar(32)                    DEFAULT '',
  LAST_EMP_LV   varchar(32)                    DEFAULT '',
  LAST_STATUS   tinyint(1)     DEFAULT 0,
  LAST_REC_USER_NAME        varchar(16)      DEFAULT '',
  LAST_REC_REAL_NAME        varchar(128)     DEFAULT '',
  PV          decimal(16,3) DEFAULT 0.000     NOT NULL,
  DEC_AMOUNT  float(16, 2) DEFAULT 0.00      NOT NULL,
  LAST_SUB_COM_ID       varchar(32) DEFAULT '',
  LAST_PROVINCE    int(6) DEFAULT 0,
  LAST_CITY        int(6) DEFAULT 0,
  LAST_COUNTY      int(6) DEFAULT 0,
  DEC_USER_ID  varchar(32)                   DEFAULT '',
  LAST_DEC_DEC_LV   varchar(32)                    DEFAULT '',
  LAST_DEC_SUB_COM_ID       varchar(32) DEFAULT '',
  LAST_DEC_PROVINCE    int(6) DEFAULT 0,
  LAST_DEC_CITY        int(6) DEFAULT 0,
  LAST_DEC_COUNTY      int(6) DEFAULT 0,
  PERIOD_NUM  int(10)                      NOT NULL,
  CALC_MONTH  int(10)                      NOT NULL,
  P_CALC_MONTH DATE             							NOT NULL,
  CREATED_AT  int(10)                      NOT NULL,
  CLOSED_AT  int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='业绩单';
COMMENT ON COLUMN AR_PERF_ORDER.SN IS '业绩单编号';
COMMENT ON COLUMN AR_PERF_ORDER.DEC_SN IS '报单编号';
COMMENT ON COLUMN AR_PERF_ORDER.DEC_TYPE IS '报单类型';
COMMENT ON COLUMN AR_PERF_ORDER.DEC_STATUS IS '业绩单状态';
COMMENT ON COLUMN AR_PERF_ORDER.USER_ID IS '产生业绩会员ID';
COMMENT ON COLUMN AR_PERF_ORDER.DEC_USER_ID IS '报单会员ID';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_STATUS IS '结算时会员状态';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_REC_USER_NAME IS '结算时开拓者编号';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_REC_REAL_NAME IS '结算时开拓者姓名';
COMMENT ON COLUMN AR_PERF_ORDER.PV IS '业绩单PV';
COMMENT ON COLUMN AR_PERF_ORDER.DEC_AMOUNT IS '报单金额';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_SUB_COM_ID IS '结算时所属分公司';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_PROVINCE IS '结算时省份';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_CITY IS '结算时城市';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_COUNTY IS '结算时地区';
COMMENT ON COLUMN AR_PERF_ORDER.DEC_USER_ID IS '报单主体ID';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_DEC_DEC_LV IS '结算时报单主体级别';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_DEC_SUB_COM_ID IS '结算时报单主体所属分公司';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_DEC_PROVINCE IS '结算时报单主体省份';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_DEC_CITY IS '结算时报单主体城市';
COMMENT ON COLUMN AR_PERF_ORDER.LAST_DEC_COUNTY IS '结算时报单主体地区';
COMMENT ON COLUMN AR_PERF_ORDER.PERIOD_NUM IS '所在期数';
COMMENT ON COLUMN AR_PERF_ORDER.CALC_MONTH IS '结算月';
COMMENT ON COLUMN AR_PERF_ORDER.P_CALC_MONTH IS '分区结算月';
COMMENT ON COLUMN AR_PERF_ORDER.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_PERF_ORDER.CLOSED_AT IS '置废时间';

ALTER TABLE `AR_PERF_ORDER` ADD UNIQUE INDEX `SN`(`SN`) USING BTREE;
ALTER TABLE `AR_PERF_ORDER` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_PERF_ORDER` ADD INDEX `DEC_USER_ID`(`DEC_USER_ID`) USING BTREE;
ALTER TABLE `AR_PERF_ORDER` ADD INDEX `DEC_TYPE`(`DEC_TYPE`) USING BTREE;
ALTER TABLE `AR_PERF_ORDER` ADD INDEX `PERIOD_NUM`(`PERIOD_NUM`) USING BTREE;

-- Excel导入记录
DROP TABLE IF EXISTS `AR_EXCEL_IMPORT`;
CREATE TABLE AR_EXCEL_IMPORT
(
  ID              varchar(32) NOT NULL,
  OPTION_NAME     varchar(32)                    NOT NULL,
  TABLE_NAME      varchar(32),
  UPLOAD_ID       varchar(32),
  AUDIT_STATUS    tinyint(1) DEFAULT 0             NOT NULL,
  IMPORT_ADMIN_ID varchar(32)                    NOT NULL,
  AUDIT_ADMIN_ID  varchar(32),
  CREATED_AT      int(10)                      NOT NULL,
  AUDITED_AT      int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Excel导入记录';
COMMENT ON COLUMN AR_EXCEL_IMPORT.OPTION_NAME IS '业务名称';
COMMENT ON COLUMN AR_EXCEL_IMPORT.TABLE_NAME IS '对应的待导入数据表名';
COMMENT ON COLUMN AR_EXCEL_IMPORT.UPLOAD_ID IS '上传文件ID';
COMMENT ON COLUMN AR_EXCEL_IMPORT.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_EXCEL_IMPORT.IMPORT_ADMIN_ID IS '导入管理员ID';
COMMENT ON COLUMN AR_EXCEL_IMPORT.AUDIT_ADMIN_ID IS '审核管理员ID';
COMMENT ON COLUMN AR_EXCEL_IMPORT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_EXCEL_IMPORT.AUDITED_AT IS '审核时间';

-- 空单录入待导入表
DROP TABLE IF EXISTS `AR_EXCEL_ADD_USER`;
CREATE TABLE AR_EXCEL_ADD_USER
(
  ID              varchar(32) NOT NULL,
  EXCEL_IMPORT_ID varchar(32)                    NOT NULL,
  USER_NAME       varchar(32),
  DEC_LV          varchar(32),
  REAL_NAME       varchar(32),
  ID_CARD         varchar(32),
  MOBILE          varchar(32),
  TEL             varchar(32),
  AREA_PROVINCE   varchar(32),
  AREA_CITY       varchar(32),
  AREA_COUNTY     varchar(32),
  ADDRESS         varchar(32),
  OPEN_BANK       varchar(32),
  BANK_ADDRESS    varchar(32),
  BANK_NO         varchar(32),
  BANK_PROVINCE   varchar(32),
  BANK_CITY       varchar(32),
  BANK_COUNTY     varchar(32),
  IS_DEC          varchar(32),
  DEC_ROLE        varchar(32),
  DEC_USER_NAME   varchar(32),
  BIRTHDAY        varchar(32),
  CON_USER_NAME   varchar(32),
  REC_USER_NAME   varchar(32),
  LOCATION        varchar(32),
  SORT            int(10)                      NOT NULL,
  STATUS          tinyint(1) DEFAULT 0             NOT NULL,
  ERROR_REMARK    text,
  CREATED_AT      int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='空单录入待导入表';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.EXCEL_IMPORT_ID IS '导入记录表ID';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.USER_NAME IS '用户名';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.DEC_LV IS '会员级别';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.REAL_NAME IS '会员姓名';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.ID_CARD IS '身份证';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.MOBILE IS '手机';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.TEL IS '电话';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.AREA_PROVINCE IS '省市';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.AREA_CITY IS '市区';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.AREA_COUNTY IS '区县';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.ADDRESS IS '地址';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.OPEN_BANK IS '开户银行';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.BANK_ADDRESS IS '开户行地址';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.BANK_NO IS '银行账号';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.BANK_PROVINCE IS '银行省市';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.BANK_CITY IS '银行市区';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.BANK_COUNTY IS '银行区县';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.IS_DEC IS '是否报单中心';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.DEC_ROLE IS '报单中心级别';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.DEC_USER_NAME IS '所属报单中心编号';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.BIRTHDAY IS '生日';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.CON_USER_NAME IS '接点人';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.REC_USER_NAME IS '开拓人';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.LOCATION IS '区位';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.SORT IS '序号';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.STATUS IS '状态';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.ERROR_REMARK IS '错误备注';
COMMENT ON COLUMN AR_EXCEL_ADD_USER.CREATED_AT IS '创建时间';

-- 补发区域津贴表
DROP TABLE IF EXISTS `AR_RESEND_QY`;
CREATE TABLE AR_RESEND_QY
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    LAST_DEC_LV   varchar(32)                    DEFAULT '',
    LAST_EMP_LV   varchar(32)                    DEFAULT '',
    LAST_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    LAST_SUB_COM_ID       varchar(32) DEFAULT '',
    LAST_PROVINCE    int(6) DEFAULT 0,
    LAST_CITY        int(6) DEFAULT 0,
    LAST_COUNTY      int(6) DEFAULT 0,
    LAST_SYSTEM_ID       varchar(32)                    NOT NULL,
    BONUS_QY      decimal(16,3) DEFAULT 0.000     NOT NULL,
    SHOULD_QY     decimal(16,3) DEFAULT 0.000     NOT NULL,
    QY_1L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_1L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_2L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_2L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_3L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_3L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_4L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_4L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_5L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_5L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    QY_LS        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_LS        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PERIOD_NUM    int(10)                      NOT NULL,
    CALC_YEAR     int(10)                      NOT NULL,
    CALC_MONTH    int(10)                      NOT NULL,
    RESEND_STATUS   tinyint(1)     DEFAULT 0              NOT NULL,
    RESEND_AUDIT_ID   varchar(32),
    RESEND_AUDIT_STATUS   tinyint(1)     DEFAULT 0,
    P_CALC_MONTH  DATE                            NOT NULL,
    CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='总奖金结算记录';
COMMENT ON COLUMN AR_RESEND_QY.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_RESEND_QY.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_RESEND_QY.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_RESEND_QY.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_RESEND_QY.LAST_SUB_COM_ID IS '结算时所属分公司';
COMMENT ON COLUMN AR_RESEND_QY.LAST_PROVINCE IS '结算时所属省份';
COMMENT ON COLUMN AR_RESEND_QY.LAST_CITY IS '结算时所属城市';
COMMENT ON COLUMN AR_RESEND_QY.LAST_COUNTY IS '结算时所属地区';
COMMENT ON COLUMN AR_RESEND_QY.LAST_SYSTEM_ID IS '结算时体系';
COMMENT ON COLUMN AR_RESEND_QY.BONUS_QY IS '区域津贴';
COMMENT ON COLUMN AR_RESEND_QY.SHOULD_QY IS '应发区域津贴';
COMMENT ON COLUMN AR_RESEND_QY.QY_1L IS '一市场区域业绩';
COMMENT ON COLUMN AR_RESEND_QY.SURPLUS_1L IS '一市场结余业绩';
COMMENT ON COLUMN AR_RESEND_QY.QY_2L IS '二市场区域业绩';
COMMENT ON COLUMN AR_RESEND_QY.SURPLUS_2L IS '二市场结余业绩';
COMMENT ON COLUMN AR_RESEND_QY.QY_3L IS '三市场区域业绩';
COMMENT ON COLUMN AR_RESEND_QY.SURPLUS_3L IS '三市场结余业绩';
COMMENT ON COLUMN AR_RESEND_QY.QY_4L IS '四市场区域业绩';
COMMENT ON COLUMN AR_RESEND_QY.SURPLUS_4L IS '四市场结余业绩';
COMMENT ON COLUMN AR_RESEND_QY.QY_5L IS '五市场区域业绩';
COMMENT ON COLUMN AR_RESEND_QY.SURPLUS_5L IS '五市场结余业绩';
COMMENT ON COLUMN AR_RESEND_QY.QY_LS IS '虚拟零售区区域业绩';
COMMENT ON COLUMN AR_RESEND_QY.SURPLUS_LS IS '虚拟零售区结余';
COMMENT ON COLUMN AR_RESEND_QY.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_RESEND_QY.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_RESEND_QY.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_RESEND_QY.RESEND_STATUS IS '补发状态';
COMMENT ON COLUMN AR_RESEND_QY.RESEND_AUDIT_ID IS '审核对应ID';
COMMENT ON COLUMN AR_RESEND_QY.RESEND_AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_RESEND_QY.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_RESEND_QY.CREATED_AT IS '创建时间';

ALTER TABLE `AR_RESEND_QY` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;

-- 补发区域津贴审核表
DROP TABLE IF EXISTS `AR_RESEND_QY_AUDIT`;
CREATE TABLE AR_RESEND_QY_AUDIT
(
  ID              varchar(32) NOT NULL,
  USER_ID         varchar(32)                    NOT NULL,
  RESEND_ID         varchar(32)                    NOT NULL,
  SHOULD_BONUS    decimal(16,3) DEFAULT 0.000     NOT NULL,
  RESEND_BONUS    decimal(16,3) DEFAULT 0.000     NOT NULL,
  PERIOD_NUM      int(10)                      NOT NULL,
  AUDIT_STATUS    tinyint(1) DEFAULT 0             NOT NULL,
  RESEND_ADMIN_ID varchar(32)                    NOT NULL,
  AUDIT_ADMIN_ID  varchar(32),
  RESEND_REMARK   text,
  AUDIT_REMARK    text,
  CREATED_AT      int(10)                      NOT NULL,
  AUDITED_AT      int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='补发区域津贴审核表';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.RESEND_ID IS '补发表ID';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.SHOULD_BONUS IS '应发金额';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.RESEND_BONUS IS '补发金额';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.PERIOD_NUM IS '补发期数';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.RESEND_ADMIN_ID IS '补发管理员ID';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.AUDIT_ADMIN_ID IS '审核管理员ID';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.RESEND_REMARK IS '补发备注';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.AUDIT_REMARK IS '审核备注';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_RESEND_QY_AUDIT.AUDITED_AT IS '审核时间';

ALTER TABLE `AR_RESEND_QY_AUDIT` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;

-- 会员注册信息审核表(用于提现)
DROP TABLE IF EXISTS `AR_REG_INFO_AUDIT`;
CREATE TABLE AR_REG_INFO_AUDIT
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  REG_TYPE      varchar(32)                    NOT NULL,
  REG_NAME      varchar(255)                  NOT NULL,
  CREDIT_CODE   varchar(255)                  NOT NULL,
  PREMISES      varchar(255),
  LEGAL_PERSON  varchar(255),
  REG_EXPIRES   int(10)                      NOT NULL,
  AUDIT_STATUS  tinyint(1) DEFAULT 0             NOT NULL,
  CREATE_ADMIN  varchar(32)                    NOT NULL,
  AUDIT_ADMIN   varchar(32),
  CREATE_REMARK text,
  AUDIT_REMARK  text,
  CREATE_PERIOD  int(10) DEFAULT 0           NOT NULL,
  AUDIT_PERIOD  int(10) DEFAULT 0            NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
  AUDITED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员注册信息审核表';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.REG_TYPE IS '注册类型';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.REG_NAME IS '注册名称';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.CREDIT_CODE IS '统一社会信用代码';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.PREMISES IS '经营场所';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.LEGAL_PERSON IS '法人';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.REG_EXPIRES IS '注册有效期';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.CREATE_ADMIN IS '创建管理员';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.AUDIT_ADMIN IS '审核管理员';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.CREATE_REMARK IS '申请备注';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.AUDIT_REMARK IS '审核备注';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.CREATE_PERIOD IS '创建期数';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.AUDIT_PERIOD IS '审核期数';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_REG_INFO_AUDIT.AUDITED_AT IS '审核时间';

ALTER TABLE `AR_REG_INFO_AUDIT` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_REG_INFO_AUDIT` ADD INDEX `REG_TYPE`(`REG_TYPE`) USING BTREE;
ALTER TABLE `AR_REG_INFO_AUDIT` ADD INDEX `AUDIT_STATUS`(`AUDIT_STATUS`) USING BTREE;

-- 发票余额审核表
DROP TABLE IF EXISTS `AR_INVOICE_BALANCE_AUDIT`;
CREATE TABLE AR_INVOICE_BALANCE_AUDIT
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  AMOUNT        decimal(16,2) DEFAULT 0.00       NOT NULL,
  AUDIT_STATUS  tinyint(1) DEFAULT 0             NOT NULL,
  CREATE_ADMIN  varchar(32)                    NOT NULL,
  AUDIT_ADMIN   varchar(32),
  CREATE_REMARK text,
  AUDIT_REMARK  text,
  CREATED_AT    int(10)                      NOT NULL,
  AUDITED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='发票余额审核表';
COMMENT ON COLUMN AR_INVOICE_BALANCE_AUDIT.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_INVOICE_BALANCE_AUDIT.AMOUNT IS '调整金额';
COMMENT ON COLUMN AR_INVOICE_BALANCE_AUDIT.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_INVOICE_BALANCE_AUDIT.CREATE_ADMIN IS '创建管理员';
COMMENT ON COLUMN AR_INVOICE_BALANCE_AUDIT.AUDIT_ADMIN IS '审核管理员';
COMMENT ON COLUMN AR_INVOICE_BALANCE_AUDIT.CREATE_REMARK IS '申请备注';
COMMENT ON COLUMN AR_INVOICE_BALANCE_AUDIT.AUDIT_REMARK IS '审核备注';
COMMENT ON COLUMN AR_INVOICE_BALANCE_AUDIT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_INVOICE_BALANCE_AUDIT.AUDITED_AT IS '审核时间';

ALTER TABLE `AR_INVOICE_BALANCE_AUDIT` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_INVOICE_BALANCE_AUDIT` ADD INDEX `AUDIT_STATUS`(`AUDIT_STATUS`) USING BTREE;

-- 发票审核表
DROP TABLE IF EXISTS `AR_INVOICE_AUDIT`;
CREATE TABLE AR_INVOICE_AUDIT
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  WITHDRAW_ID   varchar(32)                    NOT NULL,
  INVOICE_CODE  varchar(255)                   NOT NULL,
  INVOICE_NUM   varchar(255)                   NOT NULL,
  INVOICE_DATE  varchar(255)                   NOT NULL,
  AMOUNT        decimal(16,2) DEFAULT 0.00       NOT NULL,
  TAX_RATE      varchar(10) ,
  PURCHASER_NAME varchar(255)                  NOT NULL,
  PURCHASER_REGISTER_NUM  varchar(255)         NOT NULL,
  PURCHASER_ADDRESS varchar(255)               NOT NULL,
  PURCHASER_BANK varchar(255)                  NOT NULL,
  SELLER_NAME    varchar(255)                  NOT NULL,
  SELLER_REGISTER_NUM  varchar(255)            NOT NULL,
  SELLER_ADDRESS varchar(255)                  NOT NULL,
  SELLER_BANK varchar(255)                     NOT NULL,
  ITEM_NAME     varchar(255)                   NOT NULL,
  INVOICE_REMARK varchar(255),
  UPLOAD_ID     varchar(255),
  AUDIT_STATUS  tinyint(1) DEFAULT 0             NOT NULL,
  CREATE_ADMIN  varchar(32),
  AUDIT_ADMIN   varchar(32),
  CREATE_REMARK text,
  AUDIT_REMARK  text,
  CREATED_AT    int(10)                      NOT NULL,
  AUDITED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='发票审核表';
COMMENT ON COLUMN AR_INVOICE_AUDIT.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_INVOICE_AUDIT.WITHDRAW_ID IS '提现ID';
COMMENT ON COLUMN AR_INVOICE_AUDIT.INVOICE_CODE IS '发票代码';
COMMENT ON COLUMN AR_INVOICE_AUDIT.INVOICE_NUM IS '发票号码';
COMMENT ON COLUMN AR_INVOICE_AUDIT.INVOICE_DATE IS '开票日期';
COMMENT ON COLUMN AR_INVOICE_AUDIT.AMOUNT IS '交易金额';
COMMENT ON COLUMN AR_INVOICE_AUDIT.TAX_RATE IS '税率';
COMMENT ON COLUMN AR_INVOICE_AUDIT.PURCHASER_NAME IS '购买方名称';
COMMENT ON COLUMN AR_INVOICE_AUDIT.PURCHASER_REGISTER_NUM IS '购买方纳税人识别号';
COMMENT ON COLUMN AR_INVOICE_AUDIT.PURCHASER_ADDRESS IS '购买方地址电话';
COMMENT ON COLUMN AR_INVOICE_AUDIT.PURCHASER_BANK IS '购买方开户行及帐号';
COMMENT ON COLUMN AR_INVOICE_AUDIT.SELLER_NAME IS '销售方名称';
COMMENT ON COLUMN AR_INVOICE_AUDIT.SELLER_REGISTER_NUM IS '销售方纳税人识别号';
COMMENT ON COLUMN AR_INVOICE_AUDIT.SELLER_ADDRESS IS '销售方地址电话';
COMMENT ON COLUMN AR_INVOICE_AUDIT.SELLER_BANK IS '销售方开户行及帐号';
COMMENT ON COLUMN AR_INVOICE_AUDIT.ITEM_NAME IS '货物或应税劳务、服务名称';
COMMENT ON COLUMN AR_INVOICE_AUDIT.INVOICE_REMARK IS '发票备注';
COMMENT ON COLUMN AR_INVOICE_AUDIT.UPLOAD_ID IS '上传ID';
COMMENT ON COLUMN AR_INVOICE_AUDIT.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_INVOICE_AUDIT.CREATE_ADMIN IS '创建管理员';
COMMENT ON COLUMN AR_INVOICE_AUDIT.AUDIT_ADMIN IS '审核管理员';
COMMENT ON COLUMN AR_INVOICE_AUDIT.CREATE_REMARK IS '申请备注';
COMMENT ON COLUMN AR_INVOICE_AUDIT.AUDIT_REMARK IS '审核备注';
COMMENT ON COLUMN AR_INVOICE_AUDIT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_INVOICE_AUDIT.AUDITED_AT IS '审核时间';

ALTER TABLE `AR_INVOICE_AUDIT` ADD INDEX `INVOICE_NUM`(`INVOICE_NUM`) USING BTREE;
ALTER TABLE `AR_INVOICE_AUDIT` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_INVOICE_AUDIT` ADD INDEX `AUDIT_STATUS`(`AUDIT_STATUS`) USING BTREE;

-- 发票交易记录表
DROP TABLE IF EXISTS `AR_INVOICE_FLOW`;
CREATE TABLE AR_INVOICE_FLOW
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  REAL_NAME     varchar(128)                   NOT NULL,
  DEC_LV        varchar(32)                    NOT NULL,
  EMP_LV        varchar(32)                    NOT NULL,
  MOBILE        varchar(32)                    NOT NULL,
  REG_TYPE      varchar(32)                    NOT NULL,
  REG_NAME      varchar(255)                   NOT NULL,
  CREDIT_CODE   varchar(255)                   NOT NULL,
  SALE_NAME     varchar(255)                   ,
  TAXPAYER_NUMBER varchar(255)                 ,
  INVOICE_ACCOUNT varchar(255)                 NOT NULL,
  INVOICE_SN varchar(255)                 ,
  TAX_ACCOUNT   varchar(255)                   NOT NULL,
  OUTED_AT      int(10) DEFAULT 0            NOT NULL,
  DEDUCT_PERIOD_NUM bigint(32) DEFAULT 0        NOT NULL,
  AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
  TOTAL         decimal(16,3) DEFAULT 0.000     NOT NULL,
  WITHDRAW_SN   varchar(255),
  IS_INCR       tinyint(1) DEFAULT 1             NOT NULL,
  REMARK        varchar(255)                   NOT NULL,
  PERIOD_NUM    int(10)                      NOT NULL,
  CALC_MONTH    int(10)                      NOT NULL,
  CREATE_ADMIN  varchar(32)                    NOT NULL,
  CREATE_REMARK text                  ,
  CREATE_TIME   int(10)                      NOT NULL,
  AUDIT_ADMIN   varchar(32)                    NOT NULL,
  AUDIT_REMARK  text                  ,
  AUDIT_TIME    int(10)                      NOT NULL,
  P_MONTH       DATE                            NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='发票交易记录表';
COMMENT ON COLUMN AR_INVOICE_FLOW.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_INVOICE_FLOW.REAL_NAME IS '会员姓名';
COMMENT ON COLUMN AR_INVOICE_FLOW.DEC_LV IS '报单级别';
COMMENT ON COLUMN AR_INVOICE_FLOW.EMP_LV IS '聘级';
COMMENT ON COLUMN AR_INVOICE_FLOW.MOBILE IS '手机号';
COMMENT ON COLUMN AR_INVOICE_FLOW.REG_TYPE IS '注册类型';
COMMENT ON COLUMN AR_INVOICE_FLOW.REG_NAME IS '注册名称';
COMMENT ON COLUMN AR_INVOICE_FLOW.CREDIT_CODE IS '统一社会信用代码';
COMMENT ON COLUMN AR_INVOICE_FLOW.SALE_NAME IS '销售方名称';
COMMENT ON COLUMN AR_INVOICE_FLOW.TAXPAYER_NUMBER IS '纳税人识别号';
COMMENT ON COLUMN AR_INVOICE_FLOW.INVOICE_ACCOUNT IS '交易账户-发票账户';
COMMENT ON COLUMN AR_INVOICE_FLOW.INVOICE_SN IS '发票号';
COMMENT ON COLUMN AR_INVOICE_FLOW.TAX_ACCOUNT IS '交易账户-税款账户';
COMMENT ON COLUMN AR_INVOICE_FLOW.OUTED_AT IS '开票日期';
COMMENT ON COLUMN AR_INVOICE_FLOW.DEDUCT_PERIOD_NUM IS '发票冲减期数';
COMMENT ON COLUMN AR_INVOICE_FLOW.AMOUNT IS '金额';
COMMENT ON COLUMN AR_INVOICE_FLOW.TOTAL IS '当前总金额';
COMMENT ON COLUMN AR_INVOICE_FLOW.WITHDRAW_SN IS '提现流水号';
COMMENT ON COLUMN AR_INVOICE_FLOW.IS_INCR IS '是否增加';
COMMENT ON COLUMN AR_INVOICE_FLOW.REMARK IS '备注';
COMMENT ON COLUMN AR_INVOICE_FLOW.PERIOD_NUM IS '所在期数';
COMMENT ON COLUMN AR_INVOICE_FLOW.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_INVOICE_FLOW.CREATE_ADMIN IS '创建人';
COMMENT ON COLUMN AR_INVOICE_FLOW.CREATE_REMARK IS '创建备注';
COMMENT ON COLUMN AR_INVOICE_FLOW.CREATE_TIME IS '创建时间';
COMMENT ON COLUMN AR_INVOICE_FLOW.AUDIT_ADMIN IS '审核人';
COMMENT ON COLUMN AR_INVOICE_FLOW.AUDIT_REMARK IS '审核备注';
COMMENT ON COLUMN AR_INVOICE_FLOW.AUDIT_TIME IS '审核时间';
COMMENT ON COLUMN AR_INVOICE_FLOW.P_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_INVOICE_FLOW.CREATED_AT IS '创建时间';

-- 车房养老奖年度发放审核表
DROP TABLE IF EXISTS `AR_CF_LX_AUDIT`;
CREATE TABLE AR_CF_LX_AUDIT
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  CF            float(16, 2) DEFAULT 0.00      NOT NULL,
  LX            float(16, 2) DEFAULT 0.00      NOT NULL,
  YEAR          tinyint(4) DEFAULT 0             NOT NULL,
  AUDIT_STATUS  tinyint(1) DEFAULT 0             NOT NULL,
  CREATE_ADMIN  varchar(32)                    NOT NULL,
  AUDIT_ADMIN   varchar(32),
  CREATE_REMARK text,
  AUDIT_REMARK  text,
  CREATED_AT    int(10)                      NOT NULL,
  AUDITED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='车房领袖年度发放审核表';
COMMENT ON COLUMN AR_CF_LX_AUDIT.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CF_LX_AUDIT.CF IS '车房养老';
COMMENT ON COLUMN AR_CF_LX_AUDIT.LX IS '领袖分红';
COMMENT ON COLUMN AR_CF_LX_AUDIT.YEAR IS '类型';
COMMENT ON COLUMN AR_CF_LX_AUDIT.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_CF_LX_AUDIT.CREATE_ADMIN IS '创建管理员';
COMMENT ON COLUMN AR_CF_LX_AUDIT.AUDIT_ADMIN IS '审核管理员';
COMMENT ON COLUMN AR_CF_LX_AUDIT.CREATE_REMARK IS '申请备注';
COMMENT ON COLUMN AR_CF_LX_AUDIT.AUDIT_REMARK IS '审核备注';
COMMENT ON COLUMN AR_CF_LX_AUDIT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CF_LX_AUDIT.AUDITED_AT IS '审核时间';

ALTER TABLE `AR_CF_LX_AUDIT` ADD INDEX `YEAR`(`YEAR`) USING BTREE;
ALTER TABLE `AR_CF_LX_AUDIT` ADD INDEX `AUDIT_STATUS`(`AUDIT_STATUS`) USING BTREE;

-- 调整业绩审核表
DROP TABLE IF EXISTS `AR_PERF_AUDIT`;
CREATE TABLE AR_PERF_AUDIT
(
    ID            varchar(32) NOT NULL,
    USER_ID       varchar(32)                    NOT NULL,
    PV_1L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_2L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_3L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_4L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PV_5L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_1L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_2L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_3L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_4L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_5L        decimal(16,3) DEFAULT 0.000       NOT NULL,
    SURPLUS_LS        decimal(16,3) DEFAULT 0.000       NOT NULL,
    PERF_TYPE  tinyint(1) DEFAULT 0             NOT NULL,
    PERF_LOCATION  tinyint(1) DEFAULT 1             NOT NULL,
    PERF_BEFORE  decimal(16,3) DEFAULT 0.000       NOT NULL,
    PERF_AFTER  decimal(16,3) DEFAULT 0.000       NOT NULL,
    PERIOD_NUM  int(10) DEFAULT 0       NOT NULL,
    AUDIT_STATUS  tinyint(1) DEFAULT 0             NOT NULL,
    CREATE_ADMIN  varchar(32) DEFAULT '',
    REMARK text,
    AUDIT_ADMIN   varchar(32) DEFAULT '',
    CREATED_AT    int(10)                      NOT NULL,
    AUDITED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='调整业绩审核表';
COMMENT ON COLUMN AR_PERF_AUDIT.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_PERF_AUDIT.PV_1L IS '一市场累计';
COMMENT ON COLUMN AR_PERF_AUDIT.PV_2L IS '二市场累计';
COMMENT ON COLUMN AR_PERF_AUDIT.PV_3L IS '三市场累计';
COMMENT ON COLUMN AR_PERF_AUDIT.PV_4L IS '四市场累计';
COMMENT ON COLUMN AR_PERF_AUDIT.PV_5L IS '五市场累计';
COMMENT ON COLUMN AR_PERF_AUDIT.SURPLUS_1L IS '一市场结余';
COMMENT ON COLUMN AR_PERF_AUDIT.SURPLUS_2L IS '二市场结余';
COMMENT ON COLUMN AR_PERF_AUDIT.SURPLUS_3L IS '三市场结余';
COMMENT ON COLUMN AR_PERF_AUDIT.SURPLUS_4L IS '四市场结余';
COMMENT ON COLUMN AR_PERF_AUDIT.SURPLUS_5L IS '五市场结余';
COMMENT ON COLUMN AR_PERF_AUDIT.SURPLUS_LS IS '虚拟零售区结余';
COMMENT ON COLUMN AR_PERF_AUDIT.PERF_TYPE IS '业绩类型';
COMMENT ON COLUMN AR_PERF_AUDIT.PERF_LOCATION IS '业绩区域';
COMMENT ON COLUMN AR_PERF_AUDIT.PERF_BEFORE IS '业绩调整前';
COMMENT ON COLUMN AR_PERF_AUDIT.PERF_AFTER IS '业绩调整后';
COMMENT ON COLUMN AR_PERF_AUDIT.PERIOD_NUM IS '调整期数';
COMMENT ON COLUMN AR_PERF_AUDIT.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_PERF_AUDIT.CREATE_ADMIN IS '创建管理员';
COMMENT ON COLUMN AR_PERF_AUDIT.REMARK IS '备注';
COMMENT ON COLUMN AR_PERF_AUDIT.AUDIT_ADMIN IS '审核管理员';
COMMENT ON COLUMN AR_PERF_AUDIT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_PERF_AUDIT.AUDITED_AT IS '审核时间';

ALTER TABLE `AR_PERF_AUDIT` ADD INDEX `AUDIT_STATUS`(`AUDIT_STATUS`) USING BTREE;

-- 交易类型表
DROP TABLE IF EXISTS `AR_DEAL_TYPE`;
CREATE TABLE AR_DEAL_TYPE
(
    ID            varchar(32) NOT NULL,
    TYPE_NAME     varchar(255)                   NOT NULL,
    CREATE_ADMIN  varchar(32)                    NOT NULL,
    UPDATE_ADMIN   varchar(32),
    CREATE_REMARK text,
    UPDATE_REMARK  text,
    IS_PRESET     tinyint(1) DEFAULT 0 NOT NULL ,
    IS_ENABLE     tinyint(1) DEFAULT 0 NOT NULL ,
    CREATED_AT    int(10)                      NOT NULL,
    UPDATED_AT    int(10) DEFAULT 0            NOT NULL,
    SORT_ORDER    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='交易类型表';
COMMENT ON COLUMN AR_DEAL_TYPE.TYPE_NAME IS '类型名称';
COMMENT ON COLUMN AR_DEAL_TYPE.CREATE_ADMIN IS '创建人';
COMMENT ON COLUMN AR_DEAL_TYPE.UPDATE_ADMIN IS '修改人';
COMMENT ON COLUMN AR_DEAL_TYPE.CREATE_REMARK IS '创建备注';
COMMENT ON COLUMN AR_DEAL_TYPE.UPDATE_REMARK IS '修改备注';
COMMENT ON COLUMN AR_DEAL_TYPE.IS_PRESET IS '是否系统预置';
COMMENT ON COLUMN AR_DEAL_TYPE.IS_ENABLE IS '是否启用';
COMMENT ON COLUMN AR_DEAL_TYPE.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_DEAL_TYPE.UPDATED_AT IS '修改时间';
COMMENT ON COLUMN AR_DEAL_TYPE.SORT_ORDER IS '排序';

INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('141E52002AAE43B7AC304F4BAEFDA268', '奖金发放', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('6626ED606DB34A11B6CCEA768B6E36C2', '奖金提现', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
-- INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('7E3255C33BD6457B8F7155F2A86FFF73', '责任业绩扣除', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('01A753D2548F44FA99B847133C1B5F79', '提现退回', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('DAA0FB1465F748908680D941D589326E', '转出', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('DB62879E6C6B4B2F8591FAD920A2822C', '转入', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
-- INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('E57A779B2E064081B335C5D6B9E4B59B', '点位绑定转出', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
-- INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('082485287F3148B7A44DC62D5D17473A', '点位绑定转入', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
-- INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('38EB53BCAAF24BA38B2E5FDA313EC928', '点位合作转出', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
-- INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('64198F701D374D2996AA8EF1D37769AB', '点位合作转入', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('A6BDF8A2E5F7450B80CBF3B28D8010D2', '复消积分发放', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
-- INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('12840830348E456696834E0624FE2331', '领袖分红发放', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('01C2916A2ECA4D1B9C29AA333C6D13E7', '复消积分转出', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
-- INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('3CD904D1D0764A3FA3E9114DA1D930BD', '领袖分红转出', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('F6AA8D767E654D86917BBF1A5C24F439', '复消积分转入', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
-- INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('0C092D8D6D804F4B84134DBAB5BBE05C', '领袖分红转入', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('1145D8ABA7A7471FB59B6760BDB19019', '短信服务费', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('37B81A45F38646A0A16499AB27B51923', '补发', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('37EFF25E5E3F46A6BB84B8C55997F276', '永久关停扣除', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);
INSERT INTO AR_DEAL_TYPE (ID, TYPE_NAME, CREATE_ADMIN, UPDATE_ADMIN, CREATE_REMARK, UPDATE_REMARK, IS_PRESET, IS_ENABLE, CREATED_AT, UPDATED_AT, SORT_ORDER) VALUES ('A1F1E76F34EE4981AB3BF4F8D20BB53E', '注销扣除', '65F27BCE7FD278FFE055736AECE8644D', null, null, null, 1, 1, 1561942800, 0, 0);


-- 会员状态审核表
DROP TABLE IF EXISTS `AR_USER_STATUS_AUDIT`;
CREATE TABLE AR_USER_STATUS_AUDIT
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  STATUS_VALUE  tinyint(1) DEFAULT 1             NOT NULL,
  ORI_VALUE     tinyint(1) DEFAULT 1             NOT NULL,
  PERIOD_NUM    int(10)                      NOT NULL,
  AUDIT_STATUS  tinyint(1) DEFAULT 0             NOT NULL,
  DEC_LV        varchar(32) ,
  EMP_LV        varchar(32) ,
  PV_1L         decimal(16,2) ,
  PV_2L         decimal(16,2) ,
  PV_3L         decimal(16,2) ,
  PV_4L         decimal(16,2) ,
  PV_5L         decimal(16,2) ,
  SURPLUS_1L    decimal(16,2) ,
  SURPLUS_2L    decimal(16,2) ,
  SURPLUS_3L    decimal(16,2) ,
  SURPLUS_4L    decimal(16,2) ,
  SURPLUS_5L    decimal(16,2) ,
  IS_PERIOD_ADD_T  tinyint(1) DEFAULT 0             NOT NULL,
  ADD_T_PERIOD_NUM int(10) ,
  IS_PERIOD_OPEN tinyint(1) DEFAULT 0             NOT NULL,
  OPEN_PERIOD_NUM int(10) ,
  CREATE_ADMIN  varchar(32)                    NOT NULL,
  AUDIT_ADMIN   varchar(32),
  CREATE_REMARK text,
  AUDIT_REMARK  text,
  CREATED_AT    int(10)                      NOT NULL,
  AUDITED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员状态审核表';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.STATUS_VALUE IS '修改后状态值';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.ORI_VALUE IS '原始状态值';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.PERIOD_NUM IS '期数';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.DEC_LV IS '修改状态时报单级别';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.EMP_LV IS '修改状态时聘级';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.PV_1L IS '修改状态时一市场业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.PV_2L IS '修改状态时二市场业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.PV_3L IS '修改状态时三市场业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.PV_4L IS '修改状态时四市场业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.PV_5L IS '修改状态时五市场业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.SURPLUS_1L IS '修改状态时一市场剩余业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.SURPLUS_2L IS '修改状态时二市场剩余业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.SURPLUS_3L IS '修改状态时三市场剩余业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.SURPLUS_4L IS '修改状态时四市场剩余业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.SURPLUS_5L IS '修改状态时五市场剩余业绩';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.IS_PERIOD_ADD_T IS '是否按照期数加T';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.ADD_T_PERIOD_NUM IS '身份证加T的期数';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.IS_PERIOD_OPEN IS '是否按照期数开通';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.OPEN_PERIOD_NUM IS '开通期数';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.CREATE_ADMIN IS '创建人';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.AUDIT_ADMIN IS '审核人';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.CREATE_REMARK IS '创建备注';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.AUDIT_REMARK IS '审核备注';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_USER_STATUS_AUDIT.AUDITED_AT IS '审核时间';

ALTER TABLE `AR_USER_STATUS_AUDIT` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_USER_STATUS_AUDIT` ADD INDEX `PERIOD_NUM`(`PERIOD_NUM`) USING BTREE;
ALTER TABLE `AR_USER_STATUS_AUDIT` ADD INDEX `AUDIT_STATUS`(`AUDIT_STATUS`) USING BTREE;

-- 公司银行信息表
DROP TABLE IF EXISTS `AR_COMPANY_BANK`;
CREATE TABLE AR_COMPANY_BANK
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  OPEN_NAME     varchar(255)                   NOT NULL,
  OPEN_BANK     varchar(255)                   NOT NULL,
  BANK_ADDRESS  varchar(255)                   NOT NULL,
  BANK_NO       varchar(32)                    NOT NULL,
  BANK_PROVINCE int(6)                       NOT NULL,
  BANK_CITY     int(6)                       NOT NULL,
  BANK_COUNTY   int(6)                       NOT NULL,
  CREATE_ADMIN  varchar(32)                    NOT NULL,
  UPDATE_ADMIN  varchar(32),
  REMARK        text,
  CREATED_AT    int(10)                      NOT NULL,
  UPDATED_AT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='公司银行信息';
COMMENT ON COLUMN AR_COMPANY_BANK.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_COMPANY_BANK.OPEN_NAME IS '开户名';
COMMENT ON COLUMN AR_COMPANY_BANK.OPEN_BANK IS '开户行';
COMMENT ON COLUMN AR_COMPANY_BANK.BANK_ADDRESS IS '银行地址';
COMMENT ON COLUMN AR_COMPANY_BANK.BANK_NO IS '银行账号';
COMMENT ON COLUMN AR_COMPANY_BANK.BANK_PROVINCE IS '银行省份';
COMMENT ON COLUMN AR_COMPANY_BANK.BANK_CITY IS '银行城市';
COMMENT ON COLUMN AR_COMPANY_BANK.BANK_COUNTY IS '银行地区';
COMMENT ON COLUMN AR_COMPANY_BANK.CREATE_ADMIN IS '创建人';
COMMENT ON COLUMN AR_COMPANY_BANK.UPDATE_ADMIN IS '修改人';
COMMENT ON COLUMN AR_COMPANY_BANK.REMARK IS '备注';
COMMENT ON COLUMN AR_COMPANY_BANK.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_COMPANY_BANK.UPDATED_AT IS '修改时间';

-- 提现标记失败待导入表
DROP TABLE IF EXISTS `AR_EXCEL_WITHDRAW_PAID_FALSE`;
CREATE TABLE AR_EXCEL_WITHDRAW_PAID_FALSE (
  ID                  varchar(32) NOT NULL,
  EXCEL_IMPORT_ID     varchar(32)                    NOT NULL,
  SN                  varchar(32)                    NOT NULL,
  WITHDRAW_PERIOD_NUM int(10) DEFAULT 0            NOT NULL,
  PAID_AT             varchar(32) DEFAULT ''         NOT NULL,
  PAID_FAIL_REMARK    varchar(1000) DEFAULT '',
  USER_NAME           varchar(16)                    NOT NULL,
  REAL_NAME           varchar(32)                    NOT NULL,
  AMOUNT              decimal(16,2) DEFAULT 0.00       NOT NULL,
  BANK_REAL_NAME      varchar(255)                   NOT NULL,
  BANK_NO             varchar(32)                    NOT NULL,
  SORT                int(5) DEFAULT 0             NOT NULL,
  STATUS              tinyint(1) DEFAULT 0             NOT NULL,
  ERROR_REMARK        varchar(1000) DEFAULT '',
  CREATED_AT          int(10) DEFAULT 0            NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='提现标记失败待导入表';
ALTER TABLE `AR_EXCEL_WITHDRAW_PAID_FALSE` ADD INDEX `EXCEL_IMPORT_ID`(`EXCEL_IMPORT_ID`) USING BTREE;
ALTER TABLE `AR_EXCEL_WITHDRAW_PAID_FALSE` ADD INDEX `USER_NAME`(`USER_NAME`) USING BTREE;
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.EXCEL_IMPORT_ID IS '导入记录表ID';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.SN IS '提现流水号';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.WITHDRAW_PERIOD_NUM IS '提现期数';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.PAID_AT IS '付款日期';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.PAID_FAIL_REMARK IS '付款失败原因';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.USER_NAME IS '会员编号';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.REAL_NAME IS '会员姓名';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.AMOUNT IS '实付金额';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.BANK_REAL_NAME IS '实时开户名';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.BANK_NO IS '实时银行账户';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.SORT IS '序号';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.STATUS IS '状态';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.ERROR_REMARK IS '错误记录';
COMMENT ON COLUMN AR_EXCEL_WITHDRAW_PAID_FALSE.CREATED_AT IS '创建时间';

-- 调整会员余额待导入表
DROP TABLE IF EXISTS `AR_EXCEL_CHANGE_BALANCE`;
CREATE TABLE AR_EXCEL_CHANGE_BALANCE (
  ID                  varchar(32) NOT NULL,
  EXCEL_IMPORT_ID     varchar(32)                    NOT NULL,
  USER_NAME           varchar(16)                    NOT NULL,
  REAL_NAME           varchar(32)                    NOT NULL,
  TYPE        		  varchar(20)                    NOT NULL,
  AMOUNT              decimal(16,2) DEFAULT 0.00       NOT NULL,
  DEAL_TYPE           varchar(128)                    NOT NULL,
  REMARK              varchar(2000) DEFAULT '',
  REMARK_IS_SHOW      tinyint(1) DEFAULT 0            NOT NULL,
  SORT                int(5) DEFAULT 0             NOT NULL,
  STATUS              tinyint(1) DEFAULT 0             NOT NULL,
  ERROR_REMARK        varchar(1000) DEFAULT '',
  CREATED_AT          int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='调整会员余额待导入表';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.EXCEL_IMPORT_ID IS '导入记录表ID';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.USER_NAME IS '会员编号';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.REAL_NAME IS '会员姓名';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.TYPE IS '账户类型';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.AMOUNT IS '调整金额';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.DEAL_TYPE IS '交易类型';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.REMARK IS '备注';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.REMARK_IS_SHOW IS '备注显示';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.SORT IS '序号';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.STATUS IS '状态';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.ERROR_REMARK IS '错误记录';
COMMENT ON COLUMN AR_EXCEL_CHANGE_BALANCE.CREATED_AT IS '创建时间';

-- 注册信息待导入表
DROP TABLE IF EXISTS `AR_EXCEL_REG_INFO`;
CREATE TABLE AR_EXCEL_REG_INFO
(
  ID              varchar(32) NOT NULL,
  EXCEL_IMPORT_ID varchar(32)                    NOT NULL,
  USER_NAME       varchar(32),
  REAL_NAME       varchar(32),
  ID_CARD         varchar(32),
  REG_TYPE        varchar(32),
  REG_NAME        varchar(255),
  CREDIT_CODE     varchar(255),
  PREMISES        varchar(255),
  REG_EXPIRES     varchar(255),
  LEGAL_PERSON    varchar(255),
  OPEN_NAME       varchar(255),
  OPEN_BANK       varchar(255),
  BANK_ADDRESS    varchar(255),
  BANK_NO         varchar(32),
  BANK_PROVINCE   varchar(32),
  BANK_CITY       varchar(32),
  BANK_COUNTY     varchar(32),
  REMARK          text,
  SORT            int(10)                      NOT NULL,
  STATUS          tinyint(1) DEFAULT 0             NOT NULL,
  ERROR_REMARK    text,
  CREATED_AT      int(10)                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='注册信息待导入表';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.EXCEL_IMPORT_ID IS '导入记录表ID';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.USER_NAME IS '会员编号';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.REAL_NAME IS '会员姓名';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.ID_CARD IS '身份证';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.REG_TYPE IS '注册类型';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.REG_NAME IS '注册名称';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.CREDIT_CODE IS '统一社会信用代码';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.PREMISES IS '经营场所';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.LEGAL_PERSON IS '法人';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.REG_EXPIRES IS '注册有效期';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.OPEN_NAME IS '企业开户名称';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.OPEN_BANK IS '企业开户银行';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.BANK_ADDRESS IS '企业开户行地址';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.BANK_NO IS '企业银行账号';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.BANK_PROVINCE IS '企业银行省市';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.BANK_CITY IS '企业银行市区';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.BANK_COUNTY IS '企业银行区县';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.REMARK IS '备注';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.SORT IS '序号';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.STATUS IS '状态';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.ERROR_REMARK IS '错误备注';
COMMENT ON COLUMN AR_EXCEL_REG_INFO.CREATED_AT IS '创建时间';

DROP TABLE IF EXISTS `AR_YEAR_HIGHEST_EMP_LV`;
CREATE TABLE AR_YEAR_HIGHEST_EMP_LV
(
    ID varchar(32) NOT NULL,
    USER_ID varchar(32) NOT NULL,
    YEAR tinyint(4) DEFAULT 0 NOT NULL,
    HIGHEST_EMP_LV varchar(32) NOT NULL,
    HIGHEST_EMP_LV_SORT int(10) DEFAULT 0 NOT NULL,
    HIGHEST_EMP_LV_PERIOD int(10) DEFAULT 0 NOT NULL,
    CREATED_AT int(10) DEFAULT 0 NOT NULL,
    UPDATED_AT int(10) DEFAULT 0 NOT NULL,
    PARTITION_DATE        DATE            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员年度最高聘级';
COMMENT ON COLUMN AR_YEAR_HIGHEST_EMP_LV.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_YEAR_HIGHEST_EMP_LV.YEAR IS '年度';
COMMENT ON COLUMN AR_YEAR_HIGHEST_EMP_LV.HIGHEST_EMP_LV IS '年度最高聘级';
COMMENT ON COLUMN AR_YEAR_HIGHEST_EMP_LV.HIGHEST_EMP_LV_SORT IS '年度最高聘级排序';
COMMENT ON COLUMN AR_YEAR_HIGHEST_EMP_LV.HIGHEST_EMP_LV_PERIOD IS '达到年度最高聘级的期数';
COMMENT ON COLUMN AR_YEAR_HIGHEST_EMP_LV.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_YEAR_HIGHEST_EMP_LV.UPDATED_AT IS '修改时间';
ALTER TABLE `AR_YEAR_HIGHEST_EMP_LV` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_YEAR_HIGHEST_EMP_LV` ADD INDEX `YEAR`(`YEAR`) USING BTREE;

-- 任务队列
DROP TABLE IF EXISTS `AR_TASK_QUEUE`;
CREATE TABLE AR_TASK_QUEUE
(
    ID          varchar(32)     NOT NULL,
    MAIN_ID     varchar(32)                        NOT NULL,
    TYPE        int(10) DEFAULT 1                NOT NULL,
    CONTENT     varchar(255)                       NOT NULL,
    PARAMS      text                      NOT NULL,
    TOTAL_LOOP  int(10) DEFAULT 0                NOT NULL,
    DONE_TIMES  int(10) DEFAULT 0                NOT NULL,
    LOOP_TYPE   int(10) DEFAULT 0                NOT NULL,
    LOOP_CYCLE_CONTENT varchar(255) ,
    NEXT_AT     int(10) DEFAULT 0                NOT NULL,
    CREATED_AT  int(10)                          NOT NULL,
    STARTED_AT  int(10) DEFAULT 0                NOT NULL,
    FINISHED_AT  int(10) DEFAULT 0               NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='任务队列列表';
COMMENT ON COLUMN AR_TASK_QUEUE.ID IS '任务ID';
COMMENT ON COLUMN AR_TASK_QUEUE.MAIN_ID IS '主任务ID';
COMMENT ON COLUMN AR_TASK_QUEUE.TYPE IS '任务类型';
COMMENT ON COLUMN AR_TASK_QUEUE.CONTENT IS '任务内容';
COMMENT ON COLUMN AR_TASK_QUEUE.PARAMS IS '参数';
COMMENT ON COLUMN AR_TASK_QUEUE.TOTAL_LOOP IS '主任务循环次数';
COMMENT ON COLUMN AR_TASK_QUEUE.DONE_TIMES IS '完成次数';
COMMENT ON COLUMN AR_TASK_QUEUE.LOOP_TYPE IS '循环类型';
COMMENT ON COLUMN AR_TASK_QUEUE.LOOP_CYCLE_CONTENT IS '循环周期内容';
COMMENT ON COLUMN AR_TASK_QUEUE.NEXT_AT IS '下次执行任务的时间';
COMMENT ON COLUMN AR_TASK_QUEUE.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_TASK_QUEUE.STARTED_AT IS '任务开始时间';
COMMENT ON COLUMN AR_TASK_QUEUE.FINISHED_AT IS '任务完成时间';



-- 地区表
DROP TABLE IF EXISTS `AR_REGION`;
CREATE TABLE AR_REGION
(
    ID varchar(32) NOT NULL,
    REGION_CODE int(6) DEFAULT 0 NULL NOT NULL,
    DEEP tinyint(2) DEFAULT 0 NOT NULL,
    REGION_NAME varchar(128) DEFAULT '' NULL NOT NULL,
    PID int(6) DEFAULT 0 NOT NULL,
    AREA_CODE varchar(6) DEFAULT '' NULL NOT NULL,
    CREATED_AT int(10) DEFAULT 0 NOT NULL,
    UPDATED_AT int(10) DEFAULT 0 NOT NULL,
    UPDATER varchar(16) DEFAULT '',
    ADM_NAME varchar(16) DEFAULT '' NULL NOT NULL,
    STATUS tinyint(1) DEFAULT 1 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='地区';
COMMENT ON COLUMN AR_REGION.REGION_CODE IS '编码';
COMMENT ON COLUMN AR_REGION.DEEP IS '深度';
COMMENT ON COLUMN AR_REGION.REGION_NAME IS '名称';
COMMENT ON COLUMN AR_REGION.PID IS '父级ID';
COMMENT ON COLUMN AR_REGION.AREA_CODE IS '区号';
COMMENT ON COLUMN AR_REGION.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_REGION.UPDATED_AT IS '修改时间';
COMMENT ON COLUMN AR_REGION.UPDATER IS '修改人';
COMMENT ON COLUMN AR_REGION.ADM_NAME IS '操作人';
COMMENT ON COLUMN AR_REGION.STATUS IS '状态';
ALTER TABLE `AR_REGION` ADD UNIQUE INDEX `REGION_CODE`(`REGION_CODE`) USING BTREE;

-- 报单表
DROP TABLE IF EXISTS `AR_DEC_ORDER`;
CREATE TABLE AR_DEC_ORDER
(
    ID varchar(32) NOT NULL,
    DEC_SN varchar(32) DEFAULT '' NOT NULL,
    ORDER_SN varchar(32) DEFAULT '' NOT NULL,
    USER_ID varchar(32) NOT NULL,
    TO_USER_ID varchar(32) NOT NULL,
    TYPE varchar(32) NOT NULL,
    IS_ADMIN tinyint(1) DEFAULT 0 NOT NULL,
    DEC_AMOUNT decimal(16,3) DEFAULT 0.000 NOT NULL,
    DEC_PV decimal(16,3) DEFAULT 0.000 NOT NULL,
    PAID_WALLET varchar(48) NOT NULL,
    IS_BATCH tinyint(1) DEFAULT 0 NOT NULL,
    REMARK text,
    REC_USER_ID varchar(32) DEFAULT '',
    CON_USER_ID varchar(32) DEFAULT '',
    PERIOD_NUM int(10) NOT NULL,
    P_CALC_MONTH DATE NOT NULL,
    CALC_MONTH int(8) DEFAULT 0 NOT NULL,
    CREATED_AT int(10) NOT NULL,
    UPDATER varchar(32) DEFAULT '',
    UPDATED_AT varchar(32) DEFAULT 0 NOT NULL,
    IS_DEL tinyint(1) DEFAULT 0 NOT NULL,
    DELETED_AT int(10) DEFAULT 0 NOT NULL,
    DEC_ID varchar(32) DEFAULT '',
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='报单';
COMMENT ON COLUMN AR_DEC_ORDER.DEC_SN IS '报单编号';
COMMENT ON COLUMN AR_DEC_ORDER.ORDER_SN IS '订单编号';
COMMENT ON COLUMN AR_DEC_ORDER.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_DEC_ORDER.TO_USER_ID IS '报单对象ID';
COMMENT ON COLUMN AR_DEC_ORDER.TYPE IS '报单类型';
COMMENT ON COLUMN AR_DEC_ORDER.IS_ADMIN IS '是否管理员操作';
COMMENT ON COLUMN AR_DEC_ORDER.DEC_AMOUNT IS '报单金额';
COMMENT ON COLUMN AR_DEC_ORDER.DEC_PV IS '报单PV';
COMMENT ON COLUMN AR_DEC_ORDER.PAID_WALLET IS '支付钱包';
COMMENT ON COLUMN AR_DEC_ORDER.IS_BATCH IS '是否批量报单';
COMMENT ON COLUMN AR_DEC_ORDER.REMARK IS '备注';
COMMENT ON COLUMN AR_DEC_ORDER.REC_USER_ID IS '开拓人ID';
COMMENT ON COLUMN AR_DEC_ORDER.CON_USER_ID IS '上级ID';
COMMENT ON COLUMN AR_DEC_ORDER.PERIOD_NUM IS '报单期数';
COMMENT ON COLUMN AR_DEC_ORDER.P_CALC_MONTH IS '分区结算月';
COMMENT ON COLUMN AR_DEC_ORDER.CALC_MONTH IS '结算月';
COMMENT ON COLUMN AR_DEC_ORDER.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_DEC_ORDER.UPDATER IS '操作人';
COMMENT ON COLUMN AR_DEC_ORDER.UPDATED_AT IS '更新时间';
COMMENT ON COLUMN AR_DEC_ORDER.IS_DEL IS '是否删除';
COMMENT ON COLUMN AR_DEC_ORDER.DELETED_AT IS '删除时间';
ALTER TABLE `AR_DEC_ORDER` ADD UNIQUE INDEX `DEC_SN`(`DEC_SN`) USING BTREE;
ALTER TABLE `AR_DEC_ORDER` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_DEC_ORDER` ADD INDEX `TYPE`(`TYPE`) USING BTREE;
ALTER TABLE `AR_DEC_ORDER` ADD INDEX `PERIOD_NUM`(`PERIOD_NUM`) USING BTREE;
ALTER TABLE `AR_DEC_ORDER` ADD INDEX `IS_DEL`(`IS_DEL`) USING BTREE;
ALTER TABLE `AR_DEC_ORDER` ADD INDEX `ORDER_SN`(`ORDER_SN`) USING BTREE;

-- 会员钱包
DROP TABLE IF EXISTS `AR_USER_WALLET`;
CREATE TABLE AR_USER_WALLET
(
    USER_ID varchar(32) NOT NULL,
    CASH decimal(16,2) DEFAULT 0.00 NOT NULL,
    CLEAR_BY_CLOSED_AT int(10) DEFAULT 0 NOT NULL,
    UPDATED_AT int(10) DEFAULT 0 NOT NULL,
	  KEY `USER_ID`(`USER_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='钱包';
COMMENT ON COLUMN AR_USER_WALLET.USER_ID IS '用户ID';
COMMENT ON COLUMN AR_USER_WALLET.CASH IS '现金';
COMMENT ON COLUMN AR_USER_WALLET.CLEAR_BY_CLOSED_AT IS '清空关停会员钱包时间';
COMMENT ON COLUMN AR_USER_WALLET.UPDATED_AT IS '修改时间';

-- 订单
DROP TABLE IF EXISTS `AR_ORDER`;
CREATE TABLE AR_ORDER
(
    SN varchar(32) DEFAULT '' NOT NULL,
    DEC_SN varchar(32) DEFAULT '',
    USER_ID varchar(32) NOT NULL,
    USER_NAME varchar(16) NOT NULL,
    ORDER_TYPE varchar(12) NOT NULL,
    ORDER_AMOUNT decimal(16,2) DEFAULT 0.00 NOT NULL,
    PV decimal(16,2) DEFAULT 0.00 NOT NULL,
    PAY_AMOUNT decimal(16,2) DEFAULT 0.00 NOT NULL,
    PAY_PV decimal(16,2) DEFAULT 0.00 NOT NULL,
    PAY_AT int(10) DEFAULT 0 NOT NULL,
    FREIGHT float(10,2) DEFAULT 0.00 NOT NULL,
    PAY_FREIGHT float(10,2) DEFAULT 0.00 NOT NULL,
    DELIVERY_STATUS tinyint(2) DEFAULT 0 NOT NULL,
    DELIVERY_PERIOD int(10) DEFAULT 0 NOT NULL,
    DELIVERY_AT int(10) DEFAULT 0 NOT NULL,
    EXPRESS_COMPANY varchar(128) DEFAULT '',
    ORDER_TRACK_NO varchar(32) DEFAULT '',
    EXPRESS_TYPE tinyint(1) DEFAULT 0 NOT NULL,
    FRONT_REMARK varchar(1000) DEFAULT '',
    REMARK text,
    PERIOD_NUM int(10) DEFAULT 0 NOT NULL,
    STATUS tinyint(3) DEFAULT 0 NOT NULL,
    CONSIGNEE varchar(120) DEFAULT '',
    MOBILE varchar(11) DEFAULT '',
    TEL varchar(16) DEFAULT '',
    PROVINCE int(6) DEFAULT 0 NOT NULL,
    CITY int(6) DEFAULT 0 NOT NULL,
    COUNTY int(6) DEFAULT 0 NOT NULL,
    ADDRESS varchar(255) DEFAULT '' NOT NULL,
    P_CALC_MONTH DATE  NOT NULL,
    CREATED_AT int(10) DEFAULT 0 NOT NULL,
    CREATE_USER varchar(16) NOT NULL,
    UPDATED_AT int(10) DEFAULT 0 NOT NULL,
    UPDATER varchar(16) DEFAULT '',
    IS_DELETE int(10) DEFAULT 0 NOT NULL,
    DELETED_AT int(10) DEFAULT 0 NOT NULL,
	  KEY `SN`(`SN`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品订单';
COMMENT ON COLUMN AR_ORDER.SN IS '订单号';
COMMENT ON COLUMN AR_ORDER.DEC_SN IS '报单编号';
COMMENT ON COLUMN AR_ORDER.USER_ID IS '用户ID';
COMMENT ON COLUMN AR_ORDER.USER_NAME IS '会员编号';
COMMENT ON COLUMN AR_ORDER.ORDER_TYPE IS '订货类型';
COMMENT ON COLUMN AR_ORDER.ORDER_AMOUNT IS '订单总价格';
COMMENT ON COLUMN AR_ORDER.PV IS '订货PV';
COMMENT ON COLUMN AR_ORDER.PAY_AMOUNT IS '支付价格';
COMMENT ON COLUMN AR_ORDER.PAY_PV IS '实付PV';
COMMENT ON COLUMN AR_ORDER.PAY_AT IS '支付时间';
COMMENT ON COLUMN AR_ORDER.FREIGHT IS '运费';
COMMENT ON COLUMN AR_ORDER.PAY_FREIGHT IS '实付运费金额';
COMMENT ON COLUMN AR_ORDER.DELIVERY_STATUS IS '发货状态';
COMMENT ON COLUMN AR_ORDER.DELIVERY_PERIOD IS '发货期数';
COMMENT ON COLUMN AR_ORDER.DELIVERY_AT IS '发货时间';
COMMENT ON COLUMN AR_ORDER.EXPRESS_COMPANY IS '快递公司';
COMMENT ON COLUMN AR_ORDER.ORDER_TRACK_NO IS '快递单号';
COMMENT ON COLUMN AR_ORDER.EXPRESS_TYPE IS '发货方式';
COMMENT ON COLUMN AR_ORDER.FRONT_REMARK IS '前台备注';
COMMENT ON COLUMN AR_ORDER.REMARK IS '后台备注';
COMMENT ON COLUMN AR_ORDER.PERIOD_NUM IS '期数';
COMMENT ON COLUMN AR_ORDER.STATUS IS '订单状态';
COMMENT ON COLUMN AR_ORDER.CONSIGNEE IS '收货人';
COMMENT ON COLUMN AR_ORDER.MOBILE IS '收货人手机';
COMMENT ON COLUMN AR_ORDER.TEL IS '固定电话';
COMMENT ON COLUMN AR_ORDER.PROVINCE IS '省份名称';
COMMENT ON COLUMN AR_ORDER.CITY IS '城市名称';
COMMENT ON COLUMN AR_ORDER.COUNTY IS '县区';
COMMENT ON COLUMN AR_ORDER.ADDRESS IS '详细地址';
COMMENT ON COLUMN AR_ORDER.P_CALC_MONTH IS '分区日期';
COMMENT ON COLUMN AR_ORDER.CREATED_AT IS '订单创建时间';
COMMENT ON COLUMN AR_ORDER.CREATE_USER IS '订单创建人';
COMMENT ON COLUMN AR_ORDER.UPDATED_AT IS '修改时间';
COMMENT ON COLUMN AR_ORDER.UPDATER IS '修改人';
COMMENT ON COLUMN AR_ORDER.IS_DELETE IS '是否删除';
COMMENT ON COLUMN AR_ORDER.DELETED_AT IS '删除时间';
ALTER TABLE `AR_ORDER` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_ORDER` ADD INDEX `USER_NAME`(`USER_NAME`) USING BTREE;
ALTER TABLE `AR_ORDER` ADD INDEX `CREATED_AT`(`CREATED_AT`) USING BTREE;
ALTER TABLE `AR_ORDER` ADD INDEX `IS_DELETE`(`IS_DELETE`) USING BTREE;

-- 订单商品
DROP TABLE IF EXISTS `AR_ORDER_GOODS`;
CREATE TABLE AR_ORDER_GOODS
(
    ID varchar(32) NOT NULL,
    ORDER_SN varchar(32) NOT NULL,
    GOODS_ID varchar(32) NOT NULL,
    GOODS_TITLE varchar(255) NOT NULL,
    PRICE decimal(16,2) DEFAULT 0.00 NOT NULL,
    REAL_PRICE decimal(16,2) DEFAULT 0.00 NOT NULL,
    PV decimal(16,2) DEFAULT 0.00 NOT NULL,
    REAL_PV decimal(16,2) DEFAULT 0.00 NOT NULL,
    SKU_CODE varchar(16) NOT NULL,
    BUY_NUMS int(10) DEFAULT 0 NOT NULL,
    P_CALC_MONTH DATE  NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单中包含的商品';
COMMENT ON COLUMN AR_ORDER_GOODS.ORDER_SN IS '订单ID';
COMMENT ON COLUMN AR_ORDER_GOODS.GOODS_ID IS '商品ID';
COMMENT ON COLUMN AR_ORDER_GOODS.GOODS_TITLE IS '商品名称';
COMMENT ON COLUMN AR_ORDER_GOODS.PRICE IS '价格';
COMMENT ON COLUMN AR_ORDER_GOODS.REAL_PRICE IS '实际价格';
COMMENT ON COLUMN AR_ORDER_GOODS.PV IS '订货PV';
COMMENT ON COLUMN AR_ORDER_GOODS.REAL_PV IS '实际PV';
COMMENT ON COLUMN AR_ORDER_GOODS.SKU_CODE IS '商品编码';
COMMENT ON COLUMN AR_ORDER_GOODS.BUY_NUMS IS '购买数量';
COMMENT ON COLUMN AR_ORDER_GOODS.P_CALC_MONTH IS '分区日期';
ALTER TABLE `AR_ORDER_GOODS` ADD INDEX `GOODS_ID`(`GOODS_ID`) USING BTREE;
ALTER TABLE `AR_ORDER_GOODS` ADD INDEX `ORDER_SN`(`ORDER_SN`) USING BTREE;

-- 收货地址
DROP TABLE IF EXISTS `AR_RECEIVE_ADDRESS`;
CREATE TABLE AR_RECEIVE_ADDRESS
(
    ID varchar(32) NOT NULL,
    USER_ID varchar(32) NOT NULL,
    USER_NAME varchar(16) NOT NULL,
    CONSIGNEE varchar(120) NOT NULL,
    MOBILE varchar(11) NOT NULL,
    PROVINCE int(6) NOT NULL,
    CITY int(6) NOT NULL,
    COUNTY int(6) NOT NULL,
    ADDRESS varchar(255) NOT NULL,
    IS_DEFAULT tinyint(1) DEFAULT 0 NOT NULL,
    CREATED_AT int(10) DEFAULT 0 NOT NULL,
    UPDATER varchar(10) DEFAULT '',
    UPDATED_AT int(10) DEFAULT 0 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='收货地址';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.USER_ID IS '用户ID';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.USER_NAME IS '用户编号';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.CONSIGNEE IS '收货人';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.MOBILE IS '收货人手机';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.PROVINCE IS '省份名称';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.CITY IS '城市名称';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.COUNTY IS '县区名称';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.ADDRESS IS '详细地址';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.IS_DEFAULT IS '是否默认';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.UPDATER IS '修改人';
COMMENT ON COLUMN AR_RECEIVE_ADDRESS.UPDATED_AT IS '修改时间';
ALTER TABLE `AR_RECEIVE_ADDRESS` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_RECEIVE_ADDRESS` ADD INDEX `USER_NAME`(`USER_NAME`) USING BTREE;




-- 充值申请
DROP TABLE IF EXISTS `AR_RECHARGE`;
CREATE TABLE AR_RECHARGE
(
  ID              varchar(32) NOT NULL,
  SN              varchar(32),
  USER_ID         varchar(32)                    NOT NULL,
  ID_CARD         varchar(20) ,
  RECHARGE_PERIOD_NUM int(10),
  RECHARGE_YEAR   tinyint(4),
  RECHARGE_MONTH  tinyint(2),
  AMOUNT          float(16, 2) DEFAULT 0.00      NOT NULL,
  REAL_NAME       varchar(255),
  OPEN_BANK       varchar(32),
  BANK_ADDRESS    varchar(255),
  BANK_NO         varchar(32),
  BANK_PROVINCE   int(6),
  BANK_CITY       int(6),
  BANK_COUNTY     int(6),
  P_MONTH         DATE                            NOT NULL,
  AUDIT_STATUS    tinyint(1) DEFAULT 0             NOT NULL,
  BANK_PROVE          varchar(255),
  REMARK          text,
  AUDIT_ADMIN     varchar(32),
  CREATED_AT      int(10)                      NOT NULL,
  AUDITED_AT      int(10) DEFAULT 0            NOT NULL
,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='充值申请';
COMMENT ON COLUMN AR_RECHARGE.SN IS '单号';
COMMENT ON COLUMN AR_RECHARGE.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_RECHARGE.ID_CARD IS '身份证号';
COMMENT ON COLUMN AR_RECHARGE.RECHARGE_PERIOD_NUM IS '充值期数';
COMMENT ON COLUMN AR_RECHARGE.RECHARGE_YEAR IS '充值年份';
COMMENT ON COLUMN AR_RECHARGE.RECHARGE_MONTH IS '充值月份';
COMMENT ON COLUMN AR_RECHARGE.AMOUNT IS '提现金额';
COMMENT ON COLUMN AR_RECHARGE.REAL_NAME IS '会员姓名';
COMMENT ON COLUMN AR_RECHARGE.OPEN_BANK IS '开户行';
COMMENT ON COLUMN AR_RECHARGE.BANK_ADDRESS IS '银行地址';
COMMENT ON COLUMN AR_RECHARGE.BANK_NO IS '银行账号';
COMMENT ON COLUMN AR_RECHARGE.BANK_PROVINCE IS '银行省份';
COMMENT ON COLUMN AR_RECHARGE.BANK_CITY IS '银行城市';
COMMENT ON COLUMN AR_RECHARGE.BANK_COUNTY IS '银行地区';
COMMENT ON COLUMN AR_RECHARGE.BANK_PROVE IS '银行地区';
COMMENT ON COLUMN AR_RECHARGE.P_MONTH IS '表分区标识';
COMMENT ON COLUMN AR_RECHARGE.AUDIT_STATUS IS '审核状态';
COMMENT ON COLUMN AR_RECHARGE.REMARK IS '备注';
COMMENT ON COLUMN AR_RECHARGE.AUDIT_ADMIN IS '审核管理员';
COMMENT ON COLUMN AR_RECHARGE.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_RECHARGE.AUDITED_AT IS '审核时间';

ALTER TABLE `AR_RECHARGE` ADD UNIQUE INDEX `SN`(`SN`) USING BTREE;

-- 现金钱包流水
DROP TABLE IF EXISTS `AR_FLOW_WALLET`;
CREATE TABLE AR_FLOW_WALLET
(
  ID            varchar(32) NOT NULL,
  USER_ID       varchar(32)                    NOT NULL,
  CALC_ID       varchar(32),
  AMOUNT        decimal(16,3) DEFAULT 0.000     NOT NULL,
  TOTAL         decimal(16,3) DEFAULT 0.000     NOT NULL,
  IS_INCR       tinyint(1) DEFAULT 1             NOT NULL,
  REMARK        varchar(255)                   NOT NULL,
  ADMIN_NAME    varchar(32),
  PERIOD_NUM    int(10)                      NOT NULL,
  CALC_MONTH    int(10)                      NOT NULL,
  P_MONTH       DATE                            NOT NULL,
  CREATED_AT    int(10)                      NOT NULL,
  DELETED       tinyint(1) DEFAULT 0             NOT NULL,
  DELETED_AT    int(10) DEFAULT 0            NOT NULL,
  SORT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='现金钱包流水';
COMMENT ON COLUMN AR_FLOW_WALLET.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_FLOW_WALLET.CALC_ID IS '奖金结算表ID';
COMMENT ON COLUMN AR_FLOW_WALLET.AMOUNT IS '金额';
COMMENT ON COLUMN AR_FLOW_WALLET.TOTAL IS '当前总金额';
COMMENT ON COLUMN AR_FLOW_WALLET.IS_INCR IS '是否增加';
COMMENT ON COLUMN AR_FLOW_WALLET.REMARK IS '备注';
COMMENT ON COLUMN AR_FLOW_WALLET.ADMIN_NAME IS '操作人名称';
COMMENT ON COLUMN AR_FLOW_WALLET.PERIOD_NUM IS '所在期数';
COMMENT ON COLUMN AR_FLOW_WALLET.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_FLOW_WALLET.P_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_FLOW_WALLET.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_FLOW_WALLET.DELETED IS '是否删除';
COMMENT ON COLUMN AR_FLOW_WALLET.DELETED_AT IS '删除时间';
COMMENT ON COLUMN AR_FLOW_WALLET.SORT IS '排序';

-- 报单套餐
DROP TABLE IF EXISTS `AR_DECLARATION_PACKAGE`;
CREATE TABLE AR_DECLARATION_PACKAGE
(
	ID         varchar(32) NOT NULL,
	PACKAGE_NAME varchar(48)                    NOT NULL,
	AMOUNT float(16, 2) DEFAULT 0.00     NOT NULL,
	PV float(16, 2) DEFAULT 0.00     NOT NULL,
	LEVEL_ID varchar(32)                    NOT NULL,
	PACKAGE_CONTENT text,
	CREATED_AT    int(10)            NOT NULL,
	CREATE_ADMIN varchar(32)                  NOT NULL,
	UPDATE_ADMIN varchar(32),
	UPDATED_AT int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='报单套餐';
COMMENT ON COLUMN AR_DECLARATION_PACKAGE.PACKAGE_NAME IS '套餐名称';
COMMENT ON COLUMN AR_DECLARATION_PACKAGE.LEVEL_ID IS '所属报单级别ID';
COMMENT ON COLUMN AR_DECLARATION_PACKAGE.AMOUNT IS '报单套餐金额';
COMMENT ON COLUMN AR_DECLARATION_PACKAGE.PV IS '报单套餐PV';
COMMENT ON COLUMN AR_DECLARATION_PACKAGE.PACKAGE_CONTENT IS '套餐内容';
COMMENT ON COLUMN AR_DECLARATION_PACKAGE.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_DECLARATION_PACKAGE.CREATE_ADMIN IS '创建人';
COMMENT ON COLUMN AR_DECLARATION_PACKAGE.UPDATE_ADMIN IS '更新人';
COMMENT ON COLUMN AR_DECLARATION_PACKAGE.UPDATED_AT IS '更新时间';
ALTER TABLE `AR_DECLARATION_PACKAGE` ADD UNIQUE INDEX `PACKAGE_NAME`(`PACKAGE_NAME`) USING BTREE;

-- 商城商品
DROP TABLE IF EXISTS `AR_SHOP_GOODS`;
CREATE TABLE AR_SHOP_GOODS
(
	ID         varchar(32) NOT NULL,
	GOODS_NAME varchar(255)                    NOT NULL,
	CATE_ID varchar(32)                    NOT NULL,
	TYPE       tinyint(2) DEFAULT 1        NOT NULL,
	GOODS_NO varchar(32)                    NOT NULL,
	UNIT varchar(16)                    NOT NULL,
	COVER varchar(255)                    NOT NULL,
	IMAGES text                    NOT NULL,
	CONTENT text                    NOT NULL,
	SELL_PRICE float(16, 2) DEFAULT 0.00     NOT NULL,
	MARKET_PRICE float(16, 2) DEFAULT 0.00     NOT NULL,
	PRICE_PV float(16, 2) DEFAULT 0.00     NOT NULL,
	STORE_NUMS int(10) DEFAULT 0            NOT NULL,
	STATUS tinyint(1) DEFAULT 1        NOT NULL,
	CREATED_AT    int(10)                      NOT NULL,
  UPDATED_AT    int(10) DEFAULT 0            NOT NULL,
  SORT    int(10) DEFAULT 0            NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品';
COMMENT ON COLUMN AR_SHOP_GOODS.GOODS_NAME IS '商品名称';
COMMENT ON COLUMN AR_SHOP_GOODS.CATE_ID IS '所属分类ID';
COMMENT ON COLUMN AR_SHOP_GOODS.TYPE IS '商品类型';
COMMENT ON COLUMN AR_SHOP_GOODS.GOODS_NO IS '商品编号';
COMMENT ON COLUMN AR_SHOP_GOODS.UNIT IS '商品单位';
COMMENT ON COLUMN AR_SHOP_GOODS.COVER IS '商品封面';
COMMENT ON COLUMN AR_SHOP_GOODS.IMAGES IS '商品图片';
COMMENT ON COLUMN AR_SHOP_GOODS.CONTENT IS '商品内容';
COMMENT ON COLUMN AR_SHOP_GOODS.SELL_PRICE IS '销售价格';
COMMENT ON COLUMN AR_SHOP_GOODS.MARKET_PRICE IS '市场价格';
COMMENT ON COLUMN AR_SHOP_GOODS.PRICE_PV IS '价格PV';
COMMENT ON COLUMN AR_SHOP_GOODS.STORE_NUMS IS '商品库存';
COMMENT ON COLUMN AR_SHOP_GOODS.STATUS IS '是否上架';
COMMENT ON COLUMN AR_SHOP_GOODS.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_SHOP_GOODS.UPDATED_AT IS '更新时间';
COMMENT ON COLUMN AR_SHOP_GOODS.SORT IS '排序';

-- AR_CONFIG表数据修改
-- AR_CALC_BONUS_QY表结构修改
-- ALTER TABLE AR_CALC_BONUS_QY ADD ORI_BONUS decimal(16,3) DEFAULT 0 NOT NULL;
-- COMMENT ON COLUMN AR_CALC_BONUS_QY.ORI_BONUS IS '原奖金';
-- ALTER TABLE AR_CALC_BONUS_QY ADD RECONSUME_POINTS decimal(16,3) DEFAULT 0 NOT NULL;
-- COMMENT ON COLUMN AR_CALC_BONUS_QY.RECONSUME_POINTS IS '重复消费积分';
-- ALTER TABLE AR_CALC_BONUS_QY ADD MANAGE_TAX decimal(16,3) DEFAULT 0 NOT NULL;
-- COMMENT ON COLUMN AR_CALC_BONUS_QY.MANAGE_TAX IS '管理费';
-- AR_CALC_BONUS_YC表结构修改
-- ALTER TABLE AR_CALC_BONUS_YC ADD ORI_BONUS decimal(16,3) DEFAULT 0 NOT NULL;
-- COMMENT ON COLUMN AR_CALC_BONUS_YC.ORI_BONUS IS '原奖金';
-- ALTER TABLE AR_CALC_BONUS_YC ADD RECONSUME_POINTS decimal(16,3) DEFAULT 0 NOT NULL;
-- COMMENT ON COLUMN AR_CALC_BONUS_YC.RECONSUME_POINTS IS '重复消费积分';
-- ALTER TABLE AR_CALC_BONUS_YC ADD MANAGE_TAX decimal(16,3) DEFAULT 0 NOT NULL;
-- COMMENT ON COLUMN AR_CALC_BONUS_YC.MANAGE_TAX IS '管理费';
-- AR_DEC_ORDER 表结构修改
-- ALTER TABLE AR_DEC_ORDER RENAME COLUMN REC_USER_NAME TO REC_USER_ID;
-- ALTER TABLE AR_DEC_ORDER RENAME COLUMN CON_USER_NAME TO CON_USER_ID;
-- ALTER TABLE AR_DEC_ORDER DROP COLUMN REC_REAL_NAME;
-- ALTER TABLE AR_DEC_ORDER DROP COLUMN CON_REAL_NAME;
-- COMMENT ON COLUMN AR_DEC_ORDER.REC_USER_ID IS '推荐人ID';
-- COMMENT ON COLUMN AR_DEC_ORDER.CON_USER_ID IS '接点人ID';
-- ALTER TABLE AR_DEC_ORDER ADD DEC_ID varchar(32) DEFAULT '' NULL;
-- COMMENT ON COLUMN AR_DEC_ORDER.DEC_ID IS '报单中心ID';
-- AR_EMPLOY_LEVEL 表字段修改
-- ALTER TABLE AR_EMPLOY_LEVEL ADD RX_PERCENT decimal(16,2) DEFAULT 0.00 NOT NULL;
-- COMMENT ON COLUMN AR_EMPLOY_LEVEL.RX_PERCENT IS '荣衔奖比例';
-- ALTER TABLE AR_EMPLOY_LEVEL ADD OTHER_DEPART_PERF decimal(16,2) DEFAULT 0.00 NOT NULL;
-- COMMENT ON COLUMN AR_EMPLOY_LEVEL.OTHER_DEPART_PERF IS '去除最大部门，其它部门的累计推荐业绩';
-- AR_DECLARATION_LEVEL 表字段修改
-- ALTER TABLE AR_DECLARATION_LEVEL ADD GL_ODD_DEEP_ONE int(10) DEFAULT 1 NOT NULL;
-- COMMENT ON COLUMN AR_DECLARATION_LEVEL.GL_ODD_DEEP_ONE IS '共享奖推荐1人拿的代数';
-- ALTER TABLE AR_DECLARATION_LEVEL ADD GL_ODD_DEEP_TWO int(10) DEFAULT 1 NOT NULL;
-- COMMENT ON COLUMN AR_DECLARATION_LEVEL.GL_ODD_DEEP_TWO IS '共享奖推荐2人拿的代数';
-- ALTER TABLE AR_DECLARATION_LEVEL ADD GL_ODD_DEEP_THREE int(10) DEFAULT 1 NOT NULL;
-- COMMENT ON COLUMN AR_DECLARATION_LEVEL.GL_ODD_DEEP_THREE IS '共享奖推荐3人拿的代数';
-- ALTER TABLE AR_DECLARATION_LEVEL ADD INCOME_CAP decimal(16,2) DEFAULT 0.00 NOT NULL;
-- COMMENT ON COLUMN AR_DECLARATION_LEVEL.INCOME_CAP IS '共享奖推荐3人拿的代数';
-- AR_PERF_PERIOD 表字段修改
ALTER TABLE AR_PERF_PERIOD ADD PV_PSS decimal(16,3) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_PERF_PERIOD.PV_PSS IS '推荐团队业绩';
-- AR_PERF_MONTH 表字段修改
ALTER TABLE AR_PERF_MONTH ADD PV_PSS decimal(16,3) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_PERF_MONTH.PV_PSS IS '推荐团队业绩';
ALTER TABLE AR_PERF_MONTH ADD PV_PSS_TOTAL decimal(16,3) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_PERF_MONTH.PV_PSS_TOTAL IS '累计推荐团队业绩';
-- AR_CALC_BONUS 表字段修改
ALTER TABLE AR_CALC_BONUS ADD BONUS_BD decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_BD IS '报单奖';
ALTER TABLE AR_CALC_BONUS ADD ORI_BONUS_BD decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.ORI_BONUS_BD IS '报单奖原奖金';

ALTER TABLE AR_CALC_BONUS ADD BONUS_TG decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_TG IS '推广奖';
ALTER TABLE AR_CALC_BONUS ADD ORI_BONUS_TG decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.ORI_BONUS_TG IS '推广奖原奖金';

ALTER TABLE AR_CALC_BONUS ADD BONUS_YJ decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_YJ IS '业绩奖';
ALTER TABLE AR_CALC_BONUS ADD ORI_BONUS_YJ decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.ORI_BONUS_YJ IS '业绩奖原奖金';

ALTER TABLE AR_CALC_BONUS ADD ORI_BONUS_QY decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.ORI_BONUS_QY IS '团队奖原奖金';

ALTER TABLE AR_CALC_BONUS ADD ORI_BONUS_YC decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.ORI_BONUS_YC IS '荣衔奖奖原奖金';

ALTER TABLE AR_CALC_BONUS ADD BONUS_GX decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_GX IS '共享奖';
ALTER TABLE AR_CALC_BONUS ADD ORI_BONUS_GX decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.ORI_BONUS_GX IS '共享奖原奖金';

ALTER TABLE AR_CALC_BONUS ADD BONUS_GL decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.BONUS_GL IS '管理奖';
ALTER TABLE AR_CALC_BONUS ADD ORI_BONUS_GL decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.ORI_BONUS_GL IS '管理奖原奖金';

ALTER TABLE AR_CALC_BONUS ADD RECONSUME_POINTS decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.RECONSUME_POINTS IS '复消积分';

ALTER TABLE AR_CALC_BONUS ADD MANAGE_TAX decimal(16,3) default 0.000 NOT NULL;
COMMENT ON COLUMN AR_CALC_BONUS.MANAGE_TAX IS '管理费';

-- AR_USER_PERF 表字段修改
ALTER TABLE AR_USER_PERF ADD PV_PSS decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_PERF.PV_PSS IS '推荐团队累计业绩';

-- AR_USER_BONUS 表字段修改
ALTER TABLE AR_USER_BONUS ADD BD_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.BD_TOTAL IS '报单奖累计';
ALTER TABLE AR_USER_BONUS ADD TG_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.TG_TOTAL IS '推广奖累计';
ALTER TABLE AR_USER_BONUS ADD YJ_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.YJ_TOTAL IS '业绩奖累计';
ALTER TABLE AR_USER_BONUS ADD GX_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.GX_TOTAL IS '共享奖累计';
ALTER TABLE AR_USER_BONUS ADD GL_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.GL_TOTAL IS '管理奖累计';

ALTER TABLE AR_USER_BONUS ADD RECONSUME_POINTS decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.RECONSUME_POINTS IS '复消积分';
ALTER TABLE AR_USER_BONUS ADD RECONSUME_POINTS_EXPIRED decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.RECONSUME_POINTS_EXPIRED IS '过期的复消积分';
ALTER TABLE AR_USER_BONUS ADD RECONSUME_POINTS_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.RECONSUME_POINTS_TOTAL IS '复消积分累计';
ALTER TABLE AR_USER_BONUS ADD MANAGE_TAX decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.MANAGE_TAX IS '管理费累计';

ALTER TABLE AR_USER_BONUS ADD ORI_QY_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.ORI_QY_TOTAL IS '团队奖原奖金累计';
ALTER TABLE AR_USER_BONUS ADD ORI_YC_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.ORI_YC_TOTAL IS '荣衔奖原奖金累计';
ALTER TABLE AR_USER_BONUS ADD ORI_BD_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.ORI_BD_TOTAL IS '报单奖原奖金累计';
ALTER TABLE AR_USER_BONUS ADD ORI_TG_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.ORI_TG_TOTAL IS '推广奖原奖金累计';
ALTER TABLE AR_USER_BONUS ADD ORI_YJ_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.ORI_YJ_TOTAL IS '业绩奖原奖金累计';
ALTER TABLE AR_USER_BONUS ADD ORI_GX_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.ORI_GX_TOTAL IS '共享奖原奖金累计';
ALTER TABLE AR_USER_BONUS ADD ORI_GL_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.ORI_GL_TOTAL IS '管理奖原奖金累计';

ALTER TABLE AR_USER_BONUS ADD BONUS_TOTAL decimal(16,2) DEFAULT 0 NOT NULL;
COMMENT ON COLUMN AR_USER_BONUS.BONUS_TOTAL IS '总奖金累计';

-- 新增表如下：
DROP TABLE IF EXISTS `AR_FLOW_RECONSUME_POINTS`;
CREATE TABLE AR_FLOW_RECONSUME_POINTS
(
	ID varchar(32) NOT NULL,
	USER_ID varchar(32) NOT NULL,
	LAST_DEC_LV varchar(32) DEFAULT '',
	LAST_EMP_LV varchar(32) DEFAULT '',
	LAST_STATUS tinyint(1) DEFAULT 0 NOT NULL,
	AMOUNT decimal(16,3) DEFAULT 0.000 NOT NULL,
	TOTAL decimal(16,3) DEFAULT 0.000 NOT NULL,
	IS_INCR tinyint(1) DEFAULT 1 NOT NULL,
	REMARK varchar(255) NOT NULL,
	REMARK_IS_SHOW tinyint(1) DEFAULT 1 NOT NULL,
	DEAL_TYPE_ID varchar(32),
	DEAL_TYPE_IS_PRESET tinyint(1) DEFAULT 1 NOT NULL,
	ADMIN_NAME varchar(32),
	PERIOD_NUM int(10) NOT NULL,
	CALC_MONTH int(10) NOT NULL,
	P_MONTH DATE NOT NULL,
	CREATED_AT int(10) NOT NULL,
	DELETED tinyint(1) DEFAULT 0 NOT NULL,
	DELETED_AT int(10) DEFAULT 0 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='重消积分流水';

COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.LAST_DEC_LV IS '记录时会员级别';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.LAST_EMP_LV IS '记录时会员聘级';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.LAST_STATUS IS '记录时状态';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.AMOUNT IS '金额';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.TOTAL IS '当前总金额';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.IS_INCR IS '是否增加';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.REMARK IS '备注';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.REMARK_IS_SHOW IS '备注是否显示';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.DEAL_TYPE_ID IS '交易类型ID';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.DEAL_TYPE_IS_PRESET IS '交易类型是否预置';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.ADMIN_NAME IS '操作人名称';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.PERIOD_NUM IS '所在期数';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.P_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.DELETED IS '是否删除';
COMMENT ON COLUMN AR_FLOW_RECONSUME_POINTS.DELETED_AT IS '删除时间';

ALTER TABLE `AR_FLOW_RECONSUME_POINTS` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;

DROP TABLE IF EXISTS `AR_CALC_BONUS_BD`;
CREATE TABLE AR_CALC_BONUS_BD
(
	ID varchar(32) NOT NULL,
	USER_ID varchar(32) NOT NULL,
	LAST_DEC_LV varchar(32) DEFAULT '',
	LAST_EMP_LV varchar(32) DEFAULT '',
	LAST_STATUS tinyint(1) DEFAULT 0             NOT NULL,
	FROM_USER_ID varchar(32) NOT NULL,
  LAST_FROM_DEC_LV varchar(32) DEFAULT '',
  LAST_FROM_EMP_LV varchar(32) DEFAULT '',
  LAST_FROM_STATUS tinyint(1) DEFAULT 0 NOT NULL,
	AMOUNT decimal(16,3) DEFAULT 0.000     NOT NULL,
	PERIOD_NUM int(10) NOT NULL,
	CALC_YEAR int(10) NOT NULL,
	CALC_MONTH int(10) NOT NULL,
	P_CALC_MONTH DATE NOT NULL,
	LOGS varchar(2000) DEFAULT '',
	CREATED_AT int(10) NOT NULL,
	ORI_BONUS decimal(16,3) DEFAULT 0 NOT NULL,
	RECONSUME_POINTS decimal(16,3) DEFAULT 0 NOT NULL,
	MANAGE_TAX decimal(16,3) DEFAULT 0 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='报单奖结算记录';

COMMENT ON COLUMN AR_CALC_BONUS_BD.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_BD.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_BD.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_BD.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_BD.FROM_USER_ID IS '来源会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_BD.LAST_FROM_DEC_LV IS '结算时来源会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_BD.LAST_FROM_EMP_LV IS '结算时来源会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_BD.LAST_FROM_STATUS IS '结算时来源状态';
COMMENT ON COLUMN AR_CALC_BONUS_BD.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_BD.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_BD.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_BD.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_BD.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_BD.LOGS IS '日志';
COMMENT ON COLUMN AR_CALC_BONUS_BD.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_BD.ORI_BONUS IS '原奖金';
COMMENT ON COLUMN AR_CALC_BONUS_BD.RECONSUME_POINTS IS '重复消费积分';
COMMENT ON COLUMN AR_CALC_BONUS_BD.MANAGE_TAX IS '管理费';


DROP TABLE IF EXISTS `AR_CALC_BONUS_TG`;
CREATE TABLE AR_CALC_BONUS_TG
(
	ID varchar(32) NOT NULL,
	USER_ID varchar(32) NOT NULL,
	LAST_DEC_LV varchar(32) DEFAULT '',
	LAST_EMP_LV varchar(32) DEFAULT '',
	LAST_STATUS tinyint(1) DEFAULT 0             NOT NULL,
	FROM_USER_ID varchar(32) NOT NULL,
  LAST_FROM_DEC_LV varchar(32) DEFAULT '',
  LAST_FROM_EMP_LV varchar(32) DEFAULT '',
  LAST_FROM_STATUS tinyint(1) DEFAULT 0 NOT NULL,
	AMOUNT decimal(16,3) DEFAULT 0.000     NOT NULL,
	PERIOD_NUM int(10) NOT NULL,
	CALC_YEAR int(10) NOT NULL,
	CALC_MONTH int(10) NOT NULL,
	P_CALC_MONTH DATE NOT NULL,
	LOGS varchar(2000) DEFAULT '',
	CREATED_AT int(10) NOT NULL,
	ORI_BONUS decimal(16,3) DEFAULT 0 NOT NULL,
	RECONSUME_POINTS decimal(16,3) DEFAULT 0 NOT NULL,
	MANAGE_TAX decimal(16,3) DEFAULT 0 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='推广奖结算记录';

COMMENT ON COLUMN AR_CALC_BONUS_TG.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_TG.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_TG.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_TG.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_TG.FROM_USER_ID IS '来源会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_TG.LAST_FROM_DEC_LV IS '结算时来源会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_TG.LAST_FROM_EMP_LV IS '结算时来源会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_TG.LAST_FROM_STATUS IS '结算时来源状态';
COMMENT ON COLUMN AR_CALC_BONUS_TG.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_TG.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_TG.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_TG.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_TG.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_TG.LOGS IS '日志';
COMMENT ON COLUMN AR_CALC_BONUS_TG.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_TG.ORI_BONUS IS '原奖金';
COMMENT ON COLUMN AR_CALC_BONUS_TG.RECONSUME_POINTS IS '重复消费积分';
COMMENT ON COLUMN AR_CALC_BONUS_TG.MANAGE_TAX IS '管理费';


DROP TABLE IF EXISTS `AR_CALC_BONUS_YJ`;
CREATE TABLE AR_CALC_BONUS_YJ
(
	ID varchar(32) NOT NULL,
	USER_ID varchar(32) NOT NULL,
	LAST_DEC_LV varchar(32) DEFAULT '',
	LAST_EMP_LV varchar(32) DEFAULT '',
	LAST_STATUS tinyint(1) DEFAULT 0             NOT NULL,
  FROM_USER_ID varchar(32) NOT NULL,
  LAST_FROM_DEC_LV varchar(32) DEFAULT '',
  LAST_FROM_EMP_LV varchar(32) DEFAULT '',
  LAST_FROM_STATUS tinyint(1) DEFAULT 0 NOT NULL,
	AMOUNT decimal(16,3) DEFAULT 0.000     NOT NULL,
	PERIOD_NUM int(10) NOT NULL,
	CALC_YEAR int(10) NOT NULL,
	CALC_MONTH int(10) NOT NULL,
	P_CALC_MONTH DATE NOT NULL,
	LOGS varchar(2000) DEFAULT '',
	CREATED_AT int(10) NOT NULL,
	ORI_BONUS decimal(16,3) DEFAULT 0 NOT NULL,
	RECONSUME_POINTS decimal(16,3) DEFAULT 0 NOT NULL,
	MANAGE_TAX decimal(16,3) DEFAULT 0 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='业绩奖结算记录';

COMMENT ON COLUMN AR_CALC_BONUS_YJ.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.FROM_USER_ID IS '来源会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.LAST_FROM_DEC_LV IS '结算时来源会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.LAST_FROM_EMP_LV IS '结算时来源会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.LAST_FROM_STATUS IS '结算时来源状态';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.LOGS IS '日志';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.ORI_BONUS IS '原奖金';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.RECONSUME_POINTS IS '重复消费积分';
COMMENT ON COLUMN AR_CALC_BONUS_YJ.MANAGE_TAX IS '管理费';


DROP TABLE IF EXISTS `AR_CALC_BONUS_GX`;
CREATE TABLE AR_CALC_BONUS_GX
(
	ID varchar(32) NOT NULL,
	USER_ID varchar(32) NOT NULL,
	LAST_DEC_LV varchar(32) DEFAULT '',
	LAST_EMP_LV varchar(32) DEFAULT '',
	LAST_STATUS tinyint(1) DEFAULT 0             NOT NULL,
	FROM_USER_ID varchar(32) NOT NULL,
  LAST_FROM_DEC_LV varchar(32) DEFAULT '',
  LAST_FROM_EMP_LV varchar(32) DEFAULT '',
  LAST_FROM_STATUS tinyint(1) DEFAULT 0 NOT NULL,
	AMOUNT decimal(16,3) DEFAULT 0.000     NOT NULL,
	PERIOD_NUM int(10) NOT NULL,
	CALC_YEAR int(10) NOT NULL,
	CALC_MONTH int(10) NOT NULL,
	P_CALC_MONTH DATE NOT NULL,
	LOGS varchar(2000) DEFAULT '',
	CREATED_AT int(10) NOT NULL,
	ORI_BONUS decimal(16,3) DEFAULT 0 NOT NULL,
	RECONSUME_POINTS decimal(16,3) DEFAULT 0 NOT NULL,
	MANAGE_TAX decimal(16,3) DEFAULT 0 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='共享奖结算记录';
ALTER TABLE `AR_CALC_BONUS_GX` ADD INDEX `USER_ID`(`USER_ID`) USING BTREE;
ALTER TABLE `AR_CALC_BONUS_GX` ADD INDEX `FROM_USER_ID`(`FROM_USER_ID`) USING BTREE;
ALTER TABLE `AR_CALC_BONUS_GX` ADD INDEX `PERIOD_NUM`(`PERIOD_NUM`) USING BTREE;

COMMENT ON COLUMN AR_CALC_BONUS_GX.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_GX.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_GX.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_GX.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_GX.FROM_USER_ID IS '来源会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_GX.LAST_FROM_DEC_LV IS '结算时来源会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_GX.LAST_FROM_EMP_LV IS '结算时来源会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_GX.LAST_FROM_STATUS IS '结算时来源状态';
COMMENT ON COLUMN AR_CALC_BONUS_GX.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_GX.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_GX.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_GX.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_GX.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_GX.LOGS IS '日志';
COMMENT ON COLUMN AR_CALC_BONUS_GX.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_GX.ORI_BONUS IS '原奖金';
COMMENT ON COLUMN AR_CALC_BONUS_GX.RECONSUME_POINTS IS '重复消费积分';
COMMENT ON COLUMN AR_CALC_BONUS_GX.MANAGE_TAX IS '管理费';

DROP TABLE IF EXISTS `AR_CALC_BONUS_GL`;
CREATE TABLE AR_CALC_BONUS_GL
(
	ID varchar(32) NOT NULL,
	USER_ID varchar(32) NOT NULL,
	LAST_DEC_LV varchar(32) DEFAULT '',
	LAST_EMP_LV varchar(32) DEFAULT '',
	LAST_STATUS tinyint(1) DEFAULT 0             NOT NULL,
	FROM_USER_ID varchar(32) NOT NULL,
  LAST_FROM_DEC_LV varchar(32) DEFAULT '',
  LAST_FROM_EMP_LV varchar(32) DEFAULT '',
  LAST_FROM_STATUS tinyint(1) DEFAULT 0 NOT NULL,
	AMOUNT decimal(16,3) DEFAULT 0.000     NOT NULL,
	PERIOD_NUM int(10) NOT NULL,
	CALC_YEAR int(10) NOT NULL,
	CALC_MONTH int(10) NOT NULL,
	P_CALC_MONTH DATE NOT NULL,
	LOGS varchar(2000) DEFAULT '',
	CREATED_AT int(10) NOT NULL,
	ORI_BONUS decimal(16,3) DEFAULT 0 NOT NULL,
	RECONSUME_POINTS decimal(16,3) DEFAULT 0 NOT NULL,
	MANAGE_TAX decimal(16,3) DEFAULT 0 NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='管理奖结算记录';
COMMENT ON COLUMN AR_CALC_BONUS_GL.USER_ID IS '会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_GL.LAST_DEC_LV IS '结算时会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_GL.LAST_EMP_LV IS '结算时会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_GL.LAST_STATUS IS '结算时状态';
COMMENT ON COLUMN AR_CALC_BONUS_GL.FROM_USER_ID IS '来源会员ID';
COMMENT ON COLUMN AR_CALC_BONUS_GL.LAST_FROM_DEC_LV IS '结算时来源会员级别';
COMMENT ON COLUMN AR_CALC_BONUS_GL.LAST_FROM_EMP_LV IS '结算时来源会员聘级';
COMMENT ON COLUMN AR_CALC_BONUS_GL.LAST_FROM_STATUS IS '结算时来源状态';
COMMENT ON COLUMN AR_CALC_BONUS_GL.AMOUNT IS '奖金金额';
COMMENT ON COLUMN AR_CALC_BONUS_GL.PERIOD_NUM IS '结算期数';
COMMENT ON COLUMN AR_CALC_BONUS_GL.CALC_YEAR IS '所在结算年';
COMMENT ON COLUMN AR_CALC_BONUS_GL.CALC_MONTH IS '所在结算月';
COMMENT ON COLUMN AR_CALC_BONUS_GL.P_CALC_MONTH IS '表分区的日期索引';
COMMENT ON COLUMN AR_CALC_BONUS_GL.LOGS IS '日志';
COMMENT ON COLUMN AR_CALC_BONUS_GL.CREATED_AT IS '创建时间';
COMMENT ON COLUMN AR_CALC_BONUS_GL.ORI_BONUS IS '原奖金';
COMMENT ON COLUMN AR_CALC_BONUS_GL.RECONSUME_POINTS IS '重复消费积分';
COMMENT ON COLUMN AR_CALC_BONUS_GL.MANAGE_TAX IS '管理费';

-- 老系统用户表
DROP TABLE IF EXISTS `AR_TMP_OLD_USER`;
CREATE TABLE AR_TMP_OLD_USER
(
  ID          varchar(32) NOT NULL,
  USER_NAME         varchar(16)                    NOT NULL,
  REAL_NAME         varchar(128)                    NOT NULL,
  REC_USER_NAME  varchar(16)                    NOT NULL,
  REC_REAL_NAME  varchar(128)                    NOT NULL,
  NET_USER_NAME  varchar(16)                    NOT NULL,
  NET_REAL_NAME  varchar(128)                    NOT NULL,
  SORT  int(10) DEFAULT 0                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='老系统会员关系临时表';
COMMENT ON COLUMN AR_TMP_OLD_USER.USER_NAME IS '编号';
COMMENT ON COLUMN AR_TMP_OLD_USER.REAL_NAME IS '名称';
COMMENT ON COLUMN AR_TMP_OLD_USER.REC_USER_NAME IS '推荐人编号';
COMMENT ON COLUMN AR_TMP_OLD_USER.REC_REAL_NAME IS '推荐人姓名';
COMMENT ON COLUMN AR_TMP_OLD_USER.NET_USER_NAME IS '安置人编号';
COMMENT ON COLUMN AR_TMP_OLD_USER.NET_REAL_NAME IS '安置人姓名';
COMMENT ON COLUMN AR_TMP_OLD_USER.SORT IS '排序';

ALTER TABLE `AR_TMP_OLD_USER` ADD INDEX `USER_NAME`(`USER_NAME`) USING BTREE;
ALTER TABLE `AR_TMP_OLD_USER` ADD INDEX `REC_USER_NAME`(`REC_USER_NAME`) USING BTREE;
ALTER TABLE `AR_TMP_OLD_USER` ADD INDEX `NET_USER_NAME`(`NET_USER_NAME`) USING BTREE;
ALTER TABLE `AR_TMP_OLD_USER` ADD INDEX `SORT`(`SORT`) USING BTREE;


-- 老系统会员关系临时表
DROP TABLE IF EXISTS `AR_TMP_OLD_NETWORK`;
CREATE TABLE AR_TMP_OLD_NETWORK
(
  ID          varchar(32) NOT NULL,
  USER_NAME         varchar(16)                    NOT NULL,
  REAL_NAME         varchar(128)                    NOT NULL,
  PARENT_USER_NAME  varchar(16)                    NOT NULL,
  PARENT_REAL_NAME  varchar(128)                    NOT NULL,
  NET_USER_NAME  varchar(16)                    NOT NULL,
  NET_REAL_NAME  varchar(128)                    NOT NULL,
  SORT  int(10) DEFAULT 0                      NOT NULL,
	PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='老系统会员关系临时表';
COMMENT ON COLUMN AR_TMP_OLD_NETWORK.USER_NAME IS '编号';
COMMENT ON COLUMN AR_TMP_OLD_NETWORK.REAL_NAME IS '姓名';
COMMENT ON COLUMN AR_TMP_OLD_NETWORK.PARENT_USER_NAME IS '上级编号';
COMMENT ON COLUMN AR_TMP_OLD_NETWORK.PARENT_REAL_NAME IS '上级姓名';
COMMENT ON COLUMN AR_TMP_OLD_NETWORK.NET_USER_NAME IS '安置人编号';
COMMENT ON COLUMN AR_TMP_OLD_NETWORK.NET_REAL_NAME IS '安置人姓名';
COMMENT ON COLUMN AR_TMP_OLD_NETWORK.SORT IS '排序';

ALTER TABLE `AR_TMP_OLD_NETWORK` ADD INDEX `USER_NAME`(`USER_NAME`) USING BTREE;
ALTER TABLE `AR_TMP_OLD_NETWORK` ADD INDEX `PARENT_USER_NAME`(`PARENT_USER_NAME`) USING BTREE;
ALTER TABLE `AR_TMP_OLD_NETWORK` ADD INDEX `NET_USER_NAME`(`NET_USER_NAME`) USING BTREE;
ALTER TABLE `AR_TMP_OLD_NETWORK` ADD INDEX `SORT`(`SORT`) USING BTREE;