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; }
private boolean bettingMatchIsExisted(Long groupId, Long matchId) { List<BettingMatch> bettingMatchs = new ArrayList<>(); bettingMatchs = bettingMatchRepo.findAllByOrderByCreatedAtDesc(); for (BettingMatch bettingMatch : bettingMatchs) { if (bettingMatch.getGroup().getId().equals(groupId) && bettingMatch.getMatch().getId().equals(matchId)) { return true; } } return false; }
public List<BettingMatch> getBettingMatchesByRoundAndGroupId( GetBettingMatchesByRoundAndGroupIdInfo getBettingMatchesByRoundAndGroupIdInfo) { List<BettingMatch> bettingMatches = new ArrayList<>(); Round round = roundRepo.getOne(getBettingMatchesByRoundAndGroupIdInfo.getRoundId()); Group group = groupRepo.getOne(getBettingMatchesByRoundAndGroupIdInfo.getGroupId()); List<Match> matches = matchRepo.findByRound(round); for (Match match : matches) { bettingMatches.add(bettingMatchRepo.findByGroupAndMatch(group, match)); } return bettingMatches; }
@Transactional(readOnly = true) public BettingMatch findActiveBettingMatchById(Long id) { return bettingMatchRepo.findByIdAndActivated(id, true).get(); }
public BettingMatch getBettingMatchById(Long id) { return bettingMatchRepo.findOne(id); }
public List<BettingMatch> getBettingMatchesByMatch(Long matchId) { Match match = matchRepo.getOne(matchId); return bettingMatchRepo.findByMatch(match); }
public void activeBettingMatch(ActiveBettingMatchInfo activeBettingMatchInfo) { BettingMatch bettingMatch = bettingMatchRepo.findOne(activeBettingMatchInfo.getBettingMatchId()); bettingMatch.setActivated(true); bettingMatchRepo.save(bettingMatch); }