1. 程式人生 > 資料庫 >spring cloud 學習筆記--03初始化資料庫表資訊

spring cloud 學習筆記--03初始化資料庫表資訊

gulimall_oms

drop table if exists oms_order;

drop table if exists oms_order_item;

drop table if exists oms_order_operate_history;

drop table if exists oms_order_return_apply;

drop table if exists oms_order_return_reason;

drop table if exists oms_order_setting;

drop table if exists oms_payment_info;

drop table if exists oms_refund_info;

/*==============================================================*/
/* Table: oms_order                                             */
/*==============================================================*/
create table oms_order
(
   id                   bigint not null auto_increment comment 'id',
   member_id            bigint comment 'member_id',
   order_sn             char(32) comment '訂單號',
   coupon_id            bigint comment '使用的優惠券',
   create_time          datetime comment 'create_time',
   member_username      varchar(200) comment '使用者名稱',
   total_amount         decimal(18,4) comment '訂單總額',
   pay_amount           decimal(18,4) comment '應付總額',
   freight_amount       decimal(18,4) comment '運費金額',
   promotion_amount     decimal(18,4) comment '促銷優化金額(促銷價、滿減、階梯價)',
   integration_amount   decimal(18,4) comment '積分抵扣金額',
   coupon_amount        decimal(18,4) comment '優惠券抵扣金額',
   discount_amount      decimal(18,4) comment '後臺調整訂單使用的折扣金額',
   pay_type             tinyint comment '支付方式【1->支付寶;2->微信;3->銀聯; 4->貨到付款;】',
   source_type          tinyint comment '訂單來源[0->PC訂單;1->app訂單]',
   status               tinyint comment '訂單狀態【0->待付款;1->待發貨;2->已發貨;3->已完成;4->已關閉;5->無效訂單】',
   delivery_company     varchar(64) comment '物流公司(配送方式)',
   delivery_sn          varchar(64) comment '物流單號',
   auto_confirm_day     int comment '自動確認時間(天)',
   integration          int comment '可以獲得的積分',
   growth               int comment '可以獲得的成長值',
   bill_type            tinyint comment '發票型別[0->不開發票;1->電子發票;2->紙質發票]',
   bill_header          varchar(255) comment '發票抬頭',
   bill_content         varchar(255) comment '發票內容',
   bill_receiver_phone  varchar(32) comment '收票人電話',
   bill_receiver_email  varchar(64) comment '收票人郵箱',
   receiver_name        varchar(100) comment '收貨人姓名',
   receiver_phone       varchar(32) comment '收貨人電話',
   receiver_post_code   varchar(32) comment '收貨人郵編',
   receiver_province    varchar(32) comment '省份/直轄市',
   receiver_city        varchar(32) comment '城市',
   receiver_region      varchar(32) comment '區',
   receiver_detail_address varchar(200) comment '詳細地址',
   note                 varchar(500) comment '訂單備註',
   confirm_status       tinyint comment '確認收貨狀態[0->未確認;1->已確認]',
   delete_status        tinyint comment '刪除狀態【0->未刪除;1->已刪除】',
   use_integration      int comment '下單時使用的積分',
   payment_time         datetime comment '支付時間',
   delivery_time        datetime comment '發貨時間',
   receive_time         datetime comment '確認收貨時間',
   comment_time         datetime comment '評價時間',
   modify_time          datetime comment '修改時間',
   primary key (id)
);

alter table oms_order comment '訂單';

/*==============================================================*/
/* Table: oms_order_item                                        */
/*==============================================================*/
create table oms_order_item
(
   id                   bigint not null auto_increment comment 'id',
   order_id             bigint comment 'order_id',
   order_sn             char(32) comment 'order_sn',
   spu_id               bigint comment 'spu_id',
   spu_name             varchar(255) comment 'spu_name',
   spu_pic              varchar(500) comment 'spu_pic',
   spu_brand            varchar(200) comment '品牌',
   category_id          bigint comment '商品分類id',
   sku_id               bigint comment '商品sku編號',
   sku_name             varchar(255) comment '商品sku名字',
   sku_pic              varchar(500) comment '商品sku圖片',
   sku_price            decimal(18,4) comment '商品sku價格',
   sku_quantity         int comment '商品購買的數量',
   sku_attrs_vals       varchar(500) comment '商品銷售屬性組合(JSON)',
   promotion_amount     decimal(18,4) comment '商品促銷分解金額',
   coupon_amount        decimal(18,4) comment '優惠券優惠分解金額',
   integration_amount   decimal(18,4) comment '積分優惠分解金額',
   real_amount          decimal(18,4) comment '該商品經過優惠後的分解金額',
   gift_integration     int comment '贈送積分',
   gift_growth          int comment '贈送成長值',
   primary key (id)
);

alter table oms_order_item comment '訂單項資訊';

/*==============================================================*/
/* Table: oms_order_operate_history                             */
/*==============================================================*/
create table oms_order_operate_history
(
   id                   bigint not null auto_increment comment 'id',
   order_id             bigint comment '訂單id',
   operate_man          varchar(100) comment '操作人[使用者;系統;後臺管理員]',
   create_time          datetime comment '操作時間',
   order_status         tinyint comment '訂單狀態【0->待付款;1->待發貨;2->已發貨;3->已完成;4->已關閉;5->無效訂單】',
   note                 varchar(500) comment '備註',
   primary key (id)
);

