From f2272a19494060e0b6075b86eb4b59c48faa8d14 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 20 Oct 2025 17:32:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=A2=86=E5=8F=96=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/service/task/TaskServiceImpl.java | 72 +++++++++---------- .../infra/common/props/PropsSendCommon.java | 15 ++++ .../database/rds/entity/task/TaskConfig.java | 52 ++++++++++++-- .../rds/entity/task/UserTaskProgress.java | 50 +++++++++++-- .../user/user/ConsumptionLevelService.java | 2 +- 5 files changed, 145 insertions(+), 46 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/TaskServiceImpl.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/TaskServiceImpl.java index 80c3d05d..bfea4417 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/TaskServiceImpl.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/service/task/TaskServiceImpl.java @@ -200,13 +200,15 @@ public class TaskServiceImpl implements TaskService { String lockKey = "task:reward:" + date + ":" + cmd.getReqUserId() + ":" + taskId; List taskConfigs = taskConfigDao.selectList(new LambdaQueryWrapper().eq(TaskConfig::getTaskId, taskId)); - if (taskConfigs.isEmpty()) { - return false; + if (CollectionUtils.isEmpty(taskConfigs)) { + throw new RuntimeException("The task configuration does not exist."); } + try { if (redisService.lock(lockKey, 20)) { LambdaQueryWrapper eq = new LambdaQueryWrapper() .eq(UserTaskProgress::getUserId, cmd.getReqUserId()) + .eq(UserTaskProgress::getTaskStatus, 1) .eq(UserTaskProgress::getTaskId, taskId) .eq(UserTaskProgress::getIsRewardCollected, 0); if (taskConfigs.get(0).getTaskType() == 1) { @@ -215,23 +217,23 @@ public class TaskServiceImpl implements TaskService { } List userTaskProgresses = userTaskProgressDao.selectList(eq); - UserTaskProgress userTaskProgress = userTaskProgresses.get(0); - if (!Objects.isNull(userTaskProgress)) { - - - // 发送道具 - propsActivityCnfClient.sendActivityReward(new SendActivityRewardCmd() - .setTrackId(IdWorkerUtils.getId()) - .setSysOrigin(SysOriginPlatformEnum.valueOf(cmd.getReqSysOrigin().getOrigin())) - .setAcceptUserId(cmd.getReqUserId()) - .setSourceGroupId(taskConfigs.get(0).getRewardId()) - .setOrigin(SendPropsOrigin.DAILY_TASK_REWARD) - ); - - userTaskProgress.setIsRewardCollected(1); - userTaskProgress.setCompletedTime(TimestampUtils.now()); - userTaskProgressDao.updateById(userTaskProgress); + if (CollectionUtils.isEmpty(userTaskProgresses)) { + throw new RuntimeException("There are no rewards to be claimed for the moment."); } + UserTaskProgress userTaskProgress = userTaskProgresses.get(0); + + // 发送道具 + propsActivityCnfClient.sendActivityReward(new SendActivityRewardCmd() + .setTrackId(IdWorkerUtils.getId()) + .setSysOrigin(SysOriginPlatformEnum.valueOf(cmd.getReqSysOrigin().getOrigin())) + .setAcceptUserId(cmd.getReqUserId()) + .setSourceGroupId(taskConfigs.get(0).getRewardId()) + .setOrigin(SendPropsOrigin.DAILY_TASK_REWARD) + ); + + userTaskProgress.setIsRewardCollected(1); + userTaskProgress.setCompletedTime(TimestampUtils.now()); + userTaskProgressDao.updateById(userTaskProgress); } } finally { @@ -274,27 +276,25 @@ public class TaskServiceImpl implements TaskService { allTask.forEach(item -> { ActivityPropsGroup activity = activityMap.get(item.getRewardId()); -// String taskDesc = messageSource.getMessage("task.task_"+item.getTaskId()+".desc", null, locale); String taskDesc = ResourceBundle.getBundle("i18n.messages", new Locale(cmd.getReqLanguage())).getString("task.task_" + item.getTaskId() + ".desc"); - TaskDTO build = TaskDTO.builder() - .taskType(item.getTaskType()) - .taskId(item.getTaskId()) + if (activity != null && !activity.getActivityRewardProps().isEmpty()) { + TaskDTO build = TaskDTO.builder() + .taskType(item.getTaskType()) + .taskId(item.getTaskId()) // .taskDesc(taskMapByIds.get(item.getTaskId()).getTaskDesc()) - .taskDesc(taskDesc) - .jumpPage(taskMapByIds.get(item.getTaskId()).getJumpPage()) - .taskStatus(item.getTaskStatus()) - .isRewardCollected(item.getIsRewardCollected()) - .taskIcon(taskMapByIds.get(item.getTaskId()).getTaskIcon()) - .taskStatus(item.getTaskStatus()) - .conditionType(activity.getActivityRewardProps().get(0).getType()) - .cover(activity.getActivityRewardProps().get(0).getCover()) - .quantity(activity.getActivityRewardProps().get(0).getQuantity()) - .build(); - //拼接数据 -// item.setActivityPropsGroup(activityMap.getData().get(item.getRewardId())); -// item.setDayString(date); - resultList.add(build); + .taskDesc(taskDesc) + .jumpPage(taskMapByIds.get(item.getTaskId()).getJumpPage()) + .taskStatus(item.getTaskStatus()) + .isRewardCollected(item.getIsRewardCollected()) + .taskIcon(taskMapByIds.get(item.getTaskId()).getTaskIcon()) + .taskStatus(item.getTaskStatus()) + .conditionType(activity.getActivityRewardProps().get(0).getType()) + .cover(activity.getActivityRewardProps().get(0).getCover()) + .quantity(activity.getActivityRewardProps().get(0).getQuantity()) + .build(); + resultList.add(build); + } }); //拼接任务 return resultList; diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/props/PropsSendCommon.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/props/PropsSendCommon.java index dd215942..c354a281 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/props/PropsSendCommon.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/common/props/PropsSendCommon.java @@ -32,6 +32,7 @@ import com.red.circle.other.infra.database.rds.service.props.FragmentsBackpackSe import com.red.circle.other.infra.database.rds.service.props.PropsSendLogService; import com.red.circle.other.infra.database.rds.service.props.PropsSourceRecordService; import com.red.circle.other.infra.database.rds.service.props.PropsVipActualEquityService; +import com.red.circle.other.infra.database.rds.service.user.user.ConsumptionLevelService; import com.red.circle.other.infra.utils.I18nUtils; import com.red.circle.other.inner.enums.material.NobleVipEnum; import com.red.circle.other.inner.enums.material.PropsCommodityType; @@ -86,6 +87,7 @@ public class PropsSendCommon { private final RoomProfileManagerService roomProfileManagerService; private final PropsMaterialInfraConvertor propsMaterialInfraConvertor; private final PropsVipActualEquityService propsVipActualEquityService; + private final ConsumptionLevelService consumptionLevelService; private final UserRegionGateway userRegionGateway; private final OfficialNoticeClient officialNoticeClient; @@ -147,9 +149,22 @@ public class PropsSendCommon { sendRoomBadge(cmd.getAcceptUserId(), badges); } + List exps = filterPrize(cmd, PropsActivityRewardEnum.CUSTOMIZE); + sendUserExp(cmd.getAcceptUserId(), exps); + saveSendLog(cmd); } + private void sendUserExp(Long acceptUserId, List exps) { + exps.forEach(prizeDescribe -> { + PropsSourceRecord props = propsSourceRecordService.getPropsById(Long.parseLong(prizeDescribe.getContent())); + if (Objects.nonNull(props) && "EXP".equalsIgnoreCase(props.getCode())) { + consumptionLevelService.incrConsumptionDiamond(acceptUserId, BigDecimal.valueOf(prizeDescribe.getQuantity())); + } + + }); + } + public List filterPrize(PrizeDescribeRewardCmd cmd, PropsActivityRewardEnum type) { return cmd.getPrizes().stream() .filter(prizeDescribe -> type.eq(prizeDescribe.getType())) diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/task/TaskConfig.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/task/TaskConfig.java index 50f80349..3c6f2a0d 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/task/TaskConfig.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/task/TaskConfig.java @@ -6,19 +6,63 @@ import lombok.Data; @Data @TableName("task_config") public class TaskConfig { + /** + * 任务ID + */ private Long taskId; + + /** + * 任务类型(1:每日 2:成长) + */ private Integer taskType; + + /** + * 任务名称 + */ private String taskName; + + /** + * 任务描述 + */ private String taskDesc; + + /** + * 跳转页面 + */ private String jumpPage; + + /** + * 奖励类型(1:金币 2:头像框 3:气泡) + */ private Integer rewardType; + + /** + * 配置奖励id(预留) + */ private Long rewardId; + + /** + * 奖励数量(预留) + */ private Integer rewardAmount; + + /** + * 条件类型(如:MIC_DURATION)(预留) + */ private String conditionType; + + /** + * 条件值(如:600秒)(预留) + */ private String conditionValue; + + /** + * 任务图标 + */ private String taskIcon; + + /** + * 排序 + */ private Integer sortOrder; - - - -} +} \ No newline at end of file diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/task/UserTaskProgress.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/task/UserTaskProgress.java index 57d66bce..7e06041f 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/task/UserTaskProgress.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/entity/task/UserTaskProgress.java @@ -4,22 +4,62 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.sql.Timestamp; -import java.util.Date; @Data @TableName("user_task_progress") public class UserTaskProgress { + /** + * 主键id + */ private Long id; + + /** + * 用户ID + */ private Long userId; + + /** + * 任务ID + */ private Long taskId; + + /** + * 奖励ID + */ private Long rewardId; + + /** + * 任务类型(1:每日 2:成长),与 task_config 表中的 task_type 对应 + */ private Integer taskType; - //0进行中 1 已完成 + + /** + * 任务状态(0:进行中 1:已完成) + */ private Integer taskStatus; + + /** + * 奖励是否已领取(0:未领取 1:已领取) + */ private Integer isRewardCollected; - //完成时间 + + /** + * 完成时间 + */ private Timestamp completedTime; - //创建时间 + + /** + * 创建时间戳,记录任务进度记录创建的时间 + */ private Timestamp createTimestamp; + + /** + * 当前日期字符串,格式为 YYYY-MM-DD + */ private String dayString; -} + + /** + * 任务icon + */ + private String taskIcon; +} \ No newline at end of file diff --git a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ConsumptionLevelService.java b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ConsumptionLevelService.java index 26abac3f..0e0bc731 100644 --- a/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ConsumptionLevelService.java +++ b/rc-service/rc-service-other/other-infrastructure/src/main/java/com/red/circle/other/infra/database/rds/service/user/user/ConsumptionLevelService.java @@ -45,7 +45,7 @@ public interface ConsumptionLevelService extends BaseService { BigDecimal getConsumptionGolds(Long userId); /** - * 消费钻石. + * 累计用户魅力经验. * * @param userId 用户id * @param quantity 数量