roomDailyTask 更新

This commit is contained in:
tianfeng 2026-03-04 10:40:29 +08:00
parent 9fded39a3d
commit 05af847f40
7 changed files with 28 additions and 15 deletions

View File

@ -234,6 +234,16 @@ public enum UserErrorCode implements IResponseErrorCode {
*/
ACCOUNT_LOGOUT(4077, "Account has been deactivated"),
/**
* 任务不存在.
*/
TASK_NOT_FOUND(4078, "Task not found"),
/**
* 任务档位不存在.
*/
TASK_TIER_NOT_FOUND(4079, "Task tier not found"),
;

View File

@ -1,6 +1,7 @@
package com.red.circle.other.adapter.app.task;
import com.red.circle.common.business.dto.cmd.AppExtCommand;
import jakarta.validation.constraints.NotNull;
import com.red.circle.other.app.dto.clientobject.task.RoomDailyTaskCO;
import com.red.circle.other.app.dto.clientobject.task.RoomDailyTaskClaimCO;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskClaimCmd;
@ -28,8 +29,9 @@ public class RoomDailyTaskRestController {
* @eo.method get
*/
@GetMapping("/list")
public List<RoomDailyTaskCO> getTaskList(AppExtCommand cmd) {
return roomDailyTaskService.getTaskList(cmd.getReqUserId());
public List<RoomDailyTaskCO> getTaskList(AppExtCommand cmd,
@RequestParam @NotNull(message = "任务分类不能为空") Integer taskCategory) {
return roomDailyTaskService.getTaskList(cmd.getReqUserId(), taskCategory);
}
/**

View File

@ -1,6 +1,6 @@
package com.red.circle.other.app.command.task;
import com.red.circle.common.business.exception.BusinessException;
import com.red.circle.framework.core.asserts.ResponseAssert;
import com.red.circle.other.app.dto.clientobject.task.RoomDailyTaskClaimCO;
import com.red.circle.other.app.dto.cmd.task.RoomDailyTaskClaimCmd;
import com.red.circle.other.infra.database.rds.entity.task.RoomDailyTaskClaimRecord;
@ -8,6 +8,7 @@ import com.red.circle.other.infra.database.rds.entity.task.RoomDailyTaskConfig;
import com.red.circle.other.infra.database.rds.entity.task.RoomDailyTaskProgress;
import com.red.circle.other.infra.database.rds.entity.task.RoomDailyTaskTier;
import com.red.circle.other.infra.database.rds.service.RoomDailyTaskDatabaseService;
import com.red.circle.other.inner.asserts.user.UserErrorCode;
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -36,27 +37,26 @@ public class RoomDailyTaskClaimExe {
LocalDate today = ZonedDateTimeAsiaRiyadhUtils.now().toLocalDate();
String bizNo = userId + ":" + taskCode + ":" + today + ":" + tierIndex;
// 幂等校验
if (taskDatabaseService.existsClaimRecord(bizNo)) {
throw new BusinessException("该档位奖励已领取");
ResponseAssert.failure(UserErrorCode.AWARD_RECEIVED);
}
RoomDailyTaskConfig config = taskDatabaseService.getConfigByCode(taskCode);
if (config == null) {
throw new BusinessException("任务不存在");
ResponseAssert.failure(UserErrorCode.TASK_NOT_FOUND);
}
RoomDailyTaskTier tier = taskDatabaseService.getTier(taskCode, tierIndex);
if (tier == null) {
throw new BusinessException("任务档位不存在");
ResponseAssert.failure(UserErrorCode.TASK_TIER_NOT_FOUND);
}
RoomDailyTaskProgress progress = taskDatabaseService.getProgress(userId, taskCode, today);
if (progress == null || progress.getMaxTierCompleted() < tierIndex) {
throw new BusinessException("该档位任务未完成");
ResponseAssert.failure(UserErrorCode.INCOMPLETE_TASK);
}
if (progress.getMaxTierClaimed() >= tierIndex) {
throw new BusinessException("该档位奖励已领取");
ResponseAssert.failure(UserErrorCode.AWARD_RECEIVED);
}
// 更新领取状态

View File

@ -26,8 +26,8 @@ public class RoomDailyTaskQueryExe {
private final RoomDailyTaskDatabaseService taskDatabaseService;
public List<RoomDailyTaskCO> execute(Long userId) {
List<RoomDailyTaskConfig> configs = taskDatabaseService.listEnabledConfigs();
public List<RoomDailyTaskCO> execute(Long userId, Integer taskCategory) {
List<RoomDailyTaskConfig> configs = taskDatabaseService.listEnabledConfigs(taskCategory);
if (CollectionUtils.isEmpty(configs)) {
return new ArrayList<>();
}

View File

@ -18,8 +18,8 @@ public class RoomDailyTaskServiceImpl implements RoomDailyTaskService {
private final RoomDailyTaskClaimExe claimExe;
@Override
public List<RoomDailyTaskCO> getTaskList(Long userId) {
return queryExe.execute(userId);
public List<RoomDailyTaskCO> getTaskList(Long userId, Integer taskCategory) {
return queryExe.execute(userId, taskCategory);
}
@Override

View File

@ -8,7 +8,7 @@ import java.util.List;
public interface RoomDailyTaskService {
List<RoomDailyTaskCO> getTaskList(Long userId);
List<RoomDailyTaskCO> getTaskList(Long userId, Integer taskCategory);
RoomDailyTaskClaimCO claimReward(RoomDailyTaskClaimCmd cmd);
}

View File

@ -24,10 +24,11 @@ public class RoomDailyTaskDatabaseService {
private final RoomDailyTaskProgressDAO progressDAO;
private final RoomDailyTaskClaimRecordDAO claimRecordDAO;
public List<RoomDailyTaskConfig> listEnabledConfigs() {
public List<RoomDailyTaskConfig> listEnabledConfigs(Integer taskCategory) {
return configDAO.selectList(
new LambdaQueryWrapper<RoomDailyTaskConfig>()
.eq(RoomDailyTaskConfig::getStatus, 1)
.eq(RoomDailyTaskConfig::getTaskCategory, taskCategory)
.orderByAsc(RoomDailyTaskConfig::getSortOrder)
);
}