/* 配合汉鹏的新设计，重建积分相关数据表 */


-- 增加 会员资产变化类别表, 此表主要用于设置各种导致用户资产发生变化的行为的分值变化
-- 字段有id、类别码（数字类型，在java中对应常量）、类别名称、类别描述、变化值（就是签到身价加100那个100）
CREATE TABLE `distri_social_status_change_category`  (
                                                  `id` bigint NOT NULL COMMENT '会员身价变化类别id',
                                                  `name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '类别名称',
                                                  `code` int NOT NULL DEFAULT -1 COMMENT '类别码',
                                                  `variation_value` int NOT NULL DEFAULT 0 COMMENT '身价点数在本类别操作的变化值',
                                                  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '描述',

                                                  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
                                                  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                                  `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
                                                  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                                  `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                                  `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
                                                  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员身价变化类别表' ROW_FORMAT = Dynamic;

--  会员身价变化日志表
--  字段有会员资产变化类别id、分值、操作时间、对象名(如 订单表名)、对象id（如 订单id）、是否已生效、计划生效时间、实际生效时间、描述
CREATE TABLE `distri_social_status_change_log`  (
                                                  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '会员身价变化日志id',
                                                  `social_status_change_category_id` bigint NOT NULL COMMENT '会员资产变化类别id',-- 新加字段
                                                  `variation_value` bigint NOT NULL COMMENT '身价点数在本类别操作的变化值',
                                                  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '操作时间',
                                                  `object_id` bigint NOT NULL DEFAULT 0 COMMENT '操作对应业务对象id，例如订单id',
                                                  `effective` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已生效',
                                                  `description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '描述',
                                                  `plan_effective_time` datetime NULL COMMENT '计划生效时间',
                                                  `actual_effective_time` datetime NULL COMMENT '实际生效时间',

                                                  `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
                                                  `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
                                                  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                                  `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                                  `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
                                                  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '店铺表' ROW_FORMAT = Dynamic;

-- 增加 会员签到表
CREATE TABLE `distri_sign_in`  (
                                   `id` bigint NOT NULL AUTO_INCREMENT COMMENT '会员签到表id',
                                   `user_id` bigint NOT NULL DEFAULT 0 COMMENT '会员用户id',
                                   `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '签到时间',

                                   `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
                                   `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
                                   `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                   `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
                                   `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
                                   PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '店铺表' ROW_FORMAT = Dynamic;
