From b396f8a1a4db418c274a9a11df3b02bb5972bde4 Mon Sep 17 00:00:00 2001 From: huangyw <1207046171@qq.com> Date: Mon, 19 Aug 2024 15:09:36 +0800 Subject: [PATCH] =?UTF-8?q?release:=20=E4=BC=9A=E5=91=98=E6=8A=BD=E5=A5=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/luoo/user/service/LotteryService.java | 2 +- .../user/service/UserPointLogService.java | 67 ++++++++----------- luoo_user/src/main/resources/sql/20240815.sql | 2 + 3 files changed, 32 insertions(+), 39 deletions(-) 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 8de7f3a..fba3ef0 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 @@ -338,7 +338,7 @@ public class LotteryService { Integer participant = lottery.getParticipant(); if (Objects.equals(participant, PointEnums.LOTTERY_ALL_MEMBER.getCode())) { // 会员可参与 - if (!Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.INITIAL.getCode()) && + if (!Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.ACTIVE.getCode()) && !Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.LIFE.getCode())) { throw new BizException(ErrorConstants.NOT_MEMBER); } 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 d360416..d519c7e 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 @@ -204,46 +204,37 @@ public class UserPointLogService { @Transactional(rollbackFor = Exception.class) public void executeDraw(DrawDTO drawDTO) { - String taskPointId = drawDTO.getTaskPointId(); - if (taskPointId != null) { - TaskPoint taskPoint = taskPointService.getTaskPoint(taskPointId); - if(taskPoint == null) { - return ; - } + // 调整用户积分 + UserInfo userInfo = userInfoDao.findById(drawDTO.getUserId()).get(); + int point = userInfo.getPoint() == null ? 0 : userInfo.getPoint(); + if(point < drawDTO.getScore()) { + throw new BizException(ErrorConstants.POINT_NOT_ENOUGH); + } + userInfo.setPoint(point - drawDTO.getScore()); + userInfoDao.save(userInfo); - // 调整用户积分 - UserInfo userInfo = userInfoDao.findById(drawDTO.getUserId()).get(); - int point = userInfo.getPoint() == null ? 0 : userInfo.getPoint(); - if(point < taskPoint.getScore()) { - throw new BizException(ErrorConstants.POINT_NOT_ENOUGH); - } - userInfo.setPoint(point - taskPoint.getScore()); - userInfoDao.save(userInfo); - - UserPointLog userPointLog = UserPointLog.builder() - .id(String.valueOf(idWorker.nextId())) - .type(PointEnums.TASK_POINT_TYPE_REDUCE.getCode()) - .createUser(drawDTO.getUserId()) - .taskPointId(null) - .description(LOTTERY_POINTS_TYPE) - .userId(drawDTO.getUserId()) - .score(point) - .build(); - userPointLogDao.save(userPointLog); + UserPointLog userPointLog = UserPointLog.builder() + .id(String.valueOf(idWorker.nextId())) + .type(PointEnums.TASK_POINT_TYPE_REDUCE.getCode()) + .createUser(drawDTO.getUserId()) + .description(LOTTERY_POINTS_TYPE) + .userId(drawDTO.getUserId()) + .score(drawDTO.getScore()) + .build(); + userPointLogDao.save(userPointLog); - // 确保先扣除积分,再报名成功 - // 抽奖报名成功 - LotteryUser lotteryUser = LotteryUser.builder() - .id(String.valueOf(idWorker.nextId())) - .lotteryId(drawDTO.getLotteryId()) - .regionId(drawDTO.getRegionId()) - .userId(drawDTO.getUserId()) - .createUser(drawDTO.getUserId()) - .updateUser(drawDTO.getUserId()) - .build(); - - lotteryUserDao.save(lotteryUser); - } + // 确保先扣除积分,再报名成功 + // 抽奖报名成功 + LotteryUser lotteryUser = LotteryUser.builder() + .id(String.valueOf(idWorker.nextId())) + .lotteryId(drawDTO.getLotteryId()) + .regionId(drawDTO.getRegionId()) + .userId(drawDTO.getUserId()) + .createUser(drawDTO.getUserId()) + .updateUser(drawDTO.getUserId()) + .build(); + + lotteryUserDao.save(lotteryUser); } /** diff --git a/luoo_user/src/main/resources/sql/20240815.sql b/luoo_user/src/main/resources/sql/20240815.sql index 970a65e..7aa6997 100644 --- a/luoo_user/src/main/resources/sql/20240815.sql +++ b/luoo_user/src/main/resources/sql/20240815.sql @@ -1,3 +1,5 @@ alter table tb_task_point add action varchar(50) null comment 'APP动作'; +alter table tb_task_point + add task_point_id varchar(20) null comment 'tb_task_point表id'; \ No newline at end of file