release: 会员抽奖修改

release-2024-04-25
huangyw 3 months ago
parent f851ec4f22
commit b396f8a1a4

@ -338,7 +338,7 @@ public class LotteryService {
Integer participant = lottery.getParticipant(); Integer participant = lottery.getParticipant();
if (Objects.equals(participant, PointEnums.LOTTERY_ALL_MEMBER.getCode())) { 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())) { !Objects.equals(userInfo.getVipStatus(), UserVipStatusEnum.LIFE.getCode())) {
throw new BizException(ErrorConstants.NOT_MEMBER); throw new BizException(ErrorConstants.NOT_MEMBER);
} }

@ -204,46 +204,37 @@ public class UserPointLogService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void executeDraw(DrawDTO drawDTO) { public void executeDraw(DrawDTO drawDTO) {
String taskPointId = drawDTO.getTaskPointId(); // 调整用户积分
if (taskPointId != null) { UserInfo userInfo = userInfoDao.findById(drawDTO.getUserId()).get();
TaskPoint taskPoint = taskPointService.getTaskPoint(taskPointId); int point = userInfo.getPoint() == null ? 0 : userInfo.getPoint();
if(taskPoint == null) { if(point < drawDTO.getScore()) {
return ; throw new BizException(ErrorConstants.POINT_NOT_ENOUGH);
} }
userInfo.setPoint(point - drawDTO.getScore());
userInfoDao.save(userInfo);
// 调整用户积分 UserPointLog userPointLog = UserPointLog.builder()
UserInfo userInfo = userInfoDao.findById(drawDTO.getUserId()).get(); .id(String.valueOf(idWorker.nextId()))
int point = userInfo.getPoint() == null ? 0 : userInfo.getPoint(); .type(PointEnums.TASK_POINT_TYPE_REDUCE.getCode())
if(point < taskPoint.getScore()) { .createUser(drawDTO.getUserId())
throw new BizException(ErrorConstants.POINT_NOT_ENOUGH); .description(LOTTERY_POINTS_TYPE)
} .userId(drawDTO.getUserId())
userInfo.setPoint(point - taskPoint.getScore()); .score(drawDTO.getScore())
userInfoDao.save(userInfo); .build();
userPointLogDao.save(userPointLog);
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);
// 确保先扣除积分,再报名成功 // 确保先扣除积分,再报名成功
// 抽奖报名成功 // 抽奖报名成功
LotteryUser lotteryUser = LotteryUser.builder() LotteryUser lotteryUser = LotteryUser.builder()
.id(String.valueOf(idWorker.nextId())) .id(String.valueOf(idWorker.nextId()))
.lotteryId(drawDTO.getLotteryId()) .lotteryId(drawDTO.getLotteryId())
.regionId(drawDTO.getRegionId()) .regionId(drawDTO.getRegionId())
.userId(drawDTO.getUserId()) .userId(drawDTO.getUserId())
.createUser(drawDTO.getUserId()) .createUser(drawDTO.getUserId())
.updateUser(drawDTO.getUserId()) .updateUser(drawDTO.getUserId())
.build(); .build();
lotteryUserDao.save(lotteryUser); lotteryUserDao.save(lotteryUser);
}
} }
/** /**

@ -1,3 +1,5 @@
alter table tb_task_point alter table tb_task_point
add action varchar(50) null comment 'APP动作'; add action varchar(50) null comment 'APP动作';
alter table tb_task_point
add task_point_id varchar(20) null comment 'tb_task_point表id';
Loading…
Cancel
Save