4、微服务数据库设计(2)

# 4、 renrenmall_ums ---> 人人商城-会员服务 <img src="https://cos.easydoc.net/40732029/files/kt1fxwew.png"/> ```sql drop table if exists ums_growth_change_history; drop table if exists ums_integration_change_history; drop table if exists ums_member; drop table if exists ums_member_collect_spu; drop table if exists ums_member_collect_subject; drop table if exists ums_member_level; drop table if exists ums_member_login_log; drop table if exists ums_member_receive_address; drop table if exists ums_member_statistics_info; /*==============================================================*/ /* Table: ums_growth_change_history */ /*==============================================================*/ create table ums_growth_change_history ( id bigint not null auto_increment comment 'id', member_id bigint comment 'member_id', create_time datetime comment 'create_time', change_count int comment '改变的值(正负计数)', note varchar(0) comment '备注', source_type tinyint comment '积分来源[0-购物,1-管理员修改]', primary key (id) ); alter table ums_growth_change_history comment '成长值变化历史记录'; /*==============================================================*/ /* Table: ums_integration_change_history */ /*==============================================================*/ create table ums_integration_change_history ( id bigint not null auto_increment comment 'id', member_id bigint comment 'member_id', create_time datetime comment 'create_time', change_count int comment '变化的值', note varchar(255) comment '备注', source_tyoe tinyint comment '来源[0->购物;1->管理员修改;2->活动]', primary key (id) ); alter table ums_integration_change_history comment '积分变化历史记录'; /*==============================================================*/ /* Table: ums_member */ /*==============================================================*/ create table ums_member ( id bigint not null auto_increment comment 'id', level_id bigint comment '会员等级id', username char(64) comment '用户名', password varchar(64) comment '密码', nickname varchar(64) comment '昵称', mobile varchar(20) comment '手机号码', email varchar(64) comment '邮箱', header varchar(500) comment '头像', gender tinyint comment '性别', birth date comment '生日', city varchar(500) comment '所在城市', job varchar(255) comment '职业', sign varchar(255) comment '个性签名', source_type tinyint comment '用户来源', integration int comment '积分', growth int comment '成长值', status tinyint comment '启用状态', create_time datetime comment '注册时间', primary key (id) ); alter table ums_member comment '会员'; /*==============================================================*/ /* Table: ums_member_collect_spu */ /*==============================================================*/ create table ums_member_collect_spu ( id bigint not null comment 'id', member_id bigint comment '会员id', spu_id bigint comment 'spu_id', spu_name varchar(500) comment 'spu_name', spu_img varchar(500) comment 'spu_img', create_time datetime comment 'create_time', primary key (id) ); alter table ums_member_collect_spu comment '会员收藏的商品'; /*==============================================================*/ /* Table: ums_member_collect_subject */ /*==============================================================*/ create table ums_member_collect_subject ( id bigint not null auto_increment comment 'id', subject_id bigint comment 'subject_id', subject_name varchar(255) comment 'subject_name', subject_img varchar(500) comment 'subject_img', subject_urll varchar(500) comment '活动url', primary key (id) ); alter table ums_member_collect_subject comment '会员收藏的专题活动'; /*==============================================================*/ /* Table: ums_member_level */ /*==============================================================*/ create table ums_member_level ( id bigint not null auto_increment comment 'id', name varchar(100) comment '等级名称', growth_point int comment '等级需要的成长值', default_status tinyint comment '是否为默认等级[0->不是;1->是]', free_freight_point decimal(18,4) comment '免运费标准', comment_growth_point int comment '每次评价获取的成长值', priviledge_free_freight tinyint comment '是否有免邮特权', priviledge_member_price tinyint comment '是否有会员价格特权', priviledge_birthday tinyint comment '是否有生日特权', note varchar(255) comment '备注', primary key (id) ); alter table ums_member_level comment '会员等级'; /*==============================================================*/ /* Table: ums_member_login_log */ /*==============================================================*/ create table ums_member_login_log ( id bigint not null auto_increment comment 'id', member_id bigint comment 'member_id', create_time datetime comment '创建时间', ip varchar(64) comment 'ip', city varchar(64) comment 'city', login_type tinyint(1) comment '登录类型[1-web,2-app]', primary key (id) ); alter table ums_member_login_log comment '会员登录记录'; /*==============================================================*/ /* Table: ums_member_receive_address */ /*==============================================================*/ create table ums_member_receive_address ( id bigint not null auto_increment comment 'id', member_id bigint comment 'member_id', name varchar(255) comment '收货人姓名', phone varchar(64) comment '电话', post_code varchar(64) comment '邮政编码', province varchar(100) comment '省份/直辖市', city varchar(100) comment '城市', region varchar(100) comment '区', detail_address varchar(255) comment '详细地址(街道)', areacode varchar(15) comment '省市区代码', default_status tinyint(1) comment '是否默认', primary key (id) ); alter table ums_member_receive_address comment '会员收货地址'; /*==============================================================*/ /* Table: ums_member_statistics_info */ /*==============================================================*/ create table ums_member_statistics_info ( id bigint not null auto_increment comment 'id', member_id bigint comment '会员id', consume_amount decimal(18,4) comment '累计消费金额', coupon_amount decimal(18,4) comment '累计优惠金额', order_count int comment '订单数量', coupon_count int comment '优惠券数量', comment_count int comment '评价数', return_order_count int comment '退货数量', login_count int comment '登录次数', attend_count int comment '关注数量', fans_count int comment '粉丝数量', collect_product_count int comment '收藏的商品数量', collect_subject_count int comment '收藏的专题活动数量', collect_comment_count int comment '收藏的评论数量', invite_friend_count int comment '邀请的朋友数量', primary key (id) ); alter table ums_member_statistics_info comment '会员统计信息'; ``` # 5、renrenmall_sms ---> 人人商城-优惠卷服务 <img src="https://cos.easydoc.net/40732029/files/kt1gm70q.png"/> ```sql drop table if exists sms_coupon; drop table if exists sms_coupon_history; drop table if exists sms_coupon_spu_category_relation; drop table if exists sms_coupon_spu_relation; drop table if exists sms_home_adv; drop table if exists sms_home_subject; drop table if exists sms_home_subject_spu; drop table if exists sms_member_price; drop table if exists sms_seckill_promotion; drop table if exists sms_seckill_session; drop table if exists sms_seckill_sku_notice; drop table if exists sms_seckill_sku_relation; drop table if exists sms_sku_full_reduction; drop table if exists sms_sku_ladder; drop table if exists sms_spu_bounds; /*==============================================================*/ /* Table: sms_coupon */ /*==============================================================*/ create table sms_coupon ( id bigint not null auto_increment comment 'id', coupon_type tinyint(1) comment '优惠卷类型[0->全场赠券;1->会员赠券;2->购物赠券;3->注册赠券]', coupon_img varchar(2000) comment '优惠券图片', coupon_name varchar(100) comment '优惠卷名字', num int comment '数量', amount decimal(18,4) comment '金额', per_limit int comment '每人限领张数', min_point decimal(18,4) comment '使用门槛', start_time datetime comment '开始时间', end_time datetime comment '结束时间', use_type tinyint(1) comment '使用类型[0->全场通用;1->指定分类;2->指定商品]', note varchar(200) comment '备注', publish_count int(11) comment '发行数量', use_count int(11) comment '已使用数量', receive_count int(11) comment '领取数量', enable_start_time datetime comment '可以领取的开始日期', enable_end_time datetime comment '可以领取的结束日期', code varchar(64) comment '优惠码', member_level tinyint(1) comment '可以领取的会员等级[0->不限等级,其他-对应等级]', publish tinyint(1) comment '发布状态[0-未发布,1-已发布]', primary key (id) ); alter table sms_coupon comment '优惠券信息'; /*==============================================================*/ /* Table: sms_coupon_history */ /*==============================================================*/ create table sms_coupon_history ( id bigint not null auto_increment comment 'id', coupon_id bigint comment '优惠券id', member_id bigint comment '会员id', member_nick_name varchar(64) comment '会员名字', get_type tinyint(1) comment '获取方式[0->后台赠送;1->主动领取]', create_time datetime comment '创建时间', use_type tinyint(1) comment '使用状态[0->未使用;1->已使用;2->已过期]', use_time datetime comment '使用时间', order_id bigint comment '订单id', order_sn bigint comment '订单号', primary key (id) ); alter table sms_coupon_history comment '优惠券领取历史记录'; /*==============================================================*/ /* Table: sms_coupon_spu_category_relation */ /*==============================================================*/ create table sms_coupon_spu_category_relation ( id bigint not null auto_increment comment 'id', coupon_id bigint comment '优惠券id', category_id bigint comment '产品分类id', category_name varchar(64) comment '产品分类名称', primary key (id) ); alter table sms_coupon_spu_category_relation comment '优惠券分类关联'; /*==============================================================*/ /* Table: sms_coupon_spu_relation */ /*==============================================================*/ create table sms_coupon_spu_relation ( id bigint not null auto_increment comment 'id', coupon_id bigint comment '优惠券id', spu_id bigint comment 'spu_id', spu_name varchar(255) comment 'spu_name', primary key (id) ); alter table sms_coupon_spu_relation comment '优惠券与产品关联'; /*==============================================================*/ /* Table: sms_home_adv */ /*==============================================================*/ create table sms_home_adv ( id bigint not null auto_increment comment 'id', name varchar(100) comment '名字', pic varchar(500) comment '图片地址', start_time datetime comment '开始时间', end_time datetime comment '结束时间', status tinyint(1) comment '状态', click_count int comment '点击数', url varchar(500) comment '广告详情连接地址', note varchar(500) comment '备注', sort int comment '排序', publisher_id bigint comment '发布者', auth_id bigint comment '审核者', primary key (id) ); alter table sms_home_adv comment '首页轮播广告'; /*==============================================================*/ /* Table: sms_home_subject */ /*==============================================================*/ create table sms_home_subject ( id bigint not null auto_increment comment 'id', name varchar(200) comment '专题名字', title varchar(255) comment '专题标题', sub_title varchar(255) comment '专题副标题', status tinyint(1) comment '显示状态', url varchar(500) comment '详情连接', sort int comment '排序', img varchar(500) comment '专题图片地址', primary key (id) ); alter table sms_home_subject comment '首页专题表【jd首页下面很多专题,每个专题链接新的页面,展示专题商品信息】'; /*==============================================================*/ /* Table: sms_home_subject_spu */ /*==============================================================*/ create table sms_home_subject_spu ( id bigint not null auto_increment comment 'id', name varchar(200) comment '专题名字', subject_id bigint comment '专题id', spu_id bigint comment 'spu_id', sort int comment '排序', primary key (id) ); alter table sms_home_subject_spu comment '专题商品'; /*==============================================================*/ /* Table: sms_member_price */ /*==============================================================*/ create table sms_member_price ( id bigint not null auto_increment comment 'id', sku_id bigint comment 'sku_id', member_level_id bigint comment '会员等级id', member_level_name varchar(100) comment '会员等级名', member_price decimal(18,4) comment '会员对应价格', add_other tinyint(1) comment '可否叠加其他优惠[0-不可叠加优惠,1-可叠加]', primary key (id) ); alter table sms_member_price comment '商品会员价格'; /*==============================================================*/ /* Table: sms_seckill_promotion */ /*==============================================================*/ create table sms_seckill_promotion ( id bigint not null auto_increment comment 'id', title varchar(255) comment '活动标题', start_time datetime comment '开始日期', end_time datetime comment '结束日期', status tinyint comment '上下线状态', create_time datetime comment '创建时间', user_id bigint comment '创建人', primary key (id) ); alter table sms_seckill_promotion comment '秒杀活动'; /*==============================================================*/ /* Table: sms_seckill_session */ /*==============================================================*/ create table sms_seckill_session ( id bigint not null auto_increment comment 'id', name varchar(200) comment '场次名称', start_time datetime comment '每日开始时间', end_time datetime comment '每日结束时间', status tinyint(1) comment '启用状态', create_time datetime comment '创建时间', primary key (id) ); alter table sms_seckill_session comment '秒杀活动场次'; /*==============================================================*/ /* Table: sms_seckill_sku_notice */ /*==============================================================*/ create table sms_seckill_sku_notice ( id bigint not null auto_increment comment 'id', member_id bigint comment 'member_id', sku_id bigint comment 'sku_id', session_id bigint comment '活动场次id', subcribe_time datetime comment '订阅时间', send_time datetime comment '发送时间', notice_type tinyint(1) comment '通知方式[0-短信,1-邮件]', primary key (id) ); alter table sms_seckill_sku_notice comment '秒杀商品通知订阅'; /*==============================================================*/ /* Table: sms_seckill_sku_relation */ /*==============================================================*/ create table sms_seckill_sku_relation ( id bigint not null auto_increment comment 'id', promotion_id bigint comment '活动id', promotion_session_id bigint comment '活动场次id', sku_id bigint comment '商品id', seckill_price decimal comment '秒杀价格', seckill_count decimal comment '秒杀总量', seckill_limit decimal comment '每人限购数量', seckill_sort int comment '排序', primary key (id) ); alter table sms_seckill_sku_relation comment '秒杀活动商品关联'; /*==============================================================*/ /* Table: sms_sku_full_reduction */ /*==============================================================*/ create table sms_sku_full_reduction ( id bigint not null auto_increment comment 'id', sku_id bigint comment 'spu_id', full_price decimal(18,4) comment '满多少', reduce_price decimal(18,4) comment '减多少', add_other tinyint(1) comment '是否参与其他优惠', primary key (id) ); alter table sms_sku_full_reduction comment '商品满减信息'; /*==============================================================*/ /* Table: sms_sku_ladder */ /*==============================================================*/ create table sms_sku_ladder ( id bigint not null auto_increment comment 'id', sku_id bigint comment 'spu_id', full_count int comment '满几件', discount decimal(4,2) comment '打几折', price decimal(18,4) comment '折后价', add_other tinyint(1) comment '是否叠加其他优惠[0-不可叠加,1-可叠加]', primary key (id) ); alter table sms_sku_ladder comment '商品阶梯价格'; /*==============================================================*/ /* Table: sms_spu_bounds */ /*==============================================================*/ create table sms_spu_bounds ( id bigint not null auto_increment comment 'id', spu_id bigint, grow_bounds decimal(18,4) comment '成长积分', buy_bounds decimal(18,4) comment '购物积分', work tinyint(1) comment '优惠生效情况[1111(四个状态位,从右到左);0 - 无优惠,成长积分是否赠送;1 - 无优惠,购物积分是否赠送;2 - 有优惠,成长积分是否赠送;3 - 有优惠,购物积分是否赠送【状态位0:不赠送,1:赠送】]', primary key (id) ); alter table sms_spu_bounds comment '商品spu积分设置'; ```