| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- -- 拼团(团购)核心表:活动批次 / 活动商品版本 / 拼团单 / 拼团成员
- -- 执行前请确认线上库无同名表;xhOrder.groupBuyId 若已存在请跳过对应 ALTER
- CREATE TABLE IF NOT EXISTS `xhGroupBuyActivity` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `mainId` int(11) NOT NULL DEFAULT 0 COMMENT '中央id',
- `title` varchar(32) NOT NULL DEFAULT '' COMMENT '活动标题',
- `subtitle` varchar(64) NOT NULL DEFAULT '' COMMENT '活动副标题',
- `showCountdown` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否显示倒计时',
- `expand` tinyint(4) NOT NULL DEFAULT 0 COMMENT '商品展开',
- `startTime` int(11) NOT NULL DEFAULT 0 COMMENT '开始时间unix',
- `endTime` int(11) NOT NULL DEFAULT 0 COMMENT '结束时间unix',
- `desc` varchar(500) NOT NULL DEFAULT '' COMMENT '活动说明',
- `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1有效 0无效',
- `delStatus` tinyint(4) NOT NULL DEFAULT 0 COMMENT '删除状态',
- `addTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (`id`),
- KEY `mainId` (`mainId`),
- KEY `main_time` (`mainId`,`startTime`,`endTime`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团购活动批次';
- CREATE TABLE IF NOT EXISTS `xhGroupBuyGoods` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `activityId` int(11) NOT NULL DEFAULT 0 COMMENT '活动批次id',
- `mainId` int(11) NOT NULL DEFAULT 0 COMMENT '中央id',
- `goodsId` int(11) NOT NULL DEFAULT 0 COMMENT '商品id(可含规格子商品)',
- `specName` varchar(64) NOT NULL DEFAULT '' COMMENT '规格名',
- `price` decimal(15,2) NOT NULL DEFAULT 0.00 COMMENT '团购价',
- `originPrice` decimal(15,2) NOT NULL DEFAULT 0.00 COMMENT '原价快照',
- `stock` int(11) NOT NULL DEFAULT 0 COMMENT '团购库存',
- `limit` int(11) NOT NULL DEFAULT 0 COMMENT '单人限购',
- `groupSize` tinyint(4) NOT NULL DEFAULT 3 COMMENT '成团人数2/3/5',
- `virtualGroup` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否虚拟成团',
- `virtualMinutes` int(11) NOT NULL DEFAULT 0 COMMENT '虚拟成团分钟数',
- `autoRefund` tinyint(4) NOT NULL DEFAULT 1 COMMENT '失败自动退款',
- `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1展示 0隐藏(历史版本)',
- `name` varchar(128) NOT NULL DEFAULT '' COMMENT '商品名快照',
- `cover` varchar(255) NOT NULL DEFAULT '' COMMENT '封面快照',
- `realStock` int(11) NOT NULL DEFAULT 0 COMMENT '保存时真实库存快照',
- `delStatus` tinyint(4) NOT NULL DEFAULT 0 COMMENT '删除状态',
- `addTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (`id`),
- KEY `activityId` (`activityId`),
- KEY `main_goods` (`mainId`,`goodsId`),
- KEY `activity_goods_status` (`activityId`,`goodsId`,`status`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团购活动商品版本';
- CREATE TABLE IF NOT EXISTS `xhGroupBuy` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `mainId` int(11) NOT NULL DEFAULT 0 COMMENT '中央id',
- `shopId` int(11) NOT NULL DEFAULT 0 COMMENT '门店id',
- `activityId` int(11) NOT NULL DEFAULT 0 COMMENT '活动批次id',
- `activityGoodsId` int(11) NOT NULL DEFAULT 0 COMMENT '活动商品版本id',
- `goodsId` int(11) NOT NULL DEFAULT 0 COMMENT '商品id',
- `leaderCustomId` int(11) NOT NULL DEFAULT 0 COMMENT '团长客户id',
- `needNum` int(11) NOT NULL DEFAULT 0 COMMENT '成团所需人数',
- `currentNum` int(11) NOT NULL DEFAULT 0 COMMENT '已支付人数',
- `price` decimal(15,2) NOT NULL DEFAULT 0.00 COMMENT '团购价快照',
- `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1拼团中 2成功 3失败 4已取消',
- `virtualGroup` tinyint(4) NOT NULL DEFAULT 0 COMMENT '是否虚拟成团',
- `deadline` int(11) NOT NULL DEFAULT 0 COMMENT '团截止unix',
- `successTime` datetime DEFAULT NULL COMMENT '成团时间',
- `failTime` datetime DEFAULT NULL COMMENT '失败时间',
- `addTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (`id`),
- KEY `mainId` (`mainId`),
- KEY `activityGoodsId` (`activityGoodsId`),
- KEY `status_deadline` (`status`,`deadline`),
- KEY `goods_status` (`goodsId`,`status`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='拼团单';
- CREATE TABLE IF NOT EXISTS `xhGroupBuyMember` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `groupBuyId` int(11) NOT NULL DEFAULT 0 COMMENT '拼团单id',
- `mainId` int(11) NOT NULL DEFAULT 0 COMMENT '中央id',
- `orderId` int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
- `orderSn` varchar(64) NOT NULL DEFAULT '' COMMENT '订单号',
- `customId` int(11) NOT NULL DEFAULT 0 COMMENT '客户id',
- `role` tinyint(4) NOT NULL DEFAULT 2 COMMENT '1团长 2成员',
- `status` tinyint(4) NOT NULL DEFAULT 1 COMMENT '1待支付 2已支付 3已失效',
- `joinTime` datetime DEFAULT NULL COMMENT '加入时间',
- `addTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
- `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
- PRIMARY KEY (`id`),
- KEY `group_custom` (`groupBuyId`,`customId`),
- KEY `orderId` (`orderId`),
- KEY `orderSn` (`orderSn`),
- KEY `customId` (`customId`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='拼团成员';
- -- 订单关联拼团单(避开已占用的 groupId 组合字段)
- ALTER TABLE `xhOrder`
- ADD COLUMN `groupBuyId` int(11) NOT NULL DEFAULT 0 COMMENT '拼团单id' AFTER `id`,
- ADD KEY `groupBuyId` (`groupBuyId`);
|