6.27 拆分活动表,解耦逻辑
This commit is contained in:
parent
3fffdb4385
commit
b09e3bae76
@ -3,163 +3,169 @@ SET NAMES utf8mb4;
|
||||
CREATE database if NOT EXISTS `group_buying_sys` default character set utf8mb4 collate utf8mb4_0900_ai_ci;
|
||||
use `group_buying_sys`;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `group_buy_activity`;
|
||||
|
||||
--拼团活动表
|
||||
CREATE TABLE `group_buy_activity` (
|
||||
`id` bigint(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增',
|
||||
`activity_id` bigint(8) NOT NULL COMMENT '活动ID',
|
||||
`activity_name` varchar(128) NOT NULL COMMENT '活动名称',
|
||||
`source` varchar(8) NOT NULL COMMENT '来源',
|
||||
`channel` varchar(8) NOT NULL COMMENT '渠道',
|
||||
`goods_id` varchar(12) NOT NULL COMMENT '商品ID',
|
||||
`discount_id` varchar(8) NOT NULL COMMENT '折扣ID',
|
||||
`group_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '拼团方式(0自动成团、1达成目标拼团)',
|
||||
`take_limit_count` int(4) NOT NULL DEFAULT '1' COMMENT '拼团次数限制',
|
||||
`target` int(5) NOT NULL DEFAULT '1' COMMENT '拼团目标',
|
||||
`valid_time` int(4) NOT NULL DEFAULT '15' COMMENT '拼团时长(分钟)',
|
||||
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '活动状态(0创建、1生效、2过期、3废弃)',
|
||||
`start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '活动开始时间',
|
||||
`end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '活动结束时间',
|
||||
`tag_id` varchar(32) DEFAULT NULL COMMENT '人群标签规则标识',
|
||||
`tag_scope` varchar(4) DEFAULT NULL COMMENT '人群标签规则范围(多选;1可见限制、2参与限制)',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uq_activity_id` (`activity_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='拼团活动';
|
||||
|
||||
LOCK TABLES `group_buy_activity` WRITE;
|
||||
|
||||
INSERT INTO `group_buy_activity` (`id`, `activity_id`, `activity_name`, `source`, `channel`, `goods_id`, `discount_id`, `group_type`, `take_limit_count`, `target`, `valid_time`, `status`, `start_time`, `end_time`, `tag_id`, `tag_scope`, `create_time`, `update_time`)
|
||||
VALUES
|
||||
(1,100123,'测试活动','s01','c01','9890001','25120207',0,1,1,15,0,'2025-06-19 10:19:40','2025-06-19 10:19:40','1','1','2025-06-19 10:19:40','2025-06-19 11:47:27');
|
||||
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `group_buy_discount`;
|
||||
--折扣配置表
|
||||
CREATE TABLE `group_buy_discount` (
|
||||
`id` bigint(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`discount_id` int(8) NOT NULL COMMENT '折扣ID',
|
||||
`discount_name` varchar(64) NOT NULL COMMENT '折扣标题',
|
||||
`discount_desc` varchar(256) NOT NULL COMMENT '折扣描述',
|
||||
`discount_type` tinyint(1) NOT NULL DEFAULT '0' COMMENT '折扣类型(0:base、1:tag)',
|
||||
`market_plan` varchar(4) NOT NULL DEFAULT 'ZJ' COMMENT '营销优惠计划(ZJ:直减、MJ:满减、ZK:折扣、N元购)',
|
||||
`market_expr` varchar(32) NOT NULL COMMENT '营销优惠表达式',
|
||||
`tag_id` varchar(8) DEFAULT NULL COMMENT '人群标签,特定优惠限定',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uq_discount_id` (`discount_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
LOCK TABLES `group_buy_discount` WRITE;
|
||||
|
||||
INSERT INTO `group_buy_discount` (`id`, `discount_id`, `discount_name`, `discount_desc`, `discount_type`, `market_plan`, `market_expr`, `tag_id`, `create_time`, `update_time`)
|
||||
VALUES
|
||||
(1,'25120207','直减优惠20元','直减优惠20元',0,'ZJ','20',NULL,'2025-06-25 14:02:13','2025-06-25 14:02:13'),
|
||||
(2,'25120208','满减优惠100-10元','满减优惠100-10元',0,'MJ','100,10',NULL,'2025-06-25 14:02:13','2025-06-25 14:02:13'),
|
||||
(4,'25120209','折扣优惠8折','折扣优惠8折',0,'ZK','0.8',NULL,'2025-06-25 14:02:13','2025-06-25 14:02:13'),
|
||||
(5,'25120210','N元购买优惠','N元购买优惠',0,'N','1.99',NULL,'2025-06-25 14:02:13','2025-06-25 14:02:13');
|
||||
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `sku`;
|
||||
|
||||
CREATE TABLE `sku` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`source` varchar(8) NOT NULL COMMENT '渠道',
|
||||
`channel` varchar(8) NOT NULL COMMENT '来源',
|
||||
`goods_id` varchar(16) NOT NULL COMMENT '商品ID',
|
||||
`goods_name` varchar(128) NOT NULL COMMENT '商品名称',
|
||||
`original_price` decimal(10,2) NOT NULL COMMENT '商品价格',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uq_goods_id` (`goods_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品信息';
|
||||
|
||||
LOCK TABLES `sku` WRITE;
|
||||
|
||||
INSERT INTO `sku` (`id`, `source`, `channel`, `goods_id`, `goods_name`, `original_price`, `create_time`, `update_time`)
|
||||
VALUES
|
||||
(1,'s01','c01','9890001','《手写MyBatis:渐进式源码实践》',100.00,'2025-06-22 11:10:06','2025-06-22 11:10:06');
|
||||
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
-- 人群标签表
|
||||
-- ----------------------------
|
||||
-- Table structure for crowd_tags
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `crowd_tags`;
|
||||
CREATE TABLE `crowd_tags` (
|
||||
`id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`tag_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '人群ID',
|
||||
`tag_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '人群名称',
|
||||
`tag_desc` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '人群描述',
|
||||
`statistics` int NOT NULL COMMENT '人群标签统计量',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uq_tag_id`(`tag_id` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '人群标签' ROW_FORMAT = Dynamic;
|
||||
|
||||
CREATE TABLE `crowd_tags` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`tag_id` varchar(32) NOT NULL COMMENT '人群ID',
|
||||
`tag_name` varchar(64) NOT NULL COMMENT '人群名称',
|
||||
`tag_desc` varchar(256) NOT NULL COMMENT '人群描述',
|
||||
`statistics` int(8) NOT NULL COMMENT '人群标签统计量',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uq_tag_id` (`tag_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='人群标签';
|
||||
-- ----------------------------
|
||||
-- Records of crowd_tags
|
||||
-- ----------------------------
|
||||
INSERT INTO `crowd_tags` VALUES (1, 'RQ_KJHKL98UU78H66554GFDV', '潜在消费用户', '潜在消费用户', 8, '2025-06-26 09:12:22', '2025-06-26 11:47:01');
|
||||
|
||||
LOCK TABLES `crowd_tags` WRITE;
|
||||
|
||||
INSERT INTO `crowd_tags` (`id`, `tag_id`, `tag_name`, `tag_desc`, `statistics`, `create_time`, `update_time`)
|
||||
VALUES
|
||||
(1,'RQ_KJHKL98UU78H66554GFDV','潜在消费用户','潜在消费用户',6,'2025-06-26 09:12:22','2025-06-26 09:12:22');
|
||||
|
||||
UNLOCK TABLES;
|
||||
|
||||
|
||||
-- 人群标签明细表
|
||||
-- ----------------------------
|
||||
-- Table structure for crowd_tags_detail
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `crowd_tags_detail`;
|
||||
CREATE TABLE `crowd_tags_detail` (
|
||||
`id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`tag_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '人群ID',
|
||||
`user_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户ID',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uq_tag_user`(`tag_id` ASC, `user_id` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '人群标签明细' ROW_FORMAT = Dynamic;
|
||||
|
||||
CREATE TABLE `crowd_tags_detail` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`tag_id` varchar(32) NOT NULL COMMENT '人群ID',
|
||||
`user_id` varchar(16) NOT NULL COMMENT '用户ID',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uq_tag_user` (`tag_id`,`user_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='人群标签明细';
|
||||
|
||||
LOCK TABLES `crowd_tags_detail` WRITE;
|
||||
|
||||
INSERT INTO `crowd_tags_detail` (`id`, `tag_id`, `user_id`, `create_time`, `update_time`)
|
||||
VALUES
|
||||
(4,'RQ_KJHKL98UU78H66554GFDV','zy123','2025-06-26 09:08:31','2025-06-26 09:08:31'),
|
||||
(5,'RQ_KJHKL98UU78H66554GFDV','smile','2025-06-26 09:09:54','2025-06-26 09:09:54');
|
||||
|
||||
UNLOCK TABLES;
|
||||
-- ----------------------------
|
||||
-- Records of crowd_tags_detail
|
||||
-- ----------------------------
|
||||
INSERT INTO `crowd_tags_detail` VALUES (4, 'RQ_KJHKL98UU78H66554GFDV', 'zy123', '2025-06-26 09:08:31', '2025-06-26 09:08:31');
|
||||
INSERT INTO `crowd_tags_detail` VALUES (5, 'RQ_KJHKL98UU78H66554GFDV', 'smile', '2025-06-26 09:09:54', '2025-06-26 09:09:54');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for crowd_tags_job
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `crowd_tags_job`;
|
||||
CREATE TABLE `crowd_tags_job` (
|
||||
`id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`tag_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '标签ID',
|
||||
`batch_id` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '批次ID',
|
||||
`tag_type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '标签类型(参与量、消费金额)',
|
||||
`tag_rule` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '标签规则(限定类型 N次)',
|
||||
`stat_start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计数据,开始时间',
|
||||
`stat_end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计数据,结束时间',
|
||||
`status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '状态;0初始、1计划(进入执行阶段)、2重置、3完成',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uq_batch_id`(`batch_id` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '人群标签任务' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- 人群标签任务表
|
||||
CREATE TABLE `crowd_tags_job` (
|
||||
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`tag_id` varchar(32) NOT NULL COMMENT '标签ID',
|
||||
`batch_id` varchar(8) NOT NULL COMMENT '批次ID',
|
||||
`tag_type` tinyint(1) NOT NULL DEFAULT '1' COMMENT '标签类型(参与量、消费金额)',
|
||||
`tag_rule` varchar(8) NOT NULL COMMENT '标签规则(限定类型 N次)',
|
||||
`stat_start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计数据,开始时间',
|
||||
`stat_end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '统计数据,结束时间',
|
||||
`status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态;0初始、1计划(进入执行阶段)、2重置、3完成',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `uq_batch_id` (`batch_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='人群标签任务';
|
||||
-- ----------------------------
|
||||
-- Records of crowd_tags_job
|
||||
-- ----------------------------
|
||||
INSERT INTO `crowd_tags_job` VALUES (1, 'RQ_KJHKL98UU78H66554GFDV', '10001', 0, '100', '2025-06-26 09:13:31', '2025-06-26 09:13:31', 0, '2025-06-26 09:13:31', '2025-06-26 09:13:31');
|
||||
|
||||
LOCK TABLES `crowd_tags_job` WRITE;
|
||||
-- ----------------------------
|
||||
-- Table structure for group_buy_activity
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `group_buy_activity`;
|
||||
CREATE TABLE `group_buy_activity` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增',
|
||||
`activity_id` bigint NOT NULL COMMENT '活动ID',
|
||||
`activity_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '活动名称',
|
||||
`discount_id` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '折扣ID',
|
||||
`group_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '拼团方式(0自动成团、1达成目标拼团)',
|
||||
`take_limit_count` int NOT NULL DEFAULT 1 COMMENT '拼团次数限制',
|
||||
`target` int NOT NULL DEFAULT 1 COMMENT '拼团目标',
|
||||
`valid_time` int NOT NULL DEFAULT 15 COMMENT '拼团时长(分钟)',
|
||||
`status` tinyint(1) NOT NULL DEFAULT 0 COMMENT '活动状态(0创建、1生效、2过期、3废弃)',
|
||||
`start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '活动开始时间',
|
||||
`end_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '活动结束时间',
|
||||
`tag_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '人群标签规则标识',
|
||||
`tag_scope` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '人群标签规则范围(多选;1可见限制、2参与限制)',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uq_activity_id`(`activity_id` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '拼团活动' ROW_FORMAT = Dynamic;
|
||||
|
||||
INSERT INTO `crowd_tags_job` (`id`, `tag_id`, `batch_id`, `tag_type`, `tag_rule`, `stat_start_time`, `stat_end_time`, `status`, `create_time`, `update_time`)
|
||||
VALUES
|
||||
(1,'RQ_KJHKL98UU78H66554GFDV','10001',0,'100','2025-06-26 09:13:31','2025-06-26 09:13:31',0,'2025-06-26 09:13:31','2025-06-26 09:13:31');
|
||||
-- ----------------------------
|
||||
-- Records of group_buy_activity
|
||||
-- ----------------------------
|
||||
INSERT INTO `group_buy_activity` VALUES (1, 100123, '测试活动', '25120207', 0, 1, 1, 15, 1, '2025-06-19 10:19:40', '2025-06-19 10:19:40', '1', '1', '2025-06-19 10:19:40', '2025-06-26 15:27:48');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for group_buy_discount
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `group_buy_discount`;
|
||||
CREATE TABLE `group_buy_discount` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`discount_id` int NOT NULL COMMENT '折扣ID',
|
||||
`discount_name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '折扣标题',
|
||||
`discount_desc` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '折扣描述',
|
||||
`discount_type` tinyint(1) NOT NULL DEFAULT 0 COMMENT '折扣类型(0:base、1:tag)',
|
||||
`market_plan` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'ZJ' COMMENT '营销优惠计划(ZJ:直减、MJ:满减、ZK:折扣、N元购)',
|
||||
`market_expr` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '营销优惠表达式',
|
||||
`tag_id` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '人群标签,特定优惠限定',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uq_discount_id`(`discount_id` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '折扣配置' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of group_buy_discount
|
||||
-- ----------------------------
|
||||
INSERT INTO `group_buy_discount` VALUES (1, 25120207, '直减优惠20元', '直减优惠20元', 0, 'ZJ', '20', NULL, '2025-06-25 14:02:13', '2025-06-25 14:02:13');
|
||||
INSERT INTO `group_buy_discount` VALUES (2, 25120208, '满减优惠100-10元', '满减优惠100-10元', 0, 'MJ', '100,10', NULL, '2025-06-25 14:02:13', '2025-06-25 14:02:13');
|
||||
INSERT INTO `group_buy_discount` VALUES (4, 25120209, '折扣优惠8折', '折扣优惠8折', 0, 'ZK', '0.8', NULL, '2025-06-25 14:02:13', '2025-06-25 14:02:13');
|
||||
INSERT INTO `group_buy_discount` VALUES (5, 25120210, 'N元购买优惠', 'N元购买优惠', 0, 'N', '1.99', NULL, '2025-06-25 14:02:13', '2025-06-25 14:02:13');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sc_sku_activity
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sc_sku_activity`;
|
||||
CREATE TABLE `sc_sku_activity` (
|
||||
`id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`source` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '渠道',
|
||||
`channel` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '来源',
|
||||
`activity_id` bigint NOT NULL COMMENT '活动ID',
|
||||
`goods_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '商品ID',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uq_sc_goodsid`(`source` ASC, `channel` ASC, `goods_id` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '渠道商品活动配置关联表' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sc_sku_activity
|
||||
-- ----------------------------
|
||||
INSERT INTO `sc_sku_activity` VALUES (1, 's01', 'c01', 100123, '9890001', '2025-06-26 17:15:54', '2025-06-26 17:15:54');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for sku
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `sku`;
|
||||
CREATE TABLE `sku` (
|
||||
`id` int UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '自增ID',
|
||||
`source` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '渠道',
|
||||
`channel` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '来源',
|
||||
`goods_id` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '商品ID',
|
||||
`goods_name` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '商品名称',
|
||||
`original_price` decimal(10, 2) NOT NULL COMMENT '商品价格',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uq_goods_id`(`goods_id` ASC) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '商品信息' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of sku
|
||||
-- ----------------------------
|
||||
INSERT INTO `sku` VALUES (1, 's01', 'c01', '9890001', '《手写MyBatis:渐进式源码实践》', 100.00, '2025-06-22 11:10:06', '2025-06-22 11:10:06');
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
UNLOCK TABLES;
|
||||
|
@ -6,9 +6,6 @@
|
||||
<id column="id" property="id"/>
|
||||
<result column="activity_id" property="activityId"/>
|
||||
<result column="activity_name" property="activityName"/>
|
||||
<result column="source" property="source"/>
|
||||
<result column="channel" property="channel"/>
|
||||
<result column="goods_id" property="goodsId"/>
|
||||
<result column="discount_id" property="discountId"/>
|
||||
<result column="group_type" property="groupType"/>
|
||||
<result column="take_limit_count" property="takeLimitCount"/>
|
||||
@ -29,13 +26,20 @@
|
||||
|
||||
<select id="queryValidGroupBuyActivity" parameterType="edu.whut.infrastructure.dao.po.GroupBuyActivity" resultMap="dataMap">
|
||||
select
|
||||
activity_id, activity_name, source, channel, goods_id,
|
||||
discount_id, group_type, take_limit_count, target, valid_time,
|
||||
activity_id, activity_name,discount_id, group_type, take_limit_count, target, valid_time,
|
||||
status, start_time, end_time, tag_id, tag_scope
|
||||
from group_buy_activity
|
||||
where source = #{source} and channel = #{channel}
|
||||
order by id desc
|
||||
limit 1
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="queryValidGroupBuyActivityId" parameterType="java.lang.Long" resultMap="dataMap">
|
||||
select
|
||||
activity_id, activity_name, discount_id, group_type, take_limit_count,
|
||||
target, valid_time, status, start_time, end_time, tag_id, tag_scope
|
||||
from group_buy_activity
|
||||
where activity_id = #{activityId} and status = 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="edu.whut.infrastructure.dao.ISCSkuActivityDao">
|
||||
|
||||
<resultMap id="dataMap" type="edu.whut.infrastructure.dao.po.SCSkuActivity">
|
||||
<id column="id" property="id"/>
|
||||
<result column="source" property="source"/>
|
||||
<result column="channel" property="channel"/>
|
||||
<result column="activity_id" property="activityId"/>
|
||||
<result column="goods_id" property="goodsId"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="querySCSkuActivityBySCGoodsId" parameterType="edu.whut.infrastructure.dao.po.SCSkuActivity" resultMap="dataMap">
|
||||
select source, channel, activity_id, goods_id
|
||||
from sc_sku_activity
|
||||
where goods_id = #{goodsId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -36,4 +36,16 @@ public class IIndexGroupBuyMarketServiceTest {
|
||||
log.info("返回结果:{}", JSON.toJSONString(trialBalanceEntity));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_indexMarketTrial_error() throws Exception {
|
||||
MarketProductEntity marketProductEntity = new MarketProductEntity();
|
||||
marketProductEntity.setUserId("smile");
|
||||
marketProductEntity.setSource("s01");
|
||||
marketProductEntity.setChannel("c01");
|
||||
marketProductEntity.setGoodsId("9890002");
|
||||
|
||||
TrialBalanceEntity trialBalanceEntity = indexGroupBuyMarketService.indexMarketTrial(marketProductEntity);
|
||||
log.info("请求参数:{}", JSON.toJSONString(marketProductEntity));
|
||||
log.info("返回结果:{}", JSON.toJSONString(trialBalanceEntity));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package edu.whut.domain.activity.adapter.repository;
|
||||
import edu.whut.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
|
||||
import edu.whut.domain.activity.model.valobj.SCSkuActivityVO;
|
||||
import edu.whut.domain.activity.model.valobj.SkuVO;
|
||||
|
||||
/**
|
||||
@ -7,8 +8,10 @@ import edu.whut.domain.activity.model.valobj.SkuVO;
|
||||
*/
|
||||
public interface IActivityRepository {
|
||||
|
||||
GroupBuyActivityDiscountVO queryGroupBuyActivityDiscountVO(String source, String channel);
|
||||
GroupBuyActivityDiscountVO queryGroupBuyActivityDiscountVO(Long activityId);
|
||||
|
||||
SkuVO querySkuByGoodsId(String goodsId);
|
||||
|
||||
SCSkuActivityVO querySCSkuActivityBySCGoodsId(String source, String channel, String goodsId);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package edu.whut.domain.activity.model.valobj;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 渠道商品活动配置值对象
|
||||
*/
|
||||
@Getter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SCSkuActivityVO {
|
||||
|
||||
/** 渠道 */
|
||||
private String source;
|
||||
/** 来源 */
|
||||
private String chanel;
|
||||
/** 活动ID */
|
||||
private Long activityId;
|
||||
/** 商品ID */
|
||||
private String goodsId;
|
||||
|
||||
}
|
@ -15,7 +15,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 结束节点
|
||||
* 正常结束节点
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
|
@ -0,0 +1,38 @@
|
||||
package edu.whut.domain.activity.service.trial.node;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import edu.whut.domain.activity.model.entity.MarketProductEntity;
|
||||
import edu.whut.domain.activity.model.entity.TrialBalanceEntity;
|
||||
import edu.whut.domain.activity.service.trial.AbstractGroupBuyMarketSupport;
|
||||
import edu.whut.domain.activity.service.trial.factory.DefaultActivityStrategyFactory;
|
||||
import edu.whut.types.design.framework.tree.StrategyHandler;
|
||||
import edu.whut.types.enums.ResponseCode;
|
||||
import edu.whut.types.exception.AppException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 异常节点处理;无营销、流程降级、超时调用等,都可以路由到 ErrorNode 节点统一处理
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ErrorNode extends AbstractGroupBuyMarketSupport<MarketProductEntity, DefaultActivityStrategyFactory.DynamicContext, TrialBalanceEntity> {
|
||||
|
||||
@Override
|
||||
protected TrialBalanceEntity doApply(MarketProductEntity requestParameter, DefaultActivityStrategyFactory.DynamicContext dynamicContext) throws Exception {
|
||||
log.info("拼团商品查询试算服务-NoMarketNode userId:{} requestParameter:{}", requestParameter.getUserId(), JSON.toJSONString(requestParameter));
|
||||
|
||||
// 无营销配置
|
||||
if (null == dynamicContext.getGroupBuyActivityDiscountVO() || null == dynamicContext.getSkuVO()) {
|
||||
log.info("商品无拼团营销配置 {}", requestParameter.getGoodsId());
|
||||
throw new AppException(ResponseCode.E0002.getCode(), ResponseCode.E0002.getInfo());
|
||||
}
|
||||
|
||||
return TrialBalanceEntity.builder().build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public StrategyHandler<MarketProductEntity, DefaultActivityStrategyFactory.DynamicContext, TrialBalanceEntity> get(MarketProductEntity requestParameter, DefaultActivityStrategyFactory.DynamicContext dynamicContext) throws Exception {
|
||||
return defaultStrategyHandler;
|
||||
}
|
||||
|
||||
}
|
@ -33,13 +33,22 @@ public class MarketNode extends AbstractGroupBuyMarketSupport<MarketProductEntit
|
||||
|
||||
private final EndNode endNode;
|
||||
|
||||
private final ErrorNode errorNode;
|
||||
|
||||
private final Map<String, IDiscountCalculateService> discountCalculateServiceMap;
|
||||
|
||||
// 异步加载数据
|
||||
/**
|
||||
* 异步加载数据
|
||||
* @param requestParameter
|
||||
* @param dynamicContext
|
||||
* @throws ExecutionException
|
||||
* @throws InterruptedException
|
||||
* @throws TimeoutException
|
||||
*/
|
||||
@Override
|
||||
protected void multiThread(MarketProductEntity requestParameter, DefaultActivityStrategyFactory.DynamicContext dynamicContext) throws ExecutionException, InterruptedException, TimeoutException {
|
||||
// 异步查询活动配置
|
||||
QueryGroupBuyActivityDiscountVOThreadTask queryGroupBuyActivityDiscountVOThreadTask = new QueryGroupBuyActivityDiscountVOThreadTask(requestParameter.getSource(), requestParameter.getChannel(), repository);
|
||||
QueryGroupBuyActivityDiscountVOThreadTask queryGroupBuyActivityDiscountVOThreadTask = new QueryGroupBuyActivityDiscountVOThreadTask(requestParameter.getSource(), requestParameter.getChannel(),requestParameter.getGoodsId(), repository);
|
||||
FutureTask<GroupBuyActivityDiscountVO> groupBuyActivityDiscountVOFutureTask = new FutureTask<>(queryGroupBuyActivityDiscountVOThreadTask);
|
||||
threadPoolExecutor.execute(groupBuyActivityDiscountVOFutureTask);
|
||||
|
||||
@ -55,15 +64,30 @@ public class MarketNode extends AbstractGroupBuyMarketSupport<MarketProductEntit
|
||||
log.info("拼团商品查询试算服务-MarketNode userId:{} 异步线程加载数据「GroupBuyActivityDiscountVO、SkuVO」完成", requestParameter.getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 真正的业务流程实现
|
||||
* @param requestParameter
|
||||
* @param dynamicContext
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public TrialBalanceEntity doApply(MarketProductEntity requestParameter, DefaultActivityStrategyFactory.DynamicContext dynamicContext) throws Exception {
|
||||
log.info("拼团商品查询试算服务-MarketNode userId:{} requestParameter:{}", requestParameter.getUserId(), JSON.toJSONString(requestParameter));
|
||||
|
||||
// 获取上下文数据
|
||||
GroupBuyActivityDiscountVO groupBuyActivityDiscountVO = dynamicContext.getGroupBuyActivityDiscountVO();
|
||||
if (null == groupBuyActivityDiscountVO) {
|
||||
return router(requestParameter, dynamicContext);
|
||||
}
|
||||
|
||||
GroupBuyActivityDiscountVO.GroupBuyDiscount groupBuyDiscount = groupBuyActivityDiscountVO.getGroupBuyDiscount();
|
||||
|
||||
SkuVO skuVO = dynamicContext.getSkuVO();
|
||||
if (null == groupBuyDiscount || null == skuVO) {
|
||||
return router(requestParameter, dynamicContext);
|
||||
}
|
||||
|
||||
// 优惠试算
|
||||
IDiscountCalculateService discountCalculateService = discountCalculateServiceMap.get(groupBuyDiscount.getMarketPlan());
|
||||
if (null == discountCalculateService) {
|
||||
log.info("不存在{}类型的折扣计算服务,支持类型为:{}", groupBuyDiscount.getMarketPlan(), JSON.toJSONString(discountCalculateServiceMap.keySet()));
|
||||
@ -77,8 +101,19 @@ public class MarketNode extends AbstractGroupBuyMarketSupport<MarketProductEntit
|
||||
return router(requestParameter, dynamicContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前请求参数获取对应的策略处理器,当前为Markdet节点,下一个节点要不是 EndNode 节点,要不就是 ErrorNode 节点
|
||||
* @param requestParameter 入参
|
||||
* @param dynamicContext 上下文
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public StrategyHandler<MarketProductEntity, DefaultActivityStrategyFactory.DynamicContext, TrialBalanceEntity> get(MarketProductEntity requestParameter, DefaultActivityStrategyFactory.DynamicContext dynamicContext) throws Exception {
|
||||
// 不存在配置的拼团活动,走异常节点
|
||||
if (null == dynamicContext.getGroupBuyActivityDiscountVO() || null == dynamicContext.getSkuVO() || null == dynamicContext.getDeductionPrice()) {
|
||||
return errorNode;
|
||||
}
|
||||
return endNode;
|
||||
}
|
||||
|
||||
|
@ -2,12 +2,15 @@ package edu.whut.domain.activity.service.trial.thread;
|
||||
|
||||
import edu.whut.domain.activity.adapter.repository.IActivityRepository;
|
||||
import edu.whut.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
|
||||
import edu.whut.domain.activity.model.valobj.SCSkuActivityVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* 查询营销配置任务
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class QueryGroupBuyActivityDiscountVOThreadTask implements Callable<GroupBuyActivityDiscountVO> {
|
||||
|
||||
/**
|
||||
@ -20,20 +23,25 @@ public class QueryGroupBuyActivityDiscountVOThreadTask implements Callable<Group
|
||||
*/
|
||||
private final String channel;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
private final String goodsId;
|
||||
|
||||
/**
|
||||
* 活动仓储
|
||||
*/
|
||||
private final IActivityRepository activityRepository;
|
||||
|
||||
public QueryGroupBuyActivityDiscountVOThreadTask(String source, String channel, IActivityRepository activityRepository) {
|
||||
this.source = source;
|
||||
this.channel = channel;
|
||||
this.activityRepository = activityRepository;
|
||||
}
|
||||
|
||||
// 查询活动配置,查sc_sku_activity表
|
||||
@Override
|
||||
public GroupBuyActivityDiscountVO call() throws Exception {
|
||||
return activityRepository.queryGroupBuyActivityDiscountVO(source, channel);
|
||||
//根据商品id查询活动
|
||||
SCSkuActivityVO scSkuActivityVO = activityRepository.querySCSkuActivityBySCGoodsId(source, channel, goodsId);
|
||||
if (null == scSkuActivityVO) return null;
|
||||
//根据活动id查询活动配置
|
||||
return activityRepository.queryGroupBuyActivityDiscountVO(scSkuActivityVO.getActivityId());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,17 @@ package edu.whut.infrastructure.adapter.repository;
|
||||
import edu.whut.domain.activity.adapter.repository.IActivityRepository;
|
||||
import edu.whut.domain.activity.model.valobj.DiscountTypeEnum;
|
||||
import edu.whut.domain.activity.model.valobj.GroupBuyActivityDiscountVO;
|
||||
import edu.whut.domain.activity.model.valobj.SCSkuActivityVO;
|
||||
import edu.whut.domain.activity.model.valobj.SkuVO;
|
||||
import edu.whut.infrastructure.dao.IGroupBuyActivityDao;
|
||||
import edu.whut.infrastructure.dao.IGroupBuyDiscountDao;
|
||||
import edu.whut.infrastructure.dao.ISCSkuActivityDao;
|
||||
import edu.whut.infrastructure.dao.ISkuDao;
|
||||
import edu.whut.infrastructure.dao.po.GroupBuyActivity;
|
||||
import edu.whut.infrastructure.dao.po.GroupBuyDiscount;
|
||||
import edu.whut.infrastructure.dao.po.SCSkuActivity;
|
||||
import edu.whut.infrastructure.dao.po.Sku;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -18,27 +22,27 @@ import javax.annotation.Resource;
|
||||
* 活动仓储
|
||||
*/
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class ActivityRepository implements IActivityRepository {
|
||||
|
||||
@Resource
|
||||
private IGroupBuyActivityDao groupBuyActivityDao;
|
||||
@Resource
|
||||
private IGroupBuyDiscountDao groupBuyDiscountDao;
|
||||
private final IGroupBuyActivityDao groupBuyActivityDao;
|
||||
|
||||
@Resource
|
||||
private ISkuDao skuDao;
|
||||
private final IGroupBuyDiscountDao groupBuyDiscountDao;
|
||||
|
||||
private final ISkuDao skuDao;
|
||||
|
||||
private final ISCSkuActivityDao skuActivityDao;
|
||||
|
||||
@Override
|
||||
public GroupBuyActivityDiscountVO queryGroupBuyActivityDiscountVO(String source, String channel) {
|
||||
// 根据SC渠道值查询配置中最新的1个有效的活动
|
||||
GroupBuyActivity groupBuyActivityReq = new GroupBuyActivity();
|
||||
groupBuyActivityReq.setSource(source);
|
||||
groupBuyActivityReq.setChannel(channel);
|
||||
GroupBuyActivity groupBuyActivityRes = groupBuyActivityDao.queryValidGroupBuyActivity(groupBuyActivityReq);
|
||||
public GroupBuyActivityDiscountVO queryGroupBuyActivityDiscountVO(Long activityId) {
|
||||
GroupBuyActivity groupBuyActivityRes = groupBuyActivityDao.queryValidGroupBuyActivityId(activityId);
|
||||
if (null == groupBuyActivityRes) return null;
|
||||
|
||||
String discountId = groupBuyActivityRes.getDiscountId();
|
||||
|
||||
GroupBuyDiscount groupBuyDiscountRes = groupBuyDiscountDao.queryGroupBuyActivityDiscountByDiscountId(discountId);
|
||||
if (null == groupBuyDiscountRes) return null;
|
||||
|
||||
GroupBuyActivityDiscountVO.GroupBuyDiscount groupBuyDiscount = GroupBuyActivityDiscountVO.GroupBuyDiscount.builder()
|
||||
.discountName(groupBuyDiscountRes.getDiscountName())
|
||||
.discountDesc(groupBuyDiscountRes.getDiscountDesc())
|
||||
@ -51,9 +55,6 @@ public class ActivityRepository implements IActivityRepository {
|
||||
return GroupBuyActivityDiscountVO.builder()
|
||||
.activityId(groupBuyActivityRes.getActivityId())
|
||||
.activityName(groupBuyActivityRes.getActivityName())
|
||||
.source(groupBuyActivityRes.getSource())
|
||||
.channel(groupBuyActivityRes.getChannel())
|
||||
.goodsId(groupBuyActivityRes.getGoodsId())
|
||||
.groupBuyDiscount(groupBuyDiscount)
|
||||
.groupType(groupBuyActivityRes.getGroupType())
|
||||
.takeLimitCount(groupBuyActivityRes.getTakeLimitCount())
|
||||
@ -70,6 +71,7 @@ public class ActivityRepository implements IActivityRepository {
|
||||
@Override
|
||||
public SkuVO querySkuByGoodsId(String goodsId) {
|
||||
Sku sku = skuDao.querySkuByGoodsId(goodsId);
|
||||
if (null == sku) return null;
|
||||
return SkuVO.builder()
|
||||
.goodsId(sku.getGoodsId())
|
||||
.goodsName(sku.getGoodsName())
|
||||
@ -77,4 +79,22 @@ public class ActivityRepository implements IActivityRepository {
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SCSkuActivityVO querySCSkuActivityBySCGoodsId(String source, String channel, String goodsId) {
|
||||
SCSkuActivity scSkuActivityReq = new SCSkuActivity();
|
||||
scSkuActivityReq.setSource(source);
|
||||
scSkuActivityReq.setChannel(channel);
|
||||
scSkuActivityReq.setGoodsId(goodsId);
|
||||
|
||||
SCSkuActivity scSkuActivity = skuActivityDao.querySCSkuActivityBySCGoodsId(scSkuActivityReq);
|
||||
if (null == scSkuActivity) return null;
|
||||
|
||||
return SCSkuActivityVO.builder()
|
||||
.source(scSkuActivity.getSource())
|
||||
.chanel(scSkuActivity.getChannel())
|
||||
.activityId(scSkuActivity.getActivityId())
|
||||
.goodsId(scSkuActivity.getGoodsId())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,4 +13,6 @@ public interface IGroupBuyActivityDao {
|
||||
|
||||
GroupBuyActivity queryValidGroupBuyActivity(GroupBuyActivity groupBuyActivityReq);
|
||||
|
||||
GroupBuyActivity queryValidGroupBuyActivityId(Long activityId);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package edu.whut.infrastructure.dao;
|
||||
import edu.whut.infrastructure.dao.po.SCSkuActivity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 渠道商品活动配置关联表Dao
|
||||
*/
|
||||
@Mapper
|
||||
public interface ISCSkuActivityDao {
|
||||
|
||||
SCSkuActivity querySCSkuActivityBySCGoodsId(SCSkuActivity scSkuActivity);
|
||||
|
||||
}
|
@ -22,12 +22,6 @@ public class GroupBuyActivity {
|
||||
private Long activityId;
|
||||
/** 活动名称 */
|
||||
private String activityName;
|
||||
/** 来源 */
|
||||
private String source;
|
||||
/** 渠道 */
|
||||
private String channel;
|
||||
/** 商品ID */
|
||||
private String goodsId;
|
||||
/** 折扣ID */
|
||||
private String discountId;
|
||||
/** 拼团方式(0自动成团、1达成目标拼团) */
|
||||
|
@ -0,0 +1,34 @@
|
||||
package edu.whut.infrastructure.dao.po;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 渠道商品活动配置关联表
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SCSkuActivity {
|
||||
|
||||
/** 自增ID */
|
||||
private Long id;
|
||||
/** 渠道 */
|
||||
private String source;
|
||||
/** 来源 */
|
||||
private String channel;
|
||||
/** 活动ID */
|
||||
private Long activityId;
|
||||
/** 商品ID */
|
||||
private String goodsId;
|
||||
/** 创建时间 */
|
||||
private Date createTime;
|
||||
/** 更新时间 */
|
||||
private Date updateTime;
|
||||
|
||||
}
|
@ -13,6 +13,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public interface IRedisService {
|
||||
|
||||
//基本 KV
|
||||
/**
|
||||
* 设置指定 key 的值
|
||||
*
|
||||
@ -39,7 +40,23 @@ public interface IRedisService {
|
||||
<T> T getValue(String key);
|
||||
|
||||
/**
|
||||
* 获取队列
|
||||
* 移除指定 key 的值
|
||||
*
|
||||
* @param key 键
|
||||
*/
|
||||
void remove(String key);
|
||||
|
||||
/**
|
||||
* 判断指定 key 的值是否存在
|
||||
*
|
||||
* @param key 键
|
||||
* @return true/false
|
||||
*/
|
||||
boolean isExists(String key);
|
||||
|
||||
//队列
|
||||
/**
|
||||
* 获取普通队列 非阻塞的先进先出队列
|
||||
*
|
||||
* @param key 键
|
||||
* @param <T> 泛型
|
||||
@ -48,7 +65,7 @@ public interface IRedisService {
|
||||
<T> RQueue<T> getQueue(String key);
|
||||
|
||||
/**
|
||||
* 加锁队列
|
||||
* 加锁队列 消费者可以阻塞等待队列元素。
|
||||
*
|
||||
* @param key 键
|
||||
* @param <T> 泛型
|
||||
@ -57,7 +74,7 @@ public interface IRedisService {
|
||||
<T> RBlockingQueue<T> getBlockingQueue(String key);
|
||||
|
||||
/**
|
||||
* 延迟队列
|
||||
* 延迟队列 把消息延后放到阻塞队列中,适合定时任务、重试机制。
|
||||
*
|
||||
* @param rBlockingQueue 加锁队列
|
||||
* @param <T> 泛型
|
||||
@ -65,6 +82,7 @@ public interface IRedisService {
|
||||
*/
|
||||
<T> RDelayedQueue<T> getDelayedQueue(RBlockingQueue<T> rBlockingQueue);
|
||||
|
||||
//数值计数器,原子自增/自减计数器,适合做分布式编号、PV/UV 统计、限流计数等。
|
||||
/**
|
||||
* 设置值
|
||||
*
|
||||
@ -112,22 +130,7 @@ public interface IRedisService {
|
||||
*/
|
||||
long decrBy(String key, long delta);
|
||||
|
||||
|
||||
/**
|
||||
* 移除指定 key 的值
|
||||
*
|
||||
* @param key 键
|
||||
*/
|
||||
void remove(String key);
|
||||
|
||||
/**
|
||||
* 判断指定 key 的值是否存在
|
||||
*
|
||||
* @param key 键
|
||||
* @return true/false
|
||||
*/
|
||||
boolean isExists(String key);
|
||||
|
||||
//集合
|
||||
/**
|
||||
* 将指定的值添加到集合中
|
||||
*
|
||||
@ -145,6 +148,7 @@ public interface IRedisService {
|
||||
*/
|
||||
boolean isSetMember(String key, String value);
|
||||
|
||||
//列表
|
||||
/**
|
||||
* 将指定的值添加到列表中
|
||||
*
|
||||
@ -162,6 +166,8 @@ public interface IRedisService {
|
||||
*/
|
||||
String getFromList(String key, int index);
|
||||
|
||||
|
||||
//映射/哈希
|
||||
/**
|
||||
* 获取Map
|
||||
*
|
||||
@ -197,6 +203,7 @@ public interface IRedisService {
|
||||
*/
|
||||
<K, V> V getFromMap(String key, K field);
|
||||
|
||||
//有序集合
|
||||
/**
|
||||
* 将指定的值添加到有序集合中
|
||||
*
|
||||
@ -205,6 +212,8 @@ public interface IRedisService {
|
||||
*/
|
||||
void addToSortedSet(String key, String value);
|
||||
|
||||
|
||||
//分布式同步原语
|
||||
/**
|
||||
* 获取 Redis 锁(可重入锁)
|
||||
*
|
||||
@ -256,8 +265,14 @@ public interface IRedisService {
|
||||
*/
|
||||
RCountDownLatch getCountDownLatch(String key);
|
||||
|
||||
//实现分布式锁
|
||||
Boolean setNx(String key);
|
||||
|
||||
Boolean setNx(String key, long expired, TimeUnit timeUnit);
|
||||
|
||||
//布隆过滤器
|
||||
/**
|
||||
* 布隆过滤器
|
||||
* 布隆过滤器 ,海量元素去重或判定“可能存在”
|
||||
*
|
||||
* @param key 键
|
||||
* @param <T> 存放对象
|
||||
@ -265,10 +280,7 @@ public interface IRedisService {
|
||||
*/
|
||||
<T> RBloomFilter<T> getBloomFilter(String key);
|
||||
|
||||
Boolean setNx(String key);
|
||||
|
||||
Boolean setNx(String key, long expired, TimeUnit timeUnit);
|
||||
|
||||
//位图
|
||||
RBitSet getBitSet(String key);
|
||||
|
||||
default int getIndexFromUserId(String userId) {
|
||||
@ -283,5 +295,4 @@ public interface IRedisService {
|
||||
throw new RuntimeException("MD5 algorithm not found", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,14 +15,26 @@ public abstract class AbstractMultiThreadStrategyRouter<T, D, R> implements Stra
|
||||
@Setter
|
||||
protected StrategyHandler<T, D, R> defaultStrategyHandler = StrategyHandler.DEFAULT;
|
||||
|
||||
//实现自己的普通方法router
|
||||
/**
|
||||
* 实现自己的普通方法router,规定执行顺序:先获取handler,再执行handler
|
||||
* @param requestParameter
|
||||
* @param dynamicContext
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public R router(T requestParameter, D dynamicContext) throws Exception {
|
||||
StrategyHandler<T, D, R> strategyHandler = get(requestParameter, dynamicContext);
|
||||
if(null != strategyHandler) return strategyHandler.apply(requestParameter, dynamicContext);
|
||||
return defaultStrategyHandler.apply(requestParameter, dynamicContext);
|
||||
}
|
||||
|
||||
//实现了接口中的apply方法。
|
||||
/**
|
||||
* 实现了接口中的apply方法。先执行异步加载数据,再执行业务流程受理
|
||||
* @param requestParameter
|
||||
* @param dynamicContext
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public R apply(T requestParameter, D dynamicContext) throws Exception {
|
||||
// 异步加载数据
|
||||
@ -37,7 +49,7 @@ public abstract class AbstractMultiThreadStrategyRouter<T, D, R> implements Stra
|
||||
protected abstract void multiThread(T requestParameter, D dynamicContext) throws ExecutionException, InterruptedException, TimeoutException;
|
||||
|
||||
/**
|
||||
* 业务流程受理
|
||||
* 真正的业务流程,由子类实现
|
||||
*/
|
||||
protected abstract R doApply(T requestParameter, D dynamicContext) throws Exception;
|
||||
|
||||
|
@ -13,6 +13,7 @@ public enum ResponseCode {
|
||||
UN_ERROR("0001", "未知失败"),
|
||||
ILLEGAL_PARAMETER("0002", "非法参数"),
|
||||
E0001("E0001", "不存在对应的折扣计算服务"),
|
||||
E0002("E0002", "无拼团营销配置"),
|
||||
;
|
||||
|
||||
private String code;
|
||||
|
Loading…
x
Reference in New Issue
Block a user