签到修复
This commit is contained in:
parent
0ae11c76e6
commit
c2be8d1e43
@ -45,12 +45,14 @@ public class CheckInExe {
|
|||||||
private final PropsSendCommon propsSendCommon;
|
private final PropsSendCommon propsSendCommon;
|
||||||
|
|
||||||
public Integer execute(CheckInRewardCmd cmd) {
|
public Integer execute(CheckInRewardCmd cmd) {
|
||||||
boolean inrAzizi = false;
|
// 判断是否为Azizi签到(根据dailyKey是否为空)
|
||||||
if (StringUtils.isBlank(cmd.getDailyKey())) {
|
boolean isAziziCheckIn = StringUtils.isNotBlank(cmd.getDailyKey());
|
||||||
cmd.setDailyKey(CheckInKeys.DAILY_CHECK_IN.getKey("DAILY_CHECK_IN_" + cmd.getReqUserId() + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt()));
|
|
||||||
} else {
|
// 设置每日签到key
|
||||||
inrAzizi = true;
|
if (isAziziCheckIn) {
|
||||||
cmd.setDailyKey(CheckInKeys.AZIZI_CHECK_IN.getKey("AZIZI_CHECK_IN" + cmd.getReqUserId() + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt()));
|
cmd.setDailyKey(CheckInKeys.AZIZI_CHECK_IN.getKey("AZIZI_CHECK_IN" + cmd.getReqUserId() + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt()));
|
||||||
|
} else {
|
||||||
|
cmd.setDailyKey(CheckInKeys.DAILY_CHECK_IN.getKey("DAILY_CHECK_IN_" + cmd.getReqUserId() + ZonedDateTimeAsiaRiyadhUtils.nowDateToInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -69,14 +71,14 @@ public class CheckInExe {
|
|||||||
checkInCacheService.checkDailyCheckIn(cmd.getReqUserId(), cmd.getDailyKey()));
|
checkInCacheService.checkDailyCheckIn(cmd.getReqUserId(), cmd.getDailyKey()));
|
||||||
|
|
||||||
ResponseAssert.isFalse(GameErrorCode.CHECKED_IN,
|
ResponseAssert.isFalse(GameErrorCode.CHECKED_IN,
|
||||||
Objects.equals(checkInCacheService.getCheckInDays(buildKey(cmd)), 7));
|
Objects.equals(checkInCacheService.getCheckInDays(buildSevenCheckInKey(isAziziCheckIn, cmd.getReqUserId())), 7));
|
||||||
|
|
||||||
// 累计打卡天数
|
// 累计打卡天数
|
||||||
Long inDays;
|
String sevenCheckInKey = buildSevenCheckInKey(isAziziCheckIn, cmd.getReqUserId());
|
||||||
if (!inrAzizi) {
|
Long inDays = checkInCacheService.incrCheckInDays(sevenCheckInKey, getExpiredTime(isAziziCheckIn, cmd.getReqUserId()));
|
||||||
inDays = checkInCacheService.incrCheckInDays(CheckInKeys.SEVEN_CHECK_IN.getKey(cmd.getReqUserId()), getExpiredTime(cmd));
|
|
||||||
} else {
|
// Azizi签到需要检查最大天数限制
|
||||||
inDays = checkInCacheService.incrCheckInDays(CheckInKeys.AZIZI_SEVEN_CHECK_IN.getKey(cmd.getReqUserId()), getExpiredTime(cmd));
|
if (isAziziCheckIn) {
|
||||||
ResponseAssert.isTrue(GameErrorCode.MAX_CHECK_IN, inDays <= 7);
|
ResponseAssert.isTrue(GameErrorCode.MAX_CHECK_IN, inDays <= 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,24 +117,39 @@ public class CheckInExe {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
return checkInCacheService.getCheckInDays(buildKey(cmd));
|
return checkInCacheService.getCheckInDays(sevenCheckInKey);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
redisService.unlock(lockKey);
|
redisService.unlock(lockKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildKey(CheckInRewardCmd cmd) {
|
/**
|
||||||
if (StringUtils.isBlank(cmd.getDailyKey())) {
|
* 构建7日签到统计key
|
||||||
return CheckInKeys.SEVEN_CHECK_IN.getKey(cmd.getReqUserId());
|
* @param isAziziCheckIn 是否为Azizi签到
|
||||||
}
|
* @param userId 用户ID
|
||||||
return CheckInKeys.AZIZI_SEVEN_CHECK_IN.getKey(cmd.getReqUserId());
|
* @return 签到统计key
|
||||||
}
|
*/
|
||||||
|
private String buildSevenCheckInKey(boolean isAziziCheckIn, Long userId) {
|
||||||
|
return isAziziCheckIn
|
||||||
|
? CheckInKeys.AZIZI_SEVEN_CHECK_IN.getKey(userId)
|
||||||
|
: CheckInKeys.SEVEN_CHECK_IN.getKey(userId);
|
||||||
|
}
|
||||||
|
|
||||||
private long getExpiredTime(CheckInRewardCmd cmd) {
|
/**
|
||||||
|
* 获取过期时间
|
||||||
|
* @param isAziziCheckIn 是否为Azizi签到
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 过期时间(毫秒)
|
||||||
|
*/
|
||||||
|
private long getExpiredTime(boolean isAziziCheckIn, Long userId) {
|
||||||
Duration duration = getDuration();
|
Duration duration = getDuration();
|
||||||
long expiredTime = duration.plusDays(1).toMillis();
|
long expiredTime = duration.plusDays(1).toMillis();
|
||||||
if (Objects.equals(6, checkInCacheService.getCheckInDays(buildKey(cmd)))) {
|
|
||||||
|
String sevenCheckInKey = buildSevenCheckInKey(isAziziCheckIn, userId);
|
||||||
|
Integer checkInDays = checkInCacheService.getCheckInDays(sevenCheckInKey);
|
||||||
|
// 第6天及以上(包括脏数据)都在今天结束时过期,准备开始新周期
|
||||||
|
if (checkInDays != null && checkInDays >= 6) {
|
||||||
expiredTime = duration.toMillis();
|
expiredTime = duration.toMillis();
|
||||||
}
|
}
|
||||||
return expiredTime;
|
return expiredTime;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user