diff --git a/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/LotteryEventService.java b/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/LotteryEventService.java index 4efc8ce6..7eddd36d 100644 --- a/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/LotteryEventService.java +++ b/Server/src/main/java/JGS/CasperEvent/domain/event/service/eventService/LotteryEventService.java @@ -42,9 +42,8 @@ public class LotteryEventService { private final EventCacheService eventCacheService; public CasperBotResponseDto postCasperBot(BaseUser user, CasperBotRequestDto casperBotRequestDto) throws CustomException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { - LotteryParticipants participants = registerUserIfNeed(user, casperBotRequestDto); - LotteryEvent lotteryEvent = eventCacheService.getLotteryEvent(); + LotteryParticipants participants = registerUserIfNeed(lotteryEvent, user, casperBotRequestDto); CasperBot casperBot = casperBotRepository.save(new CasperBot(casperBotRequestDto, user.getPhoneNumber())); lotteryEvent.addAppliedCount(); @@ -58,6 +57,8 @@ public CasperBotResponseDto postCasperBot(BaseUser user, CasperBotRequestDto cas CasperBotResponseDto casperBotDto = CasperBotResponseDto.of(casperBot); lotteryEventRedisService.addData(casperBotDto); + eventCacheService.setLotteryEvent(); + lotteryEventRepository.save(lotteryEvent); return casperBotDto; } @@ -75,7 +76,7 @@ public CasperBotResponseDto getCasperBot(Long casperId) { } - public LotteryParticipants registerUserIfNeed(BaseUser user, CasperBotRequestDto casperBotRequestDto) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { + public LotteryParticipants registerUserIfNeed(LotteryEvent lotteryEvent, BaseUser user, CasperBotRequestDto casperBotRequestDto) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException { LotteryParticipants participant = lotteryParticipantsRepository.findByBaseUser(user).orElse(null); if (participant == null) { @@ -85,7 +86,7 @@ public LotteryParticipants registerUserIfNeed(BaseUser user, CasperBotRequestDto addReferralAppliedCount(casperBotRequestDto); userRepository.save(user); - } + } else lotteryEvent.addAppliedCount(); return participant; }