新增azizi 7天签到处理

This commit is contained in:
tianfeng 2026-02-02 19:05:06 +08:00
parent 542fc1713e
commit 7f6d6cc53b
11 changed files with 63 additions and 71 deletions

View File

@ -97,6 +97,8 @@ public enum PropsActivityTypeEnum {
*/
DAILY_REGISTER,
DAILY_REGISTER_AZIZI,
/**
* 幸运礼物抽奖.
*/

View File

@ -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<ActivityRewardPropsDTO> 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);
}

View File

@ -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()

View File

@ -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(

View File

@ -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<ActivityResourceCO> rewards = propsMaterialAppConvertor
.toActivityResourceCOList(activitySourceGroupGateway
.listActivityResource(cmd.requireReqSysOriginEnum(),
PropsActivityTypeEnum.DAILY_REGISTER));
activityType));
return new CheckInRewardListCO()
.setDays(Optional.ofNullable(checkInCacheService.getCheckInDays(cmd.getReqUserId()))

View File

@ -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<ActivityResourceCO> 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);
}

View File

@ -26,4 +26,6 @@ public class CheckInRewardCmd extends AppExtCommand {
@NotNull(message = "resourceGroupId required.")
private Long resourceGroupId;
private String dailyKey;
}

View File

@ -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<ActivityRewardPropsDTO> 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);
}

View File

@ -23,6 +23,11 @@ public enum CheckInKeys implements RedisKeys {
*/
DAILY_CHECK_IN,
/**
* azizi签到
*/
AZIZI_CHECK_IN,
;
@Override

View File

@ -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);
}

View File

@ -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));
}
}