release: 记录是否已弹出抽奖结果接口

release-2024-04-25
huangyw 1 month ago
parent 72c714b3c7
commit 99e8580040

@ -41,6 +41,9 @@ public enum PointEnums {
PARTICIPATED(1, "已参加"),
NOT_PARTICIPATED(2, "未参加"),
ALREADY_POPUP(1, "已弹出"),
NOT_POPUP(0, "未弹出"),
;
private final Integer code;
private final String description;

@ -385,7 +385,7 @@ public class PointController {
@ApiOperation(value = "3.11.抽奖结果(APP)", notes = "APP")
@GetMapping("/lottery/result/{id}")
@GlobalInterceptor(checkAppUserLogin = true)
public Result<Integer> findLotteryResult(
public Result<LotteryUserAPPVO> findLotteryResult(
@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "抽奖id", required = true) @PathVariable String id) {
return Result.success(lotteryService.getLotteryUserResult(id, token));
@ -426,6 +426,15 @@ public class PointController {
return Result.success(lotteryService.getLotteryDetailAPPVO(id));
}
@ApiOperation(value = "3.15. 记录用户中奖信息已弹出", notes = "APP")
@PostMapping("/app/popup")
@GlobalInterceptor(checkAppUserLogin = true)
public Result<Void> popup(
@ApiParam(value = "Header中的token信息", required = true) @RequestHeader("Authorization") String token,
@ApiParam(value = "lotteryUser表抽奖用户绑定id", required = true) @PathVariable String id) {
lotteryService.popup(id);
return Result.success();
}
}

@ -85,4 +85,8 @@ public class LotteryUser implements Serializable {
@ApiModelProperty(value = "更新人")
private String updateUser;
@Column(name = "popup")
@ApiModelProperty(value = "是否已弹出弹框 0-默认状态,未弹出 1-已弹出")
private Integer popup;
}

@ -580,14 +580,6 @@ public class LotteryService {
}
public PageResult<LotteryUserAPPVO> 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());
QLotteryUser qLotteryUser = QLotteryUser.lotteryUser;
QUserInfo qUserInfo = QUserInfo.userInfo;
@ -644,11 +636,44 @@ public class LotteryService {
};
}
public Integer getLotteryUserResult(String lotteryId, String token) {
public LotteryUserAPPVO getLotteryUserResult(String lotteryId, String token) {
QLotteryUser qLotteryUser = QLotteryUser.lotteryUser;
QUserInfo qUserInfo = QUserInfo.userInfo;
QRegion qRegion = QRegion.region;
UserLoginDto userLoginDto = jwtUtil.getUserLoginDto(token);
LotteryUser lotteryUser = lotteryUserDao.findByLotteryIdAndUserId(lotteryId, userLoginDto.getUserId());
return lotteryUser.getResult();
BooleanBuilder booleanBuilder = new BooleanBuilder();
booleanBuilder.and(qLotteryUser.lotteryId.eq(lotteryId));
booleanBuilder.and(qLotteryUser.userId.eq(userLoginDto.getUserId()));
// 头像字段拼接字符串
StringExpression avatarWithPrefix = Expressions.stringTemplate("{0} || {1}", Constants.RESOURCE_PREFIX, qUserInfo.avatar);
return jpaQueryFactory
.select(Projections.bean(LotteryUserAPPVO.class,
qLotteryUser.id.as("id"),
qLotteryUser.lotteryId.as("lotteryId"),
qLotteryUser.userId.as("userId"),
qLotteryUser.regionId.as("regionId"),
qLotteryUser.result.as("result"),
qLotteryUser.createTime.as("createTime"),
qLotteryUser.updateTime.as("updateTime"),
qLotteryUser.createUser.as("createUser"),
qLotteryUser.updateUser.as("updateUser"),
qUserInfo.nickName.as("nickName"),
avatarWithPrefix.as("avatar"),
qLotteryUser.popup.as("popup"),
qRegion.name.as("regionName"),
qRegion.code.as("regionCode")
))
.from(qLotteryUser)
.leftJoin(qUserInfo)
.on(qLotteryUser.userId.eq(qUserInfo.id))
.leftJoin(qRegion)
.on(qLotteryUser.regionId.eq(qRegion.id))
.where(booleanBuilder)
.fetchOne();
}
/**
@ -782,6 +807,13 @@ public class LotteryService {
}
@Transactional(rollbackFor = Exception.class)
public void popup(String lotteryUserId) {
LotteryUser one = lotteryUserDao.getOne(lotteryUserId);
one.setPopup(PointEnums.ALREADY_POPUP.getCode());
lotteryUserDao.save(one);
}
private void checkLotteryUserCondition(BooleanBuilder booleanBuilder, QLotteryUser qLotteryUser, String lotteryId, Integer userType) {
booleanBuilder.and(qLotteryUser.lotteryId.eq(lotteryId));
if (Objects.nonNull(userType)) {

@ -253,6 +253,7 @@ public class UserPointLogService {
.userId(drawDTO.getUserId())
.createUser(drawDTO.getUserId())
.updateUser(drawDTO.getUserId())
.popup(PointEnums.NOT_POPUP.getCode())
.build();
lotteryUserDao.save(lotteryUser);

@ -61,6 +61,15 @@ public class LotteryUserAPPVO implements Serializable {
@ApiModelProperty(value = "抽奖人头像")
private String avatar;
@ApiModelProperty(value = "是否已弹出弹框 0-默认状态,未弹出 1-已弹出")
private Integer popup;
@ApiModelProperty(value = "区域名称")
private String regionName;
@ApiModelProperty(value = "区域编码")
private String regionCode;
public LotteryUserAPPVO() {
}
@ -77,4 +86,21 @@ public class LotteryUserAPPVO implements Serializable {
this.nickName = nickName;
this.avatar = avatar;
}
public LotteryUserAPPVO(String id, String lotteryId, String userId, Integer regionId, Integer result, LocalDateTime createTime, LocalDateTime updateTime, String createUser, String updateUser, String nickName, String avatar, Integer popup, String regionName, String regionCode) {
this.id = id;
this.lotteryId = lotteryId;
this.userId = userId;
this.regionId = regionId;
this.result = result;
this.createTime = createTime;
this.updateTime = updateTime;
this.createUser = createUser;
this.updateUser = updateUser;
this.nickName = nickName;
this.avatar = avatar;
this.popup = popup;
this.regionName = regionName;
this.regionCode = regionCode;
}
}

@ -24,4 +24,7 @@ alter table tb_lottery
add publish_time datetime null comment '发布时间';
alter table tb_lottery
add price decimal null comment '抽奖物品价格';
add price decimal null comment '抽奖物品价格';
alter table tb_lottery_user
add popup tinyint null comment '是否已弹出弹框 0-默认状态,未弹出 1-已弹出';

Loading…
Cancel
Save