release- 每日签到返回今日是否已进行

release-2024-04-25
huangyawei 2 months ago
parent 20d76ac230
commit e3db72504d

@ -60,4 +60,7 @@ public class ErrorConstants {
public static final String APPLY_END_TIME_CANNOT_BE_BEFORE_APPLY_START_TIME = "报名结束时间不能在报名开始时间之前";
public static final String POINT_NOT_ENOUGH = "积分不足";
// 积分部分
public static final String DAILY_SIGN_ALREADY = "进入已签到";
}

@ -2,10 +2,12 @@ package com.luoo.user.service;
import api.PageResult;
import com.luoo.user.dao.TaskPointDao;
import com.luoo.user.dao.UserPointLogDao;
import com.luoo.user.dto.point.TaskPointDto;
import com.luoo.user.dto.point.TaskPointForAppDto;
import com.luoo.user.pojo.TaskPoint;
import com.luoo.user.pojo.UserPointLog;
import constants.TaskPointIdConstants;
import dto.UserLoginDto;
import java.util.List;
import java.util.Objects;
@ -44,15 +46,16 @@ public class TaskPointService {
private final JwtUtil jwtUtil;
private final UserPointLogDao userPointLogDao;
private final RedisTemplate redisTemplate;
public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil, RedisTemplate redisTemplate) {
public TaskPointService(TaskPointDao taskPointDao, IdWorker idWorker, JwtUtil jwtUtil, UserPointLogDao userPointLogDao, RedisTemplate redisTemplate) {
this.taskPointDao = taskPointDao;
this.idWorker = idWorker;
this.jwtUtil = jwtUtil;
this.userPointLogDao = userPointLogDao;
this.redisTemplate = redisTemplate;
}
@ -172,8 +175,9 @@ public class TaskPointService {
* @return
*/
public List<TaskPointForAppDto> getTaskPointListForApp(String token, Integer type) {
List<TaskPoint> taskPointList = taskPointDao.findByTypeAndValid(type, PointEnums.VALID.getCode());
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
List<TaskPoint> taskPointList = taskPointDao.findByTypeAndValid(type, PointEnums.VALID.getCode());
List<TaskPointForAppDto> result = taskPointList.stream().map(taskPoint -> {
TaskPointForAppDto taskPointForAppDto = new TaskPointForAppDto();
BeanUtils.copyProperties(taskPoint, taskPointForAppDto);
@ -182,7 +186,7 @@ public class TaskPointService {
// 如果是新手任务,需要判断是否已参与
result.forEach(taskPoint -> {
if(Objects.equals(taskPoint.getType(), PointEnums.TASK_TYPE_NEW.getCode())) {
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
UserPointLog checkLog = userPointLogService.getUserPointLog(userLoginDto.getUserId(), taskPoint.getId());
if(checkLog != null) {
taskPoint.setUserStatus(PointEnums.PARTICIPATED.getCode());
@ -190,6 +194,15 @@ public class TaskPointService {
taskPoint.setUserStatus(PointEnums.NOT_PARTICIPATED.getCode());
}
}
if (Objects.equals(taskPoint.getType(), Integer.valueOf(TaskPointIdConstants.DAILY_SIGN))) {
// 校验今日是否已签到
UserPointLog todayByUserIdAndTaskPointId = userPointLogDao.findTodayByUserIdAndTaskPointId(userLoginDto.getUserId(), TaskPointIdConstants.DAILY_SIGN);
if(todayByUserIdAndTaskPointId != null) {
taskPoint.setUserStatus(PointEnums.PARTICIPATED.getCode());
} else {
taskPoint.setUserStatus(PointEnums.NOT_PARTICIPATED.getCode());
}
}
});
return result;

@ -287,6 +287,8 @@ public class UserPointLogService {
if (daysByUserIdAndTaskPointId30.size() == 30) {
addByTaskDaily(TaskPointIdConstants.DAILY_SIGN_30, token);
}
} else {
throw new BizException(ErrorConstants.DAILY_SIGN_ALREADY);
}
}

Loading…
Cancel
Save