签到奖励处理

This commit is contained in:
tianfeng 2025-09-23 19:35:30 +08:00
parent 42cbade98c
commit 7cbcf3d0f3

View File

@ -6,15 +6,22 @@ import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.framework.core.response.CommonErrorCode; import com.red.circle.framework.core.response.CommonErrorCode;
import com.red.circle.other.app.dto.cmd.task.CheckInRewardCmd; import com.red.circle.other.app.dto.cmd.task.CheckInRewardCmd;
import com.red.circle.other.infra.common.activity.PropsActivitySendCommon; import com.red.circle.other.infra.common.activity.PropsActivitySendCommon;
import com.red.circle.other.infra.common.activity.send.SendRewardGroup; import com.red.circle.other.infra.common.props.PropsSendCommon;
import com.red.circle.other.infra.database.cache.service.other.CheckInCacheService; import com.red.circle.other.infra.database.cache.service.other.CheckInCacheService;
import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRewardConfig;
import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRuleConfig; import com.red.circle.other.infra.database.rds.entity.activity.PropsActivityRuleConfig;
import com.red.circle.other.infra.database.rds.service.activity.PropsActivityRewardConfigService;
import com.red.circle.other.infra.database.rds.service.activity.PropsActivityRuleConfigService; import com.red.circle.other.infra.database.rds.service.activity.PropsActivityRuleConfigService;
import com.red.circle.other.inner.asserts.GameErrorCode; import com.red.circle.other.inner.asserts.GameErrorCode;
import com.red.circle.tool.core.date.ZonedDateTimeUtils; import com.red.circle.other.inner.model.cmd.material.PrizeDescribe;
import com.red.circle.other.inner.model.cmd.material.PrizeDescribeRewardCmd;
import com.red.circle.other.infra.utils.ZonedDateTimeUtils;
import com.red.circle.tool.core.date.ZonedId; import com.red.circle.tool.core.date.ZonedId;
import java.time.Duration; import java.time.Duration;
import java.util.Collections;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -31,6 +38,8 @@ public class CheckInExe {
private final CheckInCacheService checkInCacheService; private final CheckInCacheService checkInCacheService;
private final PropsActivitySendCommon propsActivitySendCommon; private final PropsActivitySendCommon propsActivitySendCommon;
private final PropsActivityRuleConfigService propsActivityRuleConfigService; private final PropsActivityRuleConfigService propsActivityRuleConfigService;
private final PropsActivityRewardConfigService propsActivityRewardConfigService;
private final PropsSendCommon propsSendCommon;
public Integer execute(CheckInRewardCmd cmd) { public Integer execute(CheckInRewardCmd cmd) {
@ -52,16 +61,41 @@ public class CheckInExe {
Objects.equals(checkInCacheService.getCheckInDays(cmd.getReqUserId()), 7)); Objects.equals(checkInCacheService.getCheckInDays(cmd.getReqUserId()), 7));
// 累计打卡天数 // 累计打卡天数
checkInCacheService.incrCheckInDays(cmd.getReqUserId(), getExpiredTime(cmd)); Long inDays = checkInCacheService.incrCheckInDays(cmd.getReqUserId(), getExpiredTime(cmd));
checkInCacheService.markDailyCheckIn(cmd.getReqUserId()); checkInCacheService.markDailyCheckIn(cmd.getReqUserId());
/* 不再根据资源组发根据资源组顺序一个一个发
propsActivitySendCommon.sendActivityGroup(SendRewardGroup.builder() propsActivitySendCommon.sendActivityGroup(SendRewardGroup.builder()
.trackId(cmd.getId()) .trackId(cmd.getId())
.sysOrigin(cmd.requireReqSysOriginEnum()) .sysOrigin(cmd.requireReqSysOriginEnum())
.acceptUserId(cmd.getReqUserId()) .acceptUserId(cmd.getReqUserId())
.resourceGroupId(cmd.getResourceGroupId()) .resourceGroupId(cmd.getResourceGroupId())
.origin(SendPropsOrigin.DAILY_REGISTER) .origin(SendPropsOrigin.DAILY_REGISTER)
.build()); .build());*/
List<PropsActivityRewardConfig> configs = propsActivityRewardConfigService.listByGroupId(cmd.getResourceGroupId());
ResponseAssert.notEmpty(CommonErrorCode.NOT_FOUND_MAPPING_INFO, configs);
// 根据星期几获取对应的奖品配置星期几就是第几个配置索引需要减1
int configIndex = Math.min(inDays.intValue() - 1, configs.size() - 1);
ResponseAssert.isTrue(CommonErrorCode.NOT_FOUND_MAPPING_INFO, configIndex >= 0 && configIndex < configs.size());
PropsActivityRewardConfig config = configs.get(configIndex);
propsSendCommon.send(new PrizeDescribeRewardCmd()
.setTrackId(cmd.getId())
.setAcceptUserId(cmd.getReqUserId())
.setOrigin(SendPropsOrigin.DAILY_REGISTER)
.setSysOrigin(cmd.requireReqSysOriginEnum())
.setPrizes(Collections.singletonList(new PrizeDescribe()
.setTrackId(config.getGroupId())
.setType(config.getType())
.setDetailType(config.getDetailType())
.setContent(config.getContent())
.setQuantity(config.getQuantity())))
);
return checkInCacheService.getCheckInDays(cmd.getReqUserId()); return checkInCacheService.getCheckInDays(cmd.getReqUserId());