SpringBoot實戰電商專案mall(18k+star)地址:github.com/macrozheng/…
摘要
本文主要對優惠券功能相關表進行解析,採用資料庫表與功能對照的形式。
相關表結構
優惠券表
用於儲存優惠券資訊,需要注意的是優惠券的使用型別:0->全場通用;1->指定分類;2->指定商品,不同使用型別的優惠券使用範圍不一樣。
create table sms_coupon
(
id bigint not null auto_increment,
type int(1) comment '優惠卷型別;0->全場贈券;1->會員贈券;2->購物贈券;3->註冊贈券',
name varchar(100) comment '名稱',
platform int(1) comment '使用平臺:0->全部;1->移動;2->PC',
count int comment '數量',
amount decimal(10,2) comment '金額',
per_limit int comment '每人限領張數',
min_point decimal(10,2) comment '使用門檻;0表示無門檻',
start_time datetime comment '開始使用時間',
end_time datetime comment '結束使用時間',
use_type int(1) comment '使用型別:0->全場通用;1->指定分類;2->指定商品',
note varchar(200) comment '備註',
publish_count int comment '發行數量',
use_count int comment '已使用數量',
receive_count int comment '領取數量',
enable_time datetime comment '可以領取的日期',
code varchar(64) comment '優惠碼',
member_level int(1) comment '可領取的會員型別:0->無限制',
primary key (id)
);
複製程式碼
優惠券歷史記錄表
用於儲存會員領取及使用優惠券的記錄,當會員領取到優惠券時,會產生一條優惠券的記錄,需要注意的是它的使用狀態:0->未使用;1->已使用;2->已過期。
create table sms_coupon_history
(
id bigint not null auto_increment,
coupon_id bigint comment '優惠券id',
member_id bigint comment '會員id',
order_id bigint comment '訂單id',
coupon_code varchar(64) comment '優惠券碼',
member_nickname varchar(64) comment '領取人暱稱',
get_type int(1) comment '獲取型別:0->後臺贈送;1->主動獲取',
create_time datetime comment '建立時間',
use_status int(1) comment '使用狀態:0->未使用;1->已使用;2->已過期',
use_time datetime comment '使用時間',
order_sn varchar(100) comment '訂單號碼',
primary key (id)
);
複製程式碼
優惠券和商品的關係表
用於儲存優惠券與商品的關係,當優惠券的使用型別為指定商品時,優惠券與商品需要建立關係。
create table sms_coupon_product_relation
(
id bigint not null auto_increment,
coupon_id bigint comment '優惠券id',
product_id bigint comment '商品id',
product_name varchar(500) comment '商品名稱',
product_sn varchar(200) comment '商品條碼',
primary key (id)
);
複製程式碼
優惠券和商品分類關係表
用於儲存優惠券與商品分類的關係,當優惠券的使用型別為指定分類時,優惠券與商品分類需要建立關係。
create table sms_coupon_product_category_relation
(
id bigint not null auto_increment,
coupon_id bigint comment '優惠券id',
product_category_id bigint comment '商品分類id',
product_category_name varchar(200) comment '商品分類名稱',
parent_category_name varchar(200) comment '父分類名稱',
primary key (id)
);
複製程式碼
管理端展現
優惠券列表

編輯優惠券
全場通用

指定商品

指定分類

檢視優惠券

移動端展現
我的優惠券
未使用

已使用

已過期

優惠券詳情

公眾號
mall專案全套學習教程連載中,關注公眾號第一時間獲取。
