DROP TABLE IF EXISTS `AR_QTR_CALC_USER`;
CREATE TABLE `AR_QTR_CALC_USER`  (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `USER_ID` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `AMOUNT` decimal(16, 3) NULL DEFAULT NULL,
  `CALC_YEAR` int(11) NULL DEFAULT NULL,
  `CALC_MONTH` int(11) NULL DEFAULT NULL,
  `PERIOD_NUM` int(11) NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 106 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;


DROP TABLE IF EXISTS `AR_QTR_CALC_RECORD`;
CREATE TABLE `AR_QTR_CALC_RECORD`  (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `EVENT` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `CREATION_TIME` datetime(0) NULL DEFAULT NULL,
  `CALC_PERIOD_ID` int(11) NULL DEFAULT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 406209 CHARACTER SET = utf8 COLLATE = utf8_general_ci  ROW_FORMAT = Dynamic;


DROP TABLE IF EXISTS `AR_CALC_BONUS_QUARTER`;
CREATE TABLE `AR_CALC_BONUS_QUARTER`  (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `USER_ID` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `ORI_BONUS` decimal(16, 3) NULL DEFAULT NULL,
  `MANAGE_TAX` decimal(16, 3) NULL DEFAULT NULL,
  `AMOUNT` decimal(16, 3) NULL DEFAULT NULL,
  `RECONSUME_POINTS` decimal(16, 3) NULL DEFAULT NULL,
  `LAST_DEC_LV` varchar(32)  CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
  `CALC_MONTH` int(11) NULL DEFAULT NULL,
  `PERIOD_NUM` int(11) NULL DEFAULT NULL,
  `CREATED_AT` datetime(0) NOT NULL,
  PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2005 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `AR_QTR_CALC_WEIGHT`;
CREATE TABLE `AR_QTR_CALC_WEIGHT`  (
    `ID` int(11) NOT NULL AUTO_INCREMENT,
    `USER_ID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
    `MAX_SORT` int(11) NULL DEFAULT NULL,
    `WEIGHT` decimal(16, 3) NULL DEFAULT NULL,
    `PERIOD_NUM` int(11) NULL DEFAULT NULL,
    `CALC_MONTH` int(11) NULL DEFAULT NULL,
    `CALC_YEAR` int(11) NULL DEFAULT NULL,
    PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 512 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

DROP TABLE IF EXISTS `AR_QTR_CALC_SCORE`;
CREATE TABLE `AR_QTR_CALC_SCORE`  (
    `ID` int(11) NOT NULL AUTO_INCREMENT,
    `USER_ID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
    `CNT` int(11) NOT NULL,
    `SCORE` decimal(16, 3) NOT NULL,
    `CALC_MONTH` int(11) NULL DEFAULT NULL,
    `CALC_YEAR` int(11) NULL DEFAULT NULL,
    PRIMARY KEY (`ID`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 256 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;

alter table `AR_CALC_BONUS` add column ORI_BONUS_QUARTER decimal(16,2) not null default 0.00 comment "季度奖-原奖金";
alter table `AR_CALC_BONUS` add column BONUS_QUARTER decimal(16,2) not null default 0.00 comment "季度奖";
ALTER TABLE `AR_CALC_BONUS_QUARTER` ADD COLUMN LAST_DEC_LV varchar(32)  CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;