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 d7edf4f commit 4fa9850
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class LotteryEventService {

public CasperBotResponseDto postCasperBot(BaseUser user, CasperBotRequestDto casperBotRequestDto) throws CustomException, NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
LotteryEvent lotteryEvent = eventCacheService.getLotteryEvent();
LotteryParticipants participants = registerUserIfNeed(lotteryEvent, user, casperBotRequestDto);
LotteryParticipants participants = registerUserIfNeed(user, casperBotRequestDto);

CasperBot casperBot = casperBotRepository.save(new CasperBot(casperBotRequestDto, user.getPhoneNumber()));
lotteryEvent.addAppliedCount();
Expand All @@ -54,7 +54,6 @@ public CasperBotResponseDto postCasperBot(BaseUser user, CasperBotRequestDto cas

if (!casperBot.getExpectation().isEmpty()) {
participants.expectationAdded();
lotteryEvent.addAppliedCount();
}

CasperBotResponseDto casperBotDto = CasperBotResponseDto.of(casperBot);
Expand All @@ -78,7 +77,7 @@ public CasperBotResponseDto getCasperBot(Long casperId) {
}


public LotteryParticipants registerUserIfNeed(LotteryEvent lotteryEvent, BaseUser user, CasperBotRequestDto casperBotRequestDto) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
public LotteryParticipants registerUserIfNeed(BaseUser user, CasperBotRequestDto casperBotRequestDto) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
LotteryParticipants participant = lotteryParticipantsRepository.findByBaseUser(user).orElse(null);

if (participant == null) {
Expand All @@ -88,7 +87,7 @@ public LotteryParticipants registerUserIfNeed(LotteryEvent lotteryEvent, BaseUse
addReferralAppliedCount(casperBotRequestDto);

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

return participant;
}
Expand Down

0 comments on commit 4fa9850

Please sign in to comment.