diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/activity/PropsActivityTypeEnum.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/activity/PropsActivityTypeEnum.java index ce0af4f7..03516a16 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/activity/PropsActivityTypeEnum.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/enums/activity/PropsActivityTypeEnum.java @@ -97,6 +97,8 @@ public enum PropsActivityTypeEnum { */ DAILY_REGISTER, + DAILY_REGISTER_AZIZI, + /** * 幸运礼物抽奖. */ diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/sys/task/CheckInRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/sys/task/CheckInRestController.java index 38ab18c7..d32be29b 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/sys/task/CheckInRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/sys/task/CheckInRestController.java @@ -1,12 +1,17 @@ package com.red.circle.other.adapter.app.sys.task; +import com.alibaba.nacos.common.utils.StringUtils; import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.framework.web.controller.BaseController; import com.red.circle.other.app.dto.clientobject.task.CheckInRewardListCO; import com.red.circle.other.app.dto.cmd.task.CheckInRewardCmd; import com.red.circle.other.app.service.task.CheckInService; +import com.red.circle.other.infra.database.cache.key.CheckInKeys; +import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; import com.red.circle.other.inner.model.dto.activity.props.ActivityRewardPropsDTO; import java.util.List; + +import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; import lombok.RequiredArgsConstructor; import org.springframework.http.MediaType; import org.springframework.validation.annotation.Validated; @@ -39,24 +44,12 @@ public class CheckInRestController extends BaseController { * @eo.method get * @eo.request-type formdata */ + @Deprecated @GetMapping("/list/award/pool") public List listRewardPool(AppExtCommand cmd) { return checkInService.listRewardPool(cmd); } - /** - * ASWAT新打卡-今天是否已签到. - * - * @eo.name ASWAT新打卡-今天是否已签到. - * @eo.url /today - * @eo.method get - * @eo.request-type formdata - */ - @GetMapping("/today") - public Boolean checkToday(AppExtCommand cmd) { - return checkInService.checkToday(cmd); - } - /** * ASWAT新打卡-抽奖. * @@ -65,61 +58,44 @@ public class CheckInRestController extends BaseController { * @eo.method post * @eo.request-type formdata */ + @Deprecated @PostMapping("/lottery") public ActivityRewardPropsDTO lottery(AppExtCommand cmd) { return checkInService.lottery(cmd); } /** - * 2FUN每日签到奖励列表. - * - * @eo.name ASWAT新打卡-今天是否已签到. - * @eo.url /2fun/list/award - * @eo.method get - * @eo.request-type formdata + * 今天是否已签到. */ - @GetMapping("/2fun/list/award") - public CheckInRewardListCO listReward(AppExtCommand cmd) { - return checkInService.listReward(cmd); - } - - /** - * 2FUN打卡-领取奖励. - * - * @eo.name ASWAT新打卡-今天是否已签到. - * @eo.url /2fun - * @eo.method post - * @eo.request-type json - */ - @PostMapping("/2fun") - public Integer checkIn2Fun(@RequestBody @Validated CheckInRewardCmd cmd) { - return checkInService.checkIn2Fun(cmd); + @GetMapping("/today") + public Boolean checkToday(AppExtCommand cmd, String dailyKey) { + if (StringUtils.isBlank(dailyKey)) { + dailyKey = CheckInKeys.DAILY_CHECK_IN.getKey("DAILY_CHECK_IN_" + cmd.getReqUserId() + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt()); + } else { + dailyKey = CheckInKeys.AZIZI_CHECK_IN.getKey("AZIZI_CHECK_IN" + cmd.getReqUserId() + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt()); + } + return checkInService.checkToday(cmd, dailyKey); } /** * 每日签到奖励列表. - * - * @eo.name YOLO新打卡-今天是否已签到. - * @eo.url /2fun/list/award - * @eo.method get - * @eo.request-type formdata */ @GetMapping("/list/award") - public CheckInRewardListCO listRewardYolo(AppExtCommand cmd) { - return checkInService.listReward(cmd); + public CheckInRewardListCO listRewardYolo(AppExtCommand cmd, PropsActivityTypeEnum activityType) { + if (activityType == null) { + activityType = PropsActivityTypeEnum.DAILY_REGISTER; + } else { + activityType = PropsActivityTypeEnum.DAILY_REGISTER_AZIZI; + } + return checkInService.listReward(cmd, activityType); } /** * 打卡-领取奖励. - * - * @eo.name YOLO新打卡-今天是否已签到. - * @eo.url /2fun - * @eo.method post - * @eo.request-type json */ @PostMapping("/receive") - public Integer checkInYolo(@RequestBody @Validated CheckInRewardCmd cmd) { - return checkInService.checkIn2Fun(cmd); + public Integer receive(@RequestBody @Validated CheckInRewardCmd cmd) { + return checkInService.receive(cmd); } 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 8becb5b6..1a9a21b5 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 @@ -1,5 +1,6 @@ package com.red.circle.other.app.command.task; +import com.alibaba.nacos.common.utils.StringUtils; import com.red.circle.common.business.enums.SendPropsOrigin; import com.red.circle.component.redis.service.RedisService; import com.red.circle.framework.core.asserts.ResponseAssert; @@ -7,6 +8,7 @@ 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.props.PropsSendCommon; +import com.red.circle.other.infra.database.cache.key.CheckInKeys; 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; @@ -16,6 +18,7 @@ import com.red.circle.other.inner.asserts.GameErrorCode; 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.ZonedDateTimeAsiaRiyadhUtils; import com.red.circle.tool.core.date.ZonedId; import java.time.Duration; import java.util.Collections; @@ -42,6 +45,12 @@ public class CheckInExe { private final PropsSendCommon propsSendCommon; public Integer execute(CheckInRewardCmd cmd) { + if (StringUtils.isBlank(cmd.getDailyKey())) { + cmd.setDailyKey(CheckInKeys.DAILY_CHECK_IN.getKey("DAILY_CHECK_IN_" + cmd.getReqUserId() + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt())); + } else { + cmd.setDailyKey(CheckInKeys.AZIZI_CHECK_IN.getKey("AZIZI_CHECK_IN" + cmd.getReqUserId() + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt())); + } + PropsActivityRuleConfig ruleConfig = propsActivityRuleConfigService.getById(cmd.getId()); // 1034 没有找到映射信息 @@ -55,14 +64,14 @@ public class CheckInExe { redisService.lock(lockKey, 30)); ResponseAssert.isFalse(GameErrorCode.CHECKED_IN, - checkInCacheService.checkDailyCheckIn(cmd.getReqUserId())); + checkInCacheService.checkDailyCheckIn(cmd.getReqUserId(), cmd.getDailyKey())); ResponseAssert.isFalse(GameErrorCode.CHECKED_IN, Objects.equals(checkInCacheService.getCheckInDays(cmd.getReqUserId()), 7)); // 累计打卡天数 Long inDays = checkInCacheService.incrCheckInDays(cmd.getReqUserId(), getExpiredTime(cmd)); - checkInCacheService.markDailyCheckIn(cmd.getReqUserId()); + checkInCacheService.markDailyCheckIn(cmd.getReqUserId(), cmd.getDailyKey()); /* 不再根据资源组发,根据资源组顺序一个一个发 propsActivitySendCommon.sendActivityGroup(SendRewardGroup.builder() diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/query/CheckInLotteryQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/query/CheckInLotteryQryExe.java index 0e69048b..1dff0c0c 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/query/CheckInLotteryQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/query/CheckInLotteryQryExe.java @@ -45,7 +45,7 @@ public class CheckInLotteryQryExe { public ActivityRewardPropsDTO execute(AppExtCommand cmd) { ResponseAssert.isTrue(UserErrorCode.PROCESSED_TODAY, - Objects.equals(checkInCacheService.markDailyCheckIn(cmd.getReqUserId()), + Objects.equals(checkInCacheService.markDailyCheckIn(cmd.getReqUserId(), ""), Boolean.TRUE)); return sendRandomCheckInActivityProps( diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/query/CheckInRewardQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/query/CheckInRewardQryExe.java index 30a266a5..04894738 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/query/CheckInRewardQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/query/CheckInRewardQryExe.java @@ -25,12 +25,12 @@ public class CheckInRewardQryExe { private final CheckInCacheService checkInCacheService; private final ActivitySourceGroupGateway activitySourceGroupGateway; - public CheckInRewardListCO execute(AppExtCommand cmd) { + public CheckInRewardListCO execute(AppExtCommand cmd, PropsActivityTypeEnum activityType) { List rewards = propsMaterialAppConvertor .toActivityResourceCOList(activitySourceGroupGateway .listActivityResource(cmd.requireReqSysOriginEnum(), - PropsActivityTypeEnum.DAILY_REGISTER)); + activityType)); return new CheckInRewardListCO() .setDays(Optional.ofNullable(checkInCacheService.getCheckInDays(cmd.getReqUserId())) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/CheckInServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/CheckInServiceImpl.java index 5290e869..9c838d8c 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/CheckInServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/CheckInServiceImpl.java @@ -39,8 +39,8 @@ public class CheckInServiceImpl implements CheckInService { } @Override - public Boolean checkToday(AppExtCommand cmd) { - return checkInCacheService.checkDailyCheckIn(cmd.getReqUserId()); + public Boolean checkToday(AppExtCommand cmd, String dailyKey) { + return checkInCacheService.checkDailyCheckIn(cmd.getReqUserId(), dailyKey); } @Override @@ -49,8 +49,8 @@ public class CheckInServiceImpl implements CheckInService { } @Override - public CheckInRewardListCO listReward(AppExtCommand cmd) { - CheckInRewardListCO checkInRewardListCO = checkInRewardQryExe.execute(cmd); + public CheckInRewardListCO listReward(AppExtCommand cmd, PropsActivityTypeEnum activityType) { + CheckInRewardListCO checkInRewardListCO = checkInRewardQryExe.execute(cmd, activityType); List rewards = checkInRewardListCO.getRewards(); rewards.forEach(p->{ if (p.getPropsGroup() != null){ @@ -68,7 +68,7 @@ public class CheckInServiceImpl implements CheckInService { } @Override - public Integer checkIn2Fun(CheckInRewardCmd cmd) { + public Integer receive(CheckInRewardCmd cmd) { return checkInExe.execute(cmd); } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/task/CheckInRewardCmd.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/task/CheckInRewardCmd.java index d871b0d9..ea0d2c05 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/task/CheckInRewardCmd.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/dto/cmd/task/CheckInRewardCmd.java @@ -26,4 +26,6 @@ public class CheckInRewardCmd extends AppExtCommand { @NotNull(message = "resourceGroupId required.") private Long resourceGroupId; + private String dailyKey; + } diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/task/CheckInService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/task/CheckInService.java index a3300d26..f7707a6c 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/task/CheckInService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/task/CheckInService.java @@ -3,6 +3,7 @@ package com.red.circle.other.app.service.task; import com.red.circle.common.business.dto.cmd.AppExtCommand; import com.red.circle.other.app.dto.clientobject.task.CheckInRewardListCO; import com.red.circle.other.app.dto.cmd.task.CheckInRewardCmd; +import com.red.circle.other.inner.enums.activity.PropsActivityTypeEnum; import com.red.circle.other.inner.model.dto.activity.props.ActivityRewardPropsDTO; import java.util.List; @@ -15,12 +16,12 @@ public interface CheckInService { List listRewardPool(AppExtCommand cmd); - Boolean checkToday(AppExtCommand cmd); + Boolean checkToday(AppExtCommand cmd, String dailyKey); ActivityRewardPropsDTO lottery(AppExtCommand cmd); - CheckInRewardListCO listReward(AppExtCommand cmd); + CheckInRewardListCO listReward(AppExtCommand cmd, PropsActivityTypeEnum activityType); - Integer checkIn2Fun(CheckInRewardCmd cmd); + Integer receive(CheckInRewardCmd cmd); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/CheckInKeys.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/CheckInKeys.java index 4a6062e7..18d3e510 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/CheckInKeys.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/key/CheckInKeys.java @@ -23,6 +23,11 @@ public enum CheckInKeys implements RedisKeys { */ DAILY_CHECK_IN, + /** + * azizi签到 + */ + AZIZI_CHECK_IN, + ; @Override diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/CheckInCacheService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/CheckInCacheService.java index f2855725..bdb28b67 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/CheckInCacheService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/CheckInCacheService.java @@ -45,7 +45,7 @@ public interface CheckInCacheService { * * @param userId 用户id */ - Boolean markDailyCheckIn(Long userId); + Boolean markDailyCheckIn(Long userId, String dailyKey); /** * 校验用户今天是否已签到. @@ -53,6 +53,6 @@ public interface CheckInCacheService { * @param userId 用户id * @return true 今日已签到 */ - Boolean checkDailyCheckIn(Long userId); + Boolean checkDailyCheckIn(Long userId, String dailyKey); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/CheckInCacheServiceImpl.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/CheckInCacheServiceImpl.java index 26ce3f9e..052602ca 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/CheckInCacheServiceImpl.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/cache/service/other/impl/CheckInCacheServiceImpl.java @@ -65,18 +65,15 @@ public class CheckInCacheServiceImpl implements CheckInCacheService { } @Override - public Boolean markDailyCheckIn(Long userId) { - return redisService.setIfAbsent(CheckInKeys.DAILY_CHECK_IN - .getKey("DAILY_CHECK_IN_" + userId + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt()), - 1, 2, TimeUnit.DAYS); + public Boolean markDailyCheckIn(Long userId, String dailyKey) { + return redisService.setIfAbsent(dailyKey, 1, 2, TimeUnit.DAYS); } @Override - public Boolean checkDailyCheckIn(Long userId) { + public Boolean checkDailyCheckIn(Long userId, String dailyKey) { return StringUtils.isNotBlank(redisService - .getString(CheckInKeys.DAILY_CHECK_IN.getKey( - "DAILY_CHECK_IN_" + userId + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt()))); + .getString(dailyKey)); } }