/*!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*/`mall4cloud_user` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

USE `mall4cloud_user`;

/*Table structure for table `user` */

DROP TABLE IF EXISTS `user`;

CREATE TABLE `user` (
  `user_id` bigint NOT NULL COMMENT 'ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '注册时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `nick_name` varchar(255) DEFAULT NULL COMMENT '用户昵称',
  `sex` char(1)  DEFAULT NULL COMMENT '1(男) or 0(女)',
  `birth_date` char(10) DEFAULT NULL COMMENT '例如：2009-11-27',
  `pic` varchar(255) DEFAULT NULL COMMENT '头像图片路径',
  `status` int NOT NULL DEFAULT '1' COMMENT '状态 1 正常 0 无效',
  `level` bigint DEFAULT NULL COMMENT '会员等级（冗余字段）',
  `vip_end_time` datetime DEFAULT NULL COMMENT 'vip结束时间',
  `level_type` tinyint DEFAULT NULL COMMENT '等级条件 0 普通会员 1 付费会员',
  `phone` varchar(15) DEFAULT NULL COMMENT '手机号 (冗余字段)',
  `vip_level` tinyint DEFAULT NULL COMMENT '用户vip等级，为空则非付费会员',
  `prod_recommendation` tinyint NOT NULL DEFAULT '1' COMMENT '商品个性化推荐 1:开启 0:关闭',
  PRIMARY KEY (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户表';

/*Data for the table `user` */

/*Table structure for table `user_addr` */

DROP TABLE IF EXISTS `user_addr`;

CREATE TABLE `user_addr` (
  `addr_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 '更新时间',
  `user_id` bigint NOT NULL COMMENT '用户ID',
  `mobile` varchar(20) DEFAULT NULL COMMENT '手机',
  `is_default` tinyint NOT NULL COMMENT '是否默认地址 1是',
  `consignee` varchar(50) DEFAULT NULL COMMENT '收货人',
  `province_id` bigint DEFAULT NULL COMMENT '省ID',
  `province` varchar(100) DEFAULT NULL COMMENT '省',
  `city_id` bigint DEFAULT NULL COMMENT '城市ID',
  `city` varchar(20) DEFAULT NULL COMMENT '城市',
  `area_id` bigint DEFAULT NULL COMMENT '区ID',
  `area` varchar(20) DEFAULT NULL COMMENT '区',
  `post_code` varchar(15) DEFAULT NULL COMMENT '邮编',
  `addr` varchar(255) DEFAULT NULL COMMENT '地址',
  `lng` decimal(12,6) DEFAULT NULL COMMENT '经度',
  `lat` decimal(12,6) DEFAULT NULL COMMENT '纬度',
  PRIMARY KEY (`addr_id`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户地址';

/*Data for the table `user_addr` */

/*Table structure for table `user_collection` */

DROP TABLE IF EXISTS `user_collection`;

CREATE TABLE `user_collection` (
  `id` bigint 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 '更新时间',
  `spu_id` bigint DEFAULT NULL COMMENT '商品id',
  `user_id` bigint NOT NULL COMMENT '用户id',
  PRIMARY KEY (`id`),
  KEY `user_spu_idx`(`user_id`, `spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户商品收藏信息';

/*Data for the table `user_collection` */

/*Table structure for table `user_collection_shop` */

DROP TABLE IF EXISTS `user_collection_shop`;

CREATE TABLE `user_collection_shop` (
  `collection_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',
  `user_id` bigint NOT NULL COMMENT '用户id',
  PRIMARY KEY (`collection_id`),
  KEY `k_shop_id` (`shop_id`),
  KEY `k_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户店铺收藏记录';

/*Data for the table `user_collection_shop` */

/*Table structure for table `user_consignee` */

DROP TABLE IF EXISTS `user_consignee`;

CREATE TABLE `user_consignee` (
  `user_consignee_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 '更新时间',
  `user_id` bigint NOT NULL COMMENT '用户id',
  `name` varchar(32) DEFAULT NULL COMMENT '提货人姓名',
  `mobile` varchar(32) DEFAULT NULL COMMENT '提货人联系方式',
  PRIMARY KEY (`user_consignee_id`),
  UNIQUE KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户提货人信息';

/*Data for the table `user_consignee` */

/*Table structure for table `user_extension` */

DROP TABLE IF EXISTS `user_extension`;

CREATE TABLE `user_extension` (
  `user_extension_id` bigint 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 '更新时间',
  `user_id` bigint NOT NULL COMMENT '用户id',
  `level` int NOT NULL COMMENT '用户等级',
  `level_type` tinyint NOT NULL COMMENT '等级条件 0 普通会员 1 付费会员',
  `growth` int NOT NULL COMMENT '用户当前成长值',
  `score` bigint NOT NULL COMMENT '用户积分',
  `balance` bigint NOT NULL COMMENT '用户总余额',
  `actual_balance` bigint NOT NULL COMMENT '用户实际余额',
  `version` int NOT NULL COMMENT '乐观锁',
  `sign_day` int DEFAULT '0' COMMENT '连续签到天数',
  `vip_level` tinyint DEFAULT NULL COMMENT '用户vip等级，为空则非付费会员',
  `allinpay_balance` bigint DEFAULT '0' COMMENT '通联累计余额(单位:分)',
  `allinpay_actual_balance` bigint DEFAULT '0' COMMENT '通联实际余额(单位:分)',
  `allinpay_real_name_set` tinyint(1) DEFAULT NULL COMMENT '通联实名认证(0:否, 1:是)',
  `allinpay_phone_bind` tinyint(1) DEFAULT NULL COMMENT '通联手机绑定(0:否, 1:是)',
  `allinpay_pay_pwd_set` tinyint(1) DEFAULT NULL COMMENT '通联支付密码设置(0:否, 1:是)',
  `allinpay_protocol_sign` tinyint(1) DEFAULT NULL COMMENT '通联提现协议签约(0:否, 1:是)',
  `allinpay_pay_acct_bind` tinyint(1) DEFAULT NULL COMMENT '通联支付标识绑定(0:否, 1:是)',
  `allinpay_create` tinyint(1) DEFAULT 0 COMMENT '是否创建通联会员(0:否，1:是)',
  PRIMARY KEY (`user_extension_id`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户扩展信息';

/*Data for the table `user_extension` */

/*Table structure for table `user_growth_log` */

DROP TABLE IF EXISTS `user_growth_log`;

CREATE TABLE `user_growth_log` (
  `log_id` bigint NOT NULL AUTO_INCREMENT COMMENT '成长值获取记录表',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  `user_id` bigint NOT NULL COMMENT '用户id',
  `source` tinyint DEFAULT NULL COMMENT '来源 0:系统修改 1:订单 2:余额',
  `biz_id` bigint DEFAULT NULL COMMENT '关联业务id',
  `change_growth` int NOT NULL COMMENT '变更成长值',
  `remarks` varchar(255) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`log_id`),
  KEY `idx_biz_id` (`biz_id`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户成长值记录';

/*Data for the table `user_growth_log` */

/*Table structure for table `user_level` */

DROP TABLE IF EXISTS `user_level`;

CREATE TABLE `user_level` (
  `user_level_id` bigint 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 '更新时间',
  `level` tinyint NOT NULL COMMENT '等级',
  `level_name` varchar(50) NOT NULL COMMENT '等级名称',
  `level_type` tinyint NOT NULL COMMENT '等级类型 0:普通会员 1:付费会员',
  `need_growth` int DEFAULT NULL COMMENT '所需成长值',
  `update_status` tinyint DEFAULT NULL COMMENT '1:已更新 0:等待更新(等级修改后，用户等级的更新)',
  `recruit_status` tinyint DEFAULT '1' COMMENT '付费会员，是否可以招募会员；1可以招募，0停止招募',
  PRIMARY KEY (`user_level_id`),
  UNIQUE KEY `uni_level` (`level`,`level_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='会员等级表';

/*Data for the table `user_level` */

insert  into `user_level`(`user_level_id`,`create_time`,`update_time`,`level`,`level_name`,`level_type`,`need_growth`,`update_status`,`recruit_status`) values
(1,'2021-05-18 18:53:20','2021-06-11 16:06:19',1,'普通会员',0,0,1,1);

/*Table structure for table `user_level_log` */

DROP TABLE IF EXISTS `user_level_log`;

CREATE TABLE `user_level_log` (
  `level_log_id` bigint NOT NULL AUTO_INCREMENT COMMENT '等级记录表',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间（更新时间）',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  `user_id` bigint NOT NULL COMMENT '用户id',
  `level_io_type` tinyint DEFAULT NULL COMMENT '变更类型 -1降级 0不变 1升级',
  `level_change_reason` tinyint DEFAULT NULL COMMENT '等级变更原因1.成长值不足 2.成长值足够 3.购买会员 4.续费会员 5.会员到期',
  `term_type` tinyint DEFAULT NULL COMMENT '期数类型(0:月,1:季,2:年)',
  `before_level` tinyint DEFAULT NULL COMMENT '变更之前等级',
  `before_level_type` tinyint DEFAULT NULL COMMENT '变更之前的等级类型  0:普通会员 1:付费会员',
  `after_level` tinyint NOT NULL COMMENT '变更之后的等级',
  `after_level_type` tinyint NOT NULL COMMENT '变更之后的等级类型 0:普通会员 1:付费会员',
  `pay_id` bigint DEFAULT NULL COMMENT '支付单号',
  `pay_type` tinyint DEFAULT NULL COMMENT '支付类型',
  `pay_sys_type` tinyint(1) DEFAULT NULL COMMENT '支付系统类型(0:默认支付, 1:通联支付)',
  `is_payed` tinyint DEFAULT NULL COMMENT '是否支付1已支付0未支付',
  `pay_amount` bigint DEFAULT NULL COMMENT '支付金额',
  `level_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '等级名称',
  PRIMARY KEY (`level_log_id`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户等级记录';

/*Data for the table `user_level_log` */

/*Table structure for table `user_level_rights` */

DROP TABLE IF EXISTS `user_level_rights`;

CREATE TABLE `user_level_rights` (
  `level_rights_id` bigint NOT NULL AUTO_INCREMENT COMMENT '等级-权益关联id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '关联时间',
  `user_level_id` bigint NOT NULL COMMENT '等级id',
  `rights_id` bigint NOT NULL COMMENT '权益id',
  PRIMARY KEY (`level_rights_id`),
  UNIQUE KEY `k_level_rights_id` (`user_level_id`,`rights_id`),
  KEY `idx_level_id` (`user_level_id`),
  KEY `idx_rights_id` (`rights_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='等级-权益关联信息';

/*Data for the table `user_level_rights` */

/*Table structure for table `user_level_term` */

DROP TABLE IF EXISTS `user_level_term`;

CREATE TABLE `user_level_term` (
  `level_term_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '关联时间',
  `user_level_id` bigint NOT NULL COMMENT '等级id',
  `term_type` tinyint NOT NULL COMMENT '期数类型(0:月,1:季,2:年)',
  `need_amount` bigint NOT NULL COMMENT '价格',
  `status` tinyint(1) NOT NULL COMMENT '状态(1：启用 0：禁用)',
  PRIMARY KEY (`level_term_id`),
  KEY `level_idx`(`user_level_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/*Data for the table `user_level_term` */

/*Table structure for table `user_recharge` */

DROP TABLE IF EXISTS `user_recharge`;

CREATE TABLE `user_recharge` (
  `recharge_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 '更新时间',
  `recharge_title` varchar(50) NOT NULL COMMENT '充值余额标题',
  `recharge_amount` bigint NOT NULL COMMENT '充值金额',
  `img` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT'背景图片',
  `pres_amount` bigint NOT NULL DEFAULT '0' COMMENT '赠送金额',
  `pres_score` bigint NOT NULL DEFAULT '0' COMMENT '赠送积分',
  `pres_growth` int NOT NULL DEFAULT '0' COMMENT '赠送成长值',
  `seq` int NOT NULL COMMENT '顺序',
  PRIMARY KEY (`recharge_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='余额充值级别表';

/*Data for the table `user_recharge` */

/*Table structure for table `user_recharge_coupon` */

DROP TABLE IF EXISTS `user_recharge_coupon`;

CREATE TABLE `user_recharge_coupon` (
  `recharge_id` bigint NOT NULL COMMENT '充值id',
  `coupon_id` bigint NOT NULL COMMENT '优惠券id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `coupon_num` tinyint NOT NULL DEFAULT '1' COMMENT '优惠券数量',
  PRIMARY KEY (`recharge_id`,`coupon_id`),
  KEY `idx_coupon_id` (`coupon_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='余额优惠券关联表';

/*Data for the table `user_recharge_coupon` */

/*Table structure for table `user_rights` */

DROP TABLE IF EXISTS `user_rights`;

CREATE TABLE `user_rights` (
  `rights_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 '更新时间',
  `rights_name` varchar(36) NOT NULL COMMENT '权益名称',
  `icon` varchar(255) NOT NULL COMMENT '权益图标',
  `description` varchar(255) DEFAULT NULL COMMENT '权益简介',
  `details` text  COMMENT '权益详情',
  `status` tinyint NOT NULL COMMENT '状态：-1: 删除 0:禁用 1：正常(仅用于系统核销)',
  `seq` int NOT NULL COMMENT '排序 从小到大',
  `rights_type` tinyint NOT NULL COMMENT '权益类型[0.自定义 1.积分回馈倍率 2.优惠券 3.积分赠送(数量) 4.会员折扣 5.包邮类型]',
  `rate_score` smallint DEFAULT NULL COMMENT '积分回馈倍率(整存)',
  `pres_score` bigint DEFAULT NULL COMMENT '赠送积分',
  `discount` tinyint DEFAULT NULL COMMENT '会员折扣(整存)',
  `discount_range` tinyint DEFAULT NULL COMMENT '折扣范围[0.全平台 1.自营店]',
  `free_fee_type` tinyint DEFAULT NULL COMMENT '包邮类型[1.全平台包邮 2.自营店包邮]',
  PRIMARY KEY (`rights_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户权益信息';

/*Data for the table `user_rights` */

/*Table structure for table `user_rights_coupon` */

DROP TABLE IF EXISTS `user_rights_coupon`;

CREATE TABLE `user_rights_coupon` (
  `rights_coupon_id` bigint NOT NULL AUTO_INCREMENT COMMENT '权益优惠券关联id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '关联时间',
  `rights_id` bigint NOT NULL COMMENT '权益id',
  `coupon_id` bigint NOT NULL COMMENT '优惠券id',
  PRIMARY KEY (`rights_coupon_id`),
  KEY `idx_coupon_id` (`coupon_id`),
  KEY `idx_level_id` (`rights_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/*Data for the table `user_rights_coupon` */

/*Table structure for table `user_score_get_log` */

DROP TABLE IF EXISTS `user_score_get_log`;

CREATE TABLE `user_score_get_log` (
  `user_score_get_log_id` bigint NOT NULL AUTO_INCREMENT COMMENT '积分明细表',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  `user_id` bigint NOT NULL COMMENT '用户id',
  `usable_score` bigint DEFAULT NULL COMMENT '可用积分',
  `biz_id` varchar(100) DEFAULT NULL COMMENT '业务id',
  `expire_time` datetime DEFAULT NULL COMMENT '过期时间',
  `status` tinyint NOT NULL COMMENT '状态  -1过期 0订单抵现 1正常',
  PRIMARY KEY (`user_score_get_log_id`),
  KEY `user_idx`(`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户积分获取记录';

/*Data for the table `user_score_get_log` */

/*Table structure for table `user_score_lock` */

DROP TABLE IF EXISTS `user_score_lock`;

CREATE TABLE `user_score_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 ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `order_id` bigint DEFAULT NULL COMMENT '订单id',
  `status` tinyint DEFAULT NULL COMMENT '状态-1已解锁 0待确定 1已锁定',
  `score` bigint DEFAULT NULL COMMENT '锁定积分数量',
  `score_get_log_ids` json DEFAULT NULL COMMENT '变动的积分id集合',
  PRIMARY KEY (`id`),
  UNIQUE KEY `idx_orderid` (`order_id`),
  KEY `idx_userid` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='积分锁定信息';

/*Data for the table `user_score_lock` */

/*Table structure for table `user_tag` */

DROP TABLE IF EXISTS `user_tag`;

CREATE TABLE `user_tag` (
  `user_tag_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 '更新时间',
  `tag_name` varchar(30)  NOT NULL COMMENT '标签名字',
  `tag_type` tinyint(1) NOT NULL COMMENT '标签类型0手动1条件2系统',
  `is_sys_turn_on` tinyint(1) NOT NULL COMMENT '系统标签是否开启',
  `register_min_time` datetime DEFAULT NULL COMMENT '成为客户开始时间',
  `register_max_time` datetime DEFAULT NULL COMMENT '成为客户结束时间',
  `subscribe_min_time` datetime DEFAULT NULL COMMENT '关注开始时间',
  `subscribe_max_time` datetime DEFAULT NULL COMMENT '关注结束时间',
  `to_be_member_min_time` datetime DEFAULT NULL COMMENT '成为会员开始时间',
  `to_be_member_max_time` datetime DEFAULT NULL COMMENT '成为会员结束时间',
  `recent_purchase_time` tinyint(1) DEFAULT NULL COMMENT '最近消费时间范围0(不限)1(今天)2(最近7天)3(最近15天)4(最近30天)5(最近45天)6(最近60天)7(最近90天)8(最近180天)',
  `purchase_num_time` tinyint(1) DEFAULT NULL COMMENT '消费次数时间范围0(不限)1(今天)2(最近7天)3(最近15天)4(最近30天)5(最近45天)6(最近60天)7(最近90天)8(最近180天)',
  `purchase_num_min_num` bigint DEFAULT NULL COMMENT '消费次数最小次数',
  `purchase_num_max_num` bigint DEFAULT NULL COMMENT '消费次数最大次数',
  `purchase_amount_time` tinyint(1) DEFAULT NULL COMMENT '消费金额时间范围0(不限)1(今天)2(最近7天)3(最近15天)4(最近30天)5(最近45天)6(最近60天)7(最近90天)8(最近180天)',
  `purchase_amount_min_amount` bigint DEFAULT NULL COMMENT '消费金额最小金额',
  `purchase_amount_max_amount` bigint DEFAULT NULL COMMENT '消费金额最大金额',
  `order_average_price_time` tinyint(1) DEFAULT NULL COMMENT '订单均价时间范围0(不限)1(今天)2(最近7天)3(最近15天)4(最近30天)5(最近45天)6(最近60天)7(最近90天)8(最近180天)',
  `order_average_price_min_amount` bigint DEFAULT NULL COMMENT '订单均价最小金额',
  `order_average_price_max_amount` bigint DEFAULT NULL COMMENT '订单均价最大金额',
  `recharge_amount_time` tinyint(1) DEFAULT NULL COMMENT '充值金额时间范围0(不限)1(今天)2(最近7天)3(最近15天)4(最近30天)5(最近45天)6(最近60天)7(最近90天)8(最近180天)',
  `recharge_amount_min_amount` bigint DEFAULT NULL COMMENT '充值金额最小金额',
  `recharge_amount_max_amount` bigint DEFAULT NULL COMMENT '充值金额最大金额',
  `recharge_num_time` tinyint(1) DEFAULT NULL COMMENT '充值次数时间范围0(不限)1(今天)2(最近7天)3(最近15天)4(最近30天)5(最近45天)6(最近60天)7(最近90天)8(最近180天)',
  `recharge_num_min_num` bigint DEFAULT NULL COMMENT '充值次数最小次数',
  `recharge_num_max_num` bigint DEFAULT NULL COMMENT '充值次数最大次数',
  `user_num` bigint NOT NULL COMMENT '符合标签的人数',
  `statistic_update_time` datetime DEFAULT NULL COMMENT '统计更新时间',
  PRIMARY KEY (`user_tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='客户标签';

/*Data for the table `user_tag` */

/*Table structure for table `user_tag_user` */

DROP TABLE IF EXISTS `user_tag_user`;

CREATE TABLE `user_tag_user` (
  `user_tag_user_id` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `user_tag_id` bigint NOT NULL COMMENT '标签id',
  `user_id` bigint NOT NULL COMMENT '用户id',
  PRIMARY KEY (`user_tag_user_id`),
  KEY `idx_user_tag_id` (`user_tag_id`),
  KEY `idx_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户和标签关联表';

/*Data for the table `user_tag_user` */

/*Table structure for table `shop_customer` */
DROP TABLE IF EXISTS `shop_customer`;

CREATE TABLE `shop_customer` (
  `shop_customer_id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '店铺客户id',
  `user_id` VARCHAR(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户id',
  `member_name` VARCHAR(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '会员名称',
  `shop_id` BIGINT NOT NULL COMMENT '店铺id',
  `level_type` TINYINT DEFAULT NULL COMMENT '会员类型（-1：客户，0：免费会员，1：付费会员）',
  `level_id` BIGINT DEFAULT NULL COMMENT '会员等级Id',
  `level` INT DEFAULT NULL COMMENT '会员等级',
  `growth` INT DEFAULT NULL COMMENT '成长值',
  `regist_time` DATETIME DEFAULT NULL COMMENT '会员注册时间',
  `vip_end_time` DATETIME DEFAULT NULL COMMENT '付费会员到期时间',
  `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`shop_customer_id`),
  KEY `shop_user_level_idx`(`shop_id`, `user_id`, `level_id`),
  KEY `user_level_idx`(`user_id`, `level_id`)
) ENGINE=INNODB  DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='店铺客户';

/*Data for the table `shop_customer` */

/*Data for the table `user_withdraw_cash` */
DROP TABLE IF EXISTS `user_withdraw_cash`;
CREATE TABLE `user_withdraw_cash`  (
  `cash_id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '提现id',
  `user_id` bigint NULL COMMENT '用户id',
  `pay_sys_type` tinyint(1) NULL COMMENT '支付系统类型(0：默认，1:通联)',
  `order_no` varchar(100) NULL COMMENT '提现订单号',
  `biz_order_no` varchar(100) NULL COMMENT '通联提现订单号',
  `amount` bigint(0) NULL COMMENT '提现金额',
  `bank_card_no` varchar(100) NULL COMMENT '提现银行卡号',
  `status` tinyint(1) NULL COMMENT '通联提现状态(0:待支付 1:申请成功 2:提现成功 3:提现失败)',
  `pay_fail_message` varchar(255) NULL COMMENT '提现失败原因',
  `create_time` datetime NULL COMMENT '创建时间',
  `update_time` datetime NULL COMMENT '修改时间',
  PRIMARY KEY (`cash_id`),
  KEY `user_idx`(`user_id`)
);
/*Data for the table `user_withdraw_cash` */




/*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
('mall4cloud-user','1','1000','用户id'),
('mall4cloud-user-score-log','1','1000','mall4cloud余额日志'),
('mall4cloud-user-balance-log','1','1000','mall4cloud积分日志');

DROP TABLE IF EXISTS `cost_per_popup`;
CREATE TABLE `cost_per_popup` (
        `popup_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '弹窗广告id',
        `shop_id` bigint NOT NULL COMMENT '店铺id',
        `popup_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '弹窗名称',
        `status` tinyint NOT NULL COMMENT '状态  1.未开始 2.投放中 3.已结束',
        `page_type` tinyint NOT NULL COMMENT '触发页面类型 1.平台首页 2.会员中心 3.支付成功 4.店铺首页 5.商品详情',
        `popup_pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '弹窗图片',
        `jump_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '跳转页面',
        `user_type` tinyint NOT NULL DEFAULT '0' COMMENT '推送用户类型 0.所有用户 1.免费会员 2.付费会员 3.店铺客户',
        `start_time` datetime NOT NULL COMMENT '推送开始时间',
        `end_time` datetime NOT NULL COMMENT '推送结束时间',
        `push_frequency` tinyint NOT NULL DEFAULT '0' COMMENT '推送频次 0.永久一次 1.每次进入 2.自定义频次',
        `day_frequency` tinyint DEFAULT NULL COMMENT '按x天推送',
        `week_frequency` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '按周推送 eg. 1,2',
        `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
        PRIMARY KEY (`popup_id`),
        KEY `shop_id` (`popup_id`,`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='弹窗广告';

DROP TABLE IF EXISTS `popup_relate`;
CREATE TABLE `popup_relate` (
        `relate_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '关联id',
        `popup_id` bigint NOT NULL COMMENT '弹窗广告id',
        `spu_id` bigint DEFAULT NULL COMMENT '商品id',
        `user_level_id` bigint DEFAULT NULL COMMENT '会员等级id',
        `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
        PRIMARY KEY (`relate_id`),
        KEY `popup_id` (`popup_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='弹窗广告关联';

DROP TABLE IF EXISTS `cost_per_popup`;
CREATE TABLE `cost_per_popup` (
  `popup_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '弹窗广告id',
  `shop_id` bigint NOT NULL COMMENT '店铺id',
  `popup_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '弹窗名称',
  `status` tinyint NOT NULL COMMENT '状态  1.未开始 2.投放中 3.已结束',
  `page_type` tinyint NOT NULL COMMENT '触发页面类型 1.平台首页 2.会员中心 3.支付成功 4.店铺首页 5.商品详情',
  `popup_pic` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '弹窗图片',
  `jump_url` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '跳转页面',
  `user_type` tinyint NOT NULL DEFAULT '0' COMMENT '推送用户类型 0.所有用户 1.免费会员 2.付费会员 3.店铺客户',
  `start_time` datetime NOT NULL COMMENT '推送开始时间',
  `end_time` datetime NOT NULL COMMENT '推送结束时间',
  `push_frequency` tinyint NOT NULL DEFAULT '0' COMMENT '推送频次 0.永久一次 1.每次进入 2.自定义频次',
  `day_frequency` tinyint DEFAULT NULL COMMENT '按x天推送',
  `week_frequency` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '按周推送 eg. 1,2',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`popup_id`),
  KEY `shop_id` (`popup_id`,`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='弹窗广告';

DROP TABLE IF EXISTS `popup_relate`;
CREATE TABLE `popup_relate` (
    `relate_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '关联id',
    `popup_id` bigint NOT NULL COMMENT '弹窗广告id',
    `spu_id` bigint DEFAULT NULL COMMENT '商品id',
    `user_level_id` bigint DEFAULT NULL COMMENT '会员等级id',
    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`relate_id`),
    KEY `popup_id` (`popup_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='弹窗广告关联';


/*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 */;
