|
|
|
@ -7,7 +7,6 @@ import com.luoo.user.dto.point.UserPointLogSearchDto;
|
|
|
|
|
import com.luoo.user.pojo.TaskPoint;
|
|
|
|
|
import com.luoo.user.pojo.UserInfo;
|
|
|
|
|
import com.luoo.user.pojo.UserPointLog;
|
|
|
|
|
import com.mysql.fabric.xmlrpc.base.Param;
|
|
|
|
|
import dto.UserLoginDto;
|
|
|
|
|
import enums.PointEnums;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
@ -18,16 +17,14 @@ import javax.persistence.criteria.CriteriaQuery;
|
|
|
|
|
import javax.persistence.criteria.Predicate;
|
|
|
|
|
import javax.persistence.criteria.Root;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.data.domain.Page;
|
|
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
|
|
import org.springframework.data.domain.Sort.Direction;
|
|
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import util.IdWorker;
|
|
|
|
@ -55,16 +52,23 @@ public class UserPointLogService {
|
|
|
|
|
|
|
|
|
|
private final UserInfoService userInfoService;
|
|
|
|
|
|
|
|
|
|
private final RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
|
|
|
|
private final TaskPointService taskPointService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UserPointLogService(UserPointLogDao userPointLogDao, IdWorker idWorker, JwtUtil jwtUtil,
|
|
|
|
|
TaskPointDao taskPointDao, RabbitTemplate rabbitTemplate,
|
|
|
|
|
UserInfoService userInfoService) {
|
|
|
|
|
UserInfoService userInfoService, RedisTemplate<String, Object> redisTemplate,
|
|
|
|
|
TaskPointService taskPointService) {
|
|
|
|
|
this.userPointLogDao = userPointLogDao;
|
|
|
|
|
this.idWorker = idWorker;
|
|
|
|
|
this.jwtUtil = jwtUtil;
|
|
|
|
|
this.taskPointDao = taskPointDao;
|
|
|
|
|
this.rabbitTemplate = rabbitTemplate;
|
|
|
|
|
this.userInfoService = userInfoService;
|
|
|
|
|
this.redisTemplate = redisTemplate;
|
|
|
|
|
this.taskPointService = taskPointService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -77,10 +81,10 @@ public class UserPointLogService {
|
|
|
|
|
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
|
|
|
|
|
|
|
|
|
|
// 新手任务,只触发一次
|
|
|
|
|
if (!userPointLogDao.findUserPointLogByUserIdAndTaskPointId(userLoginDto.getUserId(),
|
|
|
|
|
taskPointId).isEmpty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// if (!userPointLogDao.findUserPointLogByUserIdAndTaskPointId(userLoginDto.getUserId(),
|
|
|
|
|
// taskPointId).isEmpty()) {
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
addByTask(taskPointId, userLoginDto);
|
|
|
|
|
}
|
|
|
|
@ -102,13 +106,10 @@ public class UserPointLogService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addByTask(String taskPointId, UserLoginDto userLoginDto) {
|
|
|
|
|
TaskPoint taskPoint = taskPointDao.findById(taskPointId).get();
|
|
|
|
|
|
|
|
|
|
UserPointLog userPointLog = UserPointLog.builder()
|
|
|
|
|
.id(String.valueOf(idWorker.nextId()))
|
|
|
|
|
.score(taskPoint.getScore())
|
|
|
|
|
.type(PointEnums.TASK_POINT_TYPE_ADD.getCode())
|
|
|
|
|
.description(taskPoint.getDescription())
|
|
|
|
|
.createUser(userLoginDto.getUserId())
|
|
|
|
|
.taskPointId(taskPointId)
|
|
|
|
|
.userId(userLoginDto.getUserId())
|
|
|
|
@ -129,7 +130,7 @@ public class UserPointLogService {
|
|
|
|
|
// 根据积分任务ID获取积分任务详情
|
|
|
|
|
// 保存积分记录
|
|
|
|
|
String taskPointId = userPointLog.getTaskPointId();
|
|
|
|
|
TaskPoint taskPoint = taskPointDao.findById(taskPointId).get();
|
|
|
|
|
TaskPoint taskPoint = taskPointService.getTaskPoint(taskPointId);
|
|
|
|
|
|
|
|
|
|
// 获取积分任务类型
|
|
|
|
|
Integer type = taskPoint.getType();
|
|
|
|
@ -143,6 +144,9 @@ public class UserPointLogService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userPointLog.setScore(taskPoint.getScore());
|
|
|
|
|
userPointLog.setDescription(taskPoint.getDescription());
|
|
|
|
|
|
|
|
|
|
// 保存用户积分记录
|
|
|
|
|
userPointLogDao.save(userPointLog);
|
|
|
|
|
|
|
|
|
|