text: /*
   Navicat Premium Data Transfer
  
   Source Server         : vm-132-docker
   Source Server Type    : MySQL
   Source Server Version : 80023
   Source Host           : 192.168.40.132:33306
   Source Schema         : lejing_wms
  
   Target Server Type    : MySQL
   Target Server Version : 80023
   File Encoding         : 65001
  
   Date: 04/02/2021 22:09:47
  */
  
  SET NAMES utf8mb4;
  SET FOREIGN_KEY_CHECKS = 0;
  
  -- ----------------------------
  -- for AT mode you must to init this sql for you business database. the seata server not need it.
  -- ----------------------------
  DROP TABLE IF EXISTS `undo_log`;
  CREATE TABLE IF NOT EXISTS `undo_log`
  (
      `id`            bigint       NOT NULL AUTO_INCREMENT COMMENT '主键id',
      `branch_id`     BIGINT       NOT NULL COMMENT 'branch transaction id',
      `xid`           VARCHAR(128) NOT NULL COMMENT 'global transaction id',
      `context`       VARCHAR(128) NOT NULL COMMENT 'undo_log context,such as serialization',
      `rollback_info` LONGBLOB     NOT NULL COMMENT 'rollback info',
      `log_status`    INT(11)      NOT NULL COMMENT '0:normal status,1:defense status',
      `log_created`   timestamp    NOT NULL COMMENT 'create datetime',
      `log_modified`  timestamp    NOT NULL COMMENT 'modify datetime',
      PRIMARY KEY (`id`) USING BTREE,
      UNIQUE KEY `ux_undo_log` (`xid`, `branch_id`)
  ) ENGINE = InnoDB
    AUTO_INCREMENT = 1
    DEFAULT CHARSET = utf8mb4 COMMENT ='AT transaction mode undo table';
  
  -- ----------------------------
  -- Table structure for wms_purchase
  -- ----------------------------
  DROP TABLE IF EXISTS `wms_purchase`;
  CREATE TABLE `wms_purchase`
  (
      `id`            bigint                                                        NOT NULL AUTO_INCREMENT COMMENT '采购单id',
      `assignee_id`   bigint                                                        NULL DEFAULT NULL COMMENT '采购人id',
      `assignee_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '采购人名',
      `phone`         char(13) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci     NULL DEFAULT NULL COMMENT '联系方式',
      `priority`      int                                                           NULL DEFAULT NULL COMMENT '优先级',
      `status`        int                                                           NULL DEFAULT NULL COMMENT '状态',
      `ware_id`       bigint                                                        NULL DEFAULT NULL COMMENT '仓库id',
      `amount`        decimal(18, 4)                                                NULL DEFAULT NULL COMMENT '总金额',
      `create_time`   datetime                                                      NULL DEFAULT NULL COMMENT '创建日期',
      `update_time`   datetime                                                      NULL DEFAULT NULL COMMENT '更新日期',
      PRIMARY KEY (`id`) USING BTREE
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_general_ci COMMENT = '采购信息'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Table structure for wms_purchase_detail
  -- ----------------------------
  DROP TABLE IF EXISTS `wms_purchase_detail`;
  CREATE TABLE `wms_purchase_detail`
  (
      `id`          bigint         NOT NULL AUTO_INCREMENT COMMENT '主键id',
      `purchase_id` bigint         NULL DEFAULT NULL COMMENT '采购单id',
      `sku_id`      bigint         NULL DEFAULT NULL COMMENT '采购商品id',
      `sku_num`     int            NULL DEFAULT NULL COMMENT '采购数量',
      `sku_price`   decimal(18, 4) NULL DEFAULT NULL COMMENT '采购金额',
      `ware_id`     bigint         NULL DEFAULT NULL COMMENT '仓库id',
      `status`      int            NULL DEFAULT NULL COMMENT '状态[0新建，1已分配，2正在采购，3已完成，4采购失败]',
      PRIMARY KEY (`id`) USING BTREE
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_general_ci COMMENT = '仓储采购表'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Table structure for wms_ware_info
  -- ----------------------------
  DROP TABLE IF EXISTS `wms_ware_info`;
  CREATE TABLE `wms_ware_info`
  (
      `id`       bigint                                                        NOT NULL AUTO_INCREMENT COMMENT 'id',
      `name`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '仓库名',
      `address`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '仓库地址',
      `areacode` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  NULL DEFAULT NULL COMMENT '区域编码',
      PRIMARY KEY (`id`) USING BTREE
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_general_ci COMMENT = '仓库信息'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Table structure for wms_ware_order_task
  -- ----------------------------
  DROP TABLE IF EXISTS `wms_ware_order_task`;
  CREATE TABLE `wms_ware_order_task`
  (
      `id`               bigint                                                        NOT NULL AUTO_INCREMENT COMMENT 'id',
      `order_id`         bigint                                                        NULL DEFAULT NULL COMMENT 'order_id',
      `order_sn`         varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'order_sn',
      `consignee`        varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '收货人',
      `consignee_tel`    char(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci     NULL DEFAULT NULL COMMENT '收货人电话',
      `delivery_address` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '配送地址',
      `order_comment`    varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '订单备注',
      `payment_way`      tinyint(1)                                                    NULL DEFAULT NULL COMMENT '付款方式【 1:在线付款 2:货到付款】',
      `task_status`      tinyint                                                       NULL DEFAULT NULL COMMENT '任务状态',
      `order_body`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '订单描述',
      `tracking_no`      char(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci     NULL DEFAULT NULL COMMENT '物流单号',
      `create_time`      datetime                                                      NULL DEFAULT NULL COMMENT 'create_time',
      `ware_id`          bigint                                                        NULL DEFAULT NULL COMMENT '仓库id',
      `task_comment`     varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '工作单备注',
      PRIMARY KEY (`id`) USING BTREE
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_general_ci COMMENT = '库存工作单'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Table structure for wms_ware_order_task_detail
  -- ----------------------------
  DROP TABLE IF EXISTS `wms_ware_order_task_detail`;
  CREATE TABLE `wms_ware_order_task_detail`
  (
      `id`          bigint                                                        NOT NULL AUTO_INCREMENT COMMENT 'id',
      `sku_id`      bigint                                                        NULL DEFAULT NULL COMMENT 'sku_id',
      `sku_name`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'sku_name',
      `sku_num`     int                                                           NULL DEFAULT NULL COMMENT '购买个数',
      `task_id`     bigint                                                        NULL DEFAULT NULL COMMENT '工作单id',
      `ware_id`     bigint                                                        NULL DEFAULT NULL COMMENT '仓库id',
      `lock_status` int                                                           NULL DEFAULT NULL COMMENT '1-已锁定 2-已解锁 3-已扣减',
      PRIMARY KEY (`id`) USING BTREE
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_general_ci COMMENT = '库存工作单'
    ROW_FORMAT = DYNAMIC;
  
  -- ----------------------------
  -- Table structure for wms_ware_sku
  -- ----------------------------
  DROP TABLE IF EXISTS `wms_ware_sku`;
  CREATE TABLE `wms_ware_sku`
  (
      `id`           bigint                                                        NOT NULL AUTO_INCREMENT COMMENT 'id',
      `sku_id`       bigint                                                        NULL DEFAULT NULL COMMENT 'sku_id',
      `ware_id`      bigint                                                        NULL DEFAULT NULL COMMENT '仓库id',
      `stock`        int                                                           NULL DEFAULT NULL COMMENT '库存数',
      `sku_name`     varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'sku_name',
      `stock_locked` int                                                           NULL DEFAULT 0 COMMENT '锁定库存',
      PRIMARY KEY (`id`) USING BTREE
  ) ENGINE = InnoDB
    CHARACTER SET = utf8mb4
    COLLATE = utf8mb4_general_ci COMMENT = '商品库存'
    ROW_FORMAT = DYNAMIC;
  
  SET FOREIGN_KEY_CHECKS = 1;
  