From 7cbcf3d0f37efb3ff371248b8dd492810627b0c5 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Tue, 23 Sep 2025 19:35:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AD=BE=E5=88=B0=E5=A5=96=E5=8A=B1=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other/app/command/task/CheckInExe.java | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/CheckInExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/CheckInExe.java index b697c2c9..8becb5b6 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/CheckInExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/CheckInExe.java @@ -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 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());