-- ======================================== -- yanzhu-module-member 建表 SQL -- 数据库: MySQL 8.0+ -- 会员中心模块 -- ======================================== SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS = 0; -- ======================================== -- 会员核心表 -- ======================================== -- ---------------------------- -- Table structure for member_user -- ---------------------------- DROP TABLE IF EXISTS `member_user`; CREATE TABLE `member_user` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户编号', `nickname` varchar(30) NOT NULL DEFAULT '' COMMENT '用户昵称', `avatar` varchar(255) NOT NULL DEFAULT '' COMMENT '用户头像', `mobile` varchar(11) NOT NULL COMMENT '手机号', `password` varchar(100) NOT NULL DEFAULT '' COMMENT '密码', `status` tinyint NOT NULL COMMENT '状态', `register_ip` varchar(32) NOT NULL COMMENT '注册 IP', `register_terminal` tinyint NOT NULL DEFAULT 3 COMMENT '注册终端', `login_ip` varchar(50) NOT NULL DEFAULT '' COMMENT '最后登录IP', `login_date` datetime DEFAULT NULL COMMENT '最后登录时间', `name` varchar(30) DEFAULT NULL COMMENT '真实名字', `sex` tinyint DEFAULT NULL COMMENT '性别', `birthday` datetime DEFAULT NULL COMMENT '出生日期', `area_id` int DEFAULT NULL COMMENT '所在地', `mark` varchar(255) DEFAULT NULL COMMENT '用户备注', `point` int NOT NULL DEFAULT 0 COMMENT '积分', `tag_ids` text COMMENT '用户标签编号列表', `level_id` bigint DEFAULT NULL COMMENT '等级编号', `experience` int DEFAULT NULL COMMENT '经验', `group_id` bigint DEFAULT NULL COMMENT '用户分组编号', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`), UNIQUE KEY `uk_mobile` (`mobile`), KEY `idx_area_id` (`area_id`), KEY `idx_group_id` (`group_id`), KEY `idx_level_id` (`level_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员表'; -- ---------------------------- -- Table structure for member_config -- ---------------------------- DROP TABLE IF EXISTS `member_config`; CREATE TABLE `member_config` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `point_trade_deduct_enable` bit(1) DEFAULT NULL COMMENT '积分抵扣开关', `point_trade_deduct_unit_price` int DEFAULT NULL COMMENT '积分抵扣单位价格', `point_trade_deduct_max_price` int DEFAULT NULL COMMENT '积分抵扣最大值', `point_trade_give_point` int DEFAULT NULL COMMENT '1元赠送积分', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员配置'; -- ---------------------------- -- Table structure for member_address -- ---------------------------- DROP TABLE IF EXISTS `member_address`; CREATE TABLE `member_address` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `user_id` bigint NOT NULL COMMENT '用户编号', `name` varchar(10) NOT NULL COMMENT '收件人名称', `mobile` varchar(20) NOT NULL COMMENT '手机号', `area_id` bigint NOT NULL COMMENT '地区编号', `detail_address` varchar(250) NOT NULL COMMENT '收件详细地址', `default_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否默认', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`), KEY `idx_user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户收件地址'; -- ---------------------------- -- Table structure for member_tag -- ---------------------------- DROP TABLE IF EXISTS `member_tag`; CREATE TABLE `member_tag` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `name` varchar(50) NOT NULL COMMENT '标签名称', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员标签'; -- ---------------------------- -- Table structure for member_level -- ---------------------------- DROP TABLE IF EXISTS `member_level`; CREATE TABLE `member_level` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `name` varchar(50) NOT NULL COMMENT '等级名称', `level` int NOT NULL COMMENT '等级', `experience` int NOT NULL COMMENT '升级经验', `discount_percent` int NOT NULL DEFAULT 100 COMMENT '享受折扣', `icon` varchar(255) NOT NULL DEFAULT '' COMMENT '等级图标', `background_url` varchar(255) NOT NULL DEFAULT '' COMMENT '等级背景图', `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`), KEY `idx_level` (`level`), KEY `idx_experience` (`experience`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员等级'; -- ---------------------------- -- Table structure for member_group -- ---------------------------- DROP TABLE IF EXISTS `member_group`; CREATE TABLE `member_group` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `name` varchar(50) NOT NULL COMMENT '名称', `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '备注', `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户分组'; -- ======================================== -- 积分记录表 -- ======================================== -- ---------------------------- -- Table structure for member_point_record -- ---------------------------- DROP TABLE IF EXISTS `member_point_record`; CREATE TABLE `member_point_record` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `user_id` bigint NOT NULL COMMENT '用户编号', `biz_type` int NOT NULL COMMENT '业务类型', `biz_id` varchar(32) DEFAULT NULL COMMENT '业务编号', `title` varchar(100) NOT NULL COMMENT '积分标题', `description` varchar(500) DEFAULT NULL COMMENT '积分描述', `point` int NOT NULL COMMENT '变动积分', `total_point` int NOT NULL COMMENT '变动后的积分', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`), KEY `idx_user_id` (`user_id`), KEY `idx_biz_type` (`biz_type`), KEY `idx_biz_id` (`biz_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='积分记录'; -- ======================================== -- 经验记录表 -- ======================================== -- ---------------------------- -- Table structure for member_experience_record -- ---------------------------- DROP TABLE IF EXISTS `member_experience_record`; CREATE TABLE `member_experience_record` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `user_id` bigint NOT NULL COMMENT '用户编号', `biz_type` int NOT NULL COMMENT '业务类型', `biz_id` varchar(32) DEFAULT NULL COMMENT '业务编号', `title` varchar(100) NOT NULL COMMENT '标题', `description` varchar(500) DEFAULT NULL COMMENT '描述', `experience` int NOT NULL COMMENT '经验', `total_experience` int NOT NULL COMMENT '变更后的经验', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`), KEY `idx_user_id` (`user_id`), KEY `idx_biz_type` (`biz_type`), KEY `idx_biz_id` (`biz_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='经验记录'; -- ---------------------------- -- Table structure for member_level_record -- ---------------------------- DROP TABLE IF EXISTS `member_level_record`; CREATE TABLE `member_level_record` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `user_id` bigint NOT NULL COMMENT '用户编号', `level_id` bigint NOT NULL COMMENT '等级编号', `level` int NOT NULL COMMENT '会员等级', `discount_percent` int NOT NULL DEFAULT 100 COMMENT '享受折扣', `experience` int NOT NULL COMMENT '升级经验', `user_experience` int NOT NULL COMMENT '会员此时的经验', `remark` varchar(500) DEFAULT NULL COMMENT '备注', `description` varchar(500) DEFAULT NULL COMMENT '描述', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`), KEY `idx_user_id` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='等级记录'; -- ======================================== -- 签到记录表 -- ======================================== -- ---------------------------- -- Table structure for member_sign_in_config -- ---------------------------- DROP TABLE IF EXISTS `member_sign_in_config`; CREATE TABLE `member_sign_in_config` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '规则编号', `day` int NOT NULL COMMENT '签到第x天', `point` int NOT NULL DEFAULT 0 COMMENT '奖励积分', `experience` int NOT NULL DEFAULT 0 COMMENT '奖励经验', `status` tinyint NOT NULL DEFAULT 1 COMMENT '状态', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`), KEY `idx_day` (`day`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='签到规则'; -- ---------------------------- -- Table structure for member_sign_in_record -- ---------------------------- DROP TABLE IF EXISTS `member_sign_in_record`; CREATE TABLE `member_sign_in_record` ( `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', `user_id` bigint NOT NULL COMMENT '签到用户', `day` int NOT NULL COMMENT '第几天签到', `point` int NOT NULL DEFAULT 0 COMMENT '签到积分', `experience` int NOT NULL DEFAULT 0 COMMENT '签到经验', `creator` varchar(64) DEFAULT '' COMMENT '创建者', `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', `updater` varchar(64) 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`), KEY `idx_user_id` (`user_id`), KEY `idx_create_time` (`create_time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='签到记录'; SET FOREIGN_KEY_CHECKS = 1;