java-mall/sql/shop/dev/20251209_01ddl.sql
2025-12-12 11:10:56 +08:00

95 lines
10 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- shop_store_activity_base
CREATE TABLE `shop_store_activity_base_1` (
`activity_id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '活动编号',
`store_id` int unsigned NOT NULL DEFAULT '0' COMMENT '店铺编号',
`user_id` int unsigned NOT NULL DEFAULT '0' COMMENT '用户编号',
`activity_name` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '活动名称',
`activity_title` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '活动标题',
`activity_remark` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '活动说明',
`activity_combo_id` int unsigned NOT NULL DEFAULT '0' COMMENT '套餐编号',
`activity_type_id` int unsigned NOT NULL DEFAULT '0' COMMENT '活动类型',
`activity_starttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '活动开始时间',
`activity_endtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '活动结束时间',
`activity_state` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '活动状态(ENUM):0-未开启;1-正常;2-已结束;3-管理员关闭;4-商家关闭',
`activity_rule` varchar(10240) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '活动规则(json):不检索{rule_id:{}, rule_id:{}},统一解析规则{"requirement":{"buy":{"item":[1,2,3],"subtotal":"通过计算修正满足的条件"}},"rule":[{"total":100,"max_num":1,"item":{"1":1,"1200":3}},{"total":200,"max_num":1,"item":{"1":1,"1200":3}}]}',
`activity_type` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '参与类型(ENUM):1-免费参与;2-积分参与;3-购买参与;4-分享参与',
`activity_order` tinyint unsigned NOT NULL DEFAULT '50' COMMENT '排序',
`activity_is_finish` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '活动是否完成(ENUM):0-未完成;1-已完成;2-已解散(目前用于团购)',
`item_id` varchar(1024) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '单品优惠商品编号DOT',
`subsite_id` varchar(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '0' COMMENT '分站ID',
`version` int unsigned NOT NULL DEFAULT '0' COMMENT '版本',
`activity_on_is_off` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '活动是否线上或线下:0:线上,1:线下',
`activity_share_num` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '活动分享次数',
`activity_use_level` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '' COMMENT '活动使用等级(DOT)',
`activity_releasetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '发布时间',
`flow_no` varchar(255) DEFAULT NULL COMMENT '思迅活动id',
`cut_hour` int DEFAULT '72' COMMENT '在活动时间范围内,用户砍价允许的天数',
`product_count` int DEFAULT '5' COMMENT '参加活动商品的总数量',
PRIMARY KEY (`activity_id`) USING BTREE,
KEY `store_id` (`store_id`,`activity_state`) USING BTREE,
KEY `activity_type_id` (`activity_type_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='活动表-通过插件实现\r\n当为拼团是activity_rule中的group_remain_quantity用于标识拼团剩余需要人数如果用户登录了需要查询出activity_groupbooking中参与该团的剩余情况';
insert into shop_store_activity_base_1 select * from shop_store_activity_base ;
drop table shop_store_activity_base;
create table shop_store_activity_base select * from shop_store_activity_base_1;
--shop_activity_cutprice_history
CREATE TABLE `shop_activity_cutprice_history_1` (
`ach_id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '砍价历史编号',
`activity_id` int unsigned NOT NULL DEFAULT '0' COMMENT '活动编号',
`user_id` int unsigned NOT NULL DEFAULT '0' COMMENT '砍价用户',
`ach_price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '砍掉价格',
`item_id` int unsigned NOT NULL DEFAULT '0' COMMENT '商品编号',
`ach_datetime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '砍价时间',
`ac_id` int unsigned NOT NULL DEFAULT '0' COMMENT '砍价编号',
PRIMARY KEY (`ach_id`) USING BTREE,
KEY `activity_id` (`activity_id`) USING BTREE,
KEY `idx_shop_activity_cutprice_history_ac_id` (`ac_id`),
KEY `idx_shop_activity_cutprice_history_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='砍价记录历史';
insert into shop_activity_cutprice_history_1 select * from shop_activity_cutprice_history;
drop table shop_activity_cutprice_history;
create table shop_activity_cutprice_history as select * FROM shop_activity_cutprice_history_1;
--shop_store_activity_item
CREATE TABLE `shop_store_activity_item_1` (
`activity_item_id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '商品表编号',
`store_id` int unsigned NOT NULL DEFAULT '0' COMMENT '店铺编号',
`activity_type_id` int unsigned NOT NULL DEFAULT '0' COMMENT '活动类型编号',
`activity_id` int unsigned NOT NULL DEFAULT '0' COMMENT '活动编号',
`product_id` int unsigned NOT NULL DEFAULT '0',
`item_id` int unsigned NOT NULL DEFAULT '0' COMMENT '商品编号',
`category_id` mediumint unsigned NOT NULL DEFAULT '0' COMMENT '商品分类',
`activity_item_starttime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '开始时间',
`activity_item_endtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '结束时间',
`activity_item_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '限时折扣价格',
`activity_item_min_quantity` int unsigned NOT NULL DEFAULT '0' COMMENT '购买下限',
`activity_item_state` tinyint unsigned NOT NULL DEFAULT '1' COMMENT '活动状态(ENUM):0-未开启;1-正常;2-已结束;3-管理员关闭',
`activity_item_recommend` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '推荐标志:0-未推荐;1-已推荐',
`activity_level_limits` tinyint NOT NULL DEFAULT '0' COMMENT '等级限制',
`activity_points_num` int NOT NULL DEFAULT '0' COMMENT '需要积分数',
`activity_points_product_num` int unsigned NOT NULL DEFAULT '0' COMMENT '积分商品剩余数量',
`activity_points_product_sale_num` int NOT NULL DEFAULT '0' COMMENT '积分商品已售数量',
PRIMARY KEY (`activity_item_id`) USING BTREE,
KEY `store_id` (`activity_id`) USING BTREE,
KEY `item_id` (`product_id`,`item_id`) USING BTREE,
KEY `item_id_2` (`item_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='参与活动商品表-用户筛选计算';
insert into shop_store_activity_item_1 select * from shop_store_activity_item;
drop table shop_store_activity_item;
create table shop_store_activity_item select * from shop_store_activity_item_1;
ALTER TABLE shop_store_activity_base MODIFY activity_id int unsigned NOT NULL AUTO_INCREMENT COMMENT '活动编号' PRIMARY KEY;
alter table shop_store_activity_base add key `store_id` (`store_id`,`activity_state`) USING BTREE;
alter table shop_store_activity_base add key `activity_type_id` (`activity_type_id`) USING BTREE;
ALTER TABLE shop_activity_cutprice_history MODIFY ach_id int unsigned NOT NULL AUTO_INCREMENT COMMENT '砍价历史编号' PRIMARY KEY;
alter table shop_activity_cutprice_history add KEY `activity_id` (`activity_id`) USING BTREE;
alter table shop_activity_cutprice_history add KEY `idx_shop_activity_cutprice_history_ac_id` (`ac_id`);
alter table shop_activity_cutprice_history add KEY `idx_shop_activity_cutprice_history_user_id` (`user_id`);
ALTER TABLE shop_store_activity_item MODIFY activity_item_id int unsigned NOT NULL AUTO_INCREMENT COMMENT '商品表编号' PRIMARY KEY;
alter table shop_store_activity_item add KEY `store_id` (`activity_id`) USING BTREE;
alter table shop_store_activity_item add KEY `item_id` (`product_id`,`item_id`) USING BTREE;
alter table shop_store_activity_item add KEY `item_id_2` (`item_id`) USING BTREE;