抽奖详情(PC)
抽奖用户列表(PC)
release-2024-04-25
huangyawei 4 months ago
parent a18a8ca557
commit 13603d06c6

@ -9,9 +9,7 @@ import com.luoo.user.service.DrawLotteryService;
import com.luoo.user.service.LotteryService; import com.luoo.user.service.LotteryService;
import com.luoo.user.service.TaskPointService; import com.luoo.user.service.TaskPointService;
import com.luoo.user.service.UserPointLogService; import com.luoo.user.service.UserPointLogService;
import com.luoo.user.vo.point.LotteryAPPVO; import com.luoo.user.vo.point.*;
import com.luoo.user.vo.point.LotteryPCVO;
import com.luoo.user.vo.point.UserPointLogVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
@ -363,7 +361,7 @@ public class PointController {
} }
@ApiOperation(value = "3.10.已参与抽奖的人(APP)", notes = "APP") @ApiOperation(value = "3.10.已参与抽奖的人(APP)", notes = "APP")
@PostMapping("/lottery/participated/{page}/{size}") @GetMapping("/lottery/participated/{page}/{size}")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
public Result<PageResult<LotteryUser>> findParticipatedLotteryUserList( public Result<PageResult<LotteryUser>> findParticipatedLotteryUserList(
@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ -374,7 +372,7 @@ public class PointController {
} }
@ApiOperation(value = "3.11.抽奖结果(APP)", notes = "APP") @ApiOperation(value = "3.11.抽奖结果(APP)", notes = "APP")
@PostMapping("/lottery/result/{id}") @GetMapping("/lottery/result/{id}")
@GlobalInterceptor(checkAppUserLogin = true) @GlobalInterceptor(checkAppUserLogin = true)
public Result<Integer> findLotteryResult( public Result<Integer> findLotteryResult(
@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token, @ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ -382,5 +380,26 @@ public class PointController {
return Result.success(lotteryService.getLotteryUserResult(id, token)); return Result.success(lotteryService.getLotteryUserResult(id, token));
} }
@ApiOperation(value = "3.12.抽奖详情(PC)", notes = "PC")
@GetMapping("/lottery/detail/{id}")
@GlobalInterceptor(checkAdminLogin = true)
public Result<LotteryDetailPCVO> findLotteryDetailPCVO(
@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "抽奖id", required = true) @PathVariable String id) {
return Result.success(lotteryService.getLotteryDetailPCVO(id));
}
@ApiOperation(value = "3.13.抽奖用户列表(PC)", notes = "PC")
@GetMapping("/lottery/user/{page}/{size}")
@GlobalInterceptor(checkAdminLogin = true)
public Result<PageResult<LotteryUserDetailPCVO>> findLotteryUserList(
@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "抽奖id") String lotteryId,
@ApiParam(value = "页码", required = true) @PathVariable Integer page,
@ApiParam(value = "每页条数", required = true) @PathVariable Integer size,
@ApiParam(value = "用户类型") Integer userType) {
return Result.success(lotteryService.getLotteryUserList(page, size, lotteryId, userType));
}
} }

@ -9,7 +9,9 @@ import com.luoo.user.dao.UserInfoDao;
import com.luoo.user.dto.point.LotterySearchDto; import com.luoo.user.dto.point.LotterySearchDto;
import com.luoo.user.pojo.*; import com.luoo.user.pojo.*;
import com.luoo.user.vo.point.LotteryAPPVO; import com.luoo.user.vo.point.LotteryAPPVO;
import com.luoo.user.vo.point.LotteryDetailPCVO;
import com.luoo.user.vo.point.LotteryPCVO; import com.luoo.user.vo.point.LotteryPCVO;
import com.luoo.user.vo.point.LotteryUserDetailPCVO;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.Projections; import com.querydsl.core.types.Projections;
import com.querydsl.jpa.impl.JPAQueryFactory; import com.querydsl.jpa.impl.JPAQueryFactory;
@ -31,8 +33,6 @@ import javax.persistence.criteria.Root;
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;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
@ -570,4 +570,111 @@ public class LotteryService {
return lotteryUser.getResult(); return lotteryUser.getResult();
} }
/**
*
*
* @param lotteryId id
* @return
*/
public LotteryDetailPCVO getLotteryDetailPCVO(String lotteryId) {
QLottery qLottery = QLottery.lottery;
LotteryDetailPCVO lotteryDetailPCVO = jpaQueryFactory
.select(Projections.bean(LotteryDetailPCVO.class,
qLottery.id,
qLottery.code,
qLottery.title,
qLottery.type,
qLottery.num,
qLottery.participant,
qLottery.point,
qLottery.applyStartTime,
qLottery.applyEndTime,
qLottery.drawTime,
qLottery.way,
qLottery.image,
qLottery.description,
qLottery.status,
qLottery.createTime,
qLottery.stopReason
))
.from(qLottery)
.where(qLottery.id.eq(lotteryId))
.fetchOne();
QLotteryRegion qLotteryRegion = QLotteryRegion.lotteryRegion;
List<LotteryRegion> lotteryRegionList = jpaQueryFactory
.select(Projections.bean(LotteryRegion.class,
qLotteryRegion.id,
qLotteryRegion.regionId,
qLotteryRegion.lotteryId
))
.from(qLotteryRegion)
.where(qLotteryRegion.lotteryId.eq(lotteryId))
.fetch();
assert lotteryDetailPCVO != null;
lotteryDetailPCVO.setLotteryRegionList(lotteryRegionList);
return lotteryDetailPCVO;
}
/**
* id
*
* @param page
* @param size
* @param lotteryId id
* @param userType null- 1-
* @return
*/
public PageResult<LotteryUserDetailPCVO> getLotteryUserList(Integer page, Integer size, String lotteryId, Integer userType) {
QLotteryUser qLotteryUser = QLotteryUser.lotteryUser;
QUserInfo qUserInfo = QUserInfo.userInfo;
QRegion qRegion = QRegion.region;
BooleanBuilder booleanBuilder = new BooleanBuilder();
checkLotteryUserCondition(booleanBuilder,qLotteryUser, lotteryId, userType);
Pageable pageable = PageRequest.of(page - 1, size);
List<LotteryUserDetailPCVO> lotteryUserList = jpaQueryFactory
.select(Projections.bean(LotteryUserDetailPCVO.class,
qLotteryUser.lotteryId.as("lotteryId"),
qLotteryUser.userId.as("userId"),
qLotteryUser.regionId.as("regionId"),
qRegion.name.as("regionName"),
qUserInfo.mobile.as("mobile"),
qUserInfo.nickName.as("nickName"),
qUserInfo.point.as("point")
))
.from(qLotteryUser)
.leftJoin(qRegion)
.on(qLotteryUser.regionId.eq(qRegion.id))
.leftJoin(qUserInfo)
.on(qLotteryUser.userId.eq(qUserInfo.id))
.where(booleanBuilder)
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
long total = jpaQueryFactory
.select(qLotteryUser.count())
.from(qLotteryUser)
.leftJoin(qRegion)
.on(qLotteryUser.regionId.eq(qRegion.id))
.leftJoin(qUserInfo)
.on(qLotteryUser.userId.eq(qUserInfo.id))
.where(booleanBuilder)
.fetchCount();
return new PageResult<>(total, lotteryUserList);
}
private void checkLotteryUserCondition(BooleanBuilder booleanBuilder, QLotteryUser qLotteryUser, String lotteryId, Integer userType) {
booleanBuilder.and(qLotteryUser.lotteryId.eq(lotteryId));
if (Objects.nonNull(userType)) {
booleanBuilder.and(qLotteryUser.result.eq(userType));
}
}
} }

@ -0,0 +1,105 @@
package com.luoo.user.vo.point;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.luoo.user.pojo.LotteryRegion;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;
import java.util.List;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @program: luoo
* @description: PC
* @author: yawei.huang
* @create: 2024-08-10 10:48
**/
@Data
public class LotteryDetailPCVO {
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "抽奖编码")
private String code;
@ApiModelProperty(value = "标题")
private String title;
@ApiModelProperty(value = "抽奖类型 1-门票抽奖 2-实物抽奖")
private Integer type;
@ApiModelProperty(value = "奖品总数量")
private Integer num;
@ApiModelProperty(value = "可参加人员 1-全部 2-全部会员 3-永久会员 4-贡献者")
private Integer participant;
@ApiModelProperty(value = "积分")
private Integer point;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "报名开始时间")
private LocalDateTime applyStartTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "报名结束时间")
private LocalDateTime applyEndTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "抽奖时间")
private LocalDateTime drawTime;
@ApiModelProperty(value = "抽奖方式 1-自动抽奖 2-手动抽奖")
private Integer way;
@ApiModelProperty(value = "抽奖封面url")
private String image;
@ApiModelProperty(value = "抽奖描述")
private String description;
@ApiModelProperty(value = "抽奖状态 0-编辑中 1-报名中 2-已抽奖 3-已停止")
private Integer status;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("创建时间")
@CreatedDate
private LocalDateTime createTime;
@ApiModelProperty(value = "停止原因")
private String stopReason;
@ApiModelProperty(value = "抽奖区域列表")
List<LotteryRegion> lotteryRegionList;
public LotteryDetailPCVO() {
}
public LotteryDetailPCVO(String id, String code, String title, Integer type, Integer num, Integer participant, Integer point, LocalDateTime applyStartTime, LocalDateTime applyEndTime, LocalDateTime drawTime, Integer way, String image, String description, Integer status, LocalDateTime createTime, String stopReason) {
this.id = id;
this.code = code;
this.title = title;
this.type = type;
this.num = num;
this.participant = participant;
this.point = point;
this.applyStartTime = applyStartTime;
this.applyEndTime = applyEndTime;
this.drawTime = drawTime;
this.way = way;
this.image = image;
this.description = description;
this.status = status;
this.createTime = createTime;
this.stopReason = stopReason;
}
}

@ -0,0 +1,41 @@
package com.luoo.user.vo.point;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import lombok.Data;
/**
* @program: luoo
* @description:
* @author: yawei.huang
* @create: 2024-08-10 10:49
**/
@Data
public class LotteryUserDetailPCVO implements Serializable {
@ApiModelProperty(value = "抽奖id")
private String lotteryId;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "区域id")
private Integer regionId;
@ApiModelProperty(value = "区域名称")
private String regionName;
@ApiModelProperty(value = "手机号")
private String mobile;
@ApiModelProperty(value = "昵称")
private String nickName;
@ApiModelProperty(value = "用户积分")
private Integer point;
@ApiModelProperty(value = "用户等级")
private String level;
}
Loading…
Cancel
Save