奖励领取接口处理

This commit is contained in:
tianfeng 2025-12-31 16:07:10 +08:00
parent 0723bb5f8c
commit c0c4a89a61
3 changed files with 30 additions and 4 deletions

View File

@ -274,6 +274,8 @@ public enum SendPropsOrigin {
*/
COUPON_EXCHANGE("Coupon Exchange"),
LUCK_DOLLAR_REWARD("Luck Dollar Rewards"),
;
private final String desc;

View File

@ -51,8 +51,9 @@ public class ActivityRewardConfigQryExe {
Map<Long, UserActivityRewardClaim> claimMap = getUserClaimMap(cmd.getReqUserId(), ruleIds);
BigDecimal userTotalAmount = userActivityRechargeService.getUserTotalAmount(
cmd.getActivityId(),
cmd.getReqUserId()
cmd.getReqUserId(),
cmd.getActivityId()
);
if (Objects.isNull(userTotalAmount)) {
userTotalAmount = BigDecimal.ZERO;

View File

@ -3,6 +3,7 @@ package com.red.circle.other.app.command.activity;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.red.circle.common.business.core.enums.SysOriginPlatformEnum;
import com.red.circle.common.business.enums.SendPropsOrigin;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.other.app.dto.clientobject.activity.ClaimRewardResultCO;
@ -16,9 +17,13 @@ import com.red.circle.other.infra.database.rds.service.activity.UserActivityRech
import com.red.circle.other.infra.database.rds.service.user.device.LatestMobileDeviceService;
import com.red.circle.other.inner.asserts.OtherErrorCode;
import com.red.circle.other.inner.endpoint.activity.LotteryTicketClient;
import com.red.circle.other.inner.endpoint.activity.PropsActivityClient;
import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum;
import com.red.circle.other.inner.model.cmd.activity.SendActivityRewardCmd;
import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsGroup;
import com.red.circle.other.inner.model.dto.activity.props.ActivityPropsRule;
import com.red.circle.other.inner.asserts.DynamicErrorCode;
import com.red.circle.other.inner.model.dto.activity.props.ActivityRewardProps;
import com.red.circle.tool.core.date.TimestampUtils;
import com.red.circle.tool.core.json.JacksonUtils;
import lombok.RequiredArgsConstructor;
@ -46,6 +51,7 @@ public class ClaimActivityRewardExe {
private final LotteryTicketClient lotteryTicketClient;
private final LatestMobileDeviceService latestMobileDeviceService;
private final LotteryDeviceRecordService lotteryDeviceRecordService;
private final PropsActivityClient propsActivityClient;
@Transactional(rollbackFor = Exception.class)
public ClaimRewardResultCO execute(ClaimActivityRewardCmd cmd) {
@ -75,8 +81,8 @@ public class ClaimActivityRewardExe {
ResponseAssert.notNull(DynamicErrorCode.NO_RELATED_INFORMATION_FOUND, requiredAmount);
BigDecimal userTotalAmount = userActivityRechargeService.getUserTotalAmount(
cmd.getActivityId(),
cmd.getReqUserId()
cmd.getReqUserId(),
cmd.getActivityId()
);
ResponseAssert.isFalse(OtherErrorCode.USER_RECHARGE_INVALID, Objects.isNull(userTotalAmount) || userTotalAmount.compareTo(requiredAmount) < 0);
@ -111,6 +117,23 @@ public class ClaimActivityRewardExe {
userActivityRewardClaimDAO.insert(claim);
ActivityPropsGroup group = activitySourceGroupGateway.getActivityPropsGroup(
sysOrigin.name(),
ruleConfigs.get(0).getResourceGroupId()
);
List<ActivityRewardProps> activityRewardProps = group.getActivityRewardProps();
ResponseAssert.isFalse(DynamicErrorCode.NO_RELATED_INFORMATION_FOUND, activityRewardProps.isEmpty());
ActivityRewardProps rewardProps = activityRewardProps.get(0);
propsActivityClient.sendActivityReward(new SendActivityRewardCmd()
.setTrackId(cmd.getActivityId())
.setOrigin(SendPropsOrigin.LUCK_DOLLAR_REWARD)
.setSysOrigin(SysOriginPlatformEnum.valueOf(cmd.getReqSysOrigin().getOrigin()))
.setSourceGroupId(rewardProps.getGroupId())
.setAcceptUserId(cmd.getReqUserId())
);
return new ClaimRewardResultCO()
.setSuccess(true)
.setLotteryTicketIds(ticketIds);