签到奖励处理
This commit is contained in:
parent
42cbade98c
commit
7cbcf3d0f3
@ -6,15 +6,22 @@ import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||
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.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.rds.entity.activity.PropsActivityRewardConfig;
|
||||
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.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 java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -31,6 +38,8 @@ public class CheckInExe {
|
||||
private final CheckInCacheService checkInCacheService;
|
||||
private final PropsActivitySendCommon propsActivitySendCommon;
|
||||
private final PropsActivityRuleConfigService propsActivityRuleConfigService;
|
||||
private final PropsActivityRewardConfigService propsActivityRewardConfigService;
|
||||
private final PropsSendCommon propsSendCommon;
|
||||
|
||||
public Integer execute(CheckInRewardCmd cmd) {
|
||||
|
||||
@ -52,16 +61,41 @@ public class CheckInExe {
|
||||
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());
|
||||
|
||||
/* 不再根据资源组发,根据资源组顺序一个一个发
|
||||
propsActivitySendCommon.sendActivityGroup(SendRewardGroup.builder()
|
||||
.trackId(cmd.getId())
|
||||
.sysOrigin(cmd.requireReqSysOriginEnum())
|
||||
.acceptUserId(cmd.getReqUserId())
|
||||
.resourceGroupId(cmd.getResourceGroupId())
|
||||
.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());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user