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

USE `mall4cloud_product`;

/*Table structure for table `attr` */

DROP TABLE IF EXISTS `attr`;

CREATE TABLE `attr` (
  `attr_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'attr 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 NOT NULL DEFAULT '0' COMMENT '店铺Id',
  `sys_type` tinyint DEFAULT '0' COMMENT '关联系统类型 1.店铺 2.平台端 3.供应商',
  `search_type` tinyint NOT NULL DEFAULT '0' COMMENT '0:不需要，1:需要',
  `attr_type` tinyint NOT NULL DEFAULT '0' COMMENT '0:销售属性，1:基本属性',
  PRIMARY KEY (`attr_id`),
  KEY `idx_shop_id` (`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='属性信息';

/*Data for the table `attr` */

/*Table structure for table `attr_category` */

DROP TABLE IF EXISTS `attr_category`;

CREATE TABLE `attr_category` (
  `attr_category_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 '更新时间',
  `category_id` bigint unsigned NOT NULL COMMENT '分类id',
  `attr_id` bigint NOT NULL COMMENT '属性id',
  PRIMARY KEY (`attr_category_id`),
  UNIQUE KEY `uni_attrgroup_id` (`category_id`,`attr_id`),
  KEY `idx_attr_id` (`attr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='属性与分类关联信息';

/*Data for the table `attr_category` */

/*Table structure for table `attr_lang` */

DROP TABLE IF EXISTS `attr_lang`;

CREATE TABLE `attr_lang` (
  `attr_id` bigint NOT NULL COMMENT '属性id',
  `lang` tinyint NOT NULL COMMENT '语言 0.通用 1.中文 2.英文',
  `name` varchar(250) DEFAULT NULL COMMENT '属性名称',
  `desc` varchar(250) DEFAULT NULL COMMENT '属性描述',
  PRIMARY KEY (`attr_id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='属性-国际化表';

/*Data for the table `attr_lang` */

/*Table structure for table `attr_value` */

DROP TABLE IF EXISTS `attr_value`;

CREATE TABLE `attr_value` (
  `attr_value_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 '更新时间',
  `attr_id` bigint unsigned NOT NULL COMMENT '属性ID',
  PRIMARY KEY (`attr_value_id`),
  KEY `idx_attr` (`attr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='属性值信息';

/*Data for the table `attr_value` */

/*Table structure for table `attr_value_lang` */

DROP TABLE IF EXISTS `attr_value_lang`;

CREATE TABLE `attr_value_lang` (
  `attr_value_id` bigint NOT NULL COMMENT '属性值id',
  `lang` tinyint NOT NULL COMMENT '语言 0.通用 1.中文 2.英文',
  `value` varchar(2000) DEFAULT NULL COMMENT '属性值',
  PRIMARY KEY (`attr_value_id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='属性值-国际化表';

/*Data for the table `attr_value_lang` */

/*Table structure for table `brand` */

DROP TABLE IF EXISTS `brand`;

CREATE TABLE `brand` (
  `brand_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'brand_id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `img_url` varchar(255) NOT NULL DEFAULT '' COMMENT '品牌logo图片',
  `first_letter` char(1) DEFAULT NULL COMMENT '检索首字母',
  `seq` int DEFAULT NULL COMMENT '排序',
  `status` tinyint unsigned DEFAULT '0' COMMENT '状态 1:enable, 0:disable, -1:deleted',
  `is_top` tinyint DEFAULT NULL COMMENT '是否置顶',
  `spu_count` int DEFAULT '0' COMMENT '品牌下的上架商品数量',
  `shop_id` bigint DEFAULT NULL COMMENT '店铺id,0代表平台品牌',
  `sys_type` tinyint DEFAULT '0' COMMENT '关联系统类型 1.店铺 2.平台端 3.供应商',
  PRIMARY KEY (`brand_id`),
  UNIQUE KEY `uni_brand_id` (`brand_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='品牌信息';

/*Data for the table `brand` */

/*Table structure for table `brand_lang` */

DROP TABLE IF EXISTS `brand_lang`;

CREATE TABLE `brand_lang` (
  `brand_id` bigint NOT NULL COMMENT '品牌id',
  `lang` tinyint NOT NULL COMMENT '语言 0.通用 1.中文 2.英文',
  `name` varchar(250) DEFAULT NULL COMMENT '品牌名称',
  `desc` varchar(250) DEFAULT NULL COMMENT '品牌描述',
  PRIMARY KEY (`brand_id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='品牌-国际化表';

/*Data for the table `brand_lang` */

/*Table structure for table `brand_shop` */

DROP TABLE IF EXISTS `brand_shop`;

CREATE TABLE `brand_shop` (
  `brand_shop_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 '更新时间',
  `shop_id` bigint unsigned NOT NULL COMMENT '店铺id',
  `sys_type` tinyint DEFAULT '0' COMMENT '关联系统类型 1.店铺 2.平台端 3.供应商',
  `brand_id` bigint unsigned NOT NULL COMMENT '品牌id',
  `qualifications` varchar(1000) DEFAULT NULL COMMENT '授权资质图片，以,分割',
  `type` tinyint DEFAULT NULL COMMENT '类型 0：平台品牌，1：店铺自定义品牌',
  PRIMARY KEY (`brand_shop_id`) USING BTREE,
  KEY `idx_brand_id` (`brand_id`) USING BTREE,
  KEY `uni_brand_shop_id` (`brand_id`,`shop_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='品牌店铺关联信息';

/*Data for the table `brand_shop` */

/*Table structure for table `category` */

DROP TABLE IF EXISTS `category`;

CREATE TABLE `category` (
  `category_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 unsigned NOT NULL COMMENT '店铺id',
  `parent_id` bigint unsigned NOT NULL DEFAULT '0' COMMENT '父ID',
  `desc` varchar(255) DEFAULT NULL COMMENT '分类描述',
  `path` varchar(255) NOT NULL DEFAULT '' COMMENT '分类地址{parent_id}-{child_id},...',
  `status` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '状态 1:enable, 0:disable, -1:deleted',
  `icon` varchar(255) DEFAULT NULL COMMENT '分类图标',
  `img_url` varchar(255) DEFAULT NULL COMMENT '分类的显示图片',
  `level` int NOT NULL COMMENT '分类层级 从0开始',
  `deduction_rate` decimal(10,4) DEFAULT NULL COMMENT '分类扣率（1代表1%）',
  `seq` int DEFAULT NULL COMMENT '排序',
  PRIMARY KEY (`category_id`),
  KEY `idx_shop_id` (`shop_id`),
  KEY `idx_pid` (`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分类信息';

/*Data for the table `category` */

/*Table structure for table `category_brand` */

DROP TABLE IF EXISTS `category_brand`;

CREATE TABLE `category_brand` (
  `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 '更新时间',
  `brand_id` bigint unsigned NOT NULL COMMENT '品牌id',
  `category_id` bigint unsigned NOT NULL COMMENT '分类id',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uni_brand_category_id` (`brand_id`,`category_id`),
  KEY `idx_category_id` (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='品牌分类关联信息';

/*Data for the table `category_brand` */

/*Table structure for table `category_lang` */

DROP TABLE IF EXISTS `category_lang`;

CREATE TABLE `category_lang` (
  `category_id` bigint NOT NULL COMMENT '分类id',
  `lang` tinyint NOT NULL COMMENT '语言 0.通用 1.中文 2.英文',
  `name` varchar(250) DEFAULT NULL COMMENT '分类名称',
  PRIMARY KEY (`category_id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='分类-国际化表';

/*Data for the table `category_lang` */

/*Table structure for table `category_shop` */

DROP TABLE IF EXISTS `category_shop`;

CREATE TABLE `category_shop` (
  `category_shop_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 '更新时间',
  `shop_id` bigint unsigned NOT NULL COMMENT '店铺id',
  `sys_type` tinyint DEFAULT '0' COMMENT '关联系统类型 1.店铺 2.平台端 3.供应商',
  `category_id` bigint unsigned NOT NULL COMMENT '分类id',
  `rate` decimal(10,4) DEFAULT NULL COMMENT '扣率: 为空代表采用平台扣率（1代表1%）',
  `qualifications` varchar(1000) DEFAULT NULL COMMENT '经营资质图片，以,分割',
  PRIMARY KEY (`category_shop_id`) USING BTREE,
  KEY `idx_category_id` (`category_id`) USING BTREE,
  KEY `idx_category_shop_id` (`shop_id`,`category_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='店铺分类关联信息';

/*Data for the table `category_shop` */

/*Table structure for table `shop_cart_item` */

DROP TABLE IF EXISTS `shop_cart_item`;

CREATE TABLE `shop_cart_item` (
  `cart_item_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 '更新时间',
  `shop_id` bigint NOT NULL COMMENT '店铺ID',
  `spu_id` bigint unsigned NOT NULL DEFAULT '0' COMMENT '产品ID',
  `sku_id` bigint unsigned NOT NULL DEFAULT '0' COMMENT 'SkuID',
  `category_id` bigint DEFAULT NULL COMMENT '分类id',
  `user_id` bigint unsigned NOT NULL COMMENT '用户ID',
  `count` int NOT NULL DEFAULT '0' COMMENT '购物车产品个数',
  `discount_id` bigint DEFAULT NULL COMMENT '满减活动ID',
  `price_fee` bigint unsigned NOT NULL COMMENT '售价，加入购物车时的商品价格',
  `distribution_user_id` bigint DEFAULT NULL COMMENT '分销员用户id',
  `is_checked` tinyint DEFAULT NULL COMMENT '是否已勾选',
  `is_closed` tinyint NOT NULL DEFAULT '1' COMMENT '店铺是否停业 1：否 0：是',
  `combo_id` bigint DEFAULT NULL COMMENT '套餐id',
  `combo_count` int DEFAULT NULL COMMENT '套餐数量',
  `parent_cart_item_id` bigint DEFAULT NULL COMMENT '主购物车id（套餐）',
  PRIMARY KEY (`cart_item_id`),
  UNIQUE KEY `uk_user_shop_sku_combo` (`sku_id`,`user_id`,`shop_id`,`combo_id`,`parent_cart_item_id`) USING BTREE,
  KEY `idx_shop_id` (`shop_id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_category_id` (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='购物车';

/*Data for the table `shop_cart_item` */

/*Table structure for table `sku` */

DROP TABLE IF EXISTS `sku`;

CREATE TABLE `sku` (
  `sku_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 '更新时间',
  `spu_id` bigint NOT NULL COMMENT 'SPU id',
  `img_url` varchar(1000) DEFAULT NULL COMMENT 'sku图片',
  `price_fee` bigint NOT NULL DEFAULT '0' COMMENT '售价，整数方式保存',
  `market_price_fee` bigint NOT NULL DEFAULT '0' COMMENT '市场价，整数方式保存',
  `score_fee` bigint NOT NULL DEFAULT '0' COMMENT '积分价格',
  `party_code` varchar(100) DEFAULT NULL COMMENT '商品编码',
  `model_id` varchar(100) DEFAULT NULL COMMENT '商品条形码',
  `weight` decimal(15,3) DEFAULT NULL COMMENT '商品重量',
  `volume` decimal(15,3) DEFAULT NULL COMMENT '商品体积',
  `status` tinyint NOT NULL DEFAULT '0' COMMENT '状态 1:enable, 0:disable, -1:deleted',
  `supplier_sku_id` bigint DEFAULT NULL COMMENT '当商品为代销商品时，供应商商品skuid',
  `stock_warning` bigint DEFAULT NULL COMMENT '库存预警',
  `stock_warning_status` tinyint NOT NULL DEFAULT '0' COMMENT '库存预警状态 0:库存充足 1:库存预警',
  PRIMARY KEY (`sku_id`),
  KEY `idx_spuid` (`spu_id`),
  KEY `idx_supplier_sku_id` (`supplier_sku_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='sku信息';

/*Data for the table `sku` */

/*Table structure for table `sku_lang` */

DROP TABLE IF EXISTS `sku_lang`;

CREATE TABLE `sku_lang` (
  `sku_id` bigint NOT NULL COMMENT 'sku id',
  `lang` tinyint NOT NULL COMMENT '语言 0.通用 1.中文 2.英文',
  `sku_name` varchar(255) DEFAULT NULL COMMENT 'sku名称',
  `attrs` varchar(255) DEFAULT NULL COMMENT '多个销售属性值id逗号分隔',
  PRIMARY KEY (`sku_id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='sku-国际化表';

/*Data for the table `sku_lang` */

/*Table structure for table `sku_stock` */

DROP TABLE IF EXISTS `sku_stock`;

/*Table structure for table `spu` */

DROP TABLE IF EXISTS `spu`;

CREATE TABLE `spu` (
  `spu_id` bigint unsigned NOT NULL COMMENT 'spu id',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `brand_id` bigint DEFAULT NULL COMMENT '品牌ID',
  `category_id` bigint NOT NULL COMMENT '分类ID',
  `shop_category_id` bigint NOT NULL DEFAULT '0' COMMENT '店铺分类ID',
  `shop_id` bigint NOT NULL COMMENT '店铺id 0:平台id, id > 0:店铺id, -1:供应商商品',
  `main_img_url` varchar(255) DEFAULT NULL COMMENT '商品介绍主图',
  `img_urls` varchar(1000) DEFAULT NULL COMMENT '商品图片 多个图片逗号分隔',
  `video` varchar(150) DEFAULT NULL COMMENT '商品视频',
  `price_fee` bigint NOT NULL DEFAULT '0' COMMENT '售价，整数方式保存',
  `market_price_fee` bigint NOT NULL DEFAULT '0' COMMENT '市场价，整数方式保存',
  `score_fee` bigint NOT NULL DEFAULT '0' COMMENT '积分价格',
  `status` tinyint NOT NULL DEFAULT '0' COMMENT '状态 -1:删除, 0:下架, 1:上架, 2:平台下架, 3: 等待审核',
  `delivery_mode` json NOT NULL COMMENT '配送方式json见TransportModeVO',
  `delivery_template_id` bigint DEFAULT NULL COMMENT '运费模板id',
  `delivery_amount` bigint DEFAULT NULL COMMENT '运费固定金额',
  `has_sku_img` tinyint NOT NULL DEFAULT '0' COMMENT 'sku是否含有图片 0无 1有',
  `spu_type` tinyint NOT NULL DEFAULT '0' COMMENT '商品类型(0普通商品 1拼团 2秒杀 3积分)',
  `activity_id` bigint DEFAULT '0' COMMENT '活动id(关联prod_type)',
  `seq` smallint NOT NULL DEFAULT '3' COMMENT '序号',
  `is_top` tinyint NOT NULL DEFAULT '0' COMMENT '是否置顶，1.置顶 0.不置顶',
  `spu_code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'spu编码',
  `supplier_spu_type` tinyint DEFAULT '0' COMMENT '供应商商品类型 0.否 1.是 2.商家代销',
  `supplier_spu_id` bigint DEFAULT '0' COMMENT '关联商品商品id，只有供应商商品为2才有',
  `supplier_delivery_type` tinyint DEFAULT NULL COMMENT '发货方式 1.供应商发货 2.仓库发货',
  `supplier_id` bigint NOT NULL DEFAULT '0' COMMENT '供应商id -1、0：商家、平台的商品， id > 0: 供应商商品',
  `measure_unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '计量单位',
  `sku_choice_status` tinyint DEFAULT NULL COMMENT '代销商品规格选择状态，1: 全选 2：部分选择',
  `is_syn_update` tinyint DEFAULT NULL COMMENT '供应商商品更新后代销商品是否已同步更新 1:已更新 -1:未更新',
  `is_update_msg` tinyint DEFAULT NULL COMMENT '代销商品基本信息是否以改变,0未改变,1已改变',
  `spu_mold` tinyint NOT NULL COMMENT '商品类别 0.实物商品 1.虚拟商品 2.组合商品',
  `is_refund` tinyint DEFAULT NULL COMMENT '是否可以退款 1.可以 0不可以',
  `pre_sale_type` tinyint DEFAULT '-1' COMMENT '预售类型  -1：未开启 0.全款预售 1.定金预售',
  `deposit_type` tinyint DEFAULT '0' COMMENT '定金收取类型 0.按比例 1.按金额',
  `deposit_amount` bigint DEFAULT '0' COMMENT '定金数额(定金收取类型比例为0时，代表百分比*100，为1时代表实际金额*100）',
  `deposit_expansion_amount` bigint DEFAULT '0' COMMENT '定金膨胀数额(定金收取类型比例为0时，代表百分比*100，为1时代表实际金额*100）',
  `deposit_start_time` datetime DEFAULT NULL COMMENT '定金支付开始时间',
  `deposit_end_time` datetime DEFAULT NULL COMMENT '定金支付结束时间',
  `balance_start_time` datetime DEFAULT NULL COMMENT '尾款支付开始时间',
  `balance_end_time` datetime DEFAULT NULL COMMENT '尾款支付结束时间',
  `pre_sale_delivery_type` tinyint DEFAULT NULL COMMENT '预售发货类型 0.固定时间 x.尾款支付后x天发货',
  `pre_sale_delivery_time` datetime DEFAULT NULL COMMENT '预售发货时间',
  `virtual_remark` json DEFAULT NULL COMMENT '虚拟商品的留言备注',
  `sku_zoned` tinyint NOT NULL DEFAULT '0' COMMENT '是否有sku分过片了',
  `write_off_num` int DEFAULT NULL COMMENT '核销次数 -1.多次核销 0.无需核销 1.单次核销',
  `write_off_multiple_count` int DEFAULT NULL COMMENT '核销次数 -1.无限次',
  `write_off_time` int DEFAULT NULL COMMENT '核销有效期 -1.长期有效 0.自定义  x.x天内有效',
  `write_off_start` datetime DEFAULT NULL COMMENT '核销开始时间',
  `write_off_end` datetime DEFAULT NULL COMMENT '核销结束时间',
  `is_all_entity` INT DEFAULT NULL COMMENT '是否为全部实物商品的组合商品 1.是 0.否',
  PRIMARY KEY (`spu_id`),
  KEY `idx_brandid` (`brand_id`),
  KEY `idx_catid` (`category_id`),
  KEY `idx_shopid` (`shop_id`),
  KEY `idx_supplierid` (`supplier_id`),
  KEY `idx_supplier_spu_id` (`supplier_spu_id`),
  KEY `idx_shop_catid` (`shop_category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='spu信息';

/*Data for the table `spu` */

/*Table structure for table `spu_attr_value` */

DROP TABLE IF EXISTS `spu_attr_value`;

CREATE TABLE `spu_attr_value` (
  `spu_attr_value_id` bigint NOT NULL AUTO_INCREMENT COMMENT '商品属性值关联信息id',
  `spu_id` bigint unsigned NOT NULL COMMENT '商品id',
  `lang` tinyint unsigned NOT NULL COMMENT '语言 0.通用 1.中文 2.英文',
  `attr_id` bigint unsigned NOT NULL COMMENT '规格属性id',
  `attr_name` varchar(255) DEFAULT NULL COMMENT '规格属性名称',
  `attr_value_id` bigint DEFAULT NULL COMMENT '规格属性值id',
  `attr_value_name` varchar(255) DEFAULT NULL COMMENT '规格属性值名称',
  `attr_desc` varchar(255) DEFAULT NULL COMMENT '规格属性描述',
  PRIMARY KEY (`spu_attr_value_id`),
  UNIQUE KEY `uni_spuid` (`spu_id`,`attr_id`,`lang`),
  KEY `idx_attrid` (`attr_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品规格属性关联信息';

/*Data for the table `spu_attr_value` */

/*Table structure for table `spu_browse_log` */

DROP TABLE IF EXISTS `spu_browse_log`;

CREATE TABLE `spu_browse_log` (
  `spu_browse_log_id` bigint NOT NULL AUTO_INCREMENT,
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  `user_id` bigint DEFAULT NULL COMMENT '用户id',
  `spu_id` bigint NOT NULL COMMENT '商品id',
  `category_id` bigint NOT NULL COMMENT '平台分类id',
  `status` tinyint NOT NULL DEFAULT '1' COMMENT '1:正常 -1:删除',
  `browse_num` int NOT NULL DEFAULT '1' COMMENT '浏览次数',
  `spu_type` tinyint NOT NULL DEFAULT '0' COMMENT '商品类型',
  PRIMARY KEY (`spu_browse_log_id`),
  KEY `idx_user_and_spu` (`user_id`,`spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品浏览记录表';

/*Data for the table `spu_browse_log` */

/*Table structure for table `spu_collection` */

DROP TABLE IF EXISTS `spu_collection`;

CREATE TABLE `spu_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`),
  UNIQUE KEY `uni_user_spu` (`user_id`,`spu_id`),
  KEY `idx_spu` (`spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品收藏信息';

/*Data for the table `spu_collection` */

/*Table structure for table `spu_comm` */

DROP TABLE IF EXISTS `spu_comm`;

CREATE TABLE `spu_comm` (
  `spu_comm_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `spu_id` bigint unsigned NOT NULL COMMENT '商品ID',
  `shop_id` bigint NOT NULL COMMENT '店铺 ID',
  `order_item_id` bigint unsigned DEFAULT NULL COMMENT '订单项ID',
  `user_id` varchar(36) DEFAULT NULL COMMENT '评论用户ID',
  `content` varchar(500) DEFAULT '' COMMENT '评论内容',
  `reply_content` varchar(500) DEFAULT '' COMMENT '掌柜回复',
  `reply_time` datetime DEFAULT NULL COMMENT '回复时间（商家回复）',
  `reply_sts` int DEFAULT '0' COMMENT '是否回复 0:未回复  1:已回复',
  `postip` varchar(16) DEFAULT NULL COMMENT 'IP来源',
  `score` tinyint DEFAULT '0' COMMENT '商品得分，1-5分',
  `store_score` tinyint DEFAULT '0' COMMENT '店铺评分 1-5分',
  `logistics_score` tinyint DEFAULT '0' COMMENT '物流评分 1-5分',
  `useful_counts` int DEFAULT '0' COMMENT '有用的计数',
  `pics` varchar(1000) DEFAULT NULL COMMENT '晒图的json字符串',
  `is_anonymous` int DEFAULT '0' COMMENT '是否匿名(1:是  0:否)',
  `status` int DEFAULT NULL COMMENT '是否显示  -1:删除 0:不显示 1:显示 2 审核不通过 3.待审核',
  `evaluate` tinyint DEFAULT NULL COMMENT '评价(1好评 2中评 3差评)',
  PRIMARY KEY (`spu_comm_id`),
  KEY `idx_spu_id` (`spu_id`),
  KEY `idx_user_id` (`user_id`),
  KEY `idx_order_item_id` (`order_item_id`),
  KEY `idx_shop_id` (`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品评论';

/*Data for the table `spu_comm` */

/*Table structure for table `spu_detail` */

DROP TABLE IF EXISTS `spu_detail`;

CREATE TABLE `spu_detail` (
  `spu_id` bigint NOT NULL COMMENT '商品id',
  `lang` tinyint NOT NULL COMMENT '语言 0.通用 1.中文 2.英文',
  `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `detail` mediumtext COMMENT '商品详情',
  PRIMARY KEY (`spu_id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品详情信息';

/*Data for the table `spu_detail` */

/*Table structure for table `spu_extension` */

DROP TABLE IF EXISTS `spu_extension`;

CREATE TABLE `spu_extension` (
  `spu_extend_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 '更新时间',
  `spu_id` bigint unsigned NOT NULL COMMENT '商品id',
  `comment_num` int unsigned NOT NULL DEFAULT '0' COMMENT '评论数量',
  `water_sold_num` int unsigned NOT NULL DEFAULT '0' COMMENT '注水销量',
  PRIMARY KEY (`spu_extend_id`),
  KEY `idx_spu` (`spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

/*Data for the table `spu_extension` */

/*Table structure for table `spu_lang` */

DROP TABLE IF EXISTS `spu_lang`;

CREATE TABLE `spu_lang` (
  `spu_id` bigint NOT NULL COMMENT '商品id',
  `lang` tinyint NOT NULL COMMENT '语言 1.中文 2.英文',
  `spu_name` varchar(255) DEFAULT NULL COMMENT '商品名称',
  `selling_point` varchar(500) DEFAULT NULL COMMENT '简要描述,卖点等',
  PRIMARY KEY (`spu_id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品-国际化表';

/*Data for the table `spu_lang` */

/*Table structure for table `spu_sku_attr_value` */

DROP TABLE IF EXISTS `spu_sku_attr_value`;

CREATE TABLE `spu_sku_attr_value` (
  `spu_sku_attr_id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '商品sku销售属性关联信息id',
  `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 NOT NULL DEFAULT '0' COMMENT 'SPU ID',
  `sku_id` bigint NOT NULL DEFAULT '0' COMMENT 'SKU ID',
  `lang` tinyint DEFAULT NULL COMMENT '语言 0.通用 1.中文 2.英文',
  `attr_id` int DEFAULT '0' COMMENT '销售属性ID',
  `attr_value_id` int DEFAULT '0' COMMENT '销售属性值ID',
  `img_url` varchar(255) DEFAULT NULL COMMENT '图片url',
  `status` tinyint NOT NULL DEFAULT '0' COMMENT '状态 1:enable, 0:disable, -1:deleted',
  PRIMARY KEY (`spu_sku_attr_id`),
  KEY `idx_spuid` (`spu_id`),
  KEY `idx_skuid` (`sku_id`),
  KEY `idx_attrid` (`attr_id`),
  KEY `idx_attrvalueid` (`attr_value_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品sku销售属性关联信息';

/*Data for the table `spu_sku_attr_value` */

/*Table structure for table `spu_sku_attr_value_lang` */

DROP TABLE IF EXISTS `spu_sku_attr_value_lang`;

CREATE TABLE `spu_sku_attr_value_lang` (
  `spu_sku_attr_id` bigint NOT NULL COMMENT '商品sku销售属性id',
  `lang` tinyint NOT NULL COMMENT '语言 1.中文 2.英文',
  `attr_name` varchar(300) DEFAULT NULL COMMENT '销售属性名称',
  `attr_value_name` varchar(500) DEFAULT NULL COMMENT '销售属性值',
  PRIMARY KEY (`spu_sku_attr_id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品sku销售属性关联信息-国际化';

/*Data for the table `spu_sku_attr_value_lang` */

/*Table structure for table `spu_tag` */

DROP TABLE IF EXISTS `spu_tag`;

CREATE TABLE `spu_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 '修改时间',
  `title` varchar(36) DEFAULT NULL COMMENT '分组标题',
  `shop_id` bigint DEFAULT NULL COMMENT '店铺Id',
  `status` tinyint(1) DEFAULT NULL COMMENT '状态(1为正常,-1为删除)',
  `is_default` tinyint(1) DEFAULT NULL COMMENT '默认类型(0:商家自定义,1:系统默认)',
  `prod_count` bigint DEFAULT NULL COMMENT '商品数量',
  `style` int DEFAULT NULL COMMENT '列表样式(0:一列一个,1:一列两个,2:一列三个)',
  `seq` int DEFAULT NULL COMMENT '排序',
  `delete_time` datetime DEFAULT NULL COMMENT '删除时间',
  PRIMARY KEY (`id`),
  KEY `shop_idx`(`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品分组表';

/*Data for the table `spu_tag` */

insert  into `spu_tag`(`id`,`create_time`,`update_time`,`title`,`shop_id`,`status`,`is_default`,`prod_count`,`style`,`seq`,`delete_time`) values
(1,'2021-04-19 15:17:40','2021-07-03 16:51:19','商城精选',0,1,1,0,0,0,NULL),
(2,'2021-04-19 15:21:43','2021-07-02 11:09:19','商城热销',0,1,1,0,0,0,NULL),
(3,'2021-04-19 15:25:34','2021-07-02 16:12:47','实惠好物',0,1,1,0,0,0,NULL),
(4,'2021-04-19 15:27:58','2021-07-01 11:08:54','潮流单品',0,1,1,0,0,0,NULL);

/*Table structure for table `spu_tag_reference` */

DROP TABLE IF EXISTS `spu_tag_reference`;

CREATE TABLE `spu_tag_reference` (
  `reference_id` bigint NOT NULL AUTO_INCREMENT COMMENT '分组引用id',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `shop_id` bigint DEFAULT NULL COMMENT '店铺id',
  `tag_id` bigint DEFAULT NULL COMMENT '标签id',
  `spu_id` bigint DEFAULT NULL COMMENT '商品id',
  `status` tinyint(1) DEFAULT NULL COMMENT '状态(1:正常,-1:删除)',
  `seq` int DEFAULT NULL COMMENT '排序',
  PRIMARY KEY (`reference_id`),
  KEY `shop_tag_spu_idx`(`shop_id`, `tag_id`, `spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品分组标签关联信息';

/*Data for the table `spu_tag_reference` */


/* Create table in target */
DROP TABLE IF EXISTS `spu_consignment_change`;
CREATE TABLE `spu_consignment_change`(
    `consignment_change_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 '修改时间',
    `spu_id` bigint NULL  COMMENT '代销商品id' ,
    `name_change` tinyint NULL  DEFAULT 0 COMMENT '代销商品名称是否已更改 0未更改，1已更改' ,
    `image_change` tinyint NULL  DEFAULT 0 COMMENT '代销图片是否已更改 0未更改，1已更改' ,
    `selling_point_change` tinyint NULL  DEFAULT 0 COMMENT '代销商品卖点是否已更改, 0未更改，1已更改' ,
    `video_change` tinyint NULL  DEFAULT 0 COMMENT '代销商品视频是否已更改, 0未更改，1已更改' ,
    `measure_unit_change` tinyint NULL  DEFAULT 0 COMMENT '代销商品计量单位是否已更改，0未更改，1已更改' ,
    `brand_change` tinyint NULL  DEFAULT 0 COMMENT '代销商品品牌是否已更改，0未更改，1已更改' ,
    `detail_change` tinyint NULL  DEFAULT 0 COMMENT '代销商品详情是否已更改，0未更改，1已更改' ,
    `spu_code_change` tinyint NULL  DEFAULT 0 COMMENT '代销商品编码是否已更改, 0未更改，1已更改' ,
    PRIMARY KEY (`consignment_change_id`) ,
    KEY `idx_spuid`(`spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8mb4' COLLATE='utf8mb4_general_ci' COMMENT='商家代销商品基本信息相对于供应商品是否改变';



/* Create table in target */
DROP TABLE IF EXISTS `spu_price_log`;
CREATE TABLE `spu_price_log`(
    `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 '修改时间',
    `spu_id` bigint NOT NULL  COMMENT '商品id' ,
    `sku_id` bigint NOT NULL  COMMENT '规格id' ,
    `before_price` bigint NOT NULL  COMMENT '原供货价' ,
    `after_price` bigint NOT NULL  COMMENT '现供货价' ,
    `price` bigint NOT NULL  COMMENT '差价' ,
    PRIMARY KEY (`id`) ,
    KEY `idx_spu_id`(`spu_id`) ,
    KEY `idx_sku_id`(`sku_id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8mb4' COLLATE='utf8mb4_general_ci' COMMENT='供应商商品调价记录';


/* Create table in target */
DROP TABLE IF EXISTS `spu_supplier_change_log`;
CREATE TABLE `spu_supplier_change_log`(
    `spu_change_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 '修改时间',
    `spu_id` bigint unsigned NOT NULL  COMMENT '商品id' ,
    `change_type` tinyint NOT NULL  COMMENT '变更类型 1.商品上架 2.商品下架 3.代销sku信息变更4.新增sku' ,
    `remarks` varchar(255) COLLATE utf8mb4_general_ci NULL  COMMENT '备注' ,
    PRIMARY KEY (`spu_change_id`) ,
    KEY `idx_spu_id`(`spu_id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8mb4' COLLATE='utf8mb4_general_ci' COMMENT='商品供应商变更记录';


/* Create table in target */
DROP TABLE IF EXISTS `stock_change_reason`;
CREATE TABLE `stock_change_reason`(
    `stock_change_reason_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 '修改时间',
    `type` tinyint NOT NULL  COMMENT '出入库类别，1：出库 2：入库' ,
    `shop_id` bigint NOT NULL  COMMENT '店铺id' ,
    `status` tinyint NOT NULL  COMMENT '状态，1：启用 0：禁用 -1：删除' ,
    `sys_type` tinyint(0) NULL COMMENT '系统类型',
    PRIMARY KEY (`stock_change_reason_id`) ,
    KEY `shop_id`(`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8mb4' COLLATE='utf8mb4_general_ci' COMMENT='出入库原因';

insert into `stock_change_reason` (`stock_change_reason_id`, `type`, `shop_id`, `status`)
values ('1', '1', '0', '1'),
       ('2', '1', '0', '1'),
       ('3', '2', '0', '1'),
       ('4', '1', '0', '1'),
       ('5', '1', '0', '1'),
       ('6', '2', '0', '1');


/* Create table in target */
DROP TABLE IF EXISTS `stock_change_reason_lang`;
CREATE TABLE `stock_change_reason_lang`(
    `stock_change_reason_id` bigint NOT NULL  ,
    `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    `lang` tinyint NOT NULL  COMMENT '语言 0.中文 1.英文' ,
    `reason` varchar(255) COLLATE utf8mb4_general_ci NULL  COMMENT '原因' ,
    `remark` varchar(255) COLLATE utf8mb4_general_ci NULL  COMMENT '备注' ,
    PRIMARY KEY (`stock_change_reason_id`,`lang`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8mb4' COLLATE='utf8mb4_general_ci' COMMENT='出入库原因-国际化';

insert into `stock_change_reason_lang` (`stock_change_reason_id`, `lang`, `reason`, `remark`)
values ('1', '0', '库存报溢', '系统内置'),
       ('1', '1', 'Inventory overrun', 'System presets'),
       ('2', '0', '其他', '系统内置'),
       ('2', '1', 'other', 'System presets'),
       ('3', '0', '补货', '系统内置'),
       ('3', '1', 'Replenishment', 'System presets'),
       ('4', '0', '报损', '系统内置'),
       ('4', '1', 'Damaged', 'System presets'),
       ('5', '0', '领用', '系统内置'),
       ('5', '1', 'Receiving', 'System presets'),
       ('6', '0', '其他', '系统内置'),
       ('6', '1', 'other', 'System presets');

/* Create table in target */
DROP TABLE IF EXISTS `stock_change_reason_status`;
CREATE TABLE `stock_change_reason_status`(
    `stock_change_reason_status_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 '修改时间',
    `stock_change_reason_id` bigint NOT NULL  COMMENT '关联的系统出入库原因id' ,
    `status` tinyint NOT NULL  COMMENT '状态，1：启用 0：禁用 -1：删除' ,
    `shop_id` bigint NOT NULL  COMMENT '店铺id' ,
    PRIMARY KEY (`stock_change_reason_status_id`) ,
    UNIQUE KEY `uni_shopId_stockChangeReasonId`(`shop_id`,`stock_change_reason_id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8mb4' COLLATE='utf8mb4_general_ci' COMMENT='出入库原因状态';


/* Create table in target */
DROP TABLE IF EXISTS `take_stock`;
CREATE TABLE `take_stock`(
    `take_stock_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 '修改时间',
    `take_stock_no` varchar(36) COLLATE utf8mb4_general_ci NOT NULL  COMMENT '盘点单号' ,
    `bill_status` tinyint NOT NULL  COMMENT '盘点状态 0已作废 1盘点中 2已完成' ,
    `maker` bigint NOT NULL  COMMENT '制单人' ,
    `stock_region_name` varchar(255) COLLATE utf8mb4_general_ci NULL  COMMENT '盘点区域名称' ,
    `remark` varchar(255) COLLATE utf8mb4_general_ci NULL  COMMENT '备注' ,
    `shop_id` bigint NOT NULL  COMMENT '店铺id' ,
    `maker_mobile` varchar(255) COLLATE utf8mb4_general_ci NULL  COMMENT '制单人手机号' ,
    `warehouse_id` bigint(0) NULL COMMENT '仓库id',
    `stock_point_type` tinyint(0) NULL COMMENT '库存点类型(1:仓库, 2:门店)' ,
    PRIMARY KEY (`take_stock_id`) ,
    KEY `idx_shop_id`(`shop_id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8mb4' COLLATE='utf8mb4_general_ci';


/* Create table in target */
DROP TABLE IF EXISTS `take_stock_spu`;

CREATE TABLE `take_stock_spu`(
    `take_stock_spu_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 '修改时间',
    `take_stock_id` bigint NOT NULL  COMMENT '盘点id' ,
    `spu_id` bigint NOT NULL  COMMENT '商品id' ,
    `sku_id` bigint NULL  COMMENT 'sku_id' ,
    `stocks` int NULL  COMMENT '账面库存' ,
    `total_stock` int NULL  COMMENT '实盘库存' ,
    `io_type` tinyint NULL  COMMENT '盈亏类型 0盘平 1盘盈 2盘亏 -1异常' ,
    `remark` varchar(255) COLLATE utf8mb4_general_ci NULL  COMMENT '备注' ,
    `exception_reason` tinyint NULL  COMMENT '异常原因 1.删除商品 2.盘点期间有库存变动 3.其他' ,
    PRIMARY KEY (`take_stock_spu_id`),
    KEY `idx_spu_id`(`spu_id`),
    KEY `idx_sku_id`(`sku_id`)
) ENGINE=InnoDB DEFAULT CHARSET='utf8mb4' COLLATE='utf8mb4_general_ci' COMMENT='盘点商品列表';


/*Table structure for table `giveaway` */

DROP TABLE IF EXISTS `giveaway`;

CREATE TABLE `giveaway`
(
    `giveaway_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 '活动结束时间',
    `shop_id`     bigint                           NOT NULL COMMENT '店铺id',
    `buy_num`     int                              NOT NULL DEFAULT '1' COMMENT '购买数量（购买了多少件才赠送赠品）',
    `spu_id`      bigint                           NOT NULL COMMENT '主商品id',
    `status`      tinyint                          NOT NULL COMMENT '状态 -1：已删除 0：关闭 1:开启',
    PRIMARY KEY (`giveaway_id`),
    KEY           `spu_id` (`spu_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=632780300328 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='赠品表';


/*Table structure for table `giveaway_spu` */

DROP TABLE IF EXISTS `giveaway_spu`;

CREATE TABLE `giveaway_spu`
(
    `giveaway_spu_id` bigint         NOT NULL AUTO_INCREMENT COMMENT '赠品商品项id',
    `giveaway_id`     bigint         NOT NULL COMMENT '赠品id',
    `spu_id`          bigint         NOT NULL COMMENT '商品id',
    `sku_id`          bigint         NOT NULL COMMENT 'skuId',
    `giveaway_num`    int            NOT NULL DEFAULT '1' COMMENT '赠送数量',
    `refund_price`    decimal(15, 2) NOT NULL DEFAULT '0.00' COMMENT '退货价',
    `status`          tinyint        NOT NULL DEFAULT '1' COMMENT '状态 1：正常 0：失效 -1：删除',
    PRIMARY KEY (`giveaway_spu_id`) USING BTREE,
    KEY               `idx_giveaway_spu_id` (`giveaway_id`,`spu_id`) USING BTREE,
    KEY               `idx_spu_id` (`spu_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=251 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='赠品套装商品项';




/*Table structure for table `sku_combo` */
DROP TABLE IF EXISTS `sku_combo`;
CREATE TABLE `sku_combo` (
        `sku_id` bigint NOT NULL COMMENT '规格id',
        `combo_sku_id` bigint NOT NULL COMMENT '组合的skuid',
        `combo_spu_id` bigint NOT NULL COMMENT '组合的spuid',
        `combo_count` int 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 '修改时间',
        PRIMARY KEY (`sku_id`,`combo_sku_id`),
        KEY `idx_spu_id` (`combo_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
('mall4cloud-product-comm','1','1000','商品评论id'),
('mall4cloud-product-sku-code','1','1000','sku的编码'),
('mall4cloud-product-stock-in','1','1000','MongoDB中stockBillLog表的入库单号'),
('mall4cloud-product-stock-out','1','1000','MongoDB中stockBillLog表的出库单号'),
('mall4cloud-spu','1','1000','商品id'),
('mall4cloud-spu-browse-log','1','1000','商品浏览记录id'),
('mall4cloud-stock-bill-log','1','1000','MongoDB中stockBillLog表的出入库日志id'),
('mall4cloud-stock-point', 1000, 1000, '库存点id');

DROP TABLE IF EXISTS `stock_point_sku`;

CREATE TABLE `stock_point_sku` (
        `stock_point_sku_id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '库存商品关联skuid',
        `stock_point_id` bigint NOT NULL COMMENT '库存点id',
        `stock_point_type` tinyint NOT NULL COMMENT '库存点类型 1仓库 2门店',
        `spu_id` bigint DEFAULT NULL COMMENT 'spuId',
        `sku_id` bigint DEFAULT NULL COMMENT 'skuid',
        `supplier_sku_id` bigint DEFAULT NULL COMMENT '当商品为代销商品时，供应商商品skuid',
        `status` tinyint DEFAULT '0' COMMENT '状态 1:enable, 0:disable, -1:deleted',
        `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
        `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
        `type` tinyint DEFAULT '1' COMMENT '仓库类型（0默认仓库，1区域仓库）',
        `stock_mode` tinyint DEFAULT NULL COMMENT '库存模式 1共享总部库存 2独立销售库存',
        PRIMARY KEY (`stock_point_sku_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

DROP TABLE IF EXISTS `warehouse`;
CREATE TABLE `warehouse` (
        `warehouse_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 '更新时间',
        `shop_id` bigint DEFAULT NULL COMMENT '店铺id',
        `warehouse_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '仓库名称',
        `type` tinyint DEFAULT NULL COMMENT '仓库类型（0默认仓库，1区域仓库）',
        `address` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '仓库地址',
        `manage` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '管理人',
        `phone` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '管理电话',
        `sys_type` tinyint DEFAULT NULL COMMENT '系统类型',
        `province_id` bigint DEFAULT NULL COMMENT '省ID',
        `province` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '省',
        `city_id` bigint DEFAULT NULL COMMENT '城市ID',
        `city` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '城市',
        `area_id` bigint DEFAULT NULL COMMENT '区ID',
        `area` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '区',
        PRIMARY KEY (`warehouse_id`),
        KEY `shop_id` (`shop_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

INSERT INTO `warehouse` (`warehouse_id`,`shop_id`, `warehouse_name`, `type`, `address`, `manage`, `phone`, `sys_type`, `province_id`, `province`, `city_id`, `city`, `area_id`, `area`)
VALUES
    (300000000000000,0,'默认仓库',0,NULL,NULL,NULL,2,NULL,NULL,NULL,NULL,NULL,NULL);

DROP TABLE IF EXISTS `warehouse_area`;
CREATE TABLE `warehouse_area` (
                                  `warehouse_area_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 '更新时间',
                                  `warehouse_id` bigint DEFAULT NULL COMMENT '仓库id',
                                  `area_id` bigint DEFAULT NULL COMMENT '城市id',
                                  PRIMARY KEY (`warehouse_area_id`) USING BTREE,
                                  KEY `idx_warehouse_id` (`warehouse_id`) USING BTREE,
                                  KEY `idx_city_id` (`area_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC 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 */;
