public void updateBettingMatch(UpdateBettingMatchInfo updateBettingMatchInfo) { BettingMatch bettingMatch = bettingMatchRepo.findOne(updateBettingMatchInfo.getBettingMatchId()); if (!bettingMatch.isActivated()) { if (updateBettingMatchInfo.getExpiredTime().isAfter(LocalDateTime.now())) { Group group = groupRepo.findOne(updateBettingMatchInfo.getGroupId()); Match match = matchRepo.findOne(updateBettingMatchInfo.getMatchId()); if (balanceIsValid(updateBettingMatchInfo.getBalance1()) && balanceIsValid(updateBettingMatchInfo.getBalance2())) { if (isExistedInTournament(match, group)) { bettingMatch.setBalance1(updateBettingMatchInfo.getBalance1()); bettingMatch.setBalance2(updateBettingMatchInfo.getBalance2()); bettingMatch.setExpiredTime(updateBettingMatchInfo.getExpiredTime()); bettingMatch.setBetAmount(updateBettingMatchInfo.getBetAmount()); bettingMatch.setMatch(match); bettingMatch.setGroup(group); bettingMatch.setDescription(updateBettingMatchInfo.getDecription()); bettingMatch.setActivated(updateBettingMatchInfo.isActivated()); bettingMatchRepo.save(bettingMatch); } else { throw new DataInvalidException("exception.match.group.invalid"); } } else { throw new DataInvalidException("exception.balance.in.valid"); } } else { throw new DataInvalidException("exception.expiredTime.invalid"); } } else { throw new DataInvalidException("exception.betting.match.is.actived"); } }
public boolean isBettingMatchNotExpired(Long bettingMatchId) { BettingMatch bettingMatch = bettingMatchRepo.findOne(bettingMatchId); if (bettingMatch.getExpiredTime().isAfter(LocalDateTime.now())) { return true; } return false; }
public BettingMatch getBettingMatchById(Long id) { return bettingMatchRepo.findOne(id); }
public void activeBettingMatch(ActiveBettingMatchInfo activeBettingMatchInfo) { BettingMatch bettingMatch = bettingMatchRepo.findOne(activeBettingMatchInfo.getBettingMatchId()); bettingMatch.setActivated(true); bettingMatchRepo.save(bettingMatch); }