秒殺設計 mysql 秒殺專案 資料庫表設計

2021-10-18 16:04:13 字數 1646 閱讀 8794

-- 資料庫初始化指令碼

-- 建立資料庫

create database seckill;

-- 使用資料庫

use seckill;

-- 建立秒殺庫存表

create table seckill(

seckill_id bigint not null auto_increment comment '商品庫存id',

nam varchar(120) not null comment '商品名稱',

number int not null comment '庫存數量',

start_time timestamp not null comment '秒殺開啟時間',

end_time timestamp not null comment '秒殺結束時間',

create_time timestamp not null comment '建立時間',

primary key (seckill_id),

key idx_start_time(start_time),

key idx_end_time(end_time),

key idx_create_time(create_time)

)engine=innodb auto_increment=1000 default charset=utf8 comment='秒殺庫存表';

--初始化資料

insert into seckill(name,number,start_time,end_time,create_time)

values

('1000元秒殺iphone6',100,'2019-3-01 00:00:00','2019-3-02 00:00:00','2019-2-27 00:00:00'),

('1元秒殺小公尺4',200,'2019-3-01 00:00:00','2019-3-02 00:00:00','2019-2-27 00:00:00'),

('100元秒殺iphone8',300,'2019-3-01 00:00:00','2019-3-02 00:00:00','2019-2-27 00:00:00'),

('3000元秒殺華為p9',400,'2019-3-01 00:00:00','2019-3-02 00:00:00','2019-2-27 00:00:00');

-- 秒殺成功明細表

-- 使用者登入認證相關資訊

create table success_killed(

seckill_id bigint not null comment '秒殺商品id',

user_phone bigint not null comment '使用者手機號',

state tinyint not null default -1 comment '狀態標識 -1 無效 0成功 1 已付 2未付款',

create_time timestamp not null comment '建立時間',

primary key(seckill_id,user_phone),/* 聯合主鍵*/

key idx_create_time(create_time)

)engine=innodb default charset=utf8 comment='秒殺成功明細表';

-- 連線資料庫的控制台

秒殺專案API設計

1.1路徑 1.2請求內容 request response loginvo 1.3響應內容 response success login.html 0,success fail 500211,登入密碼不能為空 500212,手機號不能為空 500213,手機號格式錯誤 500214,手機號不存在 ...

電商秒殺專案 秒殺模組

itemmodel中新增乙個 private promomodel promomodel 並建立get set方法。修改getitembyid方法 override public itemmodel getitembyid integer id itemmodel itemmodel convert...

秒殺系統 mysql 秒殺系統之資料庫

秒殺系統的資料庫中的庫存加減操作是最為關鍵的點。12年天貓雙十一的超賣事件,對平台的負面影響是非常巨大的。資料庫裡做庫存扣減,簡單的可以用以下sql來說明 update stock table set inventory inventory 1 where item id xx and invent...