Skip to content

Commit

Permalink
fix: 추첨 인원 반영되도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
k000927 authored Aug 23, 2024
1 parent 63f210a commit 3a0867b
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
}
Expand All @@ -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) {
Expand All @@ -85,7 +86,7 @@ public LotteryParticipants registerUserIfNeed(BaseUser user, CasperBotRequestDto
addReferralAppliedCount(casperBotRequestDto);

userRepository.save(user);
}
} else lotteryEvent.addAppliedCount();

return participant;
}
Expand Down

0 comments on commit 3a0867b

Please sign in to comment.