提交 019913af 编写于 作者: 鲸落和鲨掉's avatar 鲸落和鲨掉

活动API的完善:...

活动API的完善: 增加策略锁key的过期时间、扩展查询奖品信息接口【queryRaffleAwardList】,以用户活动为视角进行查询增加返回信息。同时修复Redisson序列化、加锁过期时间问题。
上级 5dde2c13
...@@ -11,8 +11,10 @@ import lombok.Data; ...@@ -11,8 +11,10 @@ import lombok.Data;
@Data @Data
public class RaffleAwardListRequestDTO { public class RaffleAwardListRequestDTO {
// 抽奖策略ID // 用户ID
private Long strategyId; private String userId;
// 抽奖活动ID
private Long activityId;
} }
...@@ -25,6 +25,12 @@ public class RaffleAwardListResponseDTO { ...@@ -25,6 +25,12 @@ public class RaffleAwardListResponseDTO {
private String awardSubtitle; private String awardSubtitle;
// 排序编号 // 排序编号
private Integer sort; private Integer sort;
// 奖品次数规则 - 抽奖N次后解锁,未配置则为空
private Integer awardRuleLockCount;
// 奖品是否解锁 - true 已解锁、false 未解锁
private Boolean isAwardUnlock;
// 等待解锁次数 - 规定的抽奖N次解锁减去用户已经抽奖次数
private Integer waitUnLockCount;
} }
......
24-11-26.14:44:46.454 [main ] INFO RaffleActivityDaoTest - Starting RaffleActivityDaoTest using Java 1.8.0_412 on zhaoyongfeng with PID 24288 (started by zhaoyongfeng in C:\Users\31126\Desktop\bigmarket-lite\bigmarket-app)
24-11-26.14:44:46.455 [main ] INFO RaffleActivityDaoTest - The following 1 profile is active: "dev"
24-11-26.14:44:47.728 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
24-11-26.14:44:47.732 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
24-11-26.14:44:47.813 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 63 ms. Found 0 Redis repository interfaces.
24-11-26.14:44:50.908 [main ] INFO Version - Redisson 3.23.4
24-11-26.14:44:52.489 [redisson-netty-2-4] INFO MasterPubSubConnectionPool - 1 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.14:44:52.502 [redisson-netty-2-13] INFO MasterConnectionPool - 5 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.14:44:55.529 [main ] INFO EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
24-11-26.14:44:55.628 [main ] INFO RaffleActivityDaoTest - Started RaffleActivityDaoTest in 9.786 seconds (JVM running for 11.079)
24-11-26.14:44:55.728 [main ] ERROR TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@75db5df9] to prepare test instance [cn.bugstack.test.infrastructure.RaffleActivityDaoTest@77f03916]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.bugstack.test.infrastructure.RaffleActivityDaoTest': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.bugstack.infrastructure.persistent.dao.IRaffleActivityDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:332)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:417)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:119)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83)
at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:43)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:248)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.bugstack.infrastructure.persistent.dao.IRaffleActivityDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:544)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:520)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:673)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:228)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:329)
... 29 common frames omitted
24-11-26.14:58:05.651 [main ] INFO RaffleActivityDaoTest - Starting RaffleActivityDaoTest using Java 1.8.0_412 on zhaoyongfeng with PID 12612 (started by zhaoyongfeng in C:\Users\31126\Desktop\bigmarket-lite\bigmarket-app)
24-11-26.14:58:05.652 [main ] INFO RaffleActivityDaoTest - The following 1 profile is active: "dev"
24-11-26.14:58:07.208 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
24-11-26.14:58:07.214 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
24-11-26.14:58:07.327 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 92 ms. Found 0 Redis repository interfaces.
24-11-26.14:58:10.505 [main ] INFO Version - Redisson 3.23.4
24-11-26.14:58:12.087 [redisson-netty-2-4] INFO MasterPubSubConnectionPool - 1 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.14:58:12.101 [redisson-netty-2-13] INFO MasterConnectionPool - 5 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.14:58:16.275 [main ] INFO EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
24-11-26.14:58:16.442 [main ] INFO RaffleActivityDaoTest - Started RaffleActivityDaoTest in 11.508 seconds (JVM running for 13.113)
24-11-26.14:58:16.818 [main ] INFO HikariDataSource - Retail_HikariCP - Starting...
24-11-26.14:58:17.253 [main ] INFO HikariDataSource - Retail_HikariCP - Start completed.
24-11-26.14:58:17.534 [main ] INFO RaffleActivityDaoTest - 测试结果:{"activityCountId":1,"activityDesc":"测试活动","activityId":100301,"activityName":"测试活动","beginDateTime":1732619927000,"endDateTime":1735211934000,"state":"0","stockCount":1000,"stockCountSurplus":1000,"strategyId":100006}
24-11-26.14:59:18.748 [main ] INFO RaffleActivityOrderDaoTest - Starting RaffleActivityOrderDaoTest using Java 1.8.0_412 on zhaoyongfeng with PID 18800 (started by zhaoyongfeng in C:\Users\31126\Desktop\bigmarket-lite\bigmarket-app)
24-11-26.14:59:18.749 [main ] INFO RaffleActivityOrderDaoTest - The following 1 profile is active: "dev"
24-11-26.14:59:20.080 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
24-11-26.14:59:20.084 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
24-11-26.14:59:20.170 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 70 ms. Found 0 Redis repository interfaces.
24-11-26.14:59:23.289 [main ] INFO Version - Redisson 3.23.4
24-11-26.14:59:25.040 [redisson-netty-2-4] INFO MasterPubSubConnectionPool - 1 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.14:59:25.054 [redisson-netty-2-13] INFO MasterConnectionPool - 5 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.14:59:28.634 [main ] INFO EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
24-11-26.14:59:28.752 [main ] INFO RaffleActivityOrderDaoTest - Started RaffleActivityOrderDaoTest in 10.621 seconds (JVM running for 12.018)
24-11-26.14:59:29.097 [main ] INFO HikariDataSource - Retail_HikariCP - Starting...
24-11-26.14:59:29.443 [main ] INFO HikariDataSource - Retail_HikariCP - Start completed.
24-11-26.15:11:41.013 [main ] INFO RaffleActivityOrderDaoTest - Starting RaffleActivityOrderDaoTest using Java 1.8.0_412 on zhaoyongfeng with PID 13736 (started by zhaoyongfeng in C:\Users\31126\Desktop\bigmarket-lite\bigmarket-app)
24-11-26.15:11:41.015 [main ] INFO RaffleActivityOrderDaoTest - The following 1 profile is active: "dev"
24-11-26.15:11:42.629 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
24-11-26.15:11:42.635 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
24-11-26.15:11:42.734 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 77 ms. Found 0 Redis repository interfaces.
24-11-26.15:11:45.911 [main ] INFO Version - Redisson 3.23.4
24-11-26.15:11:47.552 [redisson-netty-2-4] INFO MasterPubSubConnectionPool - 1 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.15:11:47.565 [redisson-netty-2-13] INFO MasterConnectionPool - 5 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.15:11:50.740 [main ] INFO EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
24-11-26.15:11:50.835 [main ] INFO RaffleActivityOrderDaoTest - Started RaffleActivityOrderDaoTest in 10.43 seconds (JVM running for 11.685)
24-11-26.15:11:51.155 [main ] INFO HikariDataSource - Retail_HikariCP - Starting...
24-11-26.15:11:51.486 [main ] INFO HikariDataSource - Retail_HikariCP - Start completed.
24-11-26.15:12:43.811 [main ] INFO RaffleActivityOrderDaoTest - Starting RaffleActivityOrderDaoTest using Java 1.8.0_412 on zhaoyongfeng with PID 21760 (started by zhaoyongfeng in C:\Users\31126\Desktop\bigmarket-lite\bigmarket-app)
24-11-26.15:12:43.813 [main ] INFO RaffleActivityOrderDaoTest - The following 1 profile is active: "dev"
24-11-26.15:12:45.129 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
24-11-26.15:12:45.134 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
24-11-26.15:12:45.215 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 66 ms. Found 0 Redis repository interfaces.
24-11-26.15:12:48.483 [main ] INFO Version - Redisson 3.23.4
24-11-26.15:12:50.070 [redisson-netty-2-4] INFO MasterPubSubConnectionPool - 1 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.15:12:50.083 [redisson-netty-2-13] INFO MasterConnectionPool - 5 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.15:12:53.096 [main ] INFO EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
24-11-26.15:12:53.192 [main ] INFO RaffleActivityOrderDaoTest - Started RaffleActivityOrderDaoTest in 9.965 seconds (JVM running for 11.124)
24-11-26.15:12:53.489 [main ] INFO HikariDataSource - Retail_HikariCP - Starting...
24-11-26.15:12:53.809 [main ] INFO HikariDataSource - Retail_HikariCP - Start completed.
24-11-26.15:14:17.824 [main ] INFO RaffleActivityOrderDaoTest - Starting RaffleActivityOrderDaoTest using Java 1.8.0_412 on zhaoyongfeng with PID 13588 (started by zhaoyongfeng in C:\Users\31126\Desktop\bigmarket-lite\bigmarket-app)
24-11-26.15:14:17.825 [main ] INFO RaffleActivityOrderDaoTest - The following 1 profile is active: "dev"
24-11-26.15:14:19.064 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
24-11-26.15:14:19.068 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
24-11-26.15:14:19.151 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 65 ms. Found 0 Redis repository interfaces.
24-11-26.15:14:22.155 [main ] INFO Version - Redisson 3.23.4
24-11-26.15:14:23.698 [redisson-netty-2-4] INFO MasterPubSubConnectionPool - 1 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.15:14:23.711 [redisson-netty-2-13] INFO MasterConnectionPool - 5 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.15:14:26.961 [main ] INFO EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
24-11-26.15:14:27.061 [main ] INFO RaffleActivityOrderDaoTest - Started RaffleActivityOrderDaoTest in 9.806 seconds (JVM running for 11.021)
24-11-26.15:14:27.433 [main ] INFO HikariDataSource - Retail_HikariCP - Starting...
24-11-26.15:14:27.805 [main ] INFO HikariDataSource - Retail_HikariCP - Start completed.
24-11-26.15:14:28.009 [main ] INFO RaffleActivityOrderDaoTest - 测试结果:[]
24-11-26.15:14:41.387 [main ] INFO RaffleActivityOrderDaoTest - Starting RaffleActivityOrderDaoTest using Java 1.8.0_412 on zhaoyongfeng with PID 14992 (started by zhaoyongfeng in C:\Users\31126\Desktop\bigmarket-lite\bigmarket-app)
24-11-26.15:14:41.389 [main ] INFO RaffleActivityOrderDaoTest - The following 1 profile is active: "dev"
24-11-26.15:14:42.536 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
24-11-26.15:14:42.540 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
24-11-26.15:14:42.620 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 64 ms. Found 0 Redis repository interfaces.
24-11-26.15:14:45.528 [main ] INFO Version - Redisson 3.23.4
24-11-26.15:14:47.077 [redisson-netty-2-5] INFO MasterPubSubConnectionPool - 1 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.15:14:47.090 [redisson-netty-2-13] INFO MasterConnectionPool - 5 connections initialized for 127.0.0.1/127.0.0.1:16379
24-11-26.15:14:49.879 [main ] INFO EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
24-11-26.15:14:49.968 [main ] INFO RaffleActivityOrderDaoTest - Started RaffleActivityOrderDaoTest in 9.091 seconds (JVM running for 10.251)
24-11-26.15:14:50.276 [main ] INFO HikariDataSource - Retail_HikariCP - Starting...
24-11-26.15:14:50.591 [main ] INFO HikariDataSource - Retail_HikariCP - Start completed.
24-11-26.15:14:50.802 [main ] INFO RaffleActivityOrderDaoTest - 测试结果:[{"activityId":100301,"activityName":"测试活动","orderId":"88675199","orderTime":1709954149000,"state":"not_used","strategyId":100006,"userId":"xiaofuge"},{"activityId":100301,"activityName":"测试活动","orderId":"382877096957","orderTime":1709965454000,"state":"not_used","strategyId":100006,"userId":"xiaofuge"},{"activityId":100301,"activityName":"测试活动","orderId":"832133072786","orderTime":1732605173000,"state":"not_used","strategyId":100006,"userId":"xiaofuge"}]
因为 它太大了无法显示 source diff 。你可以改为 查看blob
因为 它太大了无法显示 source diff 。你可以改为 查看blob
因为 它太大了无法显示 source diff 。你可以改为 查看blob
...@@ -10,6 +10,7 @@ import org.redisson.api.RedissonClient; ...@@ -10,6 +10,7 @@ import org.redisson.api.RedissonClient;
import org.redisson.client.codec.BaseCodec; import org.redisson.client.codec.BaseCodec;
import org.redisson.client.protocol.Decoder; import org.redisson.client.protocol.Decoder;
import org.redisson.client.protocol.Encoder; import org.redisson.client.protocol.Encoder;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.config.Config; import org.redisson.config.Config;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
...@@ -32,7 +33,7 @@ public class RedisClientConfig { ...@@ -32,7 +33,7 @@ public class RedisClientConfig {
public RedissonClient redissonClient(ConfigurableApplicationContext applicationContext, RedisClientConfigProperties properties) { public RedissonClient redissonClient(ConfigurableApplicationContext applicationContext, RedisClientConfigProperties properties) {
Config config = new Config(); Config config = new Config();
// 根据需要可以设定编解码器;https://github.com/redisson/redisson/wiki/4.-%E6%95%B0%E6%8D%AE%E5%BA%8F%E5%88%97%E5%8C%96 // 根据需要可以设定编解码器;https://github.com/redisson/redisson/wiki/4.-%E6%95%B0%E6%8D%AE%E5%BA%8F%E5%88%97%E5%8C%96
// config.setCodec(new RedisCodec()); config.setCodec(JsonJacksonCodec.INSTANCE);
config.useSingleServer() config.useSingleServer()
.setAddress("redis://" + properties.getHost() + ":" + properties.getPort()) .setAddress("redis://" + properties.getHost() + ":" + properties.getPort())
......
...@@ -31,5 +31,9 @@ ...@@ -31,5 +31,9 @@
from raffle_activity_account_day from raffle_activity_account_day
where user_id = #{userId} and activity_id = #{activityId} and day = #{day} where user_id = #{userId} and activity_id = #{activityId} and day = #{day}
</select> </select>
<select id="queryRaffleActivityAccountDayPartakeCount" parameterType="cn.bugstack.infrastructure.persistent.po.RaffleActivityAccountDay" resultType="java.lang.Integer">
select day_count - day_count_surplus
from raffle_activity_account_day
where user_id = #{userId} and activity_id = #{activityId} and day = #{day}
</select>
</mapper> </mapper>
...@@ -17,5 +17,13 @@ ...@@ -17,5 +17,13 @@
from rule_tree_node from rule_tree_node
where tree_id = #{treeId} where tree_id = #{treeId}
</select> </select>
<select id="queryRuleLocks" resultMap="dataMap">
select tree_id, rule_value
from rule_tree_node
where rule_key = 'rule_lock' and tree_id in
<foreach item="treeId" index="index" collection="array" open="(" separator="," close=")">
#{treeId}
</foreach>
</select>
</mapper> </mapper>
...@@ -97,7 +97,7 @@ public class LogicTreeTest { ...@@ -97,7 +97,7 @@ public class LogicTreeTest {
IDecisionTreeEngine treeEngine = defaultTreeFactory.openLogicTree(ruleTreeVO); IDecisionTreeEngine treeEngine = defaultTreeFactory.openLogicTree(ruleTreeVO);
DefaultTreeFactory.StrategyAwardVO data = treeEngine.process("xiaofuge", 100001L, 100); DefaultTreeFactory.StrategyAwardVO data = treeEngine.process("xiaofuge", 100001L, 100,null);
log.info("测试结果:{}", JSON.toJSONString(data)); log.info("测试结果:{}", JSON.toJSONString(data));
} }
......
package cn.bugstack.test.trigger;
import cn.bugstack.trigger.api.IRaffleActivityService;
import cn.bugstack.trigger.api.dto.ActivityDrawRequestDTO;
import cn.bugstack.trigger.api.dto.ActivityDrawResponseDTO;
import cn.bugstack.types.model.Response;
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;
/**
* @author Fuzhengwei bugstack.cn @小傅哥
* @description 抽奖活动服务测试
* @create 2024-04-20 11:02
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class RaffleActivityControllerTest {
@Resource
private IRaffleActivityService raffleActivityService;
@Test
public void test_armory() {
Response<Boolean> response = raffleActivityService.armory(100301L);
log.info("测试结果:{}", JSON.toJSONString(response));
}
@Test
public void test_draw() {
ActivityDrawRequestDTO request = new ActivityDrawRequestDTO();
request.setActivityId(100301L);
request.setUserId("xiaofuge");
Response<ActivityDrawResponseDTO> response = raffleActivityService.draw(request);
log.info("请求参数:{}", JSON.toJSONString(request));
log.info("测试结果:{}", JSON.toJSONString(response));
}
}
package cn.bugstack.test.trigger;
import cn.bugstack.trigger.api.IRaffleStrategyService;
import cn.bugstack.trigger.api.dto.RaffleAwardListRequestDTO;
import cn.bugstack.trigger.api.dto.RaffleAwardListResponseDTO;
import cn.bugstack.types.model.Response;
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 10:41
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class RaffleStrategyControllerTest {
@Resource
private IRaffleStrategyService raffleStrategyService;
@Test
public void test_queryRaffleAwardList() {
RaffleAwardListRequestDTO request = new RaffleAwardListRequestDTO();
request.setUserId("xiaofuge");
request.setActivityId(100301L);
Response<List<RaffleAwardListResponseDTO>> response = raffleStrategyService.queryRaffleAwardList(request);
log.info("请求参数:{}", JSON.toJSONString(request));
log.info("测试结果:{}", JSON.toJSONString(response));
}
}
package cn.bugstack.domain.activity.model.entity; package cn.bugstack.domain.activity.model.entity;
import cn.bugstack.domain.activity.model.valobj.UserRaffleOrderStateVO; import cn.bugstack.domain.activity.model.valobj.UserRaffleOrderStateVO;
import cn.bugstack.domain.award.model.valobj.AwardStateVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
...@@ -20,18 +21,20 @@ import java.util.Date; ...@@ -20,18 +21,20 @@ import java.util.Date;
@NoArgsConstructor @NoArgsConstructor
public class UserRaffleOrderEntity { public class UserRaffleOrderEntity {
/** 活动ID */ /** 用户ID */
private String userId; private String userId;
/** 活动名称 */ /** 活动ID */
private Long activityId; private Long activityId;
/** 抽奖策略ID */ /** 活动名称 */
private String activityName; private String activityName;
/** 订单ID */ /** 策略ID */
private Long strategyId; private Long strategyId;
/** 下单时间 */ /** 订单ID */
private String orderId; private String orderId;
/** 订单状态;create-创建、used-已使用、cancel-已作废 */ /** 下单时间 */
private Date orderTime; private Date orderTime;
/** 创建时间 */ /** 活动状态;create-创建、used-已使用、cancel-已作废 */
private UserRaffleOrderStateVO orderState; private UserRaffleOrderStateVO orderState;
/** 结束时间 */
private Date endDateTime;
} }
...@@ -49,4 +49,6 @@ public interface IActivityRepository { ...@@ -49,4 +49,6 @@ public interface IActivityRepository {
void saveCreatePartakeOrderAggregate(CreatePartakeOrderAggregate createPartakeOrderAggregate); void saveCreatePartakeOrderAggregate(CreatePartakeOrderAggregate createPartakeOrderAggregate);
List<ActivitySkuEntity> queryActivitySkuListByActivityId(Long activityId); List<ActivitySkuEntity> queryActivitySkuListByActivityId(Long activityId);
Integer queryRaffleActivityAccountDayPartakeCount(Long activityId, String userId);
} }
...@@ -18,4 +18,12 @@ public interface IRaffleActivityAccountQuotaService { ...@@ -18,4 +18,12 @@ public interface IRaffleActivityAccountQuotaService {
* @return 活动ID * @return 活动ID
*/ */
String createOrder(SkuRechargeEntity skuRechargeEntity); String createOrder(SkuRechargeEntity skuRechargeEntity);
/**
* 查询活动账户 - 日,参与次数
*
* @param activityId 活动ID
* @param userId 用户ID
* @return 参与次数
*/
Integer queryRaffleActivityAccountDayPartakeCount(Long activityId, String userId);
} }
...@@ -76,4 +76,9 @@ public class RaffleActivityAccountQuotaService extends AbstractRaffleActivityAcc ...@@ -76,4 +76,9 @@ public class RaffleActivityAccountQuotaService extends AbstractRaffleActivityAcc
public void clearActivitySkuStock(Long sku) { public void clearActivitySkuStock(Long sku) {
activityRepository.clearActivitySkuStock(sku); activityRepository.clearActivitySkuStock(sku);
} }
@Override
public Integer queryRaffleActivityAccountDayPartakeCount(Long activityId, String userId) {
return activityRepository.queryRaffleActivityAccountDayPartakeCount(activityId, userId);
}
} }
...@@ -5,6 +5,8 @@ import lombok.Builder; ...@@ -5,6 +5,8 @@ import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Date;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
* @description 抽奖因子实体 * @description 抽奖因子实体
...@@ -20,5 +22,8 @@ public class RaffleFactorEntity { ...@@ -20,5 +22,8 @@ public class RaffleFactorEntity {
private String userId; private String userId;
/** 策略ID */ /** 策略ID */
private Long strategyId; private Long strategyId;
/** 结束时间 */
private Date endDateTime;
} }
...@@ -34,5 +34,7 @@ public class StrategyAwardEntity { ...@@ -34,5 +34,7 @@ public class StrategyAwardEntity {
private BigDecimal awardRate; private BigDecimal awardRate;
/** 排序 */ /** 排序 */
private Integer sort; private Integer sort;
/** 规则模型,rule配置的模型同步到此表,便于使用 */
private String ruleModels;
} }
...@@ -7,6 +7,7 @@ import cn.bugstack.domain.strategy.model.valobj.RuleTreeVO; ...@@ -7,6 +7,7 @@ import cn.bugstack.domain.strategy.model.valobj.RuleTreeVO;
import cn.bugstack.domain.strategy.model.valobj.StrategyAwardRuleModelVO; import cn.bugstack.domain.strategy.model.valobj.StrategyAwardRuleModelVO;
import cn.bugstack.domain.strategy.model.valobj.StrategyAwardStockKeyVO; import cn.bugstack.domain.strategy.model.valobj.StrategyAwardStockKeyVO;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -60,6 +61,14 @@ public interface IStrategyRepository { ...@@ -60,6 +61,14 @@ public interface IStrategyRepository {
* @return 扣减结果 * @return 扣减结果
*/ */
Boolean subtractionAwardStock(String cacheKey); Boolean subtractionAwardStock(String cacheKey);
/**
* 缓存key,decr 方式扣减库存
*
* @param cacheKey 缓存Key
* @param endDateTime 活动结束时间
* @return 扣减结果
*/
Boolean subtractionAwardStock(String cacheKey, Date endDateTime);
/** /**
* 写入奖品库存消费队列 * 写入奖品库存消费队列
...@@ -104,4 +113,11 @@ public interface IStrategyRepository { ...@@ -104,4 +113,11 @@ public interface IStrategyRepository {
* @return 用户今日参与次数 * @return 用户今日参与次数
*/ */
Integer queryTodayUserRaffleCount(String userId, Long strategyId); Integer queryTodayUserRaffleCount(String userId, Long strategyId);
/**
* 根据规则树ID集合查询奖品中加锁数量的配置「部分奖品需要抽奖N次解锁」
*
* @param treeIds 规则树ID值
* @return key 规则树,value rule_lock 加锁值
*/
Map<String, Integer> queryAwardRuleLockCount(String... treeIds);
} }
...@@ -12,6 +12,8 @@ import cn.bugstack.types.exception.AppException; ...@@ -12,6 +12,8 @@ import cn.bugstack.types.exception.AppException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.Date;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
* @description 抽奖策略抽象类,定义抽奖的标准流程 * @description 抽奖策略抽象类,定义抽奖的标准流程
...@@ -55,7 +57,7 @@ public abstract class AbstractRaffleStrategy implements IRaffleStrategy { ...@@ -55,7 +57,7 @@ public abstract class AbstractRaffleStrategy implements IRaffleStrategy {
} }
// 3. 规则树抽奖过滤【奖品ID,会根据抽奖次数判断、库存判断、兜底兜里返回最终的可获得奖品信息】 // 3. 规则树抽奖过滤【奖品ID,会根据抽奖次数判断、库存判断、兜底兜里返回最终的可获得奖品信息】
DefaultTreeFactory.StrategyAwardVO treeStrategyAwardVO = raffleLogicTree(userId, strategyId, chainStrategyAwardVO.getAwardId()); DefaultTreeFactory.StrategyAwardVO treeStrategyAwardVO = raffleLogicTree(userId, strategyId, chainStrategyAwardVO.getAwardId(), raffleFactorEntity.getEndDateTime());
log.info("抽奖策略计算-规则树 {} {} {} {}", userId, strategyId, treeStrategyAwardVO.getAwardId(), treeStrategyAwardVO.getAwardRuleValue()); log.info("抽奖策略计算-规则树 {} {} {} {}", userId, strategyId, treeStrategyAwardVO.getAwardId(), treeStrategyAwardVO.getAwardRuleValue());
// 4. 返回抽奖结果 // 4. 返回抽奖结果
...@@ -66,8 +68,8 @@ public abstract class AbstractRaffleStrategy implements IRaffleStrategy { ...@@ -66,8 +68,8 @@ public abstract class AbstractRaffleStrategy implements IRaffleStrategy {
StrategyAwardEntity strategyAward = repository.queryStrategyAwardEntity(strategyId, awardId); StrategyAwardEntity strategyAward = repository.queryStrategyAwardEntity(strategyId, awardId);
return RaffleAwardEntity.builder() return RaffleAwardEntity.builder()
.awardId(awardId) .awardId(awardId)
.awardConfig(awardConfig)
.awardTitle(strategyAward.getAwardTitle()) .awardTitle(strategyAward.getAwardTitle())
.awardConfig(awardConfig)
.sort(strategyAward.getSort()) .sort(strategyAward.getSort())
.build(); .build();
} }
...@@ -91,4 +93,15 @@ public abstract class AbstractRaffleStrategy implements IRaffleStrategy { ...@@ -91,4 +93,15 @@ public abstract class AbstractRaffleStrategy implements IRaffleStrategy {
*/ */
public abstract DefaultTreeFactory.StrategyAwardVO raffleLogicTree(String userId, Long strategyId, Integer awardId); public abstract DefaultTreeFactory.StrategyAwardVO raffleLogicTree(String userId, Long strategyId, Integer awardId);
/**
* 抽奖结果过滤,决策树抽象方法
*
* @param userId 用户ID
* @param strategyId 策略ID
* @param awardId 奖品ID
* @param endDateTime 活动结束时间 - 用于设定缓存有效期
* @return 过滤结果【奖品ID,会根据抽奖次数判断、库存判断、兜底兜里返回最终的可获得奖品信息】
*/
public abstract DefaultTreeFactory.StrategyAwardVO raffleLogicTree(String userId, Long strategyId, Integer awardId, Date endDateTime);
} }
...@@ -19,4 +19,5 @@ public interface IRaffleAward { ...@@ -19,4 +19,5 @@ public interface IRaffleAward {
*/ */
List<StrategyAwardEntity> queryRaffleStrategyAwardList(Long strategyId); List<StrategyAwardEntity> queryRaffleStrategyAwardList(Long strategyId);
List<StrategyAwardEntity> queryRaffleStrategyAwardListByActivityId(Long activityId);
} }
package cn.bugstack.domain.strategy.service;
import java.util.Map;
/*
* @return
* @author zhaoyongfeng
* @description 抽奖规则接口;提供对规则的业务功能查询
*/
public interface IRaffleRule {
/**
* 根据规则树ID集合查询奖品中加锁数量的配置「部分奖品需要抽奖N次解锁」
*
* @param treeIds 规则树ID值
* @return key 规则树,value rule_lock 加锁值
*/
Map<String, Integer> queryAwardRuleLockCount(String[] treeIds);
}
package cn.bugstack.domain.strategy.service.armory; package cn.bugstack.domain.strategy.service.armory;
import java.util.Date;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
* @description 策略抽奖调度 * @description 策略抽奖调度
...@@ -38,6 +40,6 @@ public interface IStrategyDispatch { ...@@ -38,6 +40,6 @@ public interface IStrategyDispatch {
* @param awardId 奖品ID * @param awardId 奖品ID
* @return 扣减结果 * @return 扣减结果
*/ */
Boolean subtractionAwardStock(Long strategyId, Integer awardId); Boolean subtractionAwardStock(Long strategyId, Integer awardId, Date endDateTime);
} }
...@@ -163,9 +163,9 @@ public class StrategyArmoryDispatch implements IStrategyArmory, IStrategyDispatc ...@@ -163,9 +163,9 @@ public class StrategyArmoryDispatch implements IStrategyArmory, IStrategyDispatc
} }
@Override @Override
public Boolean subtractionAwardStock(Long strategyId, Integer awardId) { public Boolean subtractionAwardStock(Long strategyId, Integer awardId, Date endDateTime) {
String cacheKey = Constants.RedisKey.STRATEGY_AWARD_COUNT_KEY + strategyId + Constants.UNDERLINE + awardId; String cacheKey = Constants.RedisKey.STRATEGY_AWARD_COUNT_KEY + strategyId + Constants.UNDERLINE + awardId;
return repository.subtractionAwardStock(cacheKey); return repository.subtractionAwardStock(cacheKey, endDateTime);
} }
} }
...@@ -7,6 +7,7 @@ import cn.bugstack.domain.strategy.model.valobj.StrategyAwardStockKeyVO; ...@@ -7,6 +7,7 @@ import cn.bugstack.domain.strategy.model.valobj.StrategyAwardStockKeyVO;
import cn.bugstack.domain.strategy.repository.IStrategyRepository; import cn.bugstack.domain.strategy.repository.IStrategyRepository;
import cn.bugstack.domain.strategy.service.AbstractRaffleStrategy; import cn.bugstack.domain.strategy.service.AbstractRaffleStrategy;
import cn.bugstack.domain.strategy.service.IRaffleAward; import cn.bugstack.domain.strategy.service.IRaffleAward;
import cn.bugstack.domain.strategy.service.IRaffleRule;
import cn.bugstack.domain.strategy.service.IRaffleStock; import cn.bugstack.domain.strategy.service.IRaffleStock;
import cn.bugstack.domain.strategy.service.armory.IStrategyDispatch; import cn.bugstack.domain.strategy.service.armory.IStrategyDispatch;
import cn.bugstack.domain.strategy.service.rule.chain.ILogicChain; import cn.bugstack.domain.strategy.service.rule.chain.ILogicChain;
...@@ -16,7 +17,9 @@ import cn.bugstack.domain.strategy.service.rule.tree.factory.engine.IDecisionTre ...@@ -16,7 +17,9 @@ import cn.bugstack.domain.strategy.service.rule.tree.factory.engine.IDecisionTre
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
...@@ -25,7 +28,7 @@ import java.util.List; ...@@ -25,7 +28,7 @@ import java.util.List;
*/ */
@Slf4j @Slf4j
@Service @Service
public class DefaultRaffleStrategy extends AbstractRaffleStrategy implements IRaffleStock, IRaffleAward { public class DefaultRaffleStrategy extends AbstractRaffleStrategy implements IRaffleStock, IRaffleAward , IRaffleRule {
public DefaultRaffleStrategy(IStrategyRepository repository, IStrategyDispatch strategyDispatch, DefaultChainFactory defaultChainFactory, DefaultTreeFactory defaultTreeFactory) { public DefaultRaffleStrategy(IStrategyRepository repository, IStrategyDispatch strategyDispatch, DefaultChainFactory defaultChainFactory, DefaultTreeFactory defaultTreeFactory) {
super(repository, strategyDispatch, defaultChainFactory, defaultTreeFactory); super(repository, strategyDispatch, defaultChainFactory, defaultTreeFactory);
...@@ -39,6 +42,11 @@ public class DefaultRaffleStrategy extends AbstractRaffleStrategy implements IRa ...@@ -39,6 +42,11 @@ public class DefaultRaffleStrategy extends AbstractRaffleStrategy implements IRa
@Override @Override
public DefaultTreeFactory.StrategyAwardVO raffleLogicTree(String userId, Long strategyId, Integer awardId) { public DefaultTreeFactory.StrategyAwardVO raffleLogicTree(String userId, Long strategyId, Integer awardId) {
return raffleLogicTree(userId, strategyId, awardId, null);
}
@Override
public DefaultTreeFactory.StrategyAwardVO raffleLogicTree(String userId, Long strategyId, Integer awardId, Date endDateTime) {
StrategyAwardRuleModelVO strategyAwardRuleModelVO = repository.queryStrategyAwardRuleModelVO(strategyId, awardId); StrategyAwardRuleModelVO strategyAwardRuleModelVO = repository.queryStrategyAwardRuleModelVO(strategyId, awardId);
if (null == strategyAwardRuleModelVO) { if (null == strategyAwardRuleModelVO) {
return DefaultTreeFactory.StrategyAwardVO.builder().awardId(awardId).build(); return DefaultTreeFactory.StrategyAwardVO.builder().awardId(awardId).build();
...@@ -48,7 +56,7 @@ public class DefaultRaffleStrategy extends AbstractRaffleStrategy implements IRa ...@@ -48,7 +56,7 @@ public class DefaultRaffleStrategy extends AbstractRaffleStrategy implements IRa
throw new RuntimeException("存在抽奖策略配置的规则模型 Key,未在库表 rule_tree、rule_tree_node、rule_tree_line 配置对应的规则树信息 " + strategyAwardRuleModelVO.getRuleModels()); throw new RuntimeException("存在抽奖策略配置的规则模型 Key,未在库表 rule_tree、rule_tree_node、rule_tree_line 配置对应的规则树信息 " + strategyAwardRuleModelVO.getRuleModels());
} }
IDecisionTreeEngine treeEngine = defaultTreeFactory.openLogicTree(ruleTreeVO); IDecisionTreeEngine treeEngine = defaultTreeFactory.openLogicTree(ruleTreeVO);
return treeEngine.process(userId, strategyId, awardId); return treeEngine.process(userId, strategyId, awardId, endDateTime);
} }
@Override @Override
...@@ -66,4 +74,14 @@ public class DefaultRaffleStrategy extends AbstractRaffleStrategy implements IRa ...@@ -66,4 +74,14 @@ public class DefaultRaffleStrategy extends AbstractRaffleStrategy implements IRa
return repository.queryStrategyAwardList(strategyId); return repository.queryStrategyAwardList(strategyId);
} }
@Override
public List<StrategyAwardEntity> queryRaffleStrategyAwardListByActivityId(Long activityId) {
Long strategyId = repository.queryStrategyIdByActivityId(activityId);
return queryRaffleStrategyAwardList(strategyId);
}
@Override
public Map<String, Integer> queryAwardRuleLockCount(String[] treeIds) {
return repository.queryAwardRuleLockCount(treeIds);
}
} }
...@@ -2,6 +2,8 @@ package cn.bugstack.domain.strategy.service.rule.tree; ...@@ -2,6 +2,8 @@ package cn.bugstack.domain.strategy.service.rule.tree;
import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory; import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory;
import java.util.Date;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
* @description 规则树接口 * @description 规则树接口
...@@ -9,6 +11,6 @@ import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory; ...@@ -9,6 +11,6 @@ import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory;
*/ */
public interface ILogicTreeNode { public interface ILogicTreeNode {
DefaultTreeFactory.TreeActionEntity logic(String userId, Long strategyId, Integer awardId, String ruleValue); DefaultTreeFactory.TreeActionEntity logic(String userId, Long strategyId, Integer awardId, String ruleValue, Date endDateTime);
} }
...@@ -2,6 +2,8 @@ package cn.bugstack.domain.strategy.service.rule.tree.factory.engine; ...@@ -2,6 +2,8 @@ package cn.bugstack.domain.strategy.service.rule.tree.factory.engine;
import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory; import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory;
import java.util.Date;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
* @description 规则树组合接口 * @description 规则树组合接口
...@@ -9,6 +11,6 @@ import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory; ...@@ -9,6 +11,6 @@ import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory;
*/ */
public interface IDecisionTreeEngine { public interface IDecisionTreeEngine {
DefaultTreeFactory.StrategyAwardVO process(String userId, Long strategyId, Integer awardId); DefaultTreeFactory.StrategyAwardVO process(String userId, Long strategyId, Integer awardId, Date endDateTime);
} }
...@@ -6,6 +6,7 @@ import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory; ...@@ -6,6 +6,7 @@ import cn.bugstack.domain.strategy.service.rule.tree.factory.DefaultTreeFactory;
import cn.bugstack.domain.strategy.service.rule.tree.factory.engine.IDecisionTreeEngine; import cn.bugstack.domain.strategy.service.rule.tree.factory.engine.IDecisionTreeEngine;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -27,7 +28,7 @@ public class DecisionTreeEngine implements IDecisionTreeEngine { ...@@ -27,7 +28,7 @@ public class DecisionTreeEngine implements IDecisionTreeEngine {
} }
@Override @Override
public DefaultTreeFactory.StrategyAwardVO process(String userId, Long strategyId, Integer awardId) { public DefaultTreeFactory.StrategyAwardVO process(String userId, Long strategyId, Integer awardId, Date endDateTime) {
DefaultTreeFactory.StrategyAwardVO strategyAwardData = null; DefaultTreeFactory.StrategyAwardVO strategyAwardData = null;
// 获取基础信息 // 获取基础信息
...@@ -42,7 +43,7 @@ public class DecisionTreeEngine implements IDecisionTreeEngine { ...@@ -42,7 +43,7 @@ public class DecisionTreeEngine implements IDecisionTreeEngine {
String ruleValue = ruleTreeNode.getRuleValue(); String ruleValue = ruleTreeNode.getRuleValue();
// 决策节点计算 // 决策节点计算
DefaultTreeFactory.TreeActionEntity logicEntity = logicTreeNode.logic(userId, strategyId, awardId, ruleValue); DefaultTreeFactory.TreeActionEntity logicEntity = logicTreeNode.logic(userId, strategyId, awardId, ruleValue, endDateTime);
RuleLogicCheckTypeVO ruleLogicCheckTypeVO = logicEntity.getRuleLogicCheckType(); RuleLogicCheckTypeVO ruleLogicCheckTypeVO = logicEntity.getRuleLogicCheckType();
strategyAwardData = logicEntity.getStrategyAwardVO(); strategyAwardData = logicEntity.getStrategyAwardVO();
log.info("决策树引擎【{}】treeId:{} node:{} code:{}", ruleTreeVO.getTreeName(), ruleTreeVO.getTreeId(), nextNode, ruleLogicCheckTypeVO.getCode()); log.info("决策树引擎【{}】treeId:{} node:{} code:{}", ruleTreeVO.getTreeName(), ruleTreeVO.getTreeId(), nextNode, ruleLogicCheckTypeVO.getCode());
......
...@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
...@@ -22,7 +23,7 @@ public class RuleLockLogicTreeNode implements ILogicTreeNode { ...@@ -22,7 +23,7 @@ public class RuleLockLogicTreeNode implements ILogicTreeNode {
private IStrategyRepository repository; private IStrategyRepository repository;
@Override @Override
public DefaultTreeFactory.TreeActionEntity logic(String userId, Long strategyId, Integer awardId, String ruleValue) { public DefaultTreeFactory.TreeActionEntity logic(String userId, Long strategyId, Integer awardId, String ruleValue, Date endDateTime) {
log.info("规则过滤-次数锁 userId:{} strategyId:{} awardId:{}", userId, strategyId, awardId); log.info("规则过滤-次数锁 userId:{} strategyId:{} awardId:{}", userId, strategyId, awardId);
long raffleCount = 0L; long raffleCount = 0L;
...@@ -37,11 +38,14 @@ public class RuleLockLogicTreeNode implements ILogicTreeNode { ...@@ -37,11 +38,14 @@ public class RuleLockLogicTreeNode implements ILogicTreeNode {
// 用户抽奖次数大于规则限定值,规则放行 // 用户抽奖次数大于规则限定值,规则放行
if (userRaffleCount >= raffleCount) { if (userRaffleCount >= raffleCount) {
log.info("规则过滤-次数锁【放行】 userId:{} strategyId:{} awardId:{} raffleCount:{} userRaffleCount:{}", userId, strategyId, awardId, userRaffleCount, userRaffleCount);
return DefaultTreeFactory.TreeActionEntity.builder() return DefaultTreeFactory.TreeActionEntity.builder()
.ruleLogicCheckType(RuleLogicCheckTypeVO.ALLOW) .ruleLogicCheckType(RuleLogicCheckTypeVO.ALLOW)
.build(); .build();
} }
log.info("规则过滤-次数锁【拦截】 userId:{} strategyId:{} awardId:{} raffleCount:{} userRaffleCount:{}", userId, strategyId, awardId, userRaffleCount, userRaffleCount);
// 用户抽奖次数小于规则限定值,规则拦截 // 用户抽奖次数小于规则限定值,规则拦截
return DefaultTreeFactory.TreeActionEntity.builder() return DefaultTreeFactory.TreeActionEntity.builder()
.ruleLogicCheckType(RuleLogicCheckTypeVO.TAKE_OVER) .ruleLogicCheckType(RuleLogicCheckTypeVO.TAKE_OVER)
......
...@@ -7,6 +7,8 @@ import cn.bugstack.types.common.Constants; ...@@ -7,6 +7,8 @@ import cn.bugstack.types.common.Constants;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Date;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
* @description 兜底奖励节点 * @description 兜底奖励节点
...@@ -17,7 +19,7 @@ import org.springframework.stereotype.Component; ...@@ -17,7 +19,7 @@ import org.springframework.stereotype.Component;
public class RuleLuckAwardLogicTreeNode implements ILogicTreeNode { public class RuleLuckAwardLogicTreeNode implements ILogicTreeNode {
@Override @Override
public DefaultTreeFactory.TreeActionEntity logic(String userId, Long strategyId, Integer awardId, String ruleValue) { public DefaultTreeFactory.TreeActionEntity logic(String userId, Long strategyId, Integer awardId, String ruleValue, Date endDateTime) {
log.info("规则过滤-兜底奖品 userId:{} strategyId:{} awardId:{} ruleValue:{}", userId, strategyId, awardId, ruleValue); log.info("规则过滤-兜底奖品 userId:{} strategyId:{} awardId:{} ruleValue:{}", userId, strategyId, awardId, ruleValue);
String[] split = ruleValue.split(Constants.COLON); String[] split = ruleValue.split(Constants.COLON);
if (split.length == 0) { if (split.length == 0) {
......
...@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.Date;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
...@@ -26,10 +27,10 @@ public class RuleStockLogicTreeNode implements ILogicTreeNode { ...@@ -26,10 +27,10 @@ public class RuleStockLogicTreeNode implements ILogicTreeNode {
private IStrategyRepository strategyRepository; private IStrategyRepository strategyRepository;
@Override @Override
public DefaultTreeFactory.TreeActionEntity logic(String userId, Long strategyId, Integer awardId, String ruleValue) { public DefaultTreeFactory.TreeActionEntity logic(String userId, Long strategyId, Integer awardId, String ruleValue, Date endDateTime) {
log.info("规则过滤-库存扣减 userId:{} strategyId:{} awardId:{}", userId, strategyId, awardId); log.info("规则过滤-库存扣减 userId:{} strategyId:{} awardId:{}", userId, strategyId, awardId);
// 扣减库存 // 扣减库存
Boolean status = strategyDispatch.subtractionAwardStock(strategyId, awardId); Boolean status = strategyDispatch.subtractionAwardStock(strategyId, awardId, endDateTime);
// true;库存扣减成功,TAKE_OVER 规则节点接管,返回奖品ID,奖品规则配置 // true;库存扣减成功,TAKE_OVER 规则节点接管,返回奖品ID,奖品规则配置
if (status) { if (status) {
log.info("规则过滤-库存扣减-成功 userId:{} strategyId:{} awardId:{}", userId, strategyId, awardId); log.info("规则过滤-库存扣减-成功 userId:{} strategyId:{} awardId:{}", userId, strategyId, awardId);
......
...@@ -18,5 +18,6 @@ public interface IRaffleActivityAccountDayDao { ...@@ -18,5 +18,6 @@ public interface IRaffleActivityAccountDayDao {
int updateActivityAccountDaySubtractionQuota(RaffleActivityAccountDay raffleActivityAccountDay); int updateActivityAccountDaySubtractionQuota(RaffleActivityAccountDay raffleActivityAccountDay);
void insertActivityAccountDay(RaffleActivityAccountDay raffleActivityAccountDay); void insertActivityAccountDay(RaffleActivityAccountDay raffleActivityAccountDay);
@DBRouter
Integer queryRaffleActivityAccountDayPartakeCount(RaffleActivityAccountDay raffleActivityAccountDay);
} }
...@@ -15,4 +15,5 @@ public interface IRuleTreeNodeDao { ...@@ -15,4 +15,5 @@ public interface IRuleTreeNodeDao {
List<RuleTreeNode> queryRuleTreeNodeListByTreeId(String treeId); List<RuleTreeNode> queryRuleTreeNodeListByTreeId(String treeId);
List<RuleTreeNode> queryRuleLocks(String[] treeIds);
} }
...@@ -444,4 +444,15 @@ public class ActivityRepository implements IActivityRepository { ...@@ -444,4 +444,15 @@ public class ActivityRepository implements IActivityRepository {
return activitySkuEntities; return activitySkuEntities;
} }
@Override
public Integer queryRaffleActivityAccountDayPartakeCount(Long activityId, String userId) {
RaffleActivityAccountDay raffleActivityAccountDay = new RaffleActivityAccountDay();
raffleActivityAccountDay.setActivityId(activityId);
raffleActivityAccountDay.setUserId(userId);
raffleActivityAccountDay.setDay(raffleActivityAccountDay.currentDay());
Integer dayPartakeCount = raffleActivityAccountDayDao.queryRaffleActivityAccountDayPartakeCount(raffleActivityAccountDay);
// 当日未参与抽奖则为0次
return null == dayPartakeCount ? 0 : dayPartakeCount;
}
} }
...@@ -16,10 +16,7 @@ import org.redisson.api.RDelayedQueue; ...@@ -16,10 +16,7 @@ import org.redisson.api.RDelayedQueue;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static cn.bugstack.types.enums.ResponseCode.UN_ASSEMBLED_STRATEGY_ARMORY; import static cn.bugstack.types.enums.ResponseCode.UN_ASSEMBLED_STRATEGY_ARMORY;
...@@ -33,6 +30,8 @@ import static cn.bugstack.types.enums.ResponseCode.UN_ASSEMBLED_STRATEGY_ARMORY; ...@@ -33,6 +30,8 @@ import static cn.bugstack.types.enums.ResponseCode.UN_ASSEMBLED_STRATEGY_ARMORY;
@Repository @Repository
public class StrategyRepository implements IStrategyRepository { public class StrategyRepository implements IStrategyRepository {
@Resource
private IRaffleActivityDao raffleActivityDao;
@Resource @Resource
private IStrategyDao strategyDao; private IStrategyDao strategyDao;
@Resource @Resource
...@@ -40,7 +39,7 @@ public class StrategyRepository implements IStrategyRepository { ...@@ -40,7 +39,7 @@ public class StrategyRepository implements IStrategyRepository {
@Resource @Resource
private IStrategyAwardDao strategyAwardDao; private IStrategyAwardDao strategyAwardDao;
@Resource @Resource
private IRaffleActivityDao raffleActivityDao; private IRaffleActivityAccountDayDao raffleActivityAccountDayDao;
@Resource @Resource
private IRedisService redisService; private IRedisService redisService;
@Resource @Resource
...@@ -49,8 +48,6 @@ public class StrategyRepository implements IStrategyRepository { ...@@ -49,8 +48,6 @@ public class StrategyRepository implements IStrategyRepository {
private IRuleTreeNodeDao ruleTreeNodeDao; private IRuleTreeNodeDao ruleTreeNodeDao;
@Resource @Resource
private IRuleTreeNodeLineDao ruleTreeNodeLineDao; private IRuleTreeNodeLineDao ruleTreeNodeLineDao;
@Resource
private IRaffleActivityAccountDayDao raffleActivityAccountDayDao;
@Override @Override
public List<StrategyAwardEntity> queryStrategyAwardList(Long strategyId) { public List<StrategyAwardEntity> queryStrategyAwardList(Long strategyId) {
...@@ -71,6 +68,7 @@ public class StrategyRepository implements IStrategyRepository { ...@@ -71,6 +68,7 @@ public class StrategyRepository implements IStrategyRepository {
.awardCountSurplus(strategyAward.getAwardCountSurplus()) .awardCountSurplus(strategyAward.getAwardCountSurplus())
.awardRate(strategyAward.getAwardRate()) .awardRate(strategyAward.getAwardRate())
.sort(strategyAward.getSort()) .sort(strategyAward.getSort())
.ruleModels(strategyAward.getRuleModels())
.build(); .build();
strategyAwardEntities.add(strategyAwardEntity); strategyAwardEntities.add(strategyAwardEntity);
} }
...@@ -232,6 +230,11 @@ public class StrategyRepository implements IStrategyRepository { ...@@ -232,6 +230,11 @@ public class StrategyRepository implements IStrategyRepository {
@Override @Override
public Boolean subtractionAwardStock(String cacheKey) { public Boolean subtractionAwardStock(String cacheKey) {
return subtractionAwardStock(cacheKey, null);
}
@Override
public Boolean subtractionAwardStock(String cacheKey, Date endDateTime) {
long surplus = redisService.decr(cacheKey); long surplus = redisService.decr(cacheKey);
if (surplus < 0) { if (surplus < 0) {
// 库存小于0,恢复为0个 // 库存小于0,恢复为0个
...@@ -241,7 +244,13 @@ public class StrategyRepository implements IStrategyRepository { ...@@ -241,7 +244,13 @@ public class StrategyRepository implements IStrategyRepository {
// 1. 按照cacheKey decr 后的值,如 99、98、97 和 key 组成为库存锁的key进行使用。 // 1. 按照cacheKey decr 后的值,如 99、98、97 和 key 组成为库存锁的key进行使用。
// 2. 加锁为了兜底,如果后续有恢复库存,手动处理等,也不会超卖。因为所有的可用库存key,都被加锁了。 // 2. 加锁为了兜底,如果后续有恢复库存,手动处理等,也不会超卖。因为所有的可用库存key,都被加锁了。
String lockKey = cacheKey + Constants.UNDERLINE + surplus; String lockKey = cacheKey + Constants.UNDERLINE + surplus;
Boolean lock = redisService.setNx(lockKey); Boolean lock = false;
if (null != endDateTime) {
long expireMillis = endDateTime.getTime() - System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1);
lock = redisService.setNx(lockKey, expireMillis, TimeUnit.MILLISECONDS);
} else {
lock = redisService.setNx(lockKey);
}
if (!lock) { if (!lock) {
log.info("策略奖品库存加锁失败 {}", lockKey); log.info("策略奖品库存加锁失败 {}", lockKey);
} }
...@@ -319,4 +328,17 @@ public class StrategyRepository implements IStrategyRepository { ...@@ -319,4 +328,17 @@ public class StrategyRepository implements IStrategyRepository {
return raffleActivityAccountDay.getDayCount() - raffleActivityAccountDay.getDayCountSurplus(); return raffleActivityAccountDay.getDayCount() - raffleActivityAccountDay.getDayCountSurplus();
} }
@Override
public Map<String, Integer> queryAwardRuleLockCount(String[] treeIds) {
if (null == treeIds || treeIds.length == 0) return new HashMap<>();
List<RuleTreeNode> ruleTreeNodes = ruleTreeNodeDao.queryRuleLocks(treeIds);
Map<String, Integer> resultMap = new HashMap<>();
for (RuleTreeNode node : ruleTreeNodes) {
String treeId = node.getTreeId();
Integer ruleValue = Integer.valueOf(node.getRuleValue());
resultMap.put(treeId, ruleValue);
}
return resultMap;
}
} }
...@@ -114,6 +114,7 @@ public class RaffleActivityController implements IRaffleActivityService { ...@@ -114,6 +114,7 @@ public class RaffleActivityController implements IRaffleActivityService {
RaffleAwardEntity raffleAwardEntity = raffleStrategy.performRaffle(RaffleFactorEntity.builder() RaffleAwardEntity raffleAwardEntity = raffleStrategy.performRaffle(RaffleFactorEntity.builder()
.userId(orderEntity.getUserId()) .userId(orderEntity.getUserId())
.strategyId(orderEntity.getStrategyId()) .strategyId(orderEntity.getStrategyId())
.endDateTime(orderEntity.getEndDateTime())
.build()); .build());
// 4. 存放结果 - 写入中奖记录 // 4. 存放结果 - 写入中奖记录
......
package cn.bugstack.trigger.http; package cn.bugstack.trigger.http;
import cn.bugstack.domain.activity.service.IRaffleActivityAccountQuotaService;
import cn.bugstack.domain.strategy.model.entity.RaffleAwardEntity; import cn.bugstack.domain.strategy.model.entity.RaffleAwardEntity;
import cn.bugstack.domain.strategy.model.entity.RaffleFactorEntity; import cn.bugstack.domain.strategy.model.entity.RaffleFactorEntity;
import cn.bugstack.domain.strategy.model.entity.StrategyAwardEntity; import cn.bugstack.domain.strategy.model.entity.StrategyAwardEntity;
import cn.bugstack.domain.strategy.service.IRaffleAward; import cn.bugstack.domain.strategy.service.IRaffleAward;
import cn.bugstack.domain.strategy.service.IRaffleRule;
import cn.bugstack.domain.strategy.service.IRaffleStrategy; import cn.bugstack.domain.strategy.service.IRaffleStrategy;
import cn.bugstack.domain.strategy.service.armory.IStrategyArmory; import cn.bugstack.domain.strategy.service.armory.IStrategyArmory;
import cn.bugstack.trigger.api.IRaffleStrategyService; import cn.bugstack.trigger.api.IRaffleStrategyService;
...@@ -16,11 +18,13 @@ import cn.bugstack.types.exception.AppException; ...@@ -16,11 +18,13 @@ import cn.bugstack.types.exception.AppException;
import cn.bugstack.types.model.Response; import cn.bugstack.types.model.Response;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @author * @author
...@@ -36,9 +40,13 @@ public class RaffleStrategyController implements IRaffleStrategyService { ...@@ -36,9 +40,13 @@ public class RaffleStrategyController implements IRaffleStrategyService {
@Resource @Resource
private IRaffleAward raffleAward; private IRaffleAward raffleAward;
@Resource @Resource
private IRaffleRule raffleRule;
@Resource
private IRaffleStrategy raffleStrategy; private IRaffleStrategy raffleStrategy;
@Resource @Resource
private IStrategyArmory strategyArmory; private IStrategyArmory strategyArmory;
@Resource
private IRaffleActivityAccountQuotaService raffleActivityAccountQuotaService;
/** /**
* 策略装配,将策略信息装配到缓存中 * 策略装配,将策略信息装配到缓存中
...@@ -74,23 +82,41 @@ public class RaffleStrategyController implements IRaffleStrategyService { ...@@ -74,23 +82,41 @@ public class RaffleStrategyController implements IRaffleStrategyService {
* <a href="http://localhost:8091/api/v1/raffle/query_raffle_award_list">/api/v1/raffle/query_raffle_award_list</a> * <a href="http://localhost:8091/api/v1/raffle/query_raffle_award_list">/api/v1/raffle/query_raffle_award_list</a>
* 请求参数 raw json * 请求参数 raw json
* *
* @param requestDTO {"strategyId":1000001} * @param request {"strategyId":1000001}
* @return 奖品列表 * @return 奖品列表
*/ */
@RequestMapping(value = "query_raffle_award_list", method = RequestMethod.POST) @RequestMapping(value = "query_raffle_award_list", method = RequestMethod.POST)
@Override @Override
public Response<List<RaffleAwardListResponseDTO>> queryRaffleAwardList(@RequestBody RaffleAwardListRequestDTO requestDTO) { public Response<List<RaffleAwardListResponseDTO>> queryRaffleAwardList(@RequestBody RaffleAwardListRequestDTO request) {
try { try {
log.info("查询抽奖奖品列表配开始 strategyId:{}", requestDTO.getStrategyId()); log.info("查询抽奖奖品列表配开始 userId:{} activityId:{}", request.getUserId(), request.getActivityId());
// 查询奖品配置 // 1. 参数校验
List<StrategyAwardEntity> strategyAwardEntities = raffleAward.queryRaffleStrategyAwardList(requestDTO.getStrategyId()); if (StringUtils.isBlank(request.getUserId()) || null == request.getActivityId()) {
throw new AppException(ResponseCode.ILLEGAL_PARAMETER.getCode(), ResponseCode.ILLEGAL_PARAMETER.getInfo());
}
// 2. 查询奖品配置
List<StrategyAwardEntity> strategyAwardEntities = raffleAward.queryRaffleStrategyAwardListByActivityId(request.getActivityId());
// 3. 获取规则配置
String[] treeIds = strategyAwardEntities.stream()
.map(StrategyAwardEntity::getRuleModels)
.filter(ruleModel -> ruleModel != null && !ruleModel.isEmpty())
.toArray(String[]::new);
// 4. 查询规则配置 - 获取奖品的解锁限制,抽奖N次后解锁
Map<String, Integer> ruleLockCountMap = raffleRule.queryAwardRuleLockCount(treeIds);
// 5. 查询抽奖次数 - 用户已经参与的抽奖次数
Integer dayPartakeCount = raffleActivityAccountQuotaService.queryRaffleActivityAccountDayPartakeCount(request.getActivityId(), request.getUserId());
// 6. 遍历填充数据
List<RaffleAwardListResponseDTO> raffleAwardListResponseDTOS = new ArrayList<>(strategyAwardEntities.size()); List<RaffleAwardListResponseDTO> raffleAwardListResponseDTOS = new ArrayList<>(strategyAwardEntities.size());
for (StrategyAwardEntity strategyAward : strategyAwardEntities) { for (StrategyAwardEntity strategyAward : strategyAwardEntities) {
Integer awardRuleLockCount = ruleLockCountMap.get(strategyAward.getRuleModels());
raffleAwardListResponseDTOS.add(RaffleAwardListResponseDTO.builder() raffleAwardListResponseDTOS.add(RaffleAwardListResponseDTO.builder()
.awardId(strategyAward.getAwardId()) .awardId(strategyAward.getAwardId())
.awardTitle(strategyAward.getAwardTitle()) .awardTitle(strategyAward.getAwardTitle())
.awardSubtitle(strategyAward.getAwardSubtitle()) .awardSubtitle(strategyAward.getAwardSubtitle())
.sort(strategyAward.getSort()) .sort(strategyAward.getSort())
.awardRuleLockCount(awardRuleLockCount)
.isAwardUnlock(null == awardRuleLockCount || dayPartakeCount >= awardRuleLockCount)
.waitUnLockCount(null == awardRuleLockCount || awardRuleLockCount <= dayPartakeCount ? 0 : awardRuleLockCount - dayPartakeCount)
.build()); .build());
} }
Response<List<RaffleAwardListResponseDTO>> response = Response.<List<RaffleAwardListResponseDTO>>builder() Response<List<RaffleAwardListResponseDTO>> response = Response.<List<RaffleAwardListResponseDTO>>builder()
...@@ -98,11 +124,11 @@ public class RaffleStrategyController implements IRaffleStrategyService { ...@@ -98,11 +124,11 @@ public class RaffleStrategyController implements IRaffleStrategyService {
.info(ResponseCode.SUCCESS.getInfo()) .info(ResponseCode.SUCCESS.getInfo())
.data(raffleAwardListResponseDTOS) .data(raffleAwardListResponseDTOS)
.build(); .build();
log.info("查询抽奖奖品列表配置完成 strategyId:{} response: {}", requestDTO.getStrategyId(), JSON.toJSONString(response)); log.info("查询抽奖奖品列表配置完成 userId:{} activityId:{} response: {}", request.getUserId(), request.getActivityId(), JSON.toJSONString(response));
// 返回结果 // 返回结果
return response; return response;
} catch (Exception e) { } catch (Exception e) {
log.error("查询抽奖奖品列表配置失败 strategyId:{}", requestDTO.getStrategyId(), e); log.error("查询抽奖奖品列表配置失败 userId:{} activityId:{}", request.getUserId(), request.getActivityId(), e);
return Response.<List<RaffleAwardListResponseDTO>>builder() return Response.<List<RaffleAwardListResponseDTO>>builder()
.code(ResponseCode.UN_ERROR.getCode()) .code(ResponseCode.UN_ERROR.getCode())
.info(ResponseCode.UN_ERROR.getInfo()) .info(ResponseCode.UN_ERROR.getInfo())
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册