alter table oms_order_operate_history comment '訂單操作歷史記錄';

/*==============================================================*/
/* Table: oms_order_return_apply                                */
/*==============================================================*/
create table oms_order_return_apply
(
   id                   bigint not null auto_increment comment 'id',
   order_id             bigint comment 'order_id',
   sku_id               bigint comment '退貨商品id',
   order_sn             char(32) comment '訂單編號',
   create_time          datetime comment '申請時間',
   member_username      varchar(64) comment '會員使用者名稱',
   return_amount        decimal(18,4) comment '退款金額',
   return_name          varchar(100) comment '退貨人姓名',
   return_phone         varchar(20) comment '退貨人電話',
   status               tinyint(1) comment '申請狀態[0->待處理;1->退貨中;2->已完成;3->已拒絕]',
   handle_time          datetime comment '處理時間',
   sku_img              varchar(500) comment '商品圖片',
   sku_name             varchar(200) comment '商品名稱',
   sku_brand            varchar(200) comment '商品品牌',
   sku_attrs_vals       varchar(500) comment '商品銷售屬性(JSON)',
   sku_count            int comment '退貨數量',
   sku_price            decimal(18,4) comment '商品單價',
   sku_real_price       decimal(18,4) comment '商品實際支付單價',
   reason               varchar(200) comment '原因',
   description述         varchar(500) comment '描述',
   desc_pics            varchar(2000) comment '憑證圖片,以逗號隔開',
   handle_note          varchar(500) comment '處理備註',
   handle_man           varchar(200) comment '處理人員',
   receive_man          varchar(100) comment '收貨人',
   receive_time         datetime comment '收貨時間',
   receive_note         varchar(500) comment '收貨備註',
   receive_phone        varchar(20) comment '收貨電話',
   company_address      varchar(500) comment '公司收貨地址',
   primary key (id)
);

alter table oms_order_return_apply comment '訂單退貨申請';

/*==============================================================*/
/* Table: oms_order_return_reason                               */
/*==============================================================*/
create table oms_order_return_reason
(
   id                   bigint not null auto_increment comment 'id',
   name                 varchar(200) comment '退貨原因名',
   sort                 int comment '排序',
   status               tinyint(1) comment '啟用狀態',
   create_time          datetime comment 'create_time',
   primary key (id)
);

alter table oms_order_return_reason comment '退貨原因';

/*==============================================================*/
/* Table: oms_order_setting                                     */
/*==============================================================*/
create table oms_order_setting
(
   id                   bigint not null auto_increment comment 'id',
   flash_order_overtime int comment '秒殺訂單超時關閉時間(分)',
   normal_order_overtime int comment '正常訂單超時時間(分)',
   confirm_overtime     int comment '發貨後自動確認收貨時間(天)',
   finish_overtime      int comment '自動完成交易時間,不能申請退貨(天)',
   comment_overtime     int comment '訂單完成後自動好評時間(天)',
   member_level         tinyint(2) comment '會員等級【0-不限會員等級,全部通用;其他-對應的其他會員等級】',
   primary key (id)
);

alter table oms_order_setting comment '訂單配置資訊';

/*==============================================================*/
/* Table: oms_payment_info                                      */
/*==============================================================*/
create table oms_payment_info
(
   id                   bigint not null auto_increment comment 'id',
   order_sn             char(32) comment '訂單號(對外業務號)',
   order_id             bigint comment '訂單id',
   alipay_trade_no      varchar(50) comment '支付寶交易流水號',
   total_amount         decimal(18,4) comment '支付總金額',
   subject              varchar(200) comment '交易內容',
   payment_status       varchar(20) comment '支付狀態',
   create_time          datetime comment '建立時間',
   confirm_time         datetime comment '確認時間',
   callback_content     varchar(4000) comment '回撥內容',
   callback_time        datetime comment '回撥時間',
   primary key (id)
);

alter table oms_payment_info comment '支付資訊表';

/*==============================================================*/
/* Table: oms_refund_info                                       */
/*==============================================================*/
create table oms_refund_info
(
   id                   bigint not null auto_increment comment 'id',
   order_return_id      bigint comment '退款的訂單',
   refund               decimal(18,4) comment '退款金額',
   refund_sn            varchar(64) comment '退款交易流水號',
   refund_status        tinyint(1) comment '退款狀態',
   refund_channel       tinyint comment '退款渠道[1-支付寶,2-微信,3-銀聯,4-匯款]',
   refund_content       varchar(5000),
   primary key (id)
);

alter table oms_refund_info comment '退款資訊';

gulimall_pms

drop table if exists pms_attr;

drop table if exists pms_attr_attrgroup_relation;

drop table if exists pms_attr_group;

drop table if exists pms_brand;

drop table if exists pms_category;

drop table if exists pms_category_brand_relation;

drop table if exists pms_comment_replay;

drop table if exists pms_product_attr_value;

drop table if exists pms_sku_images;

drop table if exists pms_sku_info;

drop table if exists pms_sku_sale_attr_value;

drop table if exists pms_spu_comment;

drop table if exists pms_spu_images;

drop table if exists pms_spu_info;

drop table if exists pms_spu_info_desc;

/*==============================================================*/
/* Table: pms_attr                                              */
/*==============================================================*/
create table pms_attr
(
   attr_id              bigint not null auto_increment comment '屬性id',
   attr_name            char(30) comment '屬性名',
   search_type          tinyint comment '是否需要檢索[0-不需要,1-需要]',
   icon                 varchar(255) comment '屬性圖示',
   value_select         char(255) comment '可選值列表[用逗號分隔]',
   attr_type            tinyint comment '屬性型別[0-銷售屬性,1-基本屬性,2-既是銷售屬性又是基本屬性]',
   enable               bigint comment '啟用狀態[0 - 禁用,1 - 啟用]',
   catelog_id           bigint comment '所屬分類',
   show_desc            tinyint comment '快速展示【是否展示在介紹上;0-否 1-是】,在sku中仍然可以調整',
   primary key (attr_id)
);

alter table pms_attr comment '商品屬性';

/*==============================================================*/
/* Table: pms_attr_attrgroup_relation                           */
/*==============================================================*/
create table pms_attr_attrgroup_relation
(
   id                   bigint not null auto_increment comment 'id',
   attr_id              bigint comment '屬性id',
   attr_group_id        bigint comment '屬性分組id',
   attr_sort            int comment '屬性組內排序',
   primary key (id)
);

alter table pms_attr_attrgroup_relation comment '屬性&屬性分組關聯';

/*==============================================================*/
/* Table: pms_attr_group                                        */
/*==============================================================*/
create table pms_attr_group
(
   attr_group_id        bigint not null auto_increment comment '分組id',
   attr_group_name      char(20) comment '組名',
   sort                 int comment '排序',
   descript             varchar(255) comment '描述',
   icon                 varchar(255) comment '組圖示',
   catelog_id           bigint comment '所屬分類id',
   primary key (attr_group_id)
);

alter table pms_attr_group comment '屬性分組';

/*==============================================================*/
/* Table: pms_brand                                             */
/*==============================================================*/
create table pms_brand
(
   brand_id             bigint not null auto_increment comment '品牌id',
   name                 char(50) comment '品牌名',
   logo                 varchar(2000) comment '品牌logo地址',
   descript             longtext comment '介紹',
   show_status          tinyint comment '顯示狀態[0-不顯示;1-顯示]',
   first_letter         char(1) comment '檢索首字母',
   sort                 int comment '排序',
   primary key (brand_id)
);

alter table pms_brand comment '品牌';

/*==============================================================*/
/* Table: pms_category                                          */
/*==============================================================*/
create table pms_category
(
   cat_id               bigint not null auto_increment comment '分類id',
   name                 char(50) comment '分類名稱',
   parent_cid           bigint comment '父分類id',
   cat_level            int comment '層級',
   show_status          tinyint comment '是否顯示[0-不顯示,1顯示]',
   sort                 int comment '排序',
   icon                 char(255) comment '圖示地址',
   product_unit         char(50) comment '計量單位',
   product_count        int comment '商品數量',
   primary key (cat_id)
);

alter table pms_category comment '商品三級分類';

/*==============================================================*/
/* Table: pms_category_brand_relation                           */
/*==============================================================*/
create table pms_category_brand_relation
(
   id                   bigint not null auto_increment,
   brand_id             bigint comment '品牌id',
   catelog_id           bigint comment '分類id',
   brand_name           varchar(255),
   catelog_name         varchar(255),
   primary key (id)
);

alter table pms_category_brand_relation comment '品牌分類關聯';

/*==============================================================*/
/* Table: pms_comment_replay                                    */
/*==============================================================*/
create table pms_comment_replay
(
   id                   bigint not null auto_increment comment 'id',
   comment_id           bigint comment '評論id',
   reply_id             bigint comment '回覆id',
   primary key (id)
);

alter table pms_comment_replay comment '商品評價回覆關係';

/*==============================================================*/
/* Table: pms_product_attr_value                                */
/*==============================================================*/
create table pms_product_attr_value
(
   id                   bigint not null auto_increment comment 'id',
   spu_id               bigint comment '商品id',
   attr_id              bigint comment '屬性id',
   attr_name            varchar(200) comment '屬性名',
   attr_value           varchar(200) comment '屬性值',
   attr_sort            int comment '順序',
   quick_show           tinyint comment '快速展示【是否展示在介紹上;0-否 1-是】',
   primary key (id)
);

alter table pms_product_attr_value comment 'spu屬性值';

/*==============================================================*/
/* Table: pms_sku_images                                        */
/*==============================================================*/
create table pms_sku_images
(
   id                   bigint not null auto_increment comment 'id',
   sku_id               bigint comment 'sku_id',
   img_url              varchar(255) comment '圖片地址',
   img_sort             int comment '排序',
   default_img          int comment '預設圖[0 - 不是預設圖,1 - 是預設圖]',
   primary key (id)
);

alter table pms_sku_images comment 'sku圖片';

/*==============================================================*/
/* Table: pms_sku_info                                          */
/*==============================================================*/
create table pms_sku_info
(
   sku_id               bigint not null auto_increment comment 'skuId',
   spu_id               bigint comment 'spuId',
   sku_name             varchar(255) comment 'sku名稱',
   sku_desc             varchar(2000) comment 'sku介紹描述',
   catalog_id           bigint comment '所屬分類id',
   brand_id             bigint comment '品牌id',
   sku_default_img      varchar(255) comment '預設圖片',
   sku_title            varchar(255) comment '標題',
   sku_subtitle         varchar(2000) comment '副標題',
   price                decimal(18,4) comment '價格',
   sale_count           bigint comment '銷量',
   primary key (sku_id)
);

alter table pms_sku_info comment 'sku資訊';

/*==============================================================*/
/* Table: pms_sku_sale_attr_value                               */
/*==============================================================*/
create table pms_sku_sale_attr_value
(
   id                   bigint not null auto_increment comment 'id',
   sku_id               bigint comment 'sku_id',
   attr_id              bigint comment 'attr_id',
   attr_name            varchar(200) comment '銷售屬性名',
   attr_value           varchar(200) comment '銷售屬性值',
   attr_sort            int comment '順序',
   primary key (id)
);

alter table pms_sku_sale_attr_value comment 'sku銷售屬性&值';

/*==============================================================*/
/* Table: pms_spu_comment                                       */
/*==============================================================*/
create table pms_spu_comment
(
   id                   bigint not null auto_increment comment 'id',
   sku_id               bigint comment 'sku_id',
   spu_id               bigint comment 'spu_id',
   spu_name             varchar(255) comment '商品名字',
   member_nick_name     varchar(255) comment '會員暱稱',
   star                 tinyint(1) comment '星級',
   member_ip            varchar(64) comment '會員ip',
   create_time          datetime comment '建立時間',
   show_status          tinyint(1) comment '顯示狀態[0-不顯示,1-顯示]',
   spu_attributes       varchar(255) comment '購買時屬性組合',
   likes_count          int comment '點贊數',
   reply_count          int comment '回覆數',
   resources            varchar(1000) comment '評論圖片/視訊[json資料;[{type:檔案型別,url:資源路徑}]]',
   content              text comment '內容',
   member_icon          varchar(255) comment '使用者頭像',
   comment_type         tinyint comment '評論型別[0 - 對商品的直接評論,1 - 對評論的回覆]',
   primary key (id)
);

alter table pms_spu_comment comment '商品評價';

/*==============================================================*/
/* Table: pms_spu_images                                        */
/*==============================================================*/
create table pms_spu_images
(
   id                   bigint not null auto_increment comment 'id',
   spu_id               bigint comment 'spu_id',
   img_name             varchar(200) comment '圖片名',
   img_url              varchar(255) comment '圖片地址',
   img_sort             int comment '順序',
   default_img          tinyint comment '是否預設圖',
   primary key (id)
);

alter table pms_spu_images comment 'spu圖片';

/*==============================================================*/
/* Table: pms_spu_info                                          */
/*==============================================================*/
create table pms_spu_info
(
   id                   bigint not null auto_increment comment '商品id',
   spu_name             varchar(200) comment '商品名稱',
   spu_description      varchar(1000) comment '商品描述',
   catalog_id           bigint comment '所屬分類id',
   brand_id             bigint comment '品牌id',
   weight               decimal(18,4),
   publish_status       tinyint comment '上架狀態[0 - 下架,1 - 上架]',
   create_time          datetime,
   update_time          datetime,
   primary key (id)
);

alter table pms_spu_info comment 'spu資訊';

/*==============================================================*/
/* Table: pms_spu_info_desc                                     */
/*==============================================================*/
create table pms_spu_info_desc
(
   spu_id               bigint not null comment '商品id',
   decript              longtext comment '商品介紹',
   primary key (spu_id)
);

alter table pms_spu_info_desc comment 'spu資訊介紹';

gulimall_sms

drop table if exists sms_coupon;

drop table if exists sms_coupon_history;

drop table if exists sms_coupon_spu_category_relation;

drop table if exists sms_coupon_spu_relation;

drop table if exists sms_home_adv;

drop table if exists sms_home_subject;

drop table if exists sms_home_subject_spu;

drop table if exists sms_member_price;

drop table if exists sms_seckill_promotion;

drop table if exists sms_seckill_session;

drop table if exists sms_seckill_sku_notice;

drop table if exists sms_seckill_sku_relation;

drop table if exists sms_sku_full_reduction;

drop table if exists sms_sku_ladder;

drop table if exists sms_spu_bounds;

/*==============================================================*/
/* Table: sms_coupon                                            */
/*==============================================================*/
create table sms_coupon
(
   id                   bigint not null auto_increment comment 'id',
   coupon_type          tinyint(1) comment '優惠卷型別[0->全場贈券;1->會員贈券;2->購物贈券;3->註冊贈券]',
   coupon_img           varchar(2000) comment '優惠券圖片',
   coupon_name          varchar(100) comment '優惠卷名字',
   num                  int comment '數量',
   amount               decimal(18,4) comment '金額',
   per_limit            int comment '每人限領張數',
   min_point            decimal(18,4) comment '使用門檻',
   start_time           datetime comment '開始時間',
   end_time             datetime comment '結束時間',
   use_type             tinyint(1) comment '使用型別[0->全場通用;1->指定分類;2->指定商品]',
   note                 varchar(200) comment '備註',
   publish_count        int(11) comment '發行數量',
   use_count            int(11) comment '已使用數量',
   receive_count        int(11) comment '領取數量',
   enable_start_time    datetime comment '可以領取的開始日期',
   enable_end_time      datetime comment '可以領取的結束日期',
   code                 varchar(64) comment '優惠碼',
   member_level         tinyint(1) comment '可以領取的會員等級[0->不限等級,其他-對應等級]',
   publish              tinyint(1) comment '釋出狀態[0-未釋出,1-已釋出]',
   primary key (id)
);

alter table sms_coupon comment '優惠券資訊';

/*==============================================================*/
/* Table: sms_coupon_history                                    */
/*==============================================================*/
create table sms_coupon_history
(
   id                   bigint not null auto_increment comment 'id',
   coupon_id            bigint comment '優惠券id',
   member_id            bigint comment '會員id',
   member_nick_name     varchar(64) comment '會員名字',
   get_type             tinyint(1) comment '獲取方式[0->後臺贈送;1->主動領取]',
   create_time          datetime comment '建立時間',
   use_type             tinyint(1) comment '使用狀態[0->未使用;1->已使用;2->已過期]',
   use_time             datetime comment '使用時間',
   order_id             bigint comment '訂單id',
   order_sn             bigint comment '訂單號',
   primary key (id)
);

alter table sms_coupon_history comment '優惠券領取歷史記錄';

/*==============================================================*/
/* Table: sms_coupon_spu_category_relation                      */
/*==============================================================*/
create table sms_coupon_spu_category_relation
(
   id                   bigint not null auto_increment comment 'id',
   coupon_id            bigint comment '優惠券id',
   category_id          bigint comment '產品分類id',
   category_name        varchar(64) comment '產品分類名稱',
   primary key (id)
);

alter table sms_coupon_spu_category_relation comment '優惠券分類關聯';

/*==============================================================*/
/* Table: sms_coupon_spu_relation                               */
/*==============================================================*/
create table sms_coupon_spu_relation
(
   id                   bigint not null auto_increment comment 'id',
   coupon_id            bigint comment '優惠券id',
   spu_id               bigint comment 'spu_id',
   spu_name             varchar(255) comment 'spu_name',
   primary key (id)
);

alter table sms_coupon_spu_relation comment '優惠券與產品關聯';

/*==============================================================*/
/* Table: sms_home_adv                                          */
/*==============================================================*/
create table sms_home_adv
(
   id                   bigint not null auto_increment comment 'id',
   name                 varchar(100) comment '名字',
   pic                  varchar(500) comment '圖片地址',
   start_time           datetime comment '開始時間',
   end_time             datetime comment '結束時間',
   status               tinyint(1) comment '狀態',
   click_count          int comment '點選數',
   url                  varchar(500) comment '廣告詳情連線地址',
   note                 varchar(500) comment '備註',
   sort                 int comment '排序',
   publisher_id         bigint comment '釋出者',
   auth_id              bigint comment '稽核者',
   primary key (id)
);

alter table sms_home_adv comment '首頁輪播廣告';

/*==============================================================*/
/* Table: sms_home_subject                                      */
/*==============================================================*/
create table sms_home_subject
(
   id                   bigint not null auto_increment comment 'id',
   name                 varchar(200) comment '專題名字',
   title                varchar(255) comment '專題標題',
   sub_title            varchar(255) comment '專題副標題',
   status               tinyint(1) comment '顯示狀態',
   url                  varchar(500) comment '詳情連線',
   sort                 int comment '排序',
   img                  varchar(500) comment '專題圖片地址',
   primary key (id)
);

alter table sms_home_subject comment '首頁專題表【jd首頁下面很多專題,每個專題連結新的頁面,展示專題商品資訊】';

/*==============================================================*/
/* Table: sms_home_subject_spu                                  */
/*==============================================================*/
create table sms_home_subject_spu
(
   id                   bigint not null auto_increment comment 'id',
   name                 varchar(200) comment '專題名字',
   subject_id           bigint comment '專題id',
   spu_id               bigint comment 'spu_id',
   sort                 int comment '排序',
   primary key (id)
);

alter table sms_home_subject_spu comment '專題商品';

/*==============================================================*/
/* Table: sms_member_price                                      */
/*==============================================================*/
create table sms_member_price
(
   id                   bigint not null auto_increment comment 'id',
   sku_id               bigint comment 'sku_id',
   member_level_id      bigint comment '會員等級id',
   member_level_name    varchar(100) comment '會員等級名',
   member_price         decimal(18,4) comment '會員對應價格',
   add_other            tinyint(1) comment '可否疊加其他優惠[0-不可疊加優惠,1-可疊加]',
   primary key (id)
);

alter table sms_member_price comment '商品會員價格';

/*==============================================================*/
/* Table: sms_seckill_promotion                                 */
/*==============================================================*/
create table sms_seckill_promotion
(
   id                   bigint not null auto_increment comment 'id',
   title                varchar(255) comment '活動標題',
   start_time           datetime comment '開始日期',
   end_time             datetime comment '結束日期',
   status               tinyint comment '上下線狀態',
   create_time          datetime comment '建立時間',
   user_id              bigint comment '建立人',
   primary key (id)
);

alter table sms_seckill_promotion comment '秒殺活動';

/*==============================================================*/
/* Table: sms_seckill_session                                   */
/*==============================================================*/
create table sms_seckill_session
(
   id                   bigint not null auto_increment comment 'id',
   name                 varchar(200) comment '場次名稱',
   start_time           datetime comment '每日開始時間',
   end_time             datetime comment '每日結束時間',
   status               tinyint(1) comment '啟用狀態',
   create_time          datetime comment '建立時間',
   primary key (id)
);

alter table sms_seckill_session comment '秒殺活動場次';

/*==============================================================*/
/* Table: sms_seckill_sku_notice                                */
/*==============================================================*/
create table sms_seckill_sku_notice
(
   id                   bigint not null auto_increment comment 'id',
   member_id            bigint comment 'member_id',
   sku_id               bigint comment 'sku_id',
   session_id           bigint comment '活動場次id',
   subcribe_time        datetime comment '訂閱時間',
   send_time            datetime comment '傳送時間',
   notice_type          tinyint(1) comment '通知方式[0-簡訊,1-郵件]',
   primary key (id)
);

alter table sms_seckill_sku_notice comment '秒殺商品通知訂閱';

/*==============================================================*/
/* Table: sms_seckill_sku_relation                              */
/*==============================================================*/
create table sms_seckill_sku_relation
(
   id                   bigint not null auto_increment comment 'id',
   promotion_id         bigint comment '活動id',
   promotion_session_id bigint comment '活動場次id',
   sku_id               bigint comment '商品id',
   seckill_price        decimal comment '秒殺價格',
   seckill_count        decimal comment '秒殺總量',
   seckill_limit        decimal comment '每人限購數量',
   seckill_sort         int comment '排序',
   primary key (id)
);

alter table sms_seckill_sku_relation comment '秒殺活動商品關聯';

/*==============================================================*/
/* Table: sms_sku_full_reduction                                */
/*==============================================================*/
create table sms_sku_full_reduction
(
   id                   bigint not null auto_increment comment 'id',
   sku_id               bigint comment 'spu_id',
   full_price           decimal(18,4) comment '滿多少',
   reduce_price         decimal(18,4) comment '減多少',
   add_other            tinyint(1) comment '是否參與其他優惠',
   primary key (id)
);

alter table sms_sku_full_reduction comment '商品滿減資訊';

/*==============================================================*/
/* Table: sms_sku_ladder                                        */
/*==============================================================*/
create table sms_sku_ladder
(
   id                   bigint not null auto_increment comment 'id',
   sku_id               bigint comment 'spu_id',
   full_count           int comment '滿幾件',
   discount             decimal(4,2) comment '打幾折',
   price                decimal(18,4) comment '折後價',
   add_other            tinyint(1) comment '是否疊加其他優惠[0-不可疊加,1-可疊加]',
   primary key (id)
);

alter table sms_sku_ladder comment '商品階梯價格';

/*==============================================================*/
/* Table: sms_spu_bounds                                        */
/*==============================================================*/
create table sms_spu_bounds
(
   id                   bigint not null auto_increment comment 'id',
   spu_id               bigint,
   grow_bounds          decimal(18,4) comment '成長積分',
   buy_bounds           decimal(18,4) comment '購物積分',
   work                 tinyint(1) comment '優惠生效情況[1111(四個狀態位,從右到左);0 - 無優惠,成長積分是否贈送;1 - 無優惠,購物積分是否贈送;2 - 有優惠,成長積分是否贈送;3 - 有優惠,購物積分是否贈送【狀態位0:不贈送,1:贈送】]',
   primary key (id)
);

alter table sms_spu_bounds comment '商品spu積分設定';

gulimall_usm

drop table if exists ums_growth_change_history;

drop table if exists ums_integration_change_history;

drop table if exists ums_member;

drop table if exists ums_member_collect_spu;

drop table if exists ums_member_collect_subject;

drop table if exists ums_member_level;

drop table if exists ums_member_login_log;

drop table if exists ums_member_receive_address;

drop table if exists ums_member_statistics_info;

/*==============================================================*/
/* Table: ums_growth_change_history                             */
/*==============================================================*/
create table ums_growth_change_history
(
   id                   bigint not null auto_increment comment 'id',
   member_id            bigint comment 'member_id',
   create_time          datetime comment 'create_time',
   change_count         int comment '改變的值(正負計數)',
   note                 varchar(0) comment '備註',
   source_type          tinyint comment '積分來源[0-購物,1-管理員修改]',
   primary key (id)
);

alter table ums_growth_change_history comment '成長值變化歷史記錄';

/*==============================================================*/
/* Table: ums_integration_change_history                        */
/*==============================================================*/
create table ums_integration_change_history
(
   id                   bigint not null auto_increment comment 'id',
   member_id            bigint comment 'member_id',
   create_time          datetime comment 'create_time',
   change_count         int comment '變化的值',
   note                 varchar(255) comment '備註',
   source_tyoe          tinyint comment '來源[0->購物;1->管理員修改;2->活動]',
   primary key (id)
);

alter table ums_integration_change_history comment '積分變化歷史記錄';

/*==============================================================*/
/* Table: ums_member                                            */
/*==============================================================*/
create table ums_member
(
   id                   bigint not null auto_increment comment 'id',
   level_id             bigint comment '會員等級id',
   username             char(64) comment '使用者名稱',
   password             varchar(64) comment '密碼',
   nickname             varchar(64) comment '暱稱',
   mobile               varchar(20) comment '手機號碼',
   email                varchar(64) comment '郵箱',
   header               varchar(500) comment '頭像',
   gender               tinyint comment '性別',
   birth                date comment '生日',
   city                 varchar(500) comment '所在城市',
   job                  varchar(255) comment '職業',
   sign                 varchar(255) comment '個性簽名',
   source_type          tinyint comment '使用者來源',
   integration          int comment '積分',
   growth               int comment '成長值',
   status               tinyint comment '啟用狀態',
   create_time          datetime comment '註冊時間',
   primary key (id)
);

alter table ums_member comment '會員';

/*==============================================================*/
/* Table: ums_member_collect_spu                                */
/*==============================================================*/
create table ums_member_collect_spu
(
   id                   bigint not null comment 'id',
   member_id            bigint comment '會員id',
   spu_id               bigint comment 'spu_id',
   spu_name             varchar(500) comment 'spu_name',
   spu_img              varchar(500) comment 'spu_img',
   create_time          datetime comment 'create_time',
   primary key (id)
);

alter table ums_member_collect_spu comment '會員收藏的商品';

/*==============================================================*/
/* Table: ums_member_collect_subject                            */
/*==============================================================*/
create table ums_member_collect_subject
(
   id                   bigint not null auto_increment comment 'id',
   subject_id           bigint comment 'subject_id',
   subject_name         varchar(255) comment 'subject_name',
   subject_img          varchar(500) comment 'subject_img',
   subject_urll         varchar(500) comment '活動url',
   primary key (id)
);

alter table ums_member_collect_subject comment '會員收藏的專題活動';

/*==============================================================*/
/* Table: ums_member_level                                      */
/*==============================================================*/
create table ums_member_level
(
   id                   bigint not null auto_increment comment 'id',
   name                 varchar(100) comment '等級名稱',
   growth_point         int comment '等級需要的成長值',
   default_status       tinyint comment '是否為預設等級[0->不是;1->是]',
   free_freight_point   decimal(18,4) comment '免運費標準',
   comment_growth_point int comment '每次評價獲取的成長值',
   priviledge_free_freight tinyint comment '是否有免郵特權',
   priviledge_member_price tinyint comment '是否有會員價格特權',
   priviledge_birthday  tinyint comment '是否有生日特權',
   note                 varchar(255) comment '備註',
   primary key (id)
);

alter table ums_member_level comment '會員等級';

/*==============================================================*/
/* Table: ums_member_login_log                                  */
/*==============================================================*/
create table ums_member_login_log
(
   id                   bigint not null auto_increment comment 'id',
   member_id            bigint comment 'member_id',
   create_time          datetime comment '建立時間',
   ip                   varchar(64) comment 'ip',
   city                 varchar(64) comment 'city',
   login_type           tinyint(1) comment '登入型別[1-web,2-app]',
   primary key (id)
);

alter table ums_member_login_log comment '會員登入記錄';

/*==============================================================*/
/* Table: ums_member_receive_address                            */
/*==============================================================*/
create table ums_member_receive_address
(
   id                   bigint not null auto_increment comment 'id',
   member_id            bigint comment 'member_id',
   name                 varchar(255) comment '收貨人姓名',
   phone                varchar(64) comment '電話',
   post_code            varchar(64) comment '郵政編碼',
   province             varchar(100) comment '省份/直轄市',
   city                 varchar(100) comment '城市',
   region               varchar(100) comment '區',
   detail_address       varchar(255) comment '詳細地址(街道)',
   areacode             varchar(15) comment '省市區程式碼',
   default_status       tinyint(1) comment '是否預設',
   primary key (id)
);

alter table ums_member_receive_address comment '會員收貨地址';

/*==============================================================*/
/* Table: ums_member_statistics_info                            */
/*==============================================================*/
create table ums_member_statistics_info
(
   id                   bigint not null auto_increment comment 'id',
   member_id            bigint comment '會員id',
   consume_amount       decimal(18,4) comment '累計消費金額',
   coupon_amount        decimal(18,4) comment '累計優惠金額',
   order_count          int comment '訂單數量',
   coupon_count         int comment '優惠券數量',
   comment_count        int comment '評價數',
   return_order_count   int comment '退貨數量',
   login_count          int comment '登入次數',
   attend_count         int comment '關注數量',
   fans_count           int comment '粉絲數量',
   collect_product_count int comment '收藏的商品數量',
   collect_subject_count int comment '收藏的專題活動數量',
   collect_comment_count int comment '收藏的評論數量',
   invite_friend_count  int comment '邀請的朋友數量',
   primary key (id)
);

alter table ums_member_statistics_info comment '會員統計資訊';

gulimall_wms

/*
SQLyog Ultimate v11.25 (64 bit)
MySQL - 5.7.27 : Database - gulimall_wms
*********************************************************************
*/


/*!40101 SET NAMES utf8 */;

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

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_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*/`gulimall_wms` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;

USE `gulimall_wms`;

/*Table structure for table `undo_log` */

DROP TABLE IF EXISTS `undo_log`;

CREATE TABLE `undo_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `branch_id` bigint(20) NOT NULL,
  `xid` varchar(100) NOT NULL,
  `context` varchar(128) NOT NULL,
  `rollback_info` longblob NOT NULL,
  `log_status` int(11) NOT NULL,
  `log_created` datetime NOT NULL,
  `log_modified` datetime NOT NULL,
  `ext` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

/*Data for the table `undo_log` */

/*Table structure for table `wms_purchase` */

DROP TABLE IF EXISTS `wms_purchase`;

CREATE TABLE `wms_purchase` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `assignee_id` bigint(20) DEFAULT NULL,
  `assignee_name` varchar(255) DEFAULT NULL,
  `phone` char(13) DEFAULT NULL,
  `priority` int(4) DEFAULT NULL,
  `status` int(4) DEFAULT NULL,
  `ware_id` bigint(20) DEFAULT NULL,
  `amount` decimal(18,4) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  `update_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='採購資訊';

/*Data for the table `wms_purchase` */

/*Table structure for table `wms_purchase_detail` */

DROP TABLE IF EXISTS `wms_purchase_detail`;

CREATE TABLE `wms_purchase_detail` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `purchase_id` bigint(20) DEFAULT NULL COMMENT '採購單id',
  `sku_id` bigint(20) DEFAULT NULL COMMENT '採購商品id',
  `sku_num` int(11) DEFAULT NULL COMMENT '採購數量',
  `sku_price` decimal(18,4) DEFAULT NULL COMMENT '採購金額',
  `ware_id` bigint(20) DEFAULT NULL COMMENT '倉庫id',
  `status` int(11) DEFAULT NULL COMMENT '狀態[0新建,1已分配,2正在採購,3已完成,4採購失敗]',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

/*Data for the table `wms_purchase_detail` */

/*Table structure for table `wms_ware_info` */

DROP TABLE IF EXISTS `wms_ware_info`;

CREATE TABLE `wms_ware_info` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `name` varchar(255) DEFAULT NULL COMMENT '倉庫名',
  `address` varchar(255) DEFAULT NULL COMMENT '倉庫地址',
  `areacode` varchar(20) DEFAULT NULL COMMENT '區域編碼',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='倉庫資訊';

/*Data for the table `wms_ware_info` */

/*Table structure for table `wms_ware_order_task` */

DROP TABLE IF EXISTS `wms_ware_order_task`;

CREATE TABLE `wms_ware_order_task` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `order_id` bigint(20) DEFAULT NULL COMMENT 'order_id',
  `order_sn` varchar(255) DEFAULT NULL COMMENT 'order_sn',
  `consignee` varchar(100) DEFAULT NULL COMMENT '收貨人',
  `consignee_tel` char(15) DEFAULT NULL COMMENT '收貨人電話',
  `delivery_address` varchar(500) DEFAULT NULL COMMENT '配送地址',
  `order_comment` varchar(200) DEFAULT NULL COMMENT '訂單備註',
  `payment_way` tinyint(1) DEFAULT NULL COMMENT '付款方式【 1:線上付款 2:貨到付款】',
  `task_status` tinyint(2) DEFAULT NULL COMMENT '任務狀態',
  `order_body` varchar(255) DEFAULT NULL COMMENT '訂單描述',
  `tracking_no` char(30) DEFAULT NULL COMMENT '物流單號',
  `create_time` datetime DEFAULT NULL COMMENT 'create_time',
  `ware_id` bigint(20) DEFAULT NULL COMMENT '倉庫id',
  `task_comment` varchar(500) DEFAULT NULL COMMENT '工作單備註',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='庫存工作單';

/*Data for the table `wms_ware_order_task` */

/*Table structure for table `wms_ware_order_task_detail` */

DROP TABLE IF EXISTS `wms_ware_order_task_detail`;

CREATE TABLE `wms_ware_order_task_detail` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sku_id` bigint(20) DEFAULT NULL COMMENT 'sku_id',
  `sku_name` varchar(255) DEFAULT NULL COMMENT 'sku_name',
  `sku_num` int(11) DEFAULT NULL COMMENT '購買個數',
  `task_id` bigint(20) DEFAULT NULL COMMENT '工作單id',
  `ware_id` bigint(20) DEFAULT NULL COMMENT '倉庫id',
  `lock_status` int(1) DEFAULT NULL COMMENT '1-已鎖定  2-已解鎖  3-扣減',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='庫存工作單';

/*Data for the table `wms_ware_order_task_detail` */

/*Table structure for table `wms_ware_sku` */

DROP TABLE IF EXISTS `wms_ware_sku`;

CREATE TABLE `wms_ware_sku` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
  `sku_id` bigint(20) DEFAULT NULL COMMENT 'sku_id',
  `ware_id` bigint(20) DEFAULT NULL COMMENT '倉庫id',
  `stock` int(11) DEFAULT NULL COMMENT '庫存數',
  `sku_name` varchar(200) DEFAULT NULL COMMENT 'sku_name',
  `stock_locked` int(11) DEFAULT '0' COMMENT '鎖定庫存',
  PRIMARY KEY (`id`),
  KEY `sku_id` (`sku_id`) USING BTREE,
  KEY `ware_id` (`ware_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品庫存';

/*Data for the table `wms_ware_sku` */

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