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")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
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.luoo.user.Scheduler.DrawLotteryScheduler;
import com.luoo.user.config.EnvConfig;
import com.luoo.user.dao.LotteryDao;
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.dao.*;
import com.luoo.user.dto.point.DrawDTO;
import com.luoo.user.dto.point.LotteryParticipatedSearchDto;
import com.luoo.user.dto.point.LotterySearchDto;
@ -31,7 +27,6 @@ import enums.UserBetaEnum;
import enums.UserTypeEnum;
import enums.UserVipStatusEnum;
import exception.BizException;
import java.util.concurrent.atomic.AtomicReference;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
@ -55,6 +50,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
/**
* @program: luoo_parent
@ -539,41 +535,86 @@ public class LotteryService {
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();
QLottery qLottery = QLottery.lottery;
checkCondition(booleanBuilder, qLottery, lotterySearchDto);
booleanBuilder.and(qLottery.status.in(new Integer[]{PointEnums.LOTTERY_STATUS_LOTTERY.getCode(), PointEnums.LOTTERY_STATUS_SIGN.getCode()}));
// 创建分页对象
Pageable pageable = PageRequest.of(page - 1, size);
List<LotteryAPPVO> 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();
return new PageResult<>(jpaQueryFactory.select(qLottery.count()).from(qLottery).where(booleanBuilder).fetchOne(), list);
List<LotteryAPPVO> list = new ArrayList<>();
Long count = 0L;
if (lotterySearchDto.getMyJoin() != null && 1 == lotterySearchDto.getMyJoin()) {
if (userLoginDto != null) {
QLotteryUser qLotteryUser = QLotteryUser.lotteryUser;
booleanBuilder.and(qLotteryUser.userId.eq(userLoginDto.getUserId()));
// 只显示本人参与的
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)
.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) {
@ -604,10 +645,11 @@ public class LotteryService {
public PageResult<LotteryAPPVO> findLotteryListForApp(Integer page, Integer size,
LotterySearchDto lotterySearchDto,
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 -> {
if (StringUtils.isNotBlank(token)) {
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
LotteryUser lotteryUser = lotteryUserDao.findByLotteryIdAndUserId(lottery.getId(), userLoginDto.getUserId());
if (lotteryUser != null) {
lottery.setIsParticipate(PointEnums.PARTICIPATED.getCode());

Loading…
Cancel
Save