From 05af847f403ee5282f74a844bcfda30a1461e01d Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 4 Mar 2026 10:40:29 +0800 Subject: [PATCH] =?UTF-8?q?roomDailyTask=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../other/inner/asserts/user/UserErrorCode.java | 10 ++++++++++ .../app/task/RoomDailyTaskRestController.java | 6 ++++-- .../app/command/task/RoomDailyTaskClaimExe.java | 14 +++++++------- .../app/command/task/RoomDailyTaskQueryExe.java | 4 ++-- .../app/service/task/RoomDailyTaskServiceImpl.java | 4 ++-- .../app/service/task/RoomDailyTaskService.java | 2 +- .../rds/service/RoomDailyTaskDatabaseService.java | 3 ++- 7 files changed, 28 insertions(+), 15 deletions(-) diff --git a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java index d9bdf03f..f2050f34 100644 --- a/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java +++ b/rc-service/rc-inner-api/other-inner/other-inner-model/src/main/java/com/red/circle/other/inner/asserts/user/UserErrorCode.java @@ -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"), + ; diff --git a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/task/RoomDailyTaskRestController.java b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/task/RoomDailyTaskRestController.java index 1a2148e8..f6a9332b 100644 --- a/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/task/RoomDailyTaskRestController.java +++ b/rc-service/rc-service-other/other-adapter/src/main/java/com/red/circle/other/adapter/app/task/RoomDailyTaskRestController.java @@ -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 getTaskList(AppExtCommand cmd) { - return roomDailyTaskService.getTaskList(cmd.getReqUserId()); + public List getTaskList(AppExtCommand cmd, + @RequestParam @NotNull(message = "任务分类不能为空") Integer taskCategory) { + return roomDailyTaskService.getTaskList(cmd.getReqUserId(), taskCategory); } /** diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/RoomDailyTaskClaimExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/RoomDailyTaskClaimExe.java index 0ef0d484..6bc7426e 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/RoomDailyTaskClaimExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/RoomDailyTaskClaimExe.java @@ -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); } // 更新领取状态 diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/RoomDailyTaskQueryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/RoomDailyTaskQueryExe.java index baab4ceb..ef31ffc6 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/RoomDailyTaskQueryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/task/RoomDailyTaskQueryExe.java @@ -26,8 +26,8 @@ public class RoomDailyTaskQueryExe { private final RoomDailyTaskDatabaseService taskDatabaseService; - public List execute(Long userId) { - List configs = taskDatabaseService.listEnabledConfigs(); + public List execute(Long userId, Integer taskCategory) { + List configs = taskDatabaseService.listEnabledConfigs(taskCategory); if (CollectionUtils.isEmpty(configs)) { return new ArrayList<>(); } diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/RoomDailyTaskServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/RoomDailyTaskServiceImpl.java index 92eb92d6..f67cf828 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/RoomDailyTaskServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/RoomDailyTaskServiceImpl.java @@ -18,8 +18,8 @@ public class RoomDailyTaskServiceImpl implements RoomDailyTaskService { private final RoomDailyTaskClaimExe claimExe; @Override - public List getTaskList(Long userId) { - return queryExe.execute(userId); + public List getTaskList(Long userId, Integer taskCategory) { + return queryExe.execute(userId, taskCategory); } @Override diff --git a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/task/RoomDailyTaskService.java b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/task/RoomDailyTaskService.java index 19869f8d..04928977 100644 --- a/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/task/RoomDailyTaskService.java +++ b/rc-service/rc-service-other/other-client/src/main/java/com/red/circle/other/app/service/task/RoomDailyTaskService.java @@ -8,7 +8,7 @@ import java.util.List; public interface RoomDailyTaskService { - List getTaskList(Long userId); + List getTaskList(Long userId, Integer taskCategory); RoomDailyTaskClaimCO claimReward(RoomDailyTaskClaimCmd cmd); } diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/RoomDailyTaskDatabaseService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/RoomDailyTaskDatabaseService.java index d06aa073..e46dd275 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/RoomDailyTaskDatabaseService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/RoomDailyTaskDatabaseService.java @@ -24,10 +24,11 @@ public class RoomDailyTaskDatabaseService { private final RoomDailyTaskProgressDAO progressDAO; private final RoomDailyTaskClaimRecordDAO claimRecordDAO; - public List listEnabledConfigs() { + public List listEnabledConfigs(Integer taskCategory) { return configDAO.selectList( new LambdaQueryWrapper() .eq(RoomDailyTaskConfig::getStatus, 1) + .eq(RoomDailyTaskConfig::getTaskCategory, taskCategory) .orderByAsc(RoomDailyTaskConfig::getSortOrder) ); }