| | |
| | | package com.dsh.communityWorldCup.service.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.communityWorldCup.entity.WorldCup; |
| | |
| | | import java.math.RoundingMode; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | }else{ |
| | | wrapper.eq("participantType", 1); |
| | | } |
| | | int win = this.count(wrapper.eq("participantId", entrantRank.getId()).eq("matchResult", 1)); |
| | | int win = this.count(wrapper.eq("participantId", entrantRank.getId()).in("matchResult", Arrays.asList(0, 1))); |
| | | entrantRankVo.setWin(win); |
| | | |
| | | wrapper = new QueryWrapper<>(); |
| | |
| | | AppUser appUser = appUserClient.getAppUser(worldCupRank.getAppUserId()); |
| | | appUserIds = appUserClient.getAppUserIds(appUser.getCityCode()); |
| | | } |
| | | List<Map<String, Object>> lists = this.baseMapper.getWorldCupRank(worldCupRank, appUserIds); |
| | | List<WorldCupRankVo> list = new ArrayList<>(); |
| | | String sTime = null; |
| | | String eTime = null; |
| | | if(ToolUtil.isNotEmpty(worldCupRank.getTime())){ |
| | | sTime = worldCupRank.getTime().split(" - ")[0] + " 00:00:00"; |
| | | eTime = worldCupRank.getTime().split(" - ")[1] + " 23:59:59"; |
| | | } |
| | | |
| | | //总场次 |
| | | List<Map<String, Object>> lists = this.baseMapper.getWorldCupRank(worldCupRank, appUserIds, sTime, eTime); |
| | | |
| | | //未负的数据 |
| | | List<Map<String, Object>> lists1 = this.baseMapper.getWorldCupRank1(worldCupRank, appUserIds, sTime, eTime); |
| | | |
| | | List<Map<String, Object>> mapList = new ArrayList<>(); |
| | | for (int i = 0; i < lists.size(); i++) { |
| | | Map<String, Object> map = lists.get(i); |
| | | Integer participantType = Integer.valueOf(map.get("participantType").toString()); |
| | | Long participantId = Long.valueOf(map.get("participantId").toString()); |
| | | Integer appUserId = Integer.valueOf(map.get("appUserId").toString()); |
| | | Integer num = Integer.valueOf(null == map.get("num") ? "0" : map.get("num").toString()); |
| | | Integer winIntegral = Integer.valueOf(null == map.get("winIntegral") ? "0" : map.get("winIntegral").toString()); |
| | | Integer drawIntegral = Integer.valueOf(null == map.get("drawIntegral") ? "0" : map.get("drawIntegral").toString()); |
| | | Integer loseIntegral = Integer.valueOf(null == map.get("loseIntegral") ? "0" : map.get("loseIntegral").toString()); |
| | | //学员 |
| | | if(participantType == 1){ |
| | | TStudent tStudent = studentClient.queryById(participantId.intValue()); |
| | | if(tStudent.getState() != 1){ |
| | | continue; |
| | | } |
| | | } |
| | | //参赛人员 |
| | | if(participantType == 2){ |
| | | Participant participant = participantClient.getParticipant(participantId); |
| | | if(participant.getState() != 1){ |
| | | continue; |
| | | } |
| | | } |
| | | map.put("totalSession", num); |
| | | map.put("totalIntegral", winIntegral+drawIntegral+loseIntegral); |
| | | map.put("winRate", "0"); |
| | | for (Map<String, Object> objectMap : lists1) { |
| | | Integer participantType1 = Integer.valueOf(objectMap.get("participantType").toString()); |
| | | Long participantId1 = Long.valueOf(objectMap.get("participantId").toString()); |
| | | Integer appUserId1 = Integer.valueOf(objectMap.get("appUserId").toString()); |
| | | Integer num1 = Integer.valueOf(null == objectMap.get("num") ? "0" : objectMap.get("num").toString()); |
| | | if(participantType.compareTo(participantType1) == 0 && participantId.compareTo(participantId1) == 0 && appUserId.compareTo(appUserId1) == 0){ |
| | | map.put("winRate", new BigDecimal(num1).divide(new BigDecimal(num), new MathContext(4, RoundingMode.HALF_EVEN)).multiply(new BigDecimal(100)).doubleValue()); |
| | | break; |
| | | } |
| | | } |
| | | mapList.add(map); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // if(worldCupRank.getSort() == 1){ |
| | | // mapList.sort(new Comparator<Map<String, Object>>() { |
| | | // @Override |
| | | // public int compare(Map<String, Object> o1, Map<String, Object> o2) { |
| | | // return Double.valueOf(o1.get("totalSession").toString()).compareTo(Double.valueOf(o2.get("totalSession").toString())) * -1; |
| | | // } |
| | | // }); |
| | | // } |
| | | // if(worldCupRank.getSort() == 2){ |
| | | // mapList.sort(new Comparator<Map<String, Object>>() { |
| | | // @Override |
| | | // public int compare(Map<String, Object> o1, Map<String, Object> o2) { |
| | | // return Double.valueOf(o1.get("winRate").toString()).compareTo(Double.valueOf(o2.get("winRate").toString())) * -1; |
| | | // } |
| | | // }); |
| | | // } |
| | | |
| | | |
| | | List<WorldCupRankVo> list = new ArrayList<>(); |
| | | for (int i = 0; i < mapList.size(); i++) { |
| | | Map<String, Object> map = mapList.get(i); |
| | | Integer participantType = Integer.valueOf(map.get("participantType").toString()); |
| | | Long participantId = Long.valueOf(map.get("participantId").toString()); |
| | | Integer appUserId = Integer.valueOf(map.get("appUserId").toString()); |
| | | Integer totalSession = Integer.valueOf(map.get("totalSession").toString()); |
| | | Integer totalIntegral = Integer.valueOf(map.get("totalIntegral").toString()); |
| | | Double winRate = Double.valueOf(map.get("winRate").toString()); |
| | | //自己排名在20内的标识 |
| | | boolean b = false; |
| | | if(i <= 19){ |
| | | WorldCupRankVo worldCupRankVo = new WorldCupRankVo(); |
| | | worldCupRankVo.setRank(i + 1); |
| | | worldCupRankVo.setIntegral(totalIntegral); |
| | | worldCupRankVo.setTotalSession(totalSession); |
| | | worldCupRankVo.setWinRate(winRate); |
| | | //学员 |
| | |
| | | } |
| | | } |
| | | } |
| | | // 排序 |
| | | list= list.stream().sorted(Comparator.comparing(WorldCupRankVo::getIntegral).reversed().thenComparing(WorldCupRankVo::getTotalSession).reversed().thenComparing(WorldCupRankVo::getWinRate).reversed()).collect(Collectors.toList()); |
| | | return list; |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void endWorldCupCallback(String custom, Integer red_score, Integer blue_score) { |
| | | List<Long> ids = JSON.parseArray(custom, Long.class); |
| | | JSONObject jsonObject = JSON.parseObject(custom); |
| | | Integer gameType = jsonObject.getInteger("gameType"); |
| | | //智慧球场比赛 |
| | | if(2 == gameType){ |
| | | return; |
| | | } |
| | | List<Long> ids = jsonObject.getJSONArray("ids").toJavaList(Long.class); |
| | | List<WorldCupCompetitor> worldCupCompetitors = this.listByIds(ids); |
| | | try { |
| | | WorldCupCompetitor worldCupCompetitor1 = worldCupCompetitors.get(0); |
| | |
| | | worldCupCompetitor.setOpponentScore(red_score); |
| | | worldCupCompetitor.setEndTime(new Date()); |
| | | worldCupCompetitor.setWinIntegral(0); |
| | | if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && blue_score.compareTo(red_score) >= 0){ |
| | | worldCupCompetitor.setDrawIntegral(0); |
| | | worldCupCompetitor.setLoseIntegral(0); |
| | | if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && blue_score.compareTo(red_score) > 0){ |
| | | worldCupCompetitor.setWinIntegral(worldCup.getWinIntegral()); |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(worldCupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getWinIntegral()); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | }else if(null != worldCup.getDrawIntegral() && 0 < worldCup.getDrawIntegral() && blue_score.compareTo(red_score) == 0){ |
| | | worldCupCompetitor.setDrawIntegral(worldCup.getDrawIntegral()); |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(worldCupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getDrawIntegral()); |
| | | vo.setType(9); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | }else if(null != worldCup.getLoseIntegral() && 0 < worldCup.getLoseIntegral() && blue_score.compareTo(red_score) < 0){ |
| | | worldCupCompetitor.setDrawIntegral(worldCup.getLoseIntegral()); |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(worldCupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getLoseIntegral()); |
| | | vo.setType(10); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | } |
| | | } |
| | |
| | | worldCupCompetitor.setOpponentScore(blue_score); |
| | | worldCupCompetitor.setEndTime(new Date()); |
| | | worldCupCompetitor.setWinIntegral(0); |
| | | if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && red_score.compareTo(blue_score) >= 0){ |
| | | worldCupCompetitor.setDrawIntegral(0); |
| | | worldCupCompetitor.setLoseIntegral(0); |
| | | if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && red_score.compareTo(blue_score) > 0){ |
| | | worldCupCompetitor.setWinIntegral(worldCup.getWinIntegral()); |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(worldCupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getWinIntegral()); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | }else if(null != worldCup.getDrawIntegral() && 0 < worldCup.getDrawIntegral() && blue_score.compareTo(red_score) == 0){ |
| | | worldCupCompetitor.setDrawIntegral(worldCup.getDrawIntegral()); |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(worldCupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getDrawIntegral()); |
| | | vo.setType(9); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | }else if(null != worldCup.getLoseIntegral() && 0 < worldCup.getLoseIntegral() && blue_score.compareTo(red_score) < 0){ |
| | | worldCupCompetitor.setDrawIntegral(worldCup.getLoseIntegral()); |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(worldCupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getLoseIntegral()); |
| | | vo.setType(10); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | } |
| | | } |
| | |
| | | appUserIdsByCityName.setProvince(worldCupRecords.getProvince()); |
| | | appUserIdsByCityName.setCity(worldCupRecords.getCity()); |
| | | List<Integer> appUserIds = appUserClient.getAppUserIdsByCityName(appUserIdsByCityName); |
| | | List<Map<String, Object>> mapList = this.baseMapper.worldCupRecordsList(worldCupRecords, appUserIds); |
| | | String time = worldCupRecords.getTime(); |
| | | String sTime = null; |
| | | String eTime = null; |
| | | if(ToolUtil.isNotEmpty(time)){ |
| | | sTime = time.split(" - ")[0] + " 00:00:00"; |
| | | eTime = time.split(" - ")[1] + " 23:59:59"; |
| | | } |
| | | List<Map<String, Object>> mapList = this.baseMapper.worldCupRecordsList(worldCupRecords, appUserIds,sTime,eTime); |
| | | List<Map<String, Object>> mapList1 = this.baseMapper.worldCupRecordsList1(worldCupRecords, appUserIds,sTime,eTime); |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | int row_num = 0; |
| | | for (int i = 0; i < mapList.size(); i++) { |
| | | Map<String, Object> map = mapList.get(i); |
| | | Integer participantType = Integer.valueOf(map.get("participantType").toString()); |
| | | Long participantId = Long.valueOf(map.get("participantId").toString()); |
| | | Integer appUserId = Integer.valueOf(map.get("appUserId").toString()); |
| | | Integer totalSession = Integer.valueOf(map.get("totalSession").toString()); |
| | | Integer num = Integer.valueOf(null == map.get("num") ? "0" : map.get("num").toString()); |
| | | //学员 |
| | | if(participantType == 1){ |
| | | TStudent tStudent = studentClient.queryById(participantId.intValue()); |
| | | if(tStudent.getState() != 1){ |
| | | continue; |
| | | } |
| | | } |
| | | //参赛人员 |
| | | if(participantType == 2){ |
| | | Participant participant = participantClient.getParticipant(participantId); |
| | | if(participant.getState() != 1){ |
| | | continue; |
| | | } |
| | | } |
| | | map.put("totalSession", num); |
| | | map.put("winRate", "0"); |
| | | map.put("win", "0"); |
| | | for (Map<String, Object> objectMap : mapList1) { |
| | | Integer participantType1 = Integer.valueOf(objectMap.get("participantType").toString()); |
| | | Long participantId1 = Long.valueOf(objectMap.get("participantId").toString()); |
| | | Integer appUserId1 = Integer.valueOf(objectMap.get("appUserId").toString()); |
| | | Integer num1 = Integer.valueOf(null == objectMap.get("num") ? "0" : objectMap.get("num").toString()); |
| | | if(participantType.compareTo(participantType1) == 0 && participantId.compareTo(participantId1) == 0 && appUserId.compareTo(appUserId1) == 0){ |
| | | map.put("winRate", new BigDecimal(num1).divide(new BigDecimal(num), new MathContext(4, RoundingMode.HALF_EVEN)).multiply(new BigDecimal(100)).doubleValue()); |
| | | map.put("win", num1); |
| | | break; |
| | | } |
| | | } |
| | | Integer win = Integer.valueOf(map.get("win").toString()); |
| | | Integer lose = totalSession - win; |
| | | Integer lose = num - win; |
| | | map.put("lose", lose); |
| | | AppUser appUser = appUserClient.getAppUser(appUserId); |
| | | map.put("province", appUser.getProvince() + appUser.getCity()); |
| | | if(1 == participantType){ |
| | | TStudent tStudent = studentClient.queryById(participantId.intValue()); |
| | | if(tStudent.getState() != 1){ |
| | | continue; |
| | | } |
| | | map.put("name", tStudent.getName()); |
| | | map.put("phone", ToolUtil.isNotEmpty(tStudent.getPhone()) ? tStudent.getPhone() : appUser.getPhone()); |
| | | }else{ |
| | | Participant participant = participantClient.getParticipant(participantId); |
| | | if(participant.getState() != 1){ |
| | | continue; |
| | | } |
| | | map.put("name", participant.getName()); |
| | | map.put("phone", ToolUtil.isNotEmpty(participant.getPhone()) ? participant.getPhone() : appUser.getPhone()); |
| | | } |
| | | row_num++; |
| | | map.put("row_num", row_num); |
| | | list.add(map); |
| | | } |
| | | list.sort(new Comparator<Map<String, Object>>() { |
| | | @Override |
| | | public int compare(Map<String, Object> o1, Map<String, Object> o2) { |
| | | return Double.valueOf(o1.get("totalSession").toString()).compareTo(Double.valueOf(o2.get("totalSession").toString())) * -1; |
| | | } |
| | | }); |
| | | |
| | | Integer offset = worldCupRecords.getOffset(); |
| | | Integer limit = worldCupRecords.getLimit(); |
| | | limit += offset; |
| | | map1.put("rows", mapList.subList(offset, mapList.size() >= limit ? limit : mapList.size())); |
| | | int count = this.baseMapper.worldCupRecordsListCount(appUserIds); |
| | | map1.put("total", count); |
| | | map1.put("rows", list.subList(offset, list.size() >= limit ? limit : list.size())); |
| | | map1.put("total", list.size()); |
| | | return map1; |
| | | } |
| | | |
| | |
| | | .eq("participantType", participantType).eq("participantId", participantId) |
| | | .isNotNull("matchResult").orderByDesc("startTime")); |
| | | List<Map<String, Object>> mapList = new ArrayList<>(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.HH.dd HH:mm"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm"); |
| | | for (WorldCupCompetitor cupCompetitor : list) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", cupCompetitor.getId().toString()); |
| | |
| | | .eq("participant", 1).eq("worldCupId", worldCupCompetitor.getWorldCupId())); |
| | | WorldCup worldCup = worldCupService.getById(blueList.get(0).getWorldCupId()); |
| | | for (WorldCupCompetitor cupCompetitor : blueList) { |
| | | //如果之前输了,现在赢/平了,需要增加积分 |
| | | if(cupCompetitor.getMatchResult() == -1 && (blue.compareTo(red) > 0 || blue.compareTo(red) == 0)){ |
| | | //如果之前输了,现在赢了,需要增加积分 |
| | | if(cupCompetitor.getMatchResult() == -1 && (blue.compareTo(red) > 0 )){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getLoseIntegral() * -1); |
| | | vo.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getWinIntegral()); |
| | | vo1.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | cupCompetitor.setMatchResult(1); |
| | | cupCompetitor.setWinIntegral(worldCup.getWinIntegral()); |
| | | cupCompetitor.setLoseIntegral(0); |
| | | } |
| | | // 输 -> 平 |
| | | if(cupCompetitor.getMatchResult() == -1 && (blue.compareTo(red) == 0 )){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getLoseIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getDrawIntegral()); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(0); |
| | | cupCompetitor.setDrawIntegral(worldCup.getDrawIntegral()); |
| | | cupCompetitor.setLoseIntegral(0); |
| | | } |
| | | //如果之前赢了,现在输了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 1 && blue.compareTo(red) < 0){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getWinIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getLoseIntegral()); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(-1); |
| | | cupCompetitor.setWinIntegral(0); |
| | | cupCompetitor.setLoseIntegral(worldCup.getLoseIntegral()); |
| | | } |
| | | //如果之前赢了,现在平了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 1 && blue.compareTo(red) == 0){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getWinIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getDrawIntegral()); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(0); |
| | | cupCompetitor.setWinIntegral(0); |
| | | cupCompetitor.setDrawIntegral(worldCup.getDrawIntegral()); |
| | | } |
| | | //如果之前平了,现在输了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 0 && blue.compareTo(red) < 0){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getDrawIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getLoseIntegral()); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(-1); |
| | | cupCompetitor.setDrawIntegral(0); |
| | | cupCompetitor.setLoseIntegral(worldCup.getLoseIntegral()); |
| | | } |
| | | //如果之前平了,现在赢了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 0 && blue.compareTo(red) >0){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getDrawIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(1); |
| | | cupCompetitor.setDrawIntegral(0); |
| | | cupCompetitor.setWinIntegral(worldCup.getWinIntegral()); |
| | | } |
| | | //如果之前赢了,现在输了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 1 && blue.compareTo(red) < 0){ |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getWinIntegral() * -1); |
| | | vo.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(-1); |
| | | cupCompetitor.setWinIntegral(0); |
| | | } |
| | | //如果之前平了,现在输了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 0 && blue.compareTo(red) < 0){ |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getWinIntegral() * -1); |
| | | vo.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(-1); |
| | | cupCompetitor.setWinIntegral(0); |
| | | } |
| | | cupCompetitor.setOurScore(blue); |
| | | cupCompetitor.setOpponentScore(red); |
| | |
| | | List<WorldCupCompetitor> redList = this.list(new QueryWrapper<WorldCupCompetitor>().eq("code", worldCupCompetitor.getCode()) |
| | | .eq("participant", 2).eq("worldCupId", worldCupCompetitor.getWorldCupId())); |
| | | for (WorldCupCompetitor cupCompetitor : redList) { |
| | | //如果之前输了,现在赢/平了,需要增加积分 |
| | | if(cupCompetitor.getMatchResult() == -1 && (red.compareTo(blue) > 0 || red.compareTo(blue) == 0)){ |
| | | //如果之前输了,现在赢/了,需要增加积分 |
| | | if(cupCompetitor.getMatchResult() == -1 && (red.compareTo(blue) > 0)){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getLoseIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | |
| | | |
| | | cupCompetitor.setMatchResult(1); |
| | | cupCompetitor.setWinIntegral(worldCup.getWinIntegral()); |
| | | cupCompetitor.setLoseIntegral(0); |
| | | } |
| | | //如果之前输了,现在平了,需要增加积分 |
| | | if(cupCompetitor.getMatchResult() == -1 && ( red.compareTo(blue) == 0)){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getLoseIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getDrawIntegral()); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(0); |
| | | cupCompetitor.setDrawIntegral(worldCup.getDrawIntegral()); |
| | | cupCompetitor.setLoseIntegral(0); |
| | | } |
| | | //如果之前赢了,现在输了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 1 && red.compareTo(blue) < 0){ |
| | | |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getWinIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getWinIntegral() * -1); |
| | | vo.setType(8); |
| | | vo.setIntegral(worldCup.getLoseIntegral() ); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(-1); |
| | | cupCompetitor.setWinIntegral(0); |
| | | cupCompetitor.setLoseIntegral(worldCup.getLoseIntegral()); |
| | | } |
| | | //如果之前赢了,现在平了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 1 && red.compareTo(blue) ==0){ |
| | | |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getWinIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getDrawIntegral() ); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(0); |
| | | cupCompetitor.setWinIntegral(0); |
| | | cupCompetitor.setDrawIntegral(worldCup.getDrawIntegral()); |
| | | } |
| | | //如果之前平了,现在输了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 0 && red.compareTo(blue) < 0){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getDrawIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getWinIntegral() * -1); |
| | | vo.setType(8); |
| | | vo.setIntegral(worldCup.getLoseIntegral()); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(-1); |
| | | cupCompetitor.setWinIntegral(0); |
| | | cupCompetitor.setDrawIntegral(0); |
| | | cupCompetitor.setLoseIntegral(worldCup.getLoseIntegral()); |
| | | } |
| | | //如果之前平了,现在赢了,需要扣减积分 |
| | | if(cupCompetitor.getMatchResult() == 0 && red.compareTo(blue) >0){ |
| | | //先扣除 |
| | | SaveUserIntegralChangesVo vo1 = new SaveUserIntegralChangesVo(); |
| | | vo1.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo1.setIntegral(worldCup.getDrawIntegral() * -1); |
| | | vo1.setType(8); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo1); |
| | | |
| | | |
| | | //增加积分明细 |
| | | SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo(); |
| | | vo.setAppUserId(cupCompetitor.getAppUserId()); |
| | | vo.setIntegral(worldCup.getWinIntegral()); |
| | | vo.setType(7); |
| | | userIntegralChangesClient.saveUserIntegralChanges(vo); |
| | | |
| | | cupCompetitor.setMatchResult(1); |
| | | cupCompetitor.setDrawIntegral(0); |
| | | cupCompetitor.setWinIntegral(worldCup.getWinIntegral()); |
| | | } |
| | | cupCompetitor.setOurScore(red); |
| | | cupCompetitor.setOpponentScore(blue); |
| | |
| | | public int getMatchTime(Integer worldCupId) { |
| | | return this.baseMapper.getMatchTime(worldCupId); |
| | | } |
| | | |
| | | @Override |
| | | public List<WorldCupListVo> getWorldCupListFromRank(MyWorldCupList myWorldCupList) { |
| | | |
| | | return this.baseMapper.getWorldCupListFromRank(myWorldCupList); |
| | | } |
| | | |
| | | @Override |
| | | public List<WorldCupCodeListVo> getWorldCupCodeListId(Integer worldCupId) { |
| | | List<WorldCupCompetitor> worldCupCompetitors = this.baseMapper.selectList(new LambdaQueryWrapper<WorldCupCompetitor>().eq(WorldCupCompetitor::getWorldCupId, worldCupId) |
| | | .ge(WorldCupCompetitor::getStartTime, new Date()).lt(WorldCupCompetitor::getEndTime, new Date())); |
| | | List<WorldCupCodeListVo> worldCupCodeListVos = new ArrayList<>(); |
| | | |
| | | // worldCupCompetitors 通过code分组 |
| | | Map<String, List<WorldCupCompetitor>> map = worldCupCompetitors.stream().collect(Collectors.groupingBy(WorldCupCompetitor::getCode)); |
| | | |
| | | for (Map.Entry<String, List<WorldCupCompetitor>> entry : map.entrySet()) { |
| | | WorldCupCodeListVo worldCupCodeListVo = new WorldCupCodeListVo(); |
| | | String code = entry.getKey(); |
| | | List<WorldCupCompetitor> value = entry.getValue(); |
| | | worldCupCodeListVo.setCode(code); |
| | | worldCupCodeListVo.setStartTime(value.get(0).getStartTime()); |
| | | worldCupCodeListVo.setWorldCupId(value.get(0).getWorldCupId()); |
| | | List<Long> collect = value.stream().map(WorldCupCompetitor::getId).collect(Collectors.toList()); |
| | | worldCupCodeListVo.setCustoms(collect); |
| | | worldCupCodeListVos.add(worldCupCodeListVo); |
| | | } |
| | | return worldCupCodeListVos; |
| | | } |
| | | } |