/*!40101 SET NAMES utf8mb4 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
CREATE DATABASE /*!32312 IF NOT EXISTS*/`tmerclub_marketing` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

USE `tmerclub_marketing`;

/*Table structure for table `discount` */

DROP TABLE IF EXISTS `discount`;

CREATE TABLE `discount` (
  `discount_id` bigint NOT NULL AUTO_INCREMENT COMMENT '满减满折优惠id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `shop_id` bigint DEFAULT NULL COMMENT '店铺id',
  `discount_name` varchar(64) DEFAULT NULL COMMENT '活动名称',
  `discount_rule` tinyint DEFAULT NULL COMMENT '枚举DiscountRule(0 满钱减钱 3满件打折)',
  `discount_type` tinyint DEFAULT NULL COMMENT '减免类型 0按满足最高层级减一次 1每满一次减一次',
  `suitable_spu_type` tinyint DEFAULT NULL COMMENT '适用商品类型 0全部商品参与 1指定商品参与',
  `max_reduce_amount` bigint DEFAULT NULL COMMENT '最多减多少',
  `start_time` datetime DEFAULT NULL COMMENT '开始时间',
  `end_time` datetime DEFAULT NULL COMMENT '结束时间',
  `status` tinyint DEFAULT NULL COMMENT '活动状态:(0:关闭、1:开启、2:违规下线、3:平台审核)',
  `mobile_pic` varchar(255) DEFAULT NULL COMMENT '手机端活动图片',
  `pc_pic` varchar(255) DEFAULT NULL COMMENT 'pc端活动列表图片',
  `pc_background_pic` varchar(255) DEFAULT NULL COMMENT 'pc端活动背景图片',
  PRIMARY KEY (`discount_id`),
  KEY `shop_id` (`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='满减满折优惠';

/*Data for the table `discount` */

/*Table structure for table `discount_item` */

DROP TABLE IF EXISTS `discount_item`;

CREATE TABLE `discount_item` (
  `discount_item_id` bigint NOT NULL AUTO_INCREMENT COMMENT '满减满折优惠项id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  `discount_id` bigint DEFAULT NULL COMMENT '满减满折优惠id',
  `need_amount` bigint DEFAULT NULL COMMENT '所需需要金额',
  `discount` bigint DEFAULT NULL COMMENT '优惠（元/折）9.5折就是95、9.5元就是950',
  PRIMARY KEY (`discount_item_id`),
  KEY `discount_id` (`discount_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='满减满折优惠项';

/*Data for the table `discount_item` */

/*Table structure for table `discount_spu` */

DROP TABLE IF EXISTS `discount_spu`;

CREATE TABLE `discount_spu` (
  `discount_spu_id` bigint NOT NULL AUTO_INCREMENT COMMENT '满减 商品 联合id',
  `discount_id` bigint DEFAULT NULL COMMENT '满减id',
  `spu_id` bigint DEFAULT NULL COMMENT '商品id',
  PRIMARY KEY (`discount_spu_id`),
  KEY `discount_id` (`discount_id`),
  KEY `prod_id` (`spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='满减满折商品关联表';

/*Data for the table `discount_spu` */

/*Table structure for table `coupon` */

DROP TABLE IF EXISTS `coupon`;

CREATE TABLE `coupon` (
  `coupon_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '优惠券ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  `shop_id` bigint NOT NULL COMMENT '店铺ID',
  `coupon_name` varchar(20) NOT NULL COMMENT '优惠券名称',
  `sub_title` varchar(32) DEFAULT NULL COMMENT '副标题',
  `coupon_type` tinyint NOT NULL COMMENT '优惠类型 1:代金券 2:折扣券 3:兑换券',
  `suitable_prod_type` tinyint NOT NULL COMMENT '适用商品类型 0全部商品参与 1指定商品参与',
  `get_way` tinyint NOT NULL DEFAULT '0' COMMENT '获取方式 0=用户领取 1=店铺发放',
  `valid_time_type` tinyint NOT NULL COMMENT '生效类型 1:固定时间 2:领取后生效',
  `cash_condition` bigint DEFAULT NULL COMMENT '使用条件',
  `reduce_amount` bigint DEFAULT NULL COMMENT '减免金额',
  `coupon_discount` decimal(3,2) DEFAULT NULL COMMENT '折扣额度',
  `launch_time` datetime DEFAULT NULL COMMENT '投放时间',
  `start_time` datetime DEFAULT NULL COMMENT '开始时间',
  `end_time` datetime DEFAULT NULL COMMENT '结束时间',
  `after_receive_days` int DEFAULT NULL COMMENT '领券后X天起生效',
  `valid_days` int DEFAULT NULL COMMENT '有效天数',
  `total_stock` int NOT NULL COMMENT '总库存',
  `stocks` int NOT NULL COMMENT '库存',
  `limit_num` int NOT NULL DEFAULT '1' COMMENT '每个用户领券上限，如不填则默认为1',
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '优惠券状态 0:过期 1:未过期 -1:删除',
  `puton_status` tinyint NOT NULL DEFAULT '0' COMMENT '优惠券投放状态(-1:取消投放 0:自动投放 1:投放 2:违规下架 3:等待审核 4:等待投放)',
  `version` int NOT NULL DEFAULT '1' COMMENT '版本号',
  PRIMARY KEY (`coupon_id`),
  KEY `shop_id` (`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='优惠券';

/*Data for the table `coupon` */

/*Table structure for table `coupon_give_log` */

DROP TABLE IF EXISTS `coupon_give_log`;

CREATE TABLE `coupon_give_log` (
  `biz_type` tinyint NOT NULL COMMENT '赠送业务类型 1充值赠送',
  `biz_id` bigint NOT NULL COMMENT '业务id(充值记录id)',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  PRIMARY KEY (`biz_type`,`biz_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='优惠券赠送记录';

/*Data for the table `coupon_give_log` */

/*Table structure for table `coupon_lock` */

DROP TABLE IF EXISTS `coupon_lock`;

CREATE TABLE `coupon_lock` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '优惠券使用记录id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  `coupon_id` bigint DEFAULT NULL COMMENT '优惠券id',
  `coupon_user_id` bigint NOT NULL COMMENT '用户优惠券id',
  `user_id` bigint NOT NULL COMMENT '用户id',
  `order_ids` varchar(255) NOT NULL COMMENT '订单号',
  `amount` bigint NOT NULL COMMENT '优惠金额',
  `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '使用状态(状态-1已解锁 0待确定 1已锁定)',
  PRIMARY KEY (`id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_coupon_user_id` (`coupon_user_id`),
  KEY `idx_coupon_id` (`coupon_id`),
  KEY `idx_order_ids` (`order_ids`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='优惠券使用记录';

/*Data for the table `coupon_lock` */

/*Table structure for table `coupon_spu` */

DROP TABLE IF EXISTS `coupon_spu`;

CREATE TABLE `coupon_spu` (
  `coupon_spu_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '优惠券商品ID',
  `coupon_id` bigint DEFAULT NULL COMMENT '优惠券ID',
  `spu_id` bigint DEFAULT NULL COMMENT '商品ID',
  PRIMARY KEY (`coupon_spu_id`),
  KEY `ids_coupon_id` (`coupon_id`),
  KEY `ids_prod_id` (`spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='优惠券商品关联信息';

/*Data for the table `coupon_spu` */

/*Table structure for table `distribution_auditing` */

DROP TABLE IF EXISTS `distribution_auditing`;

CREATE TABLE `distribution_auditing` (
  `auditing_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '分销员申请表',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `parent_distribution_user_id` bigint DEFAULT NULL COMMENT '邀请人id',
  `distribution_user_id` bigint DEFAULT NULL COMMENT '申请人id',
  `auditing_time` datetime DEFAULT NULL COMMENT '申请时间',
  `remarks` varchar(255) DEFAULT NULL COMMENT '备注',
  `reason` tinyint DEFAULT NULL COMMENT '不通过原因(0 资料不足 1条件不足 2不招人 -1其他)',
  `state` tinyint DEFAULT NULL COMMENT '审核状态：0 未审核 1已通过 -1未通过',
  `modifier` bigint DEFAULT NULL COMMENT '操作人(0代表自动审核)',
  PRIMARY KEY (`auditing_id`),
  KEY `parent_distribution_user_id` (`parent_distribution_user_id`),
  KEY `distribution_user_id` (`distribution_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销员申请信息';

/*Table structure for table `distribution_msg` */

DROP TABLE IF EXISTS `distribution_msg`;

CREATE TABLE `distribution_msg` (
  `msg_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '公告表',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `msg_title` varchar(255) DEFAULT NULL COMMENT '公告标题',
  `start_time` datetime DEFAULT NULL COMMENT '指定上线时间',
  `end_time` datetime DEFAULT NULL COMMENT '指定下线时间',
  `is_top` tinyint DEFAULT NULL COMMENT '是否置顶(0 不置顶 1 置顶)',
  `content` text DEFAULT NULL COMMENT '公告内容',
  PRIMARY KEY (`msg_id`),
  KEY `msg_id` (`msg_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销公共信息';

/*Table structure for table `distribution_spu` */

DROP TABLE IF EXISTS `distribution_spu`;

CREATE TABLE `distribution_spu` (
  `distribution_spu_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '分销商品表id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `shop_id` bigint DEFAULT NULL COMMENT '店铺id',
  `spu_id` bigint DEFAULT NULL COMMENT '商品id',
  `state` tinyint DEFAULT NULL COMMENT '状态(0:商家下架 1:商家上架 2:违规下架 3:平台审核)',
  `award_mode` tinyint DEFAULT NULL COMMENT '奖励方式(0 按比例 1 按固定数值)',
  `parent_award_set` tinyint DEFAULT NULL COMMENT '上级奖励设置(0 关闭 1开启)',
  `award_numbers` bigint DEFAULT NULL COMMENT '奖励数额(奖励比例为0时，代表百分比*100，为1时代表实际奖励金额*100）',
  `parent_award_numbers` bigint DEFAULT NULL COMMENT '上级奖励数额(奖励比例为0时，表示百分比*100，为1时代表实际奖励金额*100）',
  `modifier` bigint DEFAULT NULL COMMENT '操作人id',
  PRIMARY KEY (`distribution_spu_id`),
  KEY `shop_id` (`shop_id`),
  KEY `spu_id` (`spu_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销商品关联信息';

/*Table structure for table `distribution_spu_bind` */

DROP TABLE IF EXISTS `distribution_spu_bind`;

CREATE TABLE `distribution_spu_bind` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '用户商品绑定表',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `distribution_user_id` bigint DEFAULT NULL COMMENT '分销员id',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `bind_time` datetime DEFAULT NULL COMMENT '绑定时间',
  `spu_id` bigint DEFAULT NULL COMMENT '商品id',
  `state` tinyint DEFAULT NULL COMMENT '状态(0失效 1生效) 分销员被清退封禁 该状态失效',
  PRIMARY KEY (`id`),
  KEY `user_spu_idx`(`user_id`, `spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户商品绑定信息';

/*Table structure for table `distribution_spu_log` */

DROP TABLE IF EXISTS `distribution_spu_log`;

CREATE TABLE `distribution_spu_log` (
  `distribution_spu_log_id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `shop_id` bigint DEFAULT NULL COMMENT '店铺id',
  `spu_id` bigint DEFAULT NULL COMMENT '商品id',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `mobile` varchar(20) DEFAULT NULL COMMENT '扫码手机号',
  PRIMARY KEY (`distribution_spu_log_id`),
  KEY `shop_spu_idx`(`shop_id`, `spu_id`),
  KEY `user_spu_idx`(`user_id`, `spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销商品浏览记录信息';

/*Table structure for table `distribution_user` */

DROP TABLE IF EXISTS `distribution_user`;

CREATE TABLE `distribution_user` (
  `distribution_user_id` bigint unsigned NOT NULL COMMENT '促销员表',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `parent_id` bigint DEFAULT NULL COMMENT '上级id',
  `parent_ids` varchar(255) DEFAULT NULL COMMENT '上级促销员ids （如：1,2,3）',
  `grade` int DEFAULT NULL COMMENT '目前促销员所处层级（0顶级）',
  `bind_time` datetime DEFAULT NULL COMMENT '绑定时间',
  `state` tinyint DEFAULT NULL COMMENT '状态(-1永久封禁 0待审核状态 1正常 2暂时封禁 3 审核未通过)',
  `nick_name` varchar(50) DEFAULT NULL COMMENT '昵称',
  `pic` varchar(255) DEFAULT NULL COMMENT '头像路径',
  `user_mobile` varchar(11) DEFAULT NULL COMMENT '手机号',
  `real_name` varchar(50) DEFAULT NULL COMMENT '真实姓名',
  `identity_card_number` varchar(20) DEFAULT NULL COMMENT '身份证号码',
  `identity_card_pic_front` varchar(255) DEFAULT NULL COMMENT '身份证正面',
  `identity_card_pic_back` varchar(255) DEFAULT NULL COMMENT '身份证背面',
  `identity_card_pic_hold` varchar(255) DEFAULT NULL COMMENT '手持身份证',
  `state_record` tinyint DEFAULT '0' COMMENT '改变成永久封禁或者暂时封禁时的状态记录',
  PRIMARY KEY (`distribution_user_id`),
  UNIQUE KEY `uk_shopid_userid` (`user_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销员信息';

/*Table structure for table `distribution_user_ban` */

DROP TABLE IF EXISTS `distribution_user_ban`;

CREATE TABLE `distribution_user_ban` (
  `ban_id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '操作时间',
  `distribution_user_id` bigint DEFAULT NULL COMMENT '分销员id',
  `ban_reason` tinyint DEFAULT NULL COMMENT '原因(0 失去联系 1恶意刷单 2其他)',
  `remarks` varchar(255) DEFAULT NULL COMMENT '备注',
  `state` tinyint DEFAULT NULL COMMENT '状态(1 正常 2暂时封禁 -1永久封禁)',
  `modifier` bigint DEFAULT NULL COMMENT '修改人',
  PRIMARY KEY (`ban_id`),
  KEY `distribution_user_id` (`distribution_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销清退记录';

/*Table structure for table `distribution_user_bind` */

DROP TABLE IF EXISTS `distribution_user_bind`;

CREATE TABLE `distribution_user_bind` (
  `bind_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '用户关系表',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `distribution_user_id` bigint DEFAULT NULL COMMENT '分销员id',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `state` tinyint DEFAULT NULL COMMENT '当前绑定关系(-1失效 0 预绑定 1生效)',
  `invalid_reason` tinyint DEFAULT NULL COMMENT '失效原因( 1管理员更改 2封禁)',
  `bind_time` datetime DEFAULT NULL COMMENT '绑定时间',
  `invalid_time` datetime DEFAULT NULL COMMENT '失效时间',
  PRIMARY KEY (`bind_id`),
  KEY `distribution_user_id` (`distribution_user_id`),
  KEY `user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销员绑定关系';

/*Table structure for table `distribution_user_income` */

DROP TABLE IF EXISTS `distribution_user_income`;

CREATE TABLE `distribution_user_income` (
  `income_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '收入记录id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `wallet_id` bigint DEFAULT NULL COMMENT '钱包id',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `pay_sys_type` tinyint(1) DEFAULT 0 COMMENT '支付系统类型(0:默认, 1:通联)',
  `income_type` tinyint DEFAULT NULL COMMENT '收入类型(1一代奖励、2二代奖励 3邀请奖励 等 )',
  `state` tinyint DEFAULT NULL COMMENT '佣金状态(0:待支付、1:待结算、2:已结算、-1:订单失效)',
  `income_amount` bigint DEFAULT NULL COMMENT '佣金数额',
  `order_id` bigint DEFAULT NULL COMMENT '关联订购流水号',
  `order_item_id` bigint DEFAULT NULL COMMENT '关联订单项order_item_id',
  `merchant_order_id` varchar(255) DEFAULT NULL COMMENT '商户订单号',
  `distribution_user_id` bigint DEFAULT NULL COMMENT '分销员id',
  `reson` tinyint DEFAULT '0' COMMENT '失效原因(0正常，1佣金为0订单失效，2订单项退款)',
  `modifier` bigint DEFAULT NULL COMMENT '操作人id',
  `shop_id` bigint DEFAULT NULL COMMENT '店铺id',
  `spu_id` bigint DEFAULT NULL COMMENT '商品id',
  PRIMARY KEY (`income_id`),
  KEY `order_id` (`order_item_id`),
  KEY `distribution_user_id` (`distribution_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销收入记录信息';

/*Table structure for table `distribution_user_wallet` */

DROP TABLE IF EXISTS `distribution_user_wallet`;

CREATE TABLE `distribution_user_wallet` (
  `wallet_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '分销员钱包id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `distribution_user_id` bigint DEFAULT NULL COMMENT '分销员id',
  `unsettled_amount` bigint DEFAULT NULL COMMENT '待结算金额',
  `settled_amount` bigint DEFAULT NULL COMMENT '可提现金额',
  `invalid_amount` bigint DEFAULT NULL COMMENT '已失效金额',
  `accumulate_amount` bigint DEFAULT NULL COMMENT '积累收益',
  `version` int DEFAULT NULL COMMENT '乐观锁',
  `state` tinyint DEFAULT NULL COMMENT '钱包状态(-1 已冻结 0未生效(分销审核未通过) 1正常)',
  PRIMARY KEY (`wallet_id`),
  KEY `distribution_user_id` (`distribution_user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销员钱包信息';

/*Table structure for table `distribution_user_wallet_bill` */

DROP TABLE IF EXISTS `distribution_user_wallet_bill`;

CREATE TABLE `distribution_user_wallet_bill` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '钱包流水记录',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `wallet_id` bigint DEFAULT NULL COMMENT '钱包id',
  `unsettled_amount` bigint DEFAULT NULL COMMENT '待结算金额变更数额',
  `settled_amount` bigint DEFAULT NULL COMMENT '可提现金额变更数额',
  `invalid_amount` bigint DEFAULT NULL COMMENT '失效金额变更数额',
  `accumulate_amount` bigint DEFAULT NULL COMMENT '积累收益变更数额',
  `remarks_en` varchar(255) DEFAULT NULL COMMENT '英文备注',
  `remarks` varchar(255) DEFAULT NULL COMMENT '备注',
  `unsettled_amount_after` bigint DEFAULT NULL COMMENT '变更后待结算金额',
  `settled_amount_after` bigint DEFAULT NULL COMMENT '变更后可提现金额',
  `invalid_amount_after` bigint DEFAULT NULL COMMENT '变更后失效金额',
  `accumulate_amount_after` bigint DEFAULT NULL COMMENT '变更后积累收益',
  `type` tinyint DEFAULT NULL COMMENT '类型(0 系统修改 1人工修改)',
  `modifier` bigint DEFAULT NULL COMMENT '操作人id',
  PRIMARY KEY (`id`),
  KEY `wallet_idx`(`wallet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销员钱包流水记录';

/*Table structure for table `distribution_withdraw_cash` */

DROP TABLE IF EXISTS `distribution_withdraw_cash`;

CREATE TABLE `distribution_withdraw_cash` (
  `withdraw_cash_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '提现记录id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `wallet_id` bigint DEFAULT NULL COMMENT '钱包id',
  `amount` bigint DEFAULT NULL COMMENT '金额',
  `fee` bigint DEFAULT NULL COMMENT '手续费',
  `type` tinyint DEFAULT NULL COMMENT '类型(0 手动提现 1自动提现)',
  `money_flow` tinyint DEFAULT NULL COMMENT '资金流向(0微信红包、1企业付款到微信零钱)',
  `merchant_order_id` varchar(255) DEFAULT NULL COMMENT '商户订单号',
  `version` int DEFAULT NULL COMMENT '乐观锁',
  `state` tinyint DEFAULT NULL COMMENT '提现状态(0:申请中 1:提现成功 -1:提现失败)',
  `biz_user_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '第三方系统userid',
  PRIMARY KEY (`withdraw_cash_id`),
  KEY `wallet_id` (`wallet_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分销员提现记录';

/*Table structure for table `enterprise_pay` */

DROP TABLE IF EXISTS `enterprise_pay`;

CREATE TABLE `enterprise_pay` (
  `ent_pay_id` bigint NOT NULL AUTO_INCREMENT COMMENT '商家转账ID',
  `status` tinyint DEFAULT NULL COMMENT '状态(1:申请中 2:已完成 -1:失败)',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `open_id` varchar(36) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户openid',
  `ent_pay_order_no` bigint DEFAULT NULL COMMENT '商家转账订单号',
  `amount` decimal(15,2) DEFAULT NULL COMMENT '金额',
  `type` tinyint DEFAULT NULL COMMENT '支付类型(1:商户提现)',
  `biz_id` bigint DEFAULT NULL COMMENT '业务id，如商户提现即商户提现记录ID',
  `version` int DEFAULT NULL COMMENT '版本号',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `out_batch_no` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '转账批次单号',
  PRIMARY KEY (`ent_pay_id`),
  KEY `user_idx`(`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商家转账';

/*Table structure for table `combo` */

DROP TABLE IF EXISTS `combo`;

CREATE TABLE `combo` (
  `combo_id` bigint NOT NULL AUTO_INCREMENT COMMENT '套餐id',
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '套餐名称',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `start_time` datetime NOT NULL COMMENT '活动开始时间',
  `end_time` datetime NOT NULL COMMENT '活动结束时间',
  `main_spu_id` bigint NOT NULL DEFAULT '0' COMMENT '主商品id',
  `price` bigint NOT NULL DEFAULT '0' COMMENT '套餐价格',
  `sold_num` int NOT NULL DEFAULT '0' COMMENT '销量',
  `shop_id` bigint NOT NULL COMMENT '店铺id',
  `status` tinyint NOT NULL COMMENT '状态 -1：已删除 0：关闭 1:进行中',
  PRIMARY KEY (`combo_id`) USING BTREE,
  KEY `idx_shop_id` (`shop_id`) USING BTREE,
  KEY `idx_spu_id` (`main_spu_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=176 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='商品套餐';

/*Table structure for table `combo_order` */

DROP TABLE IF EXISTS `combo_order`;

CREATE TABLE `combo_order` (
  `combo_order_id` bigint NOT NULL AUTO_INCREMENT COMMENT '套餐订单id',
  `shop_id` bigint DEFAULT NULL COMMENT '店铺id',
  `combo_id` bigint DEFAULT NULL COMMENT '套餐id',
  `user_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'user_id',
  `combo_num` int DEFAULT NULL COMMENT '套餐数量',
  `pay_price` bigint DEFAULT '0' COMMENT '支付金额',
  `order_number` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '订单编号',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `status` tinyint DEFAULT NULL COMMENT '状态(0:待支付、1:支付成功)',
  PRIMARY KEY (`combo_order_id`) USING BTREE,
  KEY `shop_id` (`shop_id`) USING BTREE,
  KEY `combo_id` (`combo_id`) USING BTREE,
  KEY `user_id` (`user_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=141 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='套餐订单表';

/*Table structure for table `combo_spu` */

DROP TABLE IF EXISTS `combo_spu`;

CREATE TABLE `combo_spu` (
 `combo_spu_id` bigint NOT NULL AUTO_INCREMENT COMMENT '套餐商品项id',
 `combo_id` bigint NOT NULL COMMENT '套餐id',
 `spu_id` bigint NOT NULL COMMENT '商品id',
 `combo_price` bigint NOT NULL DEFAULT '0' COMMENT '套餐价',
 `type` tinyint NOT NULL COMMENT '类型：1：主商品 2：搭配商品',
 `required` tinyint NOT NULL DEFAULT '0' COMMENT '是否必选：1：是 0：否',
 `least_num` int NOT NULL DEFAULT '1' COMMENT '起搭数量',
 `status` tinyint NOT NULL DEFAULT '1' COMMENT '状态 -1：删除 0：失效 1：正常',
 `create_time` datetime DEFAULT CURRENT_TIMESTAMP,
 `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
 PRIMARY KEY (`combo_spu_id`) USING BTREE,
 KEY `idx_combo_spu_id` (`combo_id`,`spu_id`) USING BTREE,
 KEY `idx_spu_id` (`spu_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=546 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='套餐商品项';

/*Table structure for table `combo_spu_sku` */

DROP TABLE IF EXISTS `combo_spu_sku`;

CREATE TABLE `combo_spu_sku` (
  `combo_spu_id` bigint unsigned NOT NULL DEFAULT '1' COMMENT '套餐商品项id',
  `sku_id` bigint NOT NULL COMMENT 'skuId',
  `matching_price` bigint NOT NULL DEFAULT '0' COMMENT '搭配价格',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `status` int DEFAULT '1' COMMENT '状态 -1：删除 0：失效 1：正常',
  PRIMARY KEY (`combo_spu_id`,`sku_id`,`matching_price`) USING BTREE,
  KEY `idx_sku_id` (`sku_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='套餐商品sku项';

/*Table structure for table `live_room` */
DROP TABLE IF EXISTS `live_room`;
CREATE TABLE `live_room`
(
  `room_id`  BIGINT NOT NULL AUTO_INCREMENT COMMENT '直播间信息',
  `shop_id`  BIGINT DEFAULT NULL COMMENT '店铺id',
  `name`  VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '直播间名称',
  `user_id`  BIGINT DEFAULT NULL COMMENT '主播用户id',
  `live_status` TINYINT NOT NULL COMMENT '直播间状态 0.未开始 1.直播中 2.已结束 3.暂停中 -1.违规下架',
  `cover_img` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '直播背景图',
  `share_img` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '主播分享图',
  `feeds_img` VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '直播封面图',
  `room_top`  TINYINT DEFAULT '0' COMMENT '是否置顶 1.是 0.不是',
  `start_time`  DATETIME DEFAULT NULL COMMENT '直播开始时间',
  `end_time`  DATETIME DEFAULT NULL COMMENT '直播结束时间',
  `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `remark` VARCHAR(500) COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '下线备注',
  PRIMARY KEY (`room_id`),
  KEY `shop_idx`(`shop_id`),
  KEY `user_idx`(`user_id`)
) ENGINE = INNODB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT ='直播间';

DROP TABLE IF EXISTS `live_room_prod`;
CREATE TABLE `live_room_prod`
(
  `room_prod_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '直播间商品信息',
  `spu_id` BIGINT NOT NULL COMMENT '商品id',
  `room_id`  BIGINT NOT NULL COMMENT '房间id',
  `explain_status` TINYINT DEFAULT '0' COMMENT '讲解状态 0未讲解 1讲解中',
  PRIMARY KEY (`room_prod_id`),
  KEY `room_spu_idx`(`room_id`, `spu_id`)
) ENGINE = INNODB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT ='直播商品';

/*Table structure for table `leaf_alloc` */

CREATE TABLE IF NOT EXISTS `leaf_alloc` (
  `biz_tag` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '区分业务',
  `max_id` bigint unsigned NOT NULL DEFAULT '1' COMMENT '该biz_tag目前所被分配的ID号段的最大值',
  `step` int NOT NULL COMMENT '每次分配的号段长度',
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `description` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '描述',
  PRIMARY KEY (`biz_tag`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/*Data for the table `leaf_alloc` */

insert into `leaf_alloc` (`biz_tag`, `max_id`, `step`, `description`) values
('tmerclub-distribution-user','1','1000','distribution_user表的distribution_user_id'),
('tmerclub-distribution-withdraw-order','1','1000','distribution_withdraw_cash表的merchant_order_id'),
('tmerclub-live-room-user','1','1000','直播用户id'),
('tmerclub-coupon-user','1','1000','领券记录id');


/*Table structure for table `undo_log` */

DROP TABLE IF EXISTS `undo_log`;

CREATE TABLE `undo_log` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `branch_id` bigint NOT NULL,
  `xid` varchar(100) NOT NULL,
  `context` varchar(128) NOT NULL,
  `rollback_info` longblob NOT NULL,
  `log_status` int NOT NULL,
  `log_created` datetime NOT NULL,
  `log_modified` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/*Data for the table `undo_log` */

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
