From a5de638a7766f552462ddfa1c2f8a0f0a71c3951 Mon Sep 17 00:00:00 2001
From: caathead <155051876@qq.com>
Date: Sun, 2 Mar 2025 23:10:39 +0800
Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E8=8A=82=20=E5=AE=8C?=
=?UTF-8?q?=E6=88=90=E4=BA=86=E5=9F=BA=E6=9C=AC=E7=9A=84=E6=8C=81=E4=B9=85?=
=?UTF-8?q?=E5=B1=82=E6=9E=84=E5=BB=BA=E6=9E=B6=E6=9E=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../dev-ops/mysql/sql/xfg-frame-archetype.sql | 35 ++++++++-
.../data/log/log_error.log | 0
.../data/log/log_info.log | 8 ++
.../src/main/resources/application-dev.yml | 8 +-
.../resources/mybatis/mapper/award_mapper.xml | 29 ++++++++
.../mybatis/mapper/frame_case_mapper.xml | 25 -------
.../mybatis/mapper/strategy_award_mapper.xml | 55 ++++++++++++++
.../mybatis/mapper/strategy_mapper.xml | 26 +++++++
.../mybatis/mapper/strategy_rule_mapper.xml | 37 ++++++++++
.../test/infrastructure/AwardDaoTest.java | 35 +++++++++
.../RaffleActivityAccountDayDaoTest.java | 36 +++++++++
.../infrastructure/RaffleActivityDaoTest.java | 33 +++++++++
.../RaffleActivityOrderDaoTest.java | 71 ++++++++++++++++++
.../infrastructure/RuleTreeNodeDaoTest.java | 34 +++++++++
.../StrategyRepositoryTest.java | 74 +++++++++++++++++++
.../ElasticSearchUserRaffleOrderDaoTest.java | 29 ++++++++
.../infrastructure/dao/IAwardDao.java | 15 ++++
.../infrastructure/dao/IStrategyAwardDao.java | 21 ++++++
.../infrastructure/dao/IStrategyDao.java | 13 ++++
.../infrastructure/dao/IStrategyRuleDao.java | 15 ++++
.../bugstack/infrastructure/dao/po/Award.java | 15 ++++
.../infrastructure/dao/po/Strategy.java | 23 ++++++
.../infrastructure/dao/po/StrategyAward.java | 74 +++++++++++++++++++
.../infrastructure/dao/po/StrategyRule.java | 19 +++++
.../infrastructure/dao/po/package-info.java | 4 -
25 files changed, 699 insertions(+), 35 deletions(-)
create mode 100644 xfg-frame-archetype-lite-app/data/log/log_error.log
create mode 100644 xfg-frame-archetype-lite-app/data/log/log_info.log
create mode 100644 xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/award_mapper.xml
delete mode 100644 xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/frame_case_mapper.xml
create mode 100644 xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_award_mapper.xml
create mode 100644 xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_mapper.xml
create mode 100644 xfg-frame-archetype-lite-app/src/main/resources/mybatis/mapper/strategy_rule_mapper.xml
create mode 100644 xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/AwardDaoTest.java
create mode 100644 xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityAccountDayDaoTest.java
create mode 100644 xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityDaoTest.java
create mode 100644 xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RaffleActivityOrderDaoTest.java
create mode 100644 xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/RuleTreeNodeDaoTest.java
create mode 100644 xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/StrategyRepositoryTest.java
create mode 100644 xfg-frame-archetype-lite-app/src/test/java/cn/bugstack/test/infrastructure/elasticsearch/ElasticSearchUserRaffleOrderDaoTest.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IAwardDao.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyAwardDao.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyDao.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/IStrategyRuleDao.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/Award.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/Strategy.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/StrategyAward.java
create mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/StrategyRule.java
delete mode 100644 xfg-frame-archetype-lite-infrastructure/src/main/java/cn/bugstack/infrastructure/dao/po/package-info.java
diff --git a/docs/dev-ops/mysql/sql/xfg-frame-archetype.sql b/docs/dev-ops/mysql/sql/xfg-frame-archetype.sql
index 3ad951a..b23e1b4 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 0000000..e69de29
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 0000000..d696e87
--- /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 208aed5..b0e8524 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 0000000..f9ad398
--- /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 2c3f77a..0000000
--- 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 0000000..1359e2b
--- /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 0000000..ef2ed77
--- /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 0000000..cfa0793
--- /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 0000000..10170e3
--- /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 0000000..76afcbc
--- /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 0000000..16e2cab
--- /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 0000000..18cba0e
--- /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 0000000..8c730b2
--- /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 0000000..f35ed4d
--- /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 0000000..d1afa11
--- /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 0000000..237cb2b
--- /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 0000000..b266e12
--- /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 0000000..5153293
--- /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 0000000..a594b9a
--- /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 0000000..9debd55
--- /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 0000000..9065cd3
--- /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 0000000..5046b40
--- /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 0000000..1c41e61
--- /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 d123c7c..0000000
--- 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
--
GitLab