任务领取功能完善
This commit is contained in:
parent
4b6f31dccf
commit
f2272a1949
@ -200,13 +200,15 @@ public class TaskServiceImpl implements TaskService {
|
||||
String lockKey = "task:reward:" + date + ":" + cmd.getReqUserId() + ":" + taskId;
|
||||
|
||||
List<TaskConfig> taskConfigs = taskConfigDao.selectList(new LambdaQueryWrapper<TaskConfig>().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<UserTaskProgress> eq = new LambdaQueryWrapper<UserTaskProgress>()
|
||||
.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<UserTaskProgress> 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;
|
||||
|
||||
@ -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<PrizeDescribe> exps = filterPrize(cmd, PropsActivityRewardEnum.CUSTOMIZE);
|
||||
sendUserExp(cmd.getAcceptUserId(), exps);
|
||||
|
||||
saveSendLog(cmd);
|
||||
}
|
||||
|
||||
private void sendUserExp(Long acceptUserId, List<PrizeDescribe> 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<PrizeDescribe> filterPrize(PrizeDescribeRewardCmd cmd, PropsActivityRewardEnum type) {
|
||||
return cmd.getPrizes().stream()
|
||||
.filter(prizeDescribe -> type.eq(prizeDescribe.getType()))
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -45,7 +45,7 @@ public interface ConsumptionLevelService extends BaseService<ConsumptionLevel> {
|
||||
BigDecimal getConsumptionGolds(Long userId);
|
||||
|
||||
/**
|
||||
* 消费钻石.
|
||||
* 累计用户魅力经验.
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @param quantity 数量
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user