|
|
@ -309,10 +309,6 @@ public class LotteryService {
|
|
|
|
|
|
|
|
|
|
|
|
// 校验用户是否可参与
|
|
|
|
// 校验用户是否可参与
|
|
|
|
UserInfo userInfo = userInfoDao.findById(userLoginDto.getUserId()).get();
|
|
|
|
UserInfo userInfo = userInfoDao.findById(userLoginDto.getUserId()).get();
|
|
|
|
List<LotteryUser> list = lotteryUserDao.findByLotteryIdAndUserId(id, userLoginDto.getUserId());
|
|
|
|
|
|
|
|
if (list != null && !list.isEmpty()) {
|
|
|
|
|
|
|
|
throw new BizException(ErrorConstants.ALREADY_PARTICIPATED_CANNOT_PARTICIPATE_AGAIN);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer participant = lottery.getParticipant();
|
|
|
|
Integer participant = lottery.getParticipant();
|
|
|
|
if (Objects.equals(participant, PointEnums.LOTTERY_ALL_MEMBER.getCode())) {
|
|
|
|
if (Objects.equals(participant, PointEnums.LOTTERY_ALL_MEMBER.getCode())) {
|
|
|
@ -340,9 +336,9 @@ public class LotteryService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<LotteryUser> checkUserList = lotteryUserDao.findByLotteryIdAndUserIdAndRegionId(
|
|
|
|
LotteryUser checkLotteryUser = lotteryUserDao.findByLotteryIdAndUserId(
|
|
|
|
id, userLoginDto.getUserId(), regionId);
|
|
|
|
id, userLoginDto.getUserId());
|
|
|
|
if (!checkUserList.isEmpty()) {
|
|
|
|
if (checkLotteryUser != null) {
|
|
|
|
throw new BizException(ErrorConstants.ALREADY_PARTICIPATED);
|
|
|
|
throw new BizException(ErrorConstants.ALREADY_PARTICIPATED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -398,8 +394,8 @@ public class LotteryService {
|
|
|
|
lotteryPageResult.getRows().forEach(lottery -> {
|
|
|
|
lotteryPageResult.getRows().forEach(lottery -> {
|
|
|
|
if (StringUtils.isNotBlank(token)) {
|
|
|
|
if (StringUtils.isNotBlank(token)) {
|
|
|
|
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
|
|
|
|
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
|
|
|
|
List<LotteryUser> list = lotteryUserDao.findByLotteryIdAndUserId(lottery.getId(), userLoginDto.getUserId());
|
|
|
|
LotteryUser lotteryUser = lotteryUserDao.findByLotteryIdAndUserId(lottery.getId(), userLoginDto.getUserId());
|
|
|
|
if (!list.isEmpty()) {
|
|
|
|
if (lotteryUser != null) {
|
|
|
|
lottery.setIsParticipate(PointEnums.PARTICIPATED.getCode());
|
|
|
|
lottery.setIsParticipate(PointEnums.PARTICIPATED.getCode());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
lottery.setIsParticipate(PointEnums.NOT_PARTICIPATED.getCode());
|
|
|
|
lottery.setIsParticipate(PointEnums.NOT_PARTICIPATED.getCode());
|
|
|
@ -449,5 +445,35 @@ public class LotteryService {
|
|
|
|
return lotteryRegionList;
|
|
|
|
return lotteryRegionList;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PageResult<LotteryUser> findPageByLotteryId(Integer page, Integer size, String lotteryId) {
|
|
|
|
|
|
|
|
Sort sort = new Sort(Direction.DESC, "createTime");
|
|
|
|
|
|
|
|
PageRequest pageRequest = PageRequest.of(page - 1, size, sort);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Specification<LotteryUser> specification = getLotteryUserSpecification(lotteryId);
|
|
|
|
|
|
|
|
Page<LotteryUser> lotteryUserPage = lotteryUserDao.findAll(specification, pageRequest);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long totalElements = lotteryUserPage.getTotalElements();
|
|
|
|
|
|
|
|
return new PageResult<>(totalElements, lotteryUserPage.getContent());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Specification<LotteryUser> getLotteryUserSpecification(String lotteryId) {
|
|
|
|
|
|
|
|
return (Root<LotteryUser> root, CriteriaQuery<?> query, CriteriaBuilder criteriaBuilder) -> {
|
|
|
|
|
|
|
|
List<Predicate> predicateList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(lotteryId)) {
|
|
|
|
|
|
|
|
predicateList.add(
|
|
|
|
|
|
|
|
criteriaBuilder.equal(root.get("lotteryId"), lotteryId));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return criteriaBuilder.and(predicateList.toArray(new Predicate[predicateList.size()]));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Integer getLotteryUserResult(String lotteryId, String token) {
|
|
|
|
|
|
|
|
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
|
|
|
|
|
|
|
|
LotteryUser lotteryUser = lotteryUserDao.findByLotteryIdAndUserId(lotteryId, userLoginDto.getUserId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return lotteryUser.getResult();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|