diff --git a/docs/dev-ops/mysql/sql/xfg-frame-archetype.sql b/docs/dev-ops/mysql/sql/xfg-frame-archetype.sql index 3ad951af353ed113109fc39cca77ac7d2a799c49..b23e1b487307b5addeb4bc229f628cec3c36eb05 100644 --- a/docs/dev-ops/mysql/sql/xfg-frame-archetype.sql +++ b/docs/dev-ops/mysql/sql/xfg-frame-archetype.sql @@ -122,7 +122,8 @@ CREATE TABLE `strategy` ( LOCK TABLES `strategy` WRITE; /*!40000 ALTER TABLE `strategy` DISABLE KEYS */; -INSERT INTO `strategy` (`id`, `strategy_id`, `strategy_desc`, `create_time`, `update_time`) +INSERT INTO `strategy` + (`id`, `strategy_id`, `strategy_desc`, `create_time`, `update_time`) VALUES (1,100001,'抽奖策略','2023-12-09 09:37:19','2023-12-09 09:37:19'); UNLOCK TABLES; @@ -193,4 +194,34 @@ VALUES (12,100001,106,2,'rule_luck_award','1,60','兜底奖品60以内随机积分','2023-12-09 10:30:43','2023-12-09 12:56:00'), (13,100001,NULL,1,'rule_weight','6000,102,103,104,105,106,107,108,109','消耗6000分,必中奖范围','2023-12-09 10:30:43','2023-12-09 12:58:21'), (14,100001,NULL,1,'rule_blacklist','1','黑名单抽奖,积分兜底','2023-12-09 12:59:45','2023-12-09 13:42:23'); -UNLOCK TABLES; \ No newline at end of file +UNLOCK TABLES; + + +CREATE TABLE `award` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID', + `award_id` int(8) NOT NULL COMMENT '抽奖奖品ID - 内部流转使用', + `award_key` varchar(32) NOT NULL COMMENT '奖品对接标识 - 每一个都是一个对应的发奖策略', + `award_config` varchar(32) NOT NULL COMMENT '奖品配置信息', + `award_desc` varchar(128) 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`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +LOCK TABLES `award` WRITE; +/*!40000 ALTER TABLE `award` DISABLE KEYS */; + +INSERT INTO `award` (`id`, `award_id`, `award_key`, `award_config`, `award_desc`, `create_time`, `update_time`) +VALUES + (1,101,'user_credit_random','1,100','用户积分【优先透彻规则范围,如果没有则走配置】','2023-12-09 11:07:06','2023-12-09 11:21:31'), + (2,102,'openai_use_count','5','OpenAI 增加使用次数','2023-12-09 11:07:06','2023-12-09 11:12:59'), + (3,103,'openai_use_count','10','OpenAI 增加使用次数','2023-12-09 11:07:06','2023-12-09 11:12:59'), + (4,104,'openai_use_count','20','OpenAI 增加使用次数','2023-12-09 11:07:06','2023-12-09 11:12:58'), + (5,105,'openai_model','gpt-4','OpenAI 增加模型','2023-12-09 11:07:06','2023-12-09 11:12:01'), + (6,106,'openai_model','dall-e-2','OpenAI 增加模型','2023-12-09 11:07:06','2023-12-09 11:12:08'), + (7,107,'openai_model','dall-e-3','OpenAI 增加模型','2023-12-09 11:07:06','2023-12-09 11:12:10'), + (8,108,'openai_use_count','100','OpenAI 增加使用次数','2023-12-09 11:07:06','2023-12-09 11:12:55'), + (9,109,'openai_model','gpt-4,dall-e-2,dall-e-3','OpenAI 增加模型','2023-12-09 11:07:06','2023-12-09 11:12:39'); + +/*!40000 ALTER TABLE `award` ENABLE KEYS */; +UNLOCK TABLES; diff --git a/xfg-frame-archetype-lite-app/data/log/log_error.log b/xfg-frame-archetype-lite-app/data/log/log_error.log new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/xfg-frame-archetype-lite-app/data/log/log_info.log b/xfg-frame-archetype-lite-app/data/log/log_info.log new file mode 100644 index 0000000000000000000000000000000000000000..d696e87d0e80b83b11f80316a1b52b57278d82b5 --- /dev/null +++ b/xfg-frame-archetype-lite-app/data/log/log_info.log @@ -0,0 +1,8 @@ +25-03-02.22:16:34.489 [main ] INFO AwardDaoTest - Starting AwardDaoTest using Java 17.0.10 on xruicc with PID 4280 (started by 15505 in D:\MarketingIntegrationSystem\xfg-frame-archetype-lite-app) +25-03-02.22:16:34.490 [main ] INFO AwardDaoTest - The following 1 profile is active: "dev" +25-03-02.22:16:36.666 [main ] INFO AwardDaoTest - Started AwardDaoTest in 2.655 seconds (JVM running for 3.732) +25-03-02.22:16:37.163 [main ] INFO HikariDataSource - HikariPool-1 - Starting... +25-03-02.22:16:37.722 [main ] INFO HikariDataSource - HikariPool-1 - Start completed. +25-03-02.22:16:38.021 [main ] INFO AwardDaoTest - 测试结果:[{"awardConfig":"1,100","awardDesc":"用户积分【优先透彻规则范围,如果没有则走配置】","awardId":101,"awardKey":"user_credit_random"},{"awardConfig":"5","awardDesc":"OpenAI 增加使用次数","awardId":102,"awardKey":"openai_use_count"},{"awardConfig":"10","awardDesc":"OpenAI 增加使用次数","awardId":103,"awardKey":"openai_use_count"},{"awardConfig":"20","awardDesc":"OpenAI 增加使用次数","awardId":104,"awardKey":"openai_use_count"},{"awardConfig":"gpt-4","awardDesc":"OpenAI 增加模型","awardId":105,"awardKey":"openai_model"},{"awardConfig":"dall-e-2","awardDesc":"OpenAI 增加模型","awardId":106,"awardKey":"openai_model"},{"awardConfig":"dall-e-3","awardDesc":"OpenAI 增加模型","awardId":107,"awardKey":"openai_model"},{"awardConfig":"100","awardDesc":"OpenAI 增加使用次数","awardId":108,"awardKey":"openai_use_count"},{"awardConfig":"gpt-4,dall-e-2,dall-e-3","awardDesc":"OpenAI 增加模型","awardId":109,"awardKey":"openai_model"}] +25-03-02.22:16:38.034 [SpringApplicationShutdownHook] INFO HikariDataSource - HikariPool-1 - Shutdown initiated... +25-03-02.22:16:38.046 [SpringApplicationShutdownHook] INFO HikariDataSource - HikariPool-1 - Shutdown completed. diff --git a/xfg-frame-archetype-lite-app/src/main/resources/application-dev.yml b/xfg-frame-archetype-lite-app/src/main/resources/application-dev.yml index 208aed53fef202853a657977ec7b3746729b8a78..b0e852490a7f9abc21dbc02e06c2637f9541ec74 100644 --- a/xfg-frame-archetype-lite-app/src/main/resources/application-dev.yml +++ b/xfg-frame-archetype-lite-app/src/main/resources/application-dev.yml @@ -17,7 +17,7 @@ spring: datasource: username: root password: 123456 - url: jdbc:mysql://127.0.0.1:3306/xfg_frame_archetype?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=true + url: jdbc:mysql://localhost:13306/big_market?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&serverTimezone=UTC&useSSL=true driver-class-name: com.mysql.cj.jdbc.Driver hikari: pool-name: Retail_HikariCP @@ -30,9 +30,9 @@ spring: connection-test-query: SELECT 1 type: com.zaxxer.hikari.HikariDataSource -#mybatis: -# mapper-locations: classpath:/mybatis/mapper/*.xml -# config-location: classpath:/mybatis/config/mybatis-config.xml +mybatis: + mapper-locations: classpath:/mybatis/mapper/*.xml + config-location: classpath:/mybatis/config/mybatis-config.xml # 日志 logging: diff --git a/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/award_mapper.xml b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/award_mapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..f9ad398493b917cc9f764f3e943c1aaddfa33a63 --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/award_mapper.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/frame_case_mapper.xml b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/frame_case_mapper.xml deleted file mode 100644 index 2c3f77af56c10912fab2cf604e6cbfef25098623..0000000000000000000000000000000000000000 --- a/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/frame_case_mapper.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - INSERT INTO table(a,b,c) VALUES(#{a}, #{b}, #{c}) - - - - UPDATE table SET a = #{a} WHERE b = #{b} - - - - - diff --git a/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_award_mapper.xml b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_award_mapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..1359e2be319bc78509fbcfd07fac6c9eb7e6d6e5 --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_award_mapper.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + update strategy_award + set award_count_surplus = award_count_surplus - 1 + where strategy_id = #{strategyId} and award_id = #{awardId} and award_count_surplus > 0 + + + + + + + diff --git a/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_mapper.xml b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_mapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..ef2ed777d3583b25b09cec78772978de3535b1ed --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_mapper.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + diff --git a/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_rule_mapper.xml b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_rule_mapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..cfa07935c72f4688e05c3e094bfdb527d00c502e --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_rule_mapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/AwardDaoTest.java b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/AwardDaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..10170e3d68c97ee4af2ac869beb86c2903b17e35 --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/AwardDaoTest.java @@ -0,0 +1,35 @@ +package cn.bugstack.test.infrastructure; + +import cn.bugstack.infrastructure.dao.IAwardDao; +import cn.bugstack.infrastructure.dao.po.Award; +import com.alibaba.fastjson.JSON; +import lombok.extern.slf4j.Slf4j; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author Fuzhengwei bugstack.cn @小傅哥 + * @description 奖品持久化单元测试 + * @create 2023-12-16 13:36 + */ +@Slf4j +@RunWith(SpringRunner.class) +@SpringBootTest +public class AwardDaoTest { + + @Resource + private IAwardDao awardDao; + + @Test + public void test_queryAwardList() { + + List awards = awardDao.queryAwardList(); + log.info("测试结果:{}", JSON.toJSONString(awards)); + } + +} diff --git a/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityAccountDayDaoTest.java b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityAccountDayDaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..76afcbc7d66c19b11d2ff01280ee05689d5cc908 --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityAccountDayDaoTest.java @@ -0,0 +1,36 @@ +//package cn.bugstack.test.infrastructure; +// +//import cn.bugstack.infrastructure.dao.IRaffleActivityAccountDayDao; +//import cn.bugstack.infrastructure.dao.po.RaffleActivityAccountDay; +//import lombok.extern.slf4j.Slf4j; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//import javax.annotation.Resource; +// +///** +// * @author Fuzhengwei bugstack.cn @小傅哥 +// * @description 活动日账户DAO +// * @create 2024-04-20 10:15 +// */ +//@Slf4j +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class RaffleActivityAccountDayDaoTest { +// +// @Resource +// private IRaffleActivityAccountDayDao raffleActivityAccountDayDao; +// +// @Test +// public void test_queryRaffleActivityAccountDayPartakeCount() { +// RaffleActivityAccountDay raffleActivityAccountDay = new RaffleActivityAccountDay(); +// raffleActivityAccountDay.setActivityId(100301L); +// raffleActivityAccountDay.setUserId("xiaofuge"); +// raffleActivityAccountDay.setDay(raffleActivityAccountDay.currentDay()); +// Integer dayPartakeCount = raffleActivityAccountDayDao.queryRaffleActivityAccountDayPartakeCount(raffleActivityAccountDay); +// log.info("测试结果:{}", dayPartakeCount); +// } +// +//} diff --git a/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityDaoTest.java b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityDaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..16e2cab36a45402d3fac92fcb0492bf4b0d06b89 --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityDaoTest.java @@ -0,0 +1,33 @@ +//package cn.bugstack.test.infrastructure; +// +//import cn.bugstack.infrastructure.dao.IRaffleActivityDao; +//import cn.bugstack.infrastructure.dao.po.RaffleActivity; +//import com.alibaba.fastjson2.JSON; +//import lombok.extern.slf4j.Slf4j; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//import javax.annotation.Resource; +// +///** +// * @author Fuzhengwei bugstack.cn @小傅哥 +// * @description 抽奖活动配置Dao测试 +// * @create 2024-03-09 11:30 +// */ +//@Slf4j +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class RaffleActivityDaoTest { +// +// @Resource +// private IRaffleActivityDao raffleActivityDao; +// +// @Test +// public void test_queryRaffleActivityByActivityId() { +// RaffleActivity raffleActivity = raffleActivityDao.queryRaffleActivityByActivityId(100301L); +// log.info("测试结果:{}", JSON.toJSONString(raffleActivity)); +// } +// +//} diff --git a/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityOrderDaoTest.java b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityOrderDaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..18cba0e0bb416965b14f32b606de4c81148eb078 --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityOrderDaoTest.java @@ -0,0 +1,71 @@ +//package cn.bugstack.test.infrastructure; +// +//import cn.bugstack.infrastructure.dao.IRaffleActivityOrderDao; +//import cn.bugstack.infrastructure.dao.po.RaffleActivityOrder; +//import com.alibaba.fastjson.JSON; +//import lombok.extern.slf4j.Slf4j; +//import org.apache.commons.lang.RandomStringUtils; +//import org.jeasy.random.EasyRandom; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//import javax.annotation.Resource; +//import java.util.Date; +//import java.util.List; +// +///** +// * @author Fuzhengwei bugstack.cn @小傅哥 +// * @description 抽奖活动订单测试 +// * @create 2024-03-09 10:51 +// */ +//@Slf4j +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class RaffleActivityOrderDaoTest { +// +// @Resource +// private IRaffleActivityOrderDao raffleActivityOrderDao; +// +// private final EasyRandom easyRandom = new EasyRandom(); +// +// @Test +// public void test_insert_random() { +// for (int i = 0; i < 5; i++) { +// RaffleActivityOrder raffleActivityOrder = new RaffleActivityOrder(); +// // EasyRandom 可以通过指定对象类的方式,随机生成对象值。如;easyRandom.nextObject(String.class)、easyRandom.nextObject(RaffleActivityOrder.class) +// raffleActivityOrder.setUserId(easyRandom.nextObject(String.class)); +// raffleActivityOrder.setActivityId(100301L); +// raffleActivityOrder.setActivityName("测试活动"); +// raffleActivityOrder.setStrategyId(100006L); +// raffleActivityOrder.setOrderId(RandomStringUtils.randomNumeric(12)); +// raffleActivityOrder.setOrderTime(new Date()); +// raffleActivityOrder.setState("not_used"); +// // 插入数据 +// raffleActivityOrderDao.insert(raffleActivityOrder); +// } +// } +// +// @Test +// public void test_insert() { +// RaffleActivityOrder raffleActivityOrder = new RaffleActivityOrder(); +// raffleActivityOrder.setUserId("xiaofuge"); +// raffleActivityOrder.setActivityId(100301L); +// raffleActivityOrder.setActivityName("测试活动"); +// raffleActivityOrder.setStrategyId(100006L); +// raffleActivityOrder.setOrderId(RandomStringUtils.randomNumeric(12)); +// raffleActivityOrder.setOrderTime(new Date()); +// raffleActivityOrder.setState("not_used"); +// // 插入数据 +// raffleActivityOrderDao.insert(raffleActivityOrder); +// } +// +// @Test +// public void test_queryRaffleActivityOrderByUserId() { +// String userId = "xiaofuge"; +// List raffleActivityOrders = raffleActivityOrderDao.queryRaffleActivityOrderByUserId(userId); +// log.info("测试结果:{}", JSON.toJSONString(raffleActivityOrders)); +// } +// +//} diff --git a/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RuleTreeNodeDaoTest.java b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RuleTreeNodeDaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8c730b288f826bff72386eb4fa59319421025dbb --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RuleTreeNodeDaoTest.java @@ -0,0 +1,34 @@ +//package cn.bugstack.test.infrastructure; +// +//import cn.bugstack.infrastructure.dao.IRuleTreeNodeDao; +//import cn.bugstack.infrastructure.dao.po.RuleTreeNode; +//import com.alibaba.fastjson.JSON; +//import lombok.extern.slf4j.Slf4j; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//import javax.annotation.Resource; +//import java.util.List; +// +///** +// * @author Fuzhengwei bugstack.cn @小傅哥 +// * @description 规则单元测试 +// * @create 2024-04-20 09:40 +// */ +//@Slf4j +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class RuleTreeNodeDaoTest { +// +// @Resource +// private IRuleTreeNodeDao ruleTreeNodeDao; +// +// @Test +// public void test_queryRuleLocks() { +// List ruleTreeNodes = ruleTreeNodeDao.queryRuleLocks(new String[]{"tree_lock_1", "tree_lock_2"}); +// log.info("测试结果:{}", JSON.toJSONString(ruleTreeNodes)); +// } +// +//} diff --git a/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/StrategyRepositoryTest.java b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/StrategyRepositoryTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f35ed4d6aee11b675aed1b2ce2109f6b098c135e --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/StrategyRepositoryTest.java @@ -0,0 +1,74 @@ +//package cn.bugstack.test.infrastructure; +// +//import cn.bugstack.domain.strategy.model.valobj.RuleTreeVO; +//import cn.bugstack.domain.strategy.model.valobj.StrategyAwardStockKeyVO; +//import cn.bugstack.domain.strategy.repository.IStrategyRepository; +//import cn.bugstack.infrastructure.redis.IRedisService; +//import cn.bugstack.types.common.Constants; +//import com.alibaba.fastjson2.JSON; +//import lombok.extern.slf4j.Slf4j; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.redisson.api.RBlockingQueue; +//import org.redisson.api.RDelayedQueue; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//import javax.annotation.Resource; +//import java.util.concurrent.CountDownLatch; +//import java.util.concurrent.TimeUnit; +// +///** +// * @author Fuzhengwei bugstack.cn @小傅哥 +// * @description 策略仓储测试 +// * @create 2024-02-03 09:43 +// */ +//@Slf4j +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class StrategyRepositoryTest { +// +// @Resource +// private IStrategyRepository strategyRepository; +// @Resource +// private IRedisService redisService; +// +// @Test +// public void queryRuleTreeVOByTreeId() { +// RuleTreeVO ruleTreeVO = strategyRepository.queryRuleTreeVOByTreeId("tree_lock"); +// log.info("测试结果:{}", JSON.toJSONString(ruleTreeVO)); +// } +// +// @Test +// public void test_cacheStrategyAwardCount() { +// String cacheKey = Constants.RedisKey.STRATEGY_AWARD_COUNT_KEY + "300001" + Constants.UNDERLINE + "102"; +// strategyRepository.cacheStrategyAwardCount(cacheKey, 10); +// } +// +// @Test +// public void test_subtractionAwardStock() { +// String cacheKey = Constants.RedisKey.STRATEGY_AWARD_COUNT_KEY + "300001" + Constants.UNDERLINE + "102"; +// strategyRepository.subtractionAwardStock(cacheKey); +// } +// +// @Test +// public void test_getValue() { +// String cacheKey = Constants.RedisKey.STRATEGY_AWARD_COUNT_KEY + "300001" + Constants.UNDERLINE + "102"; +// Integer value = redisService.getValue(cacheKey); +// log.info("测试结果:{}", value); +// } +// +// @Test +// public void test_queue() throws InterruptedException { +// String cacheKey = Constants.RedisKey.STRATEGY_AWARD_COUNT_QUERY_KEY; +// RBlockingQueue blockingQueue = redisService.getBlockingQueue(cacheKey); +// RDelayedQueue delayedQueue = redisService.getDelayedQueue(blockingQueue); +// delayedQueue.offer(StrategyAwardStockKeyVO.builder() +// .strategyId(100001L) +// .awardId(102) +// .build(), 3, TimeUnit.SECONDS); +// +// new CountDownLatch(1).await(); +// } +// +//} diff --git a/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/elasticsearch/ElasticSearchUserRaffleOrderDaoTest.java b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/elasticsearch/ElasticSearchUserRaffleOrderDaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d1afa1157024cc65bdcc9d5c404e5c3a63862a8d --- /dev/null +++ b/xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/elasticsearch/ElasticSearchUserRaffleOrderDaoTest.java @@ -0,0 +1,29 @@ +//package cn.bugstack.test.infrastructure.elasticsearch; +// +//import cn.bugstack.infrastructure.elasticsearch.IElasticSearchUserRaffleOrderDao; +//import cn.bugstack.infrastructure.elasticsearch.po.UserRaffleOrder; +//import com.alibaba.fastjson.JSON; +//import lombok.extern.slf4j.Slf4j; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.springframework.boot.test.context.SpringBootTest; +//import org.springframework.test.context.junit4.SpringRunner; +// +//import javax.annotation.Resource; +//import java.util.List; +// +//@Slf4j +//@RunWith(SpringRunner.class) +//@SpringBootTest +//public class ElasticSearchUserRaffleOrderDaoTest { +// +// @Resource +// private IElasticSearchUserRaffleOrderDao elasticSearchUserRaffleOrderDao; +// +// @Test +// public void test_queryUserRaffleOrderList() { +// List userRaffleOrders = elasticSearchUserRaffleOrderDao.queryUserRaffleOrderList(); +// log.info("测试结果:{}", JSON.toJSONString(userRaffleOrders)); +// } +// +//} diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IAwardDao.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IAwardDao.java new file mode 100644 index 0000000000000000000000000000000000000000..237cb2b0904bc19d5b37b1aa637f952064588633 --- /dev/null +++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IAwardDao.java @@ -0,0 +1,15 @@ +package cn.bugstack.infrastructure.dao; + +import cn.bugstack.infrastructure.dao.po.Award; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface IAwardDao { + List queryAwardList(); + + String queryAwardConfigByAwardId(Integer awardId); + + String queryAwardKeyByAwardId(Integer awardId); +} diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyAwardDao.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyAwardDao.java new file mode 100644 index 0000000000000000000000000000000000000000..b266e124df0f4937aa8fb6ad5361a13648e22968 --- /dev/null +++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyAwardDao.java @@ -0,0 +1,21 @@ +package cn.bugstack.infrastructure.dao; + +import cn.bugstack.infrastructure.dao.po.StrategyAward; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface IStrategyAwardDao { + List queryStrategyAwardList(); + + List queryStrategyAwardListByStrategyId(Long strategyId); + + String queryStrategyAwardRuleModels(StrategyAward strategyAward); + + void updateStrategyAwardStock(StrategyAward strategyAward); + + StrategyAward queryStrategyAward(StrategyAward strategyAwardReq); + + List queryOpenActivityStrategyAwardList(); +} diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyDao.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyDao.java new file mode 100644 index 0000000000000000000000000000000000000000..5153293c672adabf6b38d0629dc83df74645927d --- /dev/null +++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyDao.java @@ -0,0 +1,13 @@ +package cn.bugstack.infrastructure.dao; + +import cn.bugstack.infrastructure.dao.po.Strategy; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface IStrategyDao { + List queryStrategyList(); + + Strategy queryStrategyByStrategyId(Long strategyId); +} diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyRuleDao.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyRuleDao.java new file mode 100644 index 0000000000000000000000000000000000000000..a594b9a86ae9de182867b385f9e4fc4cd4e4199e --- /dev/null +++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyRuleDao.java @@ -0,0 +1,15 @@ +package cn.bugstack.infrastructure.dao; + +import cn.bugstack.infrastructure.dao.po.StrategyRule; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface IStrategyRuleDao { + List queryStrategyRuleList(); + + StrategyRule queryStrategyRule(StrategyRule strategyRuleReq); + + String queryStrategyRuleValue(StrategyRule strategyRule); +} diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/Award.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/Award.java new file mode 100644 index 0000000000000000000000000000000000000000..9debd55cfbe36d4ca22f3e541beef44b1bfe031b --- /dev/null +++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/Award.java @@ -0,0 +1,15 @@ +package cn.bugstack.infrastructure.dao.po; + +import lombok.Data; + +import java.util.Date; +@Data +public class Award { + private Integer id; + private Integer awardId; + private String awardKey; + private String awardConfig; + private String awardDesc; + private Date createTime; + private Date updateTime; +} diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/Strategy.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/Strategy.java new file mode 100644 index 0000000000000000000000000000000000000000..9065cd3da72c24db84220ff051112ec2c70e2957 --- /dev/null +++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/Strategy.java @@ -0,0 +1,23 @@ +package cn.bugstack.infrastructure.dao.po; + +import lombok.Data; + +import java.util.Date; + +/** + *抽奖策略 + */ +@Data +public class Strategy { + + private Long id; + + private Long strategyId; + + private String strategyDesc; + + private Date createTime; + + private Date updateTime; + +} diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/StrategyAward.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/StrategyAward.java new file mode 100644 index 0000000000000000000000000000000000000000..5046b40976eda10a6ff27097e1eeb952dc077510 --- /dev/null +++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/StrategyAward.java @@ -0,0 +1,74 @@ +package cn.bugstack.infrastructure.dao.po; + +import lombok.Data; + +import java.util.Date; + +import java.math.BigDecimal; +@Data +public class StrategyAward { + /** + * 自增ID + */ + private Long id; + + /** + * 抽奖策略ID + */ + private Long strategyId; + + /** + * 抽奖奖品ID - 内部流转使用 + */ + private Integer awardId; + + /** + * 抽奖奖品标题 + */ + private String awardTitle; + + /** + * 抽奖奖品副标题 + */ + private String awardSubtitle; + + /** + * 奖品库存总量 + */ + private Integer awardCount; + + /** + * 奖品库存剩余 + */ + private Integer awardCountSurplus; + + /** + * 奖品中奖概率 + */ + private BigDecimal awardRate; + + /** + * 规则模型,rule配置的模型同步到此表,便于使用 + */ + private String ruleModels; + + /** + * 排序 + */ + private Integer sort; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改时间 + */ + private Date updateTime; + + +} + + + diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/StrategyRule.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/StrategyRule.java new file mode 100644 index 0000000000000000000000000000000000000000..1c41e613b1bc565a6e6254bda59459f7c491aabd --- /dev/null +++ b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/StrategyRule.java @@ -0,0 +1,19 @@ +package cn.bugstack.infrastructure.dao.po; + +import lombok.Data; + +import java.util.Date; +@Data +public class StrategyRule { + private Long id; + private Integer strategyId; + private Integer awardId; + private Byte ruleType; + private String ruleModel; + private String ruleValue; + private String ruleDesc; + private Date createTime; + private Date updateTime; + + +} diff --git a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/package-info.java b/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/package-info.java deleted file mode 100644 index d123c7c896642ac6a7bcf5b8604c3560e8133a4b..0000000000000000000000000000000000000000 --- a/xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/package-info.java +++ /dev/null @@ -1,4 +0,0 @@ -/** - * 持久化对象;XxxPO 最后的 PO 是大写,UserPO - */ -package cn.bugstack.infrastructure.dao.po; \ No newline at end of file