/*用户基本信息*/
DROP TABLE IF EXISTS `bubble_user`;
CREATE TABLE `bubble_user`
(
    `id`                bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    `nick_name`         varchar(20)         NOT NULL COMMENT '昵称',
    `head_url`          varchar(256)        NOT NULL COMMENT '头像地址',
    `phone_number`      varchar(11)         NOT NULL COMMENT '手机账号',
    `open_id`           varchar(128)        NOT NULL COMMENT '微信登陆id',
    `status`            tinyint(2)          NOT NULL COMMENT '账号状态[1-正常|2-禁用|3-官方]',
    `password`          varchar(20)         NOT NULL COMMENT '密码',
    `balance`           int(10)             NOT NULL COMMENT '泡泡币',
    `bubble_currency`   int(10)             NOT NULL COMMENT '退货金额[分]',
    `income_currency`   int(10)             NOT NULL COMMENT '活动金额[分]',
    `invitation_people` int(10)             NOT NULL COMMENT '邀请人数',
    `invitation_money`  int(10)             NOT NULL COMMENT '邀请奖励金额[分]',
    `forbidden_status`  tinyint(2)          NOT NULL COMMENT '是否禁言[1否/2是]',
    `forbidden_time`    datetime DEFAULT NULL COMMENT '禁言结束时间',
    `remark`            varchar(256)        NOT NULL COMMENT '个人说明',
    `created_at`        datetime DEFAULT NULL COMMENT '创建日期',
    `updated_at`        datetime DEFAULT NULL COMMENT '修改日期',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 10003
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='泡泡用户表';
CREATE INDEX ix_bubble_user_phone ON `bubble_user` (phone_number);
CREATE INDEX ix_bubble_user_open ON `bubble_user` (open_id);

/*广告*/
DROP TABLE IF EXISTS `bubble_advertisement`;
CREATE TABLE `bubble_advertisement`
(
    `id`         bigint(20)   NOT NULL AUTO_INCREMENT COMMENT '广告id',
    `ad_type`    varchar(11)  NOT NULL COMMENT '广告类型',
    `img_url`    varchar(512) NOT NULL COMMENT '图片地址',
    `jump_url`   varchar(64)  NOT NULL COMMENT '跳转地址',
    `status`     char(1)  DEFAULT '1' COMMENT '广告状态（1正/2停）',
    `created_at` datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at` datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 30002
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='广告表';
CREATE INDEX ix_bubble_ad_img ON `bubble_advertisement` (ad_type);

/*系列标签*/
DROP TABLE IF EXISTS `bubble_tag_config`;
CREATE TABLE `bubble_tag_config`
(
    `id`                  bigint(20)   NOT NULL AUTO_INCREMENT COMMENT '标签id',
    `tag_type`            tinyint(4)   NOT NULL COMMENT '标签类型[1商品/2话题/3圈子/4盲盒]',
    `tag_name`            varchar(64)  NOT NULL COMMENT '标签名称',
    `tag_img`             varchar(128) NOT NULL COMMENT '标签图标',
    `blind_box_cover_img` text         NOT NULL COMMENT '盲盒封面图',
    `tag_status`          char(1)  DEFAULT '1' COMMENT '标签状态[1正常/2删除]',
    `created_at`          datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`          datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 30007
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='标签配置';


/*商品列表 */
DROP TABLE IF EXISTS `bubble_commodity_list`;
CREATE TABLE `bubble_commodity_list`
(
    `id`                bigint(20)    NOT NULL AUTO_INCREMENT COMMENT '商品id',
    `series_id`         bigint(20)    NOT NULL COMMENT '所属系列id',
    `price`             int(10)       NOT NULL COMMENT '商品价格[分]',
    `commodity_status`  tinyint(2)    NOT NULL COMMENT '商品状态(1正常/2停售)',
    `is_recommend`      tinyint(2)    NOT NULL COMMENT '推荐状态[1-是/2-否]',
    `commodity_img`     varchar(512)  NOT NULL COMMENT '商品图片[img1|img2]',
    `commodity_name`    varchar(128)  NOT NULL COMMENT '商品名称',
    `commodity_details` varchar(512)  NOT NULL COMMENT '商品详情图片',
    `commodity_explain` varchar(1024) NOT NULL COMMENT '商品详情文字',
    `discount_status`   tinyint(2)    NOT NULL COMMENT '折扣状态[1-开启/2-关闭]',
    `created_at`        datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`        datetime DEFAULT NULL COMMENT '修改时间',
    `preSale_at`        datetime DEFAULT NULL COMMENT '预售时间',
    `freight`           bigint(10)    NOT NULL COMMENT '运费',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 50002
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='商品列表';
CREATE INDEX ix_bubble_commodity_name ON `bubble_commodity_list` (commodity_name);
CREATE INDEX ix_bubble_series_id_1 ON `bubble_commodity_list` (series_id);

/*商品尺寸*/
DROP TABLE IF EXISTS `bubble_commodity_size`;
CREATE TABLE `bubble_commodity_size`
(
    `id`                  bigint(20)   NOT NULL AUTO_INCREMENT COMMENT '尺寸id',
    `commodity_id`        int(10)      NOT NULL COMMENT '商品id',
    `commodity_size`      varchar(128) NOT NULL COMMENT '商品规格',
    `commodity_num`       int(10)      NOT NULL COMMENT '商品数量',
    `commodity_old_price` int(10)      NOT NULL COMMENT '商品原价[分]',
    `commodity_new_price` int(10)      NOT NULL COMMENT '商品则扣价[分]',
    `created_at`          datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`          datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 80002
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='商品尺寸';
CREATE INDEX ix_bubble_commodity_id ON `bubble_commodity_size` (commodity_id);

/*盲盒商品*/
DROP TABLE IF EXISTS `bubble_blind_box_list`;
CREATE TABLE `bubble_blind_box_list`
(
    `id`                  bigint(20)   NOT NULL AUTO_INCREMENT COMMENT '商品id',
    `series_id`           bigint(20)   NOT NULL COMMENT '所属系列id',
    `price`               int(10)      NOT NULL COMMENT '商品价格[分]',
    `commodity_new_price` int(10)      NOT NULL COMMENT '商品则扣价[分]',
    `commodity_number`    int(10)      NOT NULL COMMENT '库存数量',
    `commodity_weight`    int(10)  DEFAULT '1' COMMENT '抽取权重',
    `commodity_status`    tinyint(2)   NOT NULL COMMENT '商品状态(1正常/2停售/3预售)',
    `is_recommend`        tinyint(2)   NOT NULL COMMENT '推荐状态[1-是/2-否]',
    `commodity_img`       varchar(512) NOT NULL COMMENT '商品图片[img1|img2]',
    `commodity_name`      varchar(128) NOT NULL COMMENT '商品名称',
    `commodity_details`   varchar(512) NOT NULL COMMENT '商品详情图片',
    `commodity_explain`   varchar(512) NOT NULL COMMENT '商品详情文字',
    `discount_status`     tinyint(2)   NOT NULL COMMENT '折扣状态[1-开启/2-关闭]',
    `created_at`          datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`          datetime DEFAULT NULL COMMENT '修改时间',
    `style`               tinyint(2)   NOT NULL COMMENT '是否为隐藏款',
    `freight`             bigint(10)   NOT NULL COMMENT '运费',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 50003
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='盲盒商品列表';
CREATE INDEX index_bubble_1_name ON `bubble_blind_box_list` (commodity_name);
CREATE INDEX index_bubble_series_id ON `bubble_blind_box_list` (series_id);

/*购物车*/
DROP TABLE IF EXISTS `bubble_shop_cart`;
CREATE TABLE `bubble_shop_cart`
(
    `id`             bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
    `user_id`        bigint(20) NOT NULL COMMENT '用户id',
    `series_id`      bigint(20) NOT NULL COMMENT '所属系列id',
    `commodity_id`   bigint(20) NOT NULL COMMENT '商品id',
    `commodity_size` bigint(10) NOT NULL COMMENT '商品规格id',
    `commodity_num`  int(10)    NOT NULL COMMENT '囤积商品数量',
    `commodity_type` tinyint(2) NOT NULL COMMENT '商品类型[1盲盒/2商城]',
    `created_at`     datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`     datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 10001
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='购物车';
CREATE INDEX ix_cart_user_id ON `bubble_shop_cart` (user_id);
CREATE INDEX ix_cart_comm_id ON `bubble_shop_cart` (commodity_id);
CREATE INDEX ix_cart_series_id ON `bubble_shop_cart` (series_id);

/*收货地址*/
DROP TABLE IF EXISTS `bubble_receiving_address`;
CREATE TABLE `bubble_receiving_address`
(
    `id`                bigint(20)   NOT NULL AUTO_INCREMENT COMMENT 'id',
    `user_id`           bigint(20)   NOT NULL COMMENT '用户id',
    `receiving_name`    varchar(16)  NOT NULL COMMENT '收货人名称',
    `receiving_phone`   varchar(11)  NOT NULL COMMENT '收货人电话',
    `receiving_address` varchar(128) NOT NULL COMMENT '收货人地址',
    `is_default`        tinyint(1) DEFAULT '0' COMMENT '是否位默认收获地址',
    `tag`               tinyint(2)   NOT NULL COMMENT '标签[1家/2公司/3学校]',
    `created_at`        datetime   DEFAULT NULL COMMENT '创建时间',
    `updated_at`        datetime   DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 10003
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='用户收货地址';
CREATE INDEX ix_receiving_user_id ON `bubble_receiving_address` (user_id);
CREATE INDEX ix_receiving_phone ON `bubble_receiving_address` (receiving_phone);

/*个人奖励记录*/
DROP TABLE IF EXISTS `bubble_invitation_friend`;
CREATE TABLE `bubble_invitation_friend`
(
    `id`           bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
    `user_id`      bigint(20) NOT NULL COMMENT '参与人id',
    `friend_id`    bigint(20) NOT NULL COMMENT '受邀人id',
    `reward_money` int(10)    NOT NULL COMMENT '奖励金额[分]',
    `created_at`   datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`   datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 60001
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='邀请记录';
CREATE INDEX ix_invitation_user_id ON `bubble_invitation_friend` (user_id);

/*道具卡配置*/
DROP TABLE IF EXISTS `bubble_prop_card_config`;
CREATE TABLE `bubble_prop_card_config`
(
    `id`          bigint(20)  NOT NULL AUTO_INCREMENT COMMENT 'id',
    `card_name`   varchar(32) NOT NULL COMMENT '道具卡名称',
    `explain`     varchar(64) NOT NULL COMMENT '功能说明',
    `price`       int(10)     NOT NULL COMMENT '单价[分]',
    `card_type`   tinyint(2)  NOT NULL COMMENT '类型[1盲盒/2商城]',
    `created_at`  datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`  datetime DEFAULT NULL COMMENT '修改时间',
    `card_class`  tinyint(2)  NOT NULL COMMENT '类型1排除/2透视',
    `card_money`  int(10)     NOT NULL COMMENT '折扣价[分]',
    `card_status` tinyint(2)  NOT NULL COMMENT '折扣状态[1开启/2关闭]',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 80002
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='道具卡';

/*用户道具卡*/
DROP TABLE IF EXISTS `bubble_user_prop_card`;
CREATE TABLE `bubble_user_prop_card`
(
    `id`           bigint(20)  NOT NULL AUTO_INCREMENT COMMENT 'id',
    `card_id`      bigint(20)  NOT NULL COMMENT '道具卡id',
    `user_id`      bigint(20)  NOT NULL COMMENT '用户id',
    `use_status`   tinyint(1)  NOT NULL COMMENT '1未使用/2-使用',
    `created_at`   datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`   datetime DEFAULT NULL COMMENT '修改时间',
    `commodity_id` bigint(10)  NOT NULL COMMENT '透视/排除id',
    `card_type`    tinyint(2)  NOT NULL COMMENT '卡类型1透视/2排除',
    `series_id`    bigint(10)  NOT NULL COMMENT '系列id',
    `pay_status`   tinyint(2)  NOT NULL COMMENT '支付状态[1未支付/2已支付]',
    `pay_money`    int(10)  DEFAULT NULL COMMENT '支付金额',
    `order_id`     varchar(64) NOT NULL COMMENT '订单id',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 80021
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='用户道具卡';
CREATE INDEX ix_user_prop_card_id ON `bubble_user_prop_card` (card_id);
CREATE INDEX ix_user_prop_user_id ON `bubble_user_prop_card` (user_id);

/*活动配置*/
DROP TABLE IF EXISTS `bubble_activity_config`;
CREATE TABLE `bubble_activity_config`
(
    `id`              bigint(20)   NOT NULL AUTO_INCREMENT COMMENT 'id',
    `activity_name`   varchar(64)  NOT NULL COMMENT '活动名称',
    `activity_img`    varchar(128) NOT NULL COMMENT '活动图标',
    `activity_type`   varchar(16)  NOT NULL COMMENT '活动类型',
    `activity_status` tinyint(1)   NOT NULL COMMENT '活动状态[1开启/2关闭/3删除]',
    `start_at`        datetime DEFAULT NULL COMMENT '活动开始时间',
    `end_at`          datetime DEFAULT NULL COMMENT '活动结束时间',
    `created_at`      datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`      datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 30011
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='活动配置';
CREATE INDEX ix_activity_config ON `bubble_activity_config` (start_at, end_at);


/*优惠券活动*/
DROP TABLE IF EXISTS `bubble_activity_coupon_config`;
CREATE TABLE `bubble_activity_coupon_config`
(
    `id`            bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '优惠券id',
    `parent_id`     bigint(20)  NOT NULL COMMENT '活动父id',
    `coupon_name`   varchar(24) NOT NULL COMMENT '优惠券名字',
    `support_type`  tinyint(2)  NOT NULL COMMENT '优惠券类型[1盲盒/2商城]',
    `activity_type` tinyint(2)  NOT NULL COMMENT '活动类型[1-无门槛/2-满减/3-待定]',
    `min_money`     int(10)     NOT NULL COMMENT '最小消费金额[分]',
    `reduce_money`  int(10)     NOT NULL COMMENT '活动减少金额[分]',
    `coupon_time`   int(10)     NOT NULL COMMENT '券领取后有效时间[天]',
    `created_at`    datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`    datetime DEFAULT NULL COMMENT '修改时间',
    `end_at`        datetime DEFAULT NULL COMMENT '截止时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 65004
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='优惠券配置';
CREATE INDEX ix_coupon_cfg ON `bubble_activity_coupon_config` (parent_id);

/*分销活动配置*/
DROP TABLE IF EXISTS `bubble_activity_desiri_config`;
CREATE TABLE `bubble_activity_desiri_config`
(
    `id`                   bigint(20)   NOT NULL AUTO_INCREMENT COMMENT 'id',
    `parent_id`            bigint(20)   NOT NULL COMMENT '活动父id',
    `distribution_money`   int(10)      NOT NULL COMMENT '分销奖励金额[分]',
    `distribution_explain` varchar(256) NOT NULL COMMENT '活动说明',
    `created_at`           datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`           datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 6201
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='分销活动配置';
CREATE INDEX ix_coupon_cfg ON `bubble_activity_desiri_config` (parent_id);


/*用户获取的优惠券*/
DROP TABLE IF EXISTS `bubble_coupon_user`;
CREATE TABLE `bubble_coupon_user`
(
    `id`          bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
    `user_id`     bigint(20) NOT NULL COMMENT '用户id',
    `activity_id` bigint(20) NOT NULL COMMENT '活动id',
    `coupon_id`   bigint(20) NOT NULL COMMENT '券id',
    `use_type`    tinyint(2) NOT NULL COMMENT '使用状态[1-未使用/2-已经使用/3-已过期/4-删除]',
    `get_at`      datetime DEFAULT NULL COMMENT '获取时间',
    `invalid_at`  datetime DEFAULT NULL COMMENT '失效时间',
    `over_at`     datetime DEFAULT NULL COMMENT '结束时间',
    `created_at`  datetime DEFAULT NULL COMMENT '创建时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 75001
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='用户优惠券';
CREATE INDEX ix_coupon_user_id ON `bubble_coupon_user` (user_id);
CREATE INDEX ix_coupon_id ON `bubble_coupon_user` (coupon_id);

/*用户动态*/
DROP TABLE IF EXISTS `bubble_user_dynamic`;
CREATE TABLE `bubble_user_dynamic`
(
    `id`              bigint(20)   NOT NULL AUTO_INCREMENT COMMENT '动态id',
    `dynamic_type`    tinyint(2)   NOT NULL COMMENT '动态类型[1官方/2用户]',
    `user_id`         bigint(20)   NOT NULL COMMENT '用户id',
    `dynamic_text`    varchar(512) NOT NULL COMMENT '动态内容',
    `dynamic_img`     varchar(512) NOT NULL COMMENT '动态图片',
    `commodity_id`    bigint(20)   NOT NULL COMMENT '产品id(官方账号)',
    `dynamic_like`    int(10)      NOT NULL COMMENT '动态点赞数',
    `dynamic_comment` int(10)      NOT NULL COMMENT '动态评论数',
    `dynamic_circle`  bigint(20)   NOT NULL COMMENT '圈子',
    `dynamic_topic`   varchar(32)  NOT NULL COMMENT '话题[]',
    `created_at`      datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`      datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 12506
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='用户动态';
CREATE INDEX ix_user_dynamic_id ON `bubble_user_dynamic` (user_id);
CREATE INDEX index_user_dynamic_circle ON `bubble_user_dynamic` (dynamic_circle);
CREATE INDEX index_user_dynamic_topic ON `bubble_user_dynamic` (dynamic_topic);
CREATE INDEX index_user_dynamic_created ON `bubble_user_dynamic` (created_at);

/*动态点赞*/
DROP TABLE IF EXISTS `bubble_dynamic_like`;
CREATE TABLE `bubble_dynamic_like`
(
    `id`         bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
    `user_id`    bigint(20) NOT NULL COMMENT '用户id',
    `dynamic_id` bigint(20) NOT NULL COMMENT '动态id',
    `created_at` datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at` datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 5006
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='点赞记录';
CREATE INDEX ix_like_record_user ON `bubble_dynamic_like` (user_id);
CREATE INDEX ix_like_record_dynamic ON `bubble_dynamic_like` (dynamic_id);

/*动态评论*/
DROP TABLE IF EXISTS `bubble_dynamic_comment`;
CREATE TABLE `bubble_dynamic_comment`
(
    `id`                      bigint(20)   NOT NULL AUTO_INCREMENT COMMENT 'id',
    `user_id`                 bigint(20)   NOT NULL COMMENT '发布人id',
    `user_name`               varchar(16)  NOT NULL COMMENT '发布人名称',
    `dynamic_id`              bigint(20)   NOT NULL COMMENT '动态id',
    `parent_comment_id`       bigint(20)   NOT NULL COMMENT '父评论id',
    `parent_comment_user`     bigint(20)   NOT NULL COMMENT '父评论用户id',
    `parent_comment_userName` varchar(32)  NOT NULL COMMENT '父评论用户名',
    `reply_comment_id`        bigint(20)   NOT NULL COMMENT '子评论id',
    `reply_comment_user`      bigint(20)   NOT NULL COMMENT '子评论用户id',
    `reply_comment_user_name` varchar(32)  NOT NULL COMMENT '子评论用户名',
    `comment_level`           tinyint(2)   NOT NULL COMMENT '评论等级[1父/2子]',
    `content`                 varchar(256) NOT NULL COMMENT '评论内容',
    `status`                  tinyint(2)   NOT NULL COMMENT '评论状态[1正常/2删除]',
    `created_at`              datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`              datetime DEFAULT NULL COMMENT '修改时间',
    `parent_head`             varchar(256) NOT NULL COMMENT '父评论头像',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 84011
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='评论表';
CREATE INDEX ix_comment_user_id ON `bubble_dynamic_comment` (user_id);

/*预约记录 */
DROP TABLE IF EXISTS `bubble_make_an_appoint`;
CREATE TABLE `bubble_make_an_appoint`
(
    `id`           bigint(20) NOT NULL AUTO_INCREMENT COMMENT '预约记录id',
    `user_id`      bigint(20) NOT NULL COMMENT '用户id',
    `appoint_type` tinyint(2) NOT NULL COMMENT '预约类型[1盲盒/2商品]',
    `blind_box_id` bigint(20) NOT NULL COMMENT '预约产品id',
    `start_buy_at` datetime DEFAULT NULL COMMENT '发售时间',
    `created_at`   datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`   datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 10000
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='预约记录';
CREATE INDEX index_appoint ON `bubble_make_an_appoint` (user_id);
CREATE INDEX index_appoint_comm_id ON `bubble_make_an_appoint` (blind_box_id);

/*购买记录*/
DROP TABLE IF EXISTS `bubble_pay_record`;
CREATE TABLE `bubble_pay_record`
(
    `id`                      bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
    `user_id`                 bigint(20) NOT NULL COMMENT '用户id',
    `order_id`                varchar(64) DEFAULT NULL COMMENT '系统订单id',
    `commodity_type`          tinyint(2) NOT NULL COMMENT '商品类型[1盲盒/2商城]',
    `commodity_id`            bigint(20) NOT NULL COMMENT '商品id',
    `size_id`                 bigint(10) NOT NULL COMMENT '尺寸id',
    `commodity_num`           bigint(10) NOT NULL COMMENT '购买商品数量',
    `change_status`           tinyint(2) NOT NULL COMMENT '交易状态[1-待支付,2-支付失败,3-支付成功,4-待发货,5-运输中,6-已经到达]',
    `total_money`             int(10)    NOT NULL COMMENT '总金额',
    `activity_Id`             bigint(20) NOT NULL COMMENT '活动id',
    `activity_realization_id` bigint(20) NOT NULL COMMENT '活动实现id',
    `activity_money`          int(10)    NOT NULL COMMENT '活动减少金额[分]',
    `other_money`             int(10)    NOT NULL COMMENT '其他金额[运费]',
    `pay_money`               int(10)    NOT NULL COMMENT '支付金额[分]',
    `address_id`              bigint(10) NOT NULL COMMENT '收获地址id',
    `created_at`              datetime    DEFAULT NULL COMMENT '创建时间',
    `updated_at`              datetime    DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 25516
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='购买记录';
CREATE INDEX ix_user_pay ON `bubble_pay_record` (user_id, commodity_id, size_id);
CREATE INDEX ix_pay_order ON `bubble_pay_record` (order_id);
CREATE INDEX ix_pay__create ON `bubble_pay_record` (created_at);

/*售出记录*/
DROP TABLE IF EXISTS `bubble_sold_record`;
CREATE TABLE `bubble_sold_record`
(
    `id`                      bigint(20) NOT NULL AUTO_INCREMENT COMMENT '业务id',
    `order_id`                varchar(64) DEFAULT NULL COMMENT '系统订单id',
    `commodity_id`            bigint(20) NOT NULL COMMENT '商品id',
    `commodity_type`          tinyint(2) NOT NULL COMMENT '商品类型[1盲盒/2商城]',
    `size_id`                 bigint(20) NOT NULL COMMENT '商品尺寸id',
    `old_price`               int(10)    NOT NULL COMMENT '原价',
    `pay_money`               int(10)    NOT NULL COMMENT '实际出售金额',
    `pay_number`              int(10)    NOT NULL COMMENT '出售数量',
    `activity_id`             bigint(20) NOT NULL COMMENT '参与活动id',
    `activity_realization_id` bigint(20) NOT NULL COMMENT '活动实现id',
    `discount_money`          int(10)    NOT NULL COMMENT '优惠金额',
    `commodity_status`        tinyint(2) NOT NULL COMMENT '商品状态[1-未支付,2-支付,3-出库,4-发货,....]',
    `created_at`              datetime    DEFAULT NULL COMMENT '创建时间',
    `updated_at`              datetime    DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 10016
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='售出记录';
CREATE INDEX ix_sold_record ON `bubble_sold_record` (commodity_id);
CREATE INDEX ix_order_id_1 ON `bubble_sold_record` (order_id);

/*支付流水*/
DROP TABLE IF EXISTS `bubble_pay_flow`;
CREATE TABLE `bubble_pay_flow`
(
    `id`              bigint(20) NOT NULL AUTO_INCREMENT COMMENT '业务id',
    `user_id`         bigint(20) NOT NULL COMMENT '用户id',
    `commodity_type`  tinyint(2) NOT NULL COMMENT '商品类型[1盲盒/2商城]',
    `order_id`        varchar(256) DEFAULT NULL COMMENT '系统订单id',
    `transaction_id`  varchar(256) DEFAULT NULL COMMENT '微信订单id',
    `total`           bigint(10)   DEFAULT NULL COMMENT '订单总金额(分)',
    `payer_total`     bigint(11)   DEFAULT NULL COMMENT '用户支付金额(分)',
    `pay_method`      tinyint(2) NOT NULL COMMENT '支付方式[1-微信/2-支付宝/3-银行卡/4-其他]',
    `success_time`    varchar(256) DEFAULT NULL COMMENT '支付完成时间',
    `trade_state`     varchar(256) DEFAULT NULL COMMENT '交易状态',
    `callback_status` tinyint(2) NOT NULL COMMENT '回调状态[1-成功/2-失败/3-未回调]',
    `created_at`      datetime     DEFAULT NULL COMMENT '创建时间',
    `updated_at`      datetime     DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 10016
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='支付流水';
CREATE INDEX IX_flow_user_id ON `bubble_pay_flow` (user_id);

/*动态记录*/
CREATE TABLE `bubble_dynamic_comment_record`
(
    `id`         bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
    `user_id`    bigint(20) NOT NULL COMMENT '用户id',
    `dynamic_id` bigint(20) NOT NULL COMMENT '动态id',
    `created_at` datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at` datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `ix_comment_record_dynamic` (`dynamic_id`),
    KEY `ix_comment_record_user` (`user_id`)
) ENGINE = InnoDB
  AUTO_INCREMENT = 5001
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='评论记录';
CREATE INDEX IX_dynamic_user_id ON `bubble_pay_flow` (user_id);


/*发货管理*/
DROP TABLE IF EXISTS `bubble_send_goods`;
CREATE TABLE `bubble_send_goods`
(
    `id`           bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '消息id',
    `order_id`     varchar(64) NOT NULL COMMENT '订单id',
    `express_id`   varchar(64) NOT NULL COMMENT '快递编号',
    `goods_type`   tinyint(2)  NOT NULL COMMENT '类型[1盲盒/2商品]',
    `express_name` varchar(64) NOT NULL COMMENT '快递公司',
    `created_at`   datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`   datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 6500
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='发货管理';
CREATE INDEX IX_send_goods ON `bubble_send_goods` (order_id);


/*退货记录*/
DROP TABLE IF EXISTS `bubble_return_goods`;
CREATE TABLE `bubble_return_goods`
(
    `id`                bigint(20)   NOT NULL AUTO_INCREMENT COMMENT '消息id',
    `order_id`          varchar(64)  NOT NULL COMMENT '订单id',
    `return_to`         tinyint(2)   NOT NULL COMMENT '退款方向[1系统/2微信余额]',
    `return_reason`     varchar(256) NOT NULL COMMENT '退款原因',
    `return_money`      bigint(10)   NOT NULL COMMENT '退款金额',
    `return_type`       tinyint(2)   NOT NULL COMMENT '退货商品类型[1盲盒/2商品]',
    `admin_id`          bigint(20)   NOT NULL COMMENT '管理员id',
    `user_id`           bigint(20)   NOT NULL COMMENT '用户id',
    `return_trade_no`   varchar(64)  NOT NULL COMMENT '管理员退款流水号',
    `return_remark`     varchar(256) NOT NULL COMMENT '管理员退款备注',
    `img`               varchar(512) NOT NULL COMMENT '用户图片',
    `return_time`       datetime DEFAULT NULL COMMENT '管理员退款时间',
    `return_not_remark` varchar(256) NOT NULL COMMENT '管理员拒绝退款原因',
    `return_status`     tinyint(2)   NOT NULL COMMENT '退款状态[1未处理/2处理同意退款/3不同意退款]',
    `back_score`        int(10)      NOT NULL COMMENT '待返回积分',
    `created_at`        datetime DEFAULT NULL COMMENT '申请退款时间',
    `updated_at`        datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 75800
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='退货记录';
CREATE INDEX IX_return_goods ON `bubble_send_goods` (order_id);

/*微信提现成功*/
DROP TABLE IF EXISTS `bubble_wechat_transfers`;
CREATE TABLE `bubble_wechat_transfers`
(
    `id`               bigint(20)  NOT NULL AUTO_INCREMENT COMMENT '消息id',
    `order_id`         varchar(64) NOT NULL COMMENT '订单id',
    `return_money`     bigint(10)  NOT NULL COMMENT '提现金额',
    `user_id`          bigint(20)  NOT NULL COMMENT '用户id',
    `admin_id`         bigint(20)  NOT NULL COMMENT '管理id',
    `transfer_status`  bigint(20)  NOT NULL COMMENT '审核状态[1未审核/2通过/3未通过]',
    `transfer_remake`  bigint(20)  NOT NULL COMMENT '备注',
    `mch_app_id`       varchar(64) NOT NULL COMMENT 'appId',
    `mch_id`           varchar(64) NOT NULL COMMENT '商户id',
    `nonce_str`        varchar(64) NOT NULL COMMENT '随机字符串	',
    `partner_trade_no` varchar(64) NOT NULL COMMENT '商户订单号',
    `payment_no`       varchar(64) NOT NULL COMMENT '微信付款单号',
    `payment_time`     varchar(64) NOT NULL COMMENT '付款成功时间	',
    `updated_at`       datetime DEFAULT NULL COMMENT '修改时间',
    `created_at`       datetime DEFAULT NULL COMMENT '申请退款时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 75800
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='退货记录';
CREATE INDEX IX_wechat_goods ON `bubble_wechat_transfers` (order_id);
CREATE INDEX IX_wechat_u_goods ON `bubble_wechat_transfers` (user_id);

/*分享配置*/

/*发货管理*/
DROP TABLE IF EXISTS `bubble_share_config`;
CREATE TABLE `bubble_share_config`
(
    `id`            bigint(20)   NOT NULL AUTO_INCREMENT COMMENT '消息id',
    `share_img`     varchar(256) NOT NULL COMMENT '分享图片',
    `share_explain` varchar(64)  NOT NULL COMMENT '分享说明',
    `created_at`    datetime DEFAULT NULL COMMENT '创建时间',
    `updated_at`    datetime DEFAULT NULL COMMENT '修改时间',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 35200
  DEFAULT CHARSET = utf8mb4
  ROW_FORMAT = COMPACT COMMENT ='分享配置';



