azizi签到处理
This commit is contained in:
parent
4faae9b097
commit
f1228d27a8
@ -208,6 +208,11 @@ public enum GameErrorCode implements IResponseErrorCode {
|
||||
*/
|
||||
USER_ALREADY_EXISTS(8139, "User already exists"),
|
||||
|
||||
/**
|
||||
* 已达到最大签到数量
|
||||
*/
|
||||
MAX_CHECK_IN(8140, "Max check in."),
|
||||
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
|
||||
@ -67,10 +67,17 @@ public class CheckInExe {
|
||||
checkInCacheService.checkDailyCheckIn(cmd.getReqUserId(), cmd.getDailyKey()));
|
||||
|
||||
ResponseAssert.isFalse(GameErrorCode.CHECKED_IN,
|
||||
Objects.equals(checkInCacheService.getCheckInDays(cmd.getReqUserId()), 7));
|
||||
Objects.equals(checkInCacheService.getCheckInDays(buildKey(cmd)), 7));
|
||||
|
||||
// 累计打卡天数
|
||||
Long inDays = checkInCacheService.incrCheckInDays(cmd.getReqUserId(), getExpiredTime(cmd));
|
||||
Long inDays;
|
||||
if (StringUtils.isBlank(cmd.getDailyKey())) {
|
||||
inDays = checkInCacheService.incrCheckInDays(CheckInKeys.SEVEN_CHECK_IN.getKey(cmd.getReqUserId()), getExpiredTime(cmd));
|
||||
} else {
|
||||
inDays = checkInCacheService.incrCheckInDays(CheckInKeys.AZIZI_SEVEN_CHECK_IN.getKey(cmd.getReqUserId()), getExpiredTime(cmd));
|
||||
ResponseAssert.isTrue(GameErrorCode.MAX_CHECK_IN, inDays <= 7);
|
||||
}
|
||||
|
||||
checkInCacheService.markDailyCheckIn(cmd.getReqUserId(), cmd.getDailyKey());
|
||||
|
||||
/* 不再根据资源组发,根据资源组顺序一个一个发
|
||||
@ -106,17 +113,24 @@ public class CheckInExe {
|
||||
);
|
||||
|
||||
|
||||
return checkInCacheService.getCheckInDays(cmd.getReqUserId());
|
||||
return checkInCacheService.getCheckInDays(buildKey(cmd));
|
||||
|
||||
} finally {
|
||||
redisService.unlock(lockKey);
|
||||
}
|
||||
}
|
||||
|
||||
private String buildKey(CheckInRewardCmd cmd) {
|
||||
if (StringUtils.isBlank(cmd.getDailyKey())) {
|
||||
return CheckInKeys.SEVEN_CHECK_IN.getKey(cmd.getReqUserId());
|
||||
}
|
||||
return CheckInKeys.AZIZI_SEVEN_CHECK_IN.getKey(cmd.getReqUserId());
|
||||
}
|
||||
|
||||
private long getExpiredTime(CheckInRewardCmd cmd) {
|
||||
Duration duration = getDuration();
|
||||
long expiredTime = duration.plusDays(1).toMillis();
|
||||
if (Objects.equals(6, checkInCacheService.getCheckInDays(cmd.getReqUserId()))) {
|
||||
if (Objects.equals(6, checkInCacheService.getCheckInDays(buildKey(cmd)))) {
|
||||
expiredTime = duration.toMillis();
|
||||
}
|
||||
return expiredTime;
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
package com.red.circle.other.app.command.task.query;
|
||||
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.red.circle.common.business.dto.cmd.AppExtCommand;
|
||||
import com.red.circle.other.app.convertor.material.PropsMaterialAppConvertor;
|
||||
import com.red.circle.other.app.dto.clientobject.activity.ActivityResourceCO;
|
||||
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.domain.gateway.props.ActivitySourceGroupGateway;
|
||||
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.inner.enums.activity.PropsActivityTypeEnum;
|
||||
import java.util.List;
|
||||
@ -33,9 +36,16 @@ public class CheckInRewardQryExe {
|
||||
activityType));
|
||||
|
||||
return new CheckInRewardListCO()
|
||||
.setDays(Optional.ofNullable(checkInCacheService.getCheckInDays(cmd.getReqUserId()))
|
||||
.setDays(Optional.ofNullable(checkInCacheService.getCheckInDays(buildKey(cmd.getReqUserId(), activityType.name())))
|
||||
.orElse(0))
|
||||
.setRewards(rewards);
|
||||
}
|
||||
|
||||
private String buildKey(Long userId, String activityType) {
|
||||
if (PropsActivityTypeEnum.DAILY_REGISTER_AZIZI.name().equals(activityType)) {
|
||||
return CheckInKeys.AZIZI_SEVEN_CHECK_IN.getKey(userId);
|
||||
}
|
||||
return CheckInKeys.SEVEN_CHECK_IN.getKey(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ public class SevenCheckInGetQryExe {
|
||||
return new CheckInCO()
|
||||
.setType(getType(nobleVip))
|
||||
.setClockedIn(checkInCacheService.getMarkDaySevenCheckIn(cmd.getReqUserId()))
|
||||
.setConsecutiveDays(checkInCacheService.getCheckInDays(cmd.getReqUserId()))
|
||||
.setConsecutiveDays(checkInCacheService.getCheckInDays("cmd.getReqUserId()"))
|
||||
.putNobleRewardQuantity(Optional.ofNullable(nobleVip)
|
||||
.map(nobleVipCache -> enumConfigCacheService
|
||||
.goldsToDiamondQuantity(nobleVipCache.getLoginRewardsAmount(),
|
||||
|
||||
@ -28,6 +28,11 @@ public enum CheckInKeys implements RedisKeys {
|
||||
*/
|
||||
AZIZI_CHECK_IN,
|
||||
|
||||
/**
|
||||
* azizi七日签到
|
||||
*/
|
||||
AZIZI_SEVEN_CHECK_IN,
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
|
||||
@ -13,7 +13,7 @@ public interface CheckInCacheService {
|
||||
* @param userId 用户id
|
||||
* @param timeoutMilliseconds 过期时间
|
||||
*/
|
||||
Long incrCheckInDays(Long userId, long timeoutMilliseconds);
|
||||
Long incrCheckInDays(String key, long timeoutMilliseconds);
|
||||
|
||||
/**
|
||||
* 缓存用户打卡天数.
|
||||
@ -21,7 +21,7 @@ public interface CheckInCacheService {
|
||||
* @param userId 用户id
|
||||
* @return ignore
|
||||
*/
|
||||
Integer getCheckInDays(Long userId);
|
||||
Integer getCheckInDays(String key);
|
||||
|
||||
/**
|
||||
* 标记用户已打卡.
|
||||
|
||||
@ -23,23 +23,14 @@ public class CheckInCacheServiceImpl implements CheckInCacheService {
|
||||
private final RedisService redisService;
|
||||
|
||||
@Override
|
||||
public Long incrCheckInDays(Long userId, long timeoutMilliseconds) {
|
||||
return incrCheckInDays(CheckInKeys.SEVEN_CHECK_IN.getKey(userId),
|
||||
timeoutMilliseconds);
|
||||
}
|
||||
|
||||
private Long incrCheckInDays(String key, long timeoutMilliseconds) {
|
||||
public Long incrCheckInDays(String key, long timeoutMilliseconds) {
|
||||
Long size = Optional.ofNullable(redisService.increment(key)).orElse(0L);
|
||||
redisService.expire(key, timeoutMilliseconds, TimeUnit.MILLISECONDS);
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCheckInDays(Long userId) {
|
||||
return getCheckInDays(CheckInKeys.SEVEN_CHECK_IN.getKey(userId));
|
||||
}
|
||||
|
||||
private Integer getCheckInDays(String key) {
|
||||
public Integer getCheckInDays(String key) {
|
||||
return Optional.ofNullable(redisService.getStringToInteger(key)).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user