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

用户领取活动扣减账户额度,并写入中奖记录和MQ消息消费队列

上级 42280b6e
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-19.13:13:59.192 [main ] INFO LogicChainTest - Starting LogicChainTest using Java 1.8.0_412 on zhaoyongfeng with PID 19480 (started by zhaoyongfeng in C:\Users\31126\Desktop\study\xfg-frame-archetype-lite\xfg-frame-archetype-lite-app)
24-11-19.13:13:59.193 [main ] INFO LogicChainTest - The following 1 profile is active: "dev"
24-11-19.13:14:00.369 [main ] INFO RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode
24-11-19.13:14:00.374 [main ] INFO RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode.
24-11-19.13:14:00.444 [main ] INFO RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 51 ms. Found 0 Redis repository interfaces.
24-11-19.13:14:03.216 [main ] INFO Version - Redisson 3.23.4
24-11-19.13:14:04.813 [redisson-netty-2-4] INFO MasterPubSubConnectionPool - 1 connections initialized for 127.0.0.1/127.0.0.1:6379
24-11-19.13:14:04.827 [redisson-netty-2-13] INFO MasterConnectionPool - 5 connections initialized for 127.0.0.1/127.0.0.1:6379
24-11-19.13:14:07.367 [main ] INFO EndpointLinksResolver - Exposing 1 endpoint(s) beneath base path '/actuator'
24-11-19.13:14:07.463 [main ] INFO LogicChainTest - Started LogicChainTest in 8.931 seconds (JVM running for 10.393)
24-11-19.13:14:08.109 [main ] INFO HikariDataSource - HikariPool-1 - Starting...
24-11-19.13:14:08.484 [main ] INFO HikariDataSource - HikariPool-1 - Start completed.
24-11-19.13:14:08.562 [main ] INFO LogicChainTest - 测试结果:true
24-11-19.13:14:08.566 [main ] INFO RuleWeightLogicChain - 抽奖责任链-权重开始 userId: xiaofuge strategyId: 100001 ruleModel: rule_weight
24-11-19.13:14:08.596 [main ] INFO RuleWeightLogicChain - 抽奖责任链-权重接管 userId: xiaofuge strategyId: 100001 ruleModel: rule_weight awardId: 102
24-11-19.13:14:08.596 [main ] INFO LogicChainTest - 测试结果:102
24-11-19.13:14:08.639 [SpringApplicationShutdownHook] INFO HikariDataSource - HikariPool-1 - Shutdown initiated...
24-11-19.13:14:08.648 [SpringApplicationShutdownHook] INFO HikariDataSource - HikariPool-1 - Shutdown completed.
此差异已折叠。
此差异已折叠。
...@@ -25,6 +25,7 @@ spring: ...@@ -25,6 +25,7 @@ spring:
prefetch: 1 # 每次投递n个消息,消费完在投递n个 prefetch: 1 # 每次投递n个消息,消费完在投递n个
topic: topic:
activity_sku_stock_zero: activity_sku_stock_zero activity_sku_stock_zero: activity_sku_stock_zero
send_award: send_award
# 线程池配置 # 线程池配置
thread: thread:
pool: pool:
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.bugstack.infrastructure.persistent.dao.IUserAwardRecordDao">
<insert id="insert" parameterType="cn.bugstack.infrastructure.persistent.po.UserAwardRecord"></insert>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.bugstack.infrastructure.persistent.dao.IRaffleActivityAccountDayDao">
<resultMap id="dataMap" type="cn.bugstack.infrastructure.persistent.po.RaffleActivityAccountDay">
<id column="id" property="id"/>
<result column="user_id" property="userId"/>
<result column="activity_id" property="activityId"/>
<result column="day" property="day"/>
<result column="day_count" property="dayCount"/>
<result column="day_count_surplus" property="dayCountSurplus"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
</resultMap>
<insert id="insertActivityAccountDay" parameterType="cn.bugstack.infrastructure.persistent.po.RaffleActivityAccountDay">
insert into raffle_activity_account_day(
user_id, activity_id, day, day_count, day_count_surplus, create_time, update_time)
values
(#{userId}, #{activityId}, #{day}, #{dayCount}, #{dayCountSurplus}, now(), now())
</insert>
<update id="updateActivityAccountDaySubtractionQuota" parameterType="cn.bugstack.infrastructure.persistent.po.RaffleActivityAccountDay">
update raffle_activity_account_day
set day_count_surplus = day_count_surplus - 1, update_time = now()
where user_id = #{userId} and activity_id = #{activityId} and day = #{day} and day_count_surplus > 0
</update>
<select id="queryActivityAccountDayByUserId" parameterType="cn.bugstack.infrastructure.persistent.po.RaffleActivityAccountDay" resultMap="dataMap">
select user_id, activity_id, day, day_count, day_count_surplus
from raffle_activity_account_day
where user_id = #{userId} and activity_id = #{activityId} and day = #{day}
</select>
</mapper>
...@@ -38,4 +38,32 @@ ...@@ -38,4 +38,32 @@
where user_id = #{userId} and activity_id = #{activityId} where user_id = #{userId} and activity_id = #{activityId}
</update> </update>
<select id="queryActivityAccountByUserId" parameterType="cn.bugstack.infrastructure.persistent.po.RaffleActivityAccount" resultMap="dataMap">
select user_id, activity_id, total_count, total_count_surplus, day_count,
day_count_surplus, month_count, month_count_surplus
from raffle_activity_account
where user_id = #{userId} and activity_id = #{activityId}
</select>
<update id="updateActivityAccountSubtractionQuota" parameterType="cn.bugstack.infrastructure.persistent.po.RaffleActivityAccount">
update raffle_activity_account
set total_count_surplus = total_count_surplus - 1,
day_count_surplus = day_count_surplus - 1,
month_count_surplus = month_count_surplus - 1,
update_time = now()
where user_id = #{userId} and activity_id = #{activityId} and total_count_surplus > 0 and day_count_surplus > 0 and month_count_surplus > 0
</update>
<update id="updateActivityAccountMonthSurplusImageQuota" parameterType="cn.bugstack.infrastructure.persistent.po.RaffleActivityAccount">
update raffle_activity_account
set month_count_surplus = #{monthCountSurplus} - 1, update_time = now()
where user_id = #{userId} and activity_id = #{activityId}
</update>
<update id="updateActivityAccountDaySurplusImageQuota" parameterType="cn.bugstack.infrastructure.persistent.po.RaffleActivityAccountDay">
update raffle_activity_account
set day_count_surplus = #{dayCountSurplus} - 1, update_time = now()
where user_id = #{userId} and activity_id = #{activityId}
</update>
</mapper> </mapper>
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<mapper namespace="cn.bugstack.infrastructure.persistent.dao.IRaffleActivitySkuDao"> <mapper namespace="cn.bugstack.infrastructure.persistent.dao.IRaffleActivitySkuDao">
<resultMap id="dataMap" type="cn.bugstack.infrastructure.persistent.po.RaffleActivitySku"> <resultMap id="dataMap" type="cn.bugstack.infrastructure.persistent.po.RaffleActivitySku">
<id column="id" property="id"/>
<result column="sku" property="sku"/> <result column="sku" property="sku"/>
<result column="activity_id" property="activityId"/> <result column="activity_id" property="activityId"/>
<result column="activity_count_id" property="activityCountId"/> <result column="activity_count_id" property="activityCountId"/>
......
package cn.bugstack.test.domain.activity;
import cn.bugstack.domain.activity.model.entity.PartakeRaffleActivityEntity;
import cn.bugstack.domain.activity.model.entity.UserRaffleOrderEntity;
import cn.bugstack.domain.activity.service.IRaffleActivityPartakeService;
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 zyf
* @description 抽奖活动订单单测
* @create 2024-03-16 11:51
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest
public class RaffleActivityPartakeServiceTest {
@Resource
private IRaffleActivityPartakeService raffleActivityPartakeService;
@Test
public void test_createOrder() {
// 请求参数
PartakeRaffleActivityEntity partakeRaffleActivityEntity = new PartakeRaffleActivityEntity();
partakeRaffleActivityEntity.setUserId("xiaofuge");
partakeRaffleActivityEntity.setActivityId(100301L);
// 调用接口
UserRaffleOrderEntity userRaffleOrder = raffleActivityPartakeService.createOrder(partakeRaffleActivityEntity);
log.info("请求参数:{}", JSON.toJSONString(partakeRaffleActivityEntity));
log.info("测试结果:{}", JSON.toJSONString(userRaffleOrder));
}
}
...@@ -6,10 +6,8 @@ import cn.bugstack.domain.activity.model.valobj.ActivitySkuStockKeyVO; ...@@ -6,10 +6,8 @@ import cn.bugstack.domain.activity.model.valobj.ActivitySkuStockKeyVO;
* @return * @return
* @author zhaoyongfeng * @author zhaoyongfeng
* @description 活动sku库存处理接口 * @description 活动sku库存处理接口
*
* @param null
*/ */
public interface ISkuStock { public interface IRaffleActivitySkuStockService {
/** /**
* 获取活动sku库存消耗队列 * 获取活动sku库存消耗队列
* *
......
package cn.bugstack.domain.activity.service.rule; package cn.bugstack.domain.activity.service.quota.rule;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
......
package cn.bugstack.domain.activity.service.rule; package cn.bugstack.domain.activity.service.quota.rule;
import cn.bugstack.domain.activity.model.entity.ActivityCountEntity; import cn.bugstack.domain.activity.model.entity.ActivityCountEntity;
import cn.bugstack.domain.activity.model.entity.ActivityEntity; import cn.bugstack.domain.activity.model.entity.ActivityEntity;
......
package cn.bugstack.domain.activity.service.rule; package cn.bugstack.domain.activity.service.quota.rule;
/** /**
* @author Fuzhengwei bugstack.cn @小傅哥 * @author Fuzhengwei bugstack.cn @小傅哥
......
package cn.bugstack.domain.award.model.valobj;
import lombok.AllArgsConstructor;
import lombok.Getter;
/*
* @author zhaoyongfeng
* @description 奖品状态枚举值对象
*/
@Getter
@AllArgsConstructor
public enum AwardStateVO {
create("create", "创建"),
complete("complete", "发奖完成"),
fail("fail", "发奖失败"),
;
private final String code;
private final String desc;
}
/**
* 外部接口适配器层;当需要调用外部接口时,则创建出这一层,并定义接口,之后由基础设施层的 adapter 层具体实现
*/
package cn.bugstack.domain.xxx.adapter.port;
\ No newline at end of file
package cn.bugstack.infrastructure.persistent.dao; package cn.bugstack.infrastructure.persistent.dao;
import cn.bugstack.domain.activity.model.entity.ActivityCountEntity;
import cn.bugstack.infrastructure.persistent.po.RaffleActivityCount; import cn.bugstack.infrastructure.persistent.po.RaffleActivityCount;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
......
...@@ -11,7 +11,6 @@ import java.util.Date; ...@@ -11,7 +11,6 @@ import java.util.Date;
*/ */
@Data @Data
public class RaffleActivitySku { public class RaffleActivitySku {
/** /**
* 商品sku * 商品sku
*/ */
......
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId> <artifactId>spring-boot-starter-amqp</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.bugstack.middleware</groupId>
<artifactId>db-router-spring-boot-starter</artifactId>
</dependency>
<!-- 系统模块 --> <!-- 系统模块 -->
<dependency> <dependency>
<groupId>cn.bugstack</groupId> <groupId>cn.bugstack</groupId>
...@@ -45,6 +49,7 @@ ...@@ -45,6 +49,7 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册