release- 3.9新增筛选 仅显示本人参与

release-2024-04-25
pikaqiudeshujia 2 months ago
parent c475c6a767
commit 7c27a163e0

@ -44,4 +44,7 @@ public class LotterySearchDto {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime; private LocalDateTime endTime;
@ApiModelProperty(value = "只显示我参与的 1- 只显示我参与的")
private Integer myJoin;
} }

@ -5,11 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.luoo.user.Scheduler.DrawLotteryScheduler; import com.luoo.user.Scheduler.DrawLotteryScheduler;
import com.luoo.user.config.EnvConfig; import com.luoo.user.config.EnvConfig;
import com.luoo.user.dao.LotteryDao; import com.luoo.user.dao.*;
import com.luoo.user.dao.LotteryRegionDao;
import com.luoo.user.dao.LotteryUserDao;
import com.luoo.user.dao.UserInfoDao;
import com.luoo.user.dao.UserPointLogDao;
import com.luoo.user.dto.point.DrawDTO; import com.luoo.user.dto.point.DrawDTO;
import com.luoo.user.dto.point.LotteryParticipatedSearchDto; import com.luoo.user.dto.point.LotteryParticipatedSearchDto;
import com.luoo.user.dto.point.LotterySearchDto; import com.luoo.user.dto.point.LotterySearchDto;
@ -31,7 +27,6 @@ import enums.UserBetaEnum;
import enums.UserTypeEnum; import enums.UserTypeEnum;
import enums.UserVipStatusEnum; import enums.UserVipStatusEnum;
import exception.BizException; import exception.BizException;
import java.util.concurrent.atomic.AtomicReference;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
@ -55,6 +50,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* @program: luoo_parent * @program: luoo_parent
@ -539,41 +535,86 @@ public class LotteryService {
return new PageResult<>(jpaQueryFactory.select(qLottery.count()).from(qLottery).where(booleanBuilder).fetchOne(), list); return new PageResult<>(jpaQueryFactory.select(qLottery.count()).from(qLottery).where(booleanBuilder).fetchOne(), list);
} }
public PageResult<LotteryAPPVO> lotteryAPPVOPageResult(Integer page, Integer size, LotterySearchDto lotterySearchDto) { public PageResult<LotteryAPPVO> lotteryAPPVOPageResult(Integer page, Integer size, LotterySearchDto lotterySearchDto, UserLoginDto userLoginDto) {
BooleanBuilder booleanBuilder = new BooleanBuilder(); BooleanBuilder booleanBuilder = new BooleanBuilder();
QLottery qLottery = QLottery.lottery; QLottery qLottery = QLottery.lottery;
checkCondition(booleanBuilder, qLottery, lotterySearchDto); checkCondition(booleanBuilder, qLottery, lotterySearchDto);
booleanBuilder.and(qLottery.status.in(new Integer[]{PointEnums.LOTTERY_STATUS_LOTTERY.getCode(), PointEnums.LOTTERY_STATUS_SIGN.getCode()})); booleanBuilder.and(qLottery.status.in(new Integer[]{PointEnums.LOTTERY_STATUS_LOTTERY.getCode(), PointEnums.LOTTERY_STATUS_SIGN.getCode()}));
// 创建分页对象 // 创建分页对象
Pageable pageable = PageRequest.of(page - 1, size); Pageable pageable = PageRequest.of(page - 1, size);
List<LotteryAPPVO> list = jpaQueryFactory.select(Projections.constructor(LotteryAPPVO.class, List<LotteryAPPVO> list = new ArrayList<>();
qLottery.id, Long count = 0L;
qLottery.code, if (lotterySearchDto.getMyJoin() != null && 1 == lotterySearchDto.getMyJoin()) {
qLottery.title, if (userLoginDto != null) {
qLottery.type, QLotteryUser qLotteryUser = QLotteryUser.lotteryUser;
qLottery.num, booleanBuilder.and(qLotteryUser.userId.eq(userLoginDto.getUserId()));
qLottery.participant, // 只显示本人参与的
qLottery.point, list = jpaQueryFactory.select(Projections.constructor(LotteryAPPVO.class,
qLottery.regionCode, qLottery.id,
qLottery.regionName, qLottery.code,
qLottery.applyStartTime, qLottery.title,
qLottery.applyEndTime, qLottery.type,
qLottery.drawTime, qLottery.num,
qLottery.way, qLottery.participant,
qLottery.image, qLottery.point,
qLottery.description, qLottery.regionCode,
qLottery.status, qLottery.regionName,
qLottery.createTime, qLottery.applyStartTime,
qLottery.stopReason, qLottery.applyEndTime,
qLottery.price, qLottery.drawTime,
qLottery.publishTime qLottery.way,
)).from(qLottery) qLottery.image,
.where(booleanBuilder) qLottery.description,
.orderBy(qLottery.status.asc(), qLottery.publishTime.desc()) qLottery.status,
.offset(pageable.getOffset()) qLottery.createTime,
.limit(pageable.getPageSize()) qLottery.stopReason,
.fetch(); qLottery.price,
return new PageResult<>(jpaQueryFactory.select(qLottery.count()).from(qLottery).where(booleanBuilder).fetchOne(), list); qLottery.publishTime
)).from(qLottery)
.innerJoin(qLotteryUser)
.on(qLotteryUser.lotteryId.eq(qLottery.id))
.where(booleanBuilder)
.orderBy(qLottery.status.asc(), qLottery.publishTime.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
count = jpaQueryFactory.select(qLottery.count()).from(qLottery)
.innerJoin(qLotteryUser)
.on(qLotteryUser.lotteryId.eq(qLottery.id))
.where(booleanBuilder)
.fetchOne();
}
} else {
list = jpaQueryFactory.select(Projections.constructor(LotteryAPPVO.class,
qLottery.id,
qLottery.code,
qLottery.title,
qLottery.type,
qLottery.num,
qLottery.participant,
qLottery.point,
qLottery.regionCode,
qLottery.regionName,
qLottery.applyStartTime,
qLottery.applyEndTime,
qLottery.drawTime,
qLottery.way,
qLottery.image,
qLottery.description,
qLottery.status,
qLottery.createTime,
qLottery.stopReason,
qLottery.price,
qLottery.publishTime
)).from(qLottery)
.where(booleanBuilder)
.orderBy(qLottery.status.asc(), qLottery.publishTime.desc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
count = jpaQueryFactory.select(qLottery.count()).from(qLottery).where(booleanBuilder).fetchOne();
}
return new PageResult<>(count, list);
} }
private void checkCondition(BooleanBuilder booleanBuilder, QLottery qLottery, LotterySearchDto lotterySearch) { private void checkCondition(BooleanBuilder booleanBuilder, QLottery qLottery, LotterySearchDto lotterySearch) {
@ -604,10 +645,11 @@ public class LotteryService {
public PageResult<LotteryAPPVO> findLotteryListForApp(Integer page, Integer size, public PageResult<LotteryAPPVO> findLotteryListForApp(Integer page, Integer size,
LotterySearchDto lotterySearchDto, LotterySearchDto lotterySearchDto,
String token) { String token) {
PageResult<LotteryAPPVO> lotteryPageResult = lotteryAPPVOPageResult(page, size, lotterySearchDto); UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
PageResult<LotteryAPPVO> lotteryPageResult = lotteryAPPVOPageResult(page, size, lotterySearchDto, userLoginDto);
lotteryPageResult.getRows().forEach(lottery -> { lotteryPageResult.getRows().forEach(lottery -> {
if (StringUtils.isNotBlank(token)) { if (StringUtils.isNotBlank(token)) {
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
LotteryUser lotteryUser = lotteryUserDao.findByLotteryIdAndUserId(lottery.getId(), userLoginDto.getUserId()); LotteryUser lotteryUser = lotteryUserDao.findByLotteryIdAndUserId(lottery.getId(), userLoginDto.getUserId());
if (lotteryUser != null) { if (lotteryUser != null) {
lottery.setIsParticipate(PointEnums.PARTICIPATED.getCode()); lottery.setIsParticipate(PointEnums.PARTICIPATED.getCode());

Loading…
Cancel
Save