From 99e85800402b83b2519c1deffe7d394c8425a75c Mon Sep 17 00:00:00 2001 From: huangyw <1207046171@qq.com> Date: Fri, 11 Oct 2024 09:34:44 +0800 Subject: [PATCH] =?UTF-8?q?release:=20=E8=AE=B0=E5=BD=95=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E5=B7=B2=E5=BC=B9=E5=87=BA=E6=8A=BD=E5=A5=96=E7=BB=93=E6=9E=9C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/enums/PointEnums.java | 3 ++ .../luoo/user/controller/PointController.java | 11 +++- .../java/com/luoo/user/pojo/LotteryUser.java | 4 ++ .../com/luoo/user/service/LotteryService.java | 54 +++++++++++++++---- .../user/service/UserPointLogService.java | 1 + .../luoo/user/vo/point/LotteryUserAPPVO.java | 26 +++++++++ luoo_user/src/main/resources/sql/20240904.sql | 5 +- 7 files changed, 91 insertions(+), 13 deletions(-) diff --git a/luoo_common/src/main/java/enums/PointEnums.java b/luoo_common/src/main/java/enums/PointEnums.java index a7841f9..8a93d05 100644 --- a/luoo_common/src/main/java/enums/PointEnums.java +++ b/luoo_common/src/main/java/enums/PointEnums.java @@ -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; diff --git a/luoo_user/src/main/java/com/luoo/user/controller/PointController.java b/luoo_user/src/main/java/com/luoo/user/controller/PointController.java index 6e7e3b7..a3a8140 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/PointController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/PointController.java @@ -385,7 +385,7 @@ public class PointController { @ApiOperation(value = "3.11.抽奖结果(APP)", notes = "APP") @GetMapping("/lottery/result/{id}") @GlobalInterceptor(checkAppUserLogin = true) - public Result findLotteryResult( + public Result 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 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(); + } } diff --git a/luoo_user/src/main/java/com/luoo/user/pojo/LotteryUser.java b/luoo_user/src/main/java/com/luoo/user/pojo/LotteryUser.java index 8111931..a6e14c9 100644 --- a/luoo_user/src/main/java/com/luoo/user/pojo/LotteryUser.java +++ b/luoo_user/src/main/java/com/luoo/user/pojo/LotteryUser.java @@ -85,4 +85,8 @@ public class LotteryUser implements Serializable { @ApiModelProperty(value = "更新人") private String updateUser; + @Column(name = "popup") + @ApiModelProperty(value = "是否已弹出弹框 0-默认状态,未弹出 1-已弹出") + private Integer popup; + } \ No newline at end of file diff --git a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java index dbe2f65..911f774 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/LotteryService.java @@ -580,14 +580,6 @@ public class LotteryService { } public PageResult findPageByLotteryId(Integer page, Integer size, String lotteryId) { -// Sort sort = new Sort(Direction.DESC, "createTime"); -// PageRequest pageRequest = PageRequest.of(page - 1, size, sort); -// -// Specification specification = getLotteryUserSpecification(lotteryId); -// Page 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)) { diff --git a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java index c977537..0a7a8ee 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/UserPointLogService.java @@ -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); diff --git a/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryUserAPPVO.java b/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryUserAPPVO.java index 0fb5f3a..6d9cb4e 100644 --- a/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryUserAPPVO.java +++ b/luoo_user/src/main/java/com/luoo/user/vo/point/LotteryUserAPPVO.java @@ -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; + } } diff --git a/luoo_user/src/main/resources/sql/20240904.sql b/luoo_user/src/main/resources/sql/20240904.sql index 956fb84..89bc3be 100644 --- a/luoo_user/src/main/resources/sql/20240904.sql +++ b/luoo_user/src/main/resources/sql/20240904.sql @@ -24,4 +24,7 @@ alter table tb_lottery add publish_time datetime null comment '发布时间'; alter table tb_lottery - add price decimal null comment '抽奖物品价格'; \ No newline at end of file + add price decimal null comment '抽奖物品价格'; + +alter table tb_lottery_user + add popup tinyint null comment '是否已弹出弹框 0-默认状态,未弹出 1-已弹出';