无关风月
2025-05-08 9486766c806fe1d9e082b2fd02ea1cc558f1b443
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
@@ -1,17 +1,16 @@
package com.dsh.communityWorldCup.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsh.communityWorldCup.entity.WorldCup;
import com.dsh.communityWorldCup.entity.WorldCupCompetitor;
import com.dsh.communityWorldCup.feignclient.account.AppUserClient;
import com.dsh.communityWorldCup.feignclient.account.StudentClient;
import com.dsh.communityWorldCup.feignclient.account.StudentHonorClient;
import com.dsh.communityWorldCup.feignclient.account.UserIntegralChangesClient;
import com.dsh.communityWorldCup.feignclient.account.model.AppUser;
import com.dsh.communityWorldCup.feignclient.account.model.AppUserIdsByCityName;
import com.dsh.communityWorldCup.feignclient.account.model.SaveUserIntegralChangesVo;
import com.dsh.communityWorldCup.feignclient.account.model.TStudent;
import com.dsh.communityWorldCup.feignclient.account.model.*;
import com.dsh.communityWorldCup.feignclient.competition.ParticipantClient;
import com.dsh.communityWorldCup.feignclient.competition.model.Participant;
import com.dsh.communityWorldCup.feignclient.other.StoreClient;
@@ -54,6 +53,9 @@
    @Resource
    private UserIntegralChangesClient userIntegralChangesClient;
    @Resource
    private StudentHonorClient studentHonorClient;
@@ -81,7 +83,7 @@
        for (int i = 0; i < mapList.size(); i++) {
            Map<String, Object> map = mapList.get(i);
            Integer participantType = Integer.valueOf(map.get("participantType").toString());
            Integer participantId = Integer.valueOf(map.get("participantId").toString());
            Long participantId = Long.valueOf(map.get("participantId").toString());
            Integer num = Integer.valueOf(map.get("num").toString());
            if(null != participantId && participantId.equals(entrantRank.getId()) && participantType.equals(entrantRank.getIsStudent())){
                entrantRankVo.setNationalRank(i + 1);
@@ -101,7 +103,7 @@
        for (int i = 0; i < mapList1.size(); i++) {
            Map<String, Object> map = mapList1.get(i);
            Integer participantType = Integer.valueOf(map.get("participantType").toString());
            Integer participantId = Integer.valueOf(map.get("participantId").toString());
            Long participantId = Long.valueOf(map.get("participantId").toString());
            Integer num = Integer.valueOf(map.get("num").toString());
            if(null != participantId && participantId.equals(entrantRank.getId()) && participantType.equals(entrantRank.getIsStudent())){
                entrantRankVo.setCityRank(i + 1);
@@ -113,7 +115,7 @@
        }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<>();
@@ -145,7 +147,7 @@
        matchRecord.setPageNo(pageNo);
        MatchRecordVo matchRecordVo = new MatchRecordVo();
        int count = this.count(new QueryWrapper<WorldCupCompetitor>().eq("participantId", matchRecord.getId())
                .eq("participantType", matchRecord.getIsStudent()));
                .eq("participantType", matchRecord.getIsStudent()).isNotNull("matchResult"));
        matchRecordVo.setTotalSession(count);
        List<MatchRecordList> matchRecord1 = this.baseMapper.getMatchRecord(matchRecord);
        matchRecordVo.setList(matchRecord1);
@@ -166,10 +168,64 @@
            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<>();
        //未负的数据
        List<Map<String, Object>> lists1 = this.baseMapper.getWorldCupRank1(worldCupRank, appUserIds);
        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());
            //学员
            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");
            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());
@@ -196,9 +252,8 @@
                }
                //参赛人员
                if(participantType == 2){
                    AppUser appUser1 = appUserClient.getAppUser(appUserId);
                    Participant participant = participantClient.getParticipant(participantId);
                    worldCupRankVo.setAvatar(appUser1.getHeadImg());
                    worldCupRankVo.setAvatar(participant.getHeadImg());
                    String name = participant.getName();
                    if(name.length() > 2){
                        name = name.charAt(0) + "*" + name.substring(2);
@@ -208,7 +263,7 @@
                    worldCupRankVo.setName(name);
                }
                if(worldCupRank.getIsStudent().equals(participantType) && worldCupRank.getId().equals(participantId)){
                if(worldCupRank.getIsStudent().compareTo(participantType) == 0 && worldCupRank.getId().compareTo(participantId) == 0){
                    worldCupRankVo.setOneself(1);
                    b = true;
                }else{
@@ -223,7 +278,7 @@
            }
            //排名前20的数据添加完成后且包含自己,需要将自己找出来后添加到21位
            if(i > 19 && !b){
                if(worldCupRank.getIsStudent().equals(participantType) && worldCupRank.getId().equals(participantId)){
                if(worldCupRank.getIsStudent().compareTo(participantType) == 0 && worldCupRank.getId().compareTo(participantId) == 0){
                    WorldCupRankVo worldCupRankVo = new WorldCupRankVo();
                    worldCupRankVo.setRank(i + 1);
                    worldCupRankVo.setTotalSession(totalSession);
@@ -242,9 +297,8 @@
                    }
                    //参赛人员
                    if(participantType == 2){
                        AppUser appUser1 = appUserClient.getAppUser(appUserId);
                        Participant participant = participantClient.getParticipant(participantId);
                        worldCupRankVo.setAvatar(appUser1.getHeadImg());
                        worldCupRankVo.setAvatar(participant.getHeadImg());
                        String name = participant.getName();
                        if(name.length() > 2){
                            name = name.charAt(0) + "*" + name.substring(2);
@@ -272,7 +326,13 @@
     */
    @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);
@@ -288,12 +348,9 @@
                    worldCupCompetitor.setWinIntegral(0);
                    if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && blue_score.compareTo(red_score) >= 0){
                        worldCupCompetitor.setWinIntegral(worldCup.getWinIntegral());
                        AppUser appUser = appUserClient.getAppUser(worldCupCompetitor.getAppUserId());
                        appUser.setIntegral(appUser.getIntegral() + worldCup.getWinIntegral());
                        appUserClient.updateAppUser(appUser);
                        //增加积分明细
                        SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo();
                        vo.setAppUserId(appUser.getId());
                        vo.setAppUserId(worldCupCompetitor.getAppUserId());
                        vo.setIntegral(worldCup.getWinIntegral());
                        vo.setType(7);
                        userIntegralChangesClient.saveUserIntegralChanges(vo);
@@ -308,12 +365,9 @@
                    worldCupCompetitor.setWinIntegral(0);
                    if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && red_score.compareTo(blue_score) >= 0){
                        worldCupCompetitor.setWinIntegral(worldCup.getWinIntegral());
                        AppUser appUser = appUserClient.getAppUser(worldCupCompetitor.getAppUserId());
                        appUser.setIntegral(appUser.getIntegral() + worldCup.getWinIntegral());
                        appUserClient.updateAppUser(appUser);
                        //增加积分明细
                        SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo();
                        vo.setAppUserId(appUser.getId());
                        vo.setAppUserId(worldCupCompetitor.getAppUserId());
                        vo.setIntegral(worldCup.getWinIntegral());
                        vo.setType(7);
                        userIntegralChangesClient.saveUserIntegralChanges(vo);
@@ -325,6 +379,28 @@
        }
        this.updateBatchById(worldCupCompetitors);
        //添加勋章
        for (WorldCupCompetitor worldCupCompetitor : worldCupCompetitors) {
            Integer appUserId = worldCupCompetitor.getAppUserId();
            //常胜将军
            if(1 == worldCupCompetitor.getMatchResult()){
                int count = this.count(new QueryWrapper<WorldCupCompetitor>().eq("appUserId", appUserId).eq("matchResult", 1));
                StudentHonor studentHonor = new StudentHonor();
                studentHonor.setAppUserId(appUserId);
                studentHonor.setHonorType(5);
                studentHonor.setNumber(count);
                studentHonorClient.saveStudentHonor(studentHonor);
            }
            //越战越勇
            int count = this.count(new QueryWrapper<WorldCupCompetitor>().eq("appUserId", appUserId));
            StudentHonor studentHonor = new StudentHonor();
            studentHonor.setAppUserId(appUserId);
            studentHonor.setHonorType(6);
            studentHonor.setNumber(count);
            studentHonorClient.saveStudentHonor(studentHonor);
        }
    }
@@ -341,33 +417,79 @@
        appUserIdsByCityName.setCity(worldCupRecords.getCity());
        List<Integer> appUserIds = appUserClient.getAppUserIdsByCityName(appUserIdsByCityName);
        List<Map<String, Object>> mapList = this.baseMapper.worldCupRecordsList(worldCupRecords, appUserIds);
        List<Map<String, Object>> mapList1 = this.baseMapper.worldCupRecordsList1(worldCupRecords, appUserIds);
        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", tStudent.getPhone());
                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", participant.getPhone());
                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;
    }
@@ -404,7 +526,7 @@
                if(ToolUtil.isNotEmpty(name) && tStudent.getName().indexOf(name) == -1){
                    continue;
                }
                if(ToolUtil.isNotEmpty(phone) && tStudent.getPhone().indexOf(phone) == -1){
                if(ToolUtil.isNotEmpty(phone) && (ToolUtil.isEmpty(tStudent.getPhone()) ? appUser.getPhone() : tStudent.getPhone()).indexOf(phone) == -1){
                    continue;
                }
                if(ToolUtil.isNotEmpty(idcard) && tStudent.getIdCard().indexOf(idcard) == -1){
@@ -413,12 +535,13 @@
                map.put("name", tStudent.getName());
                map.put("phone", ToolUtil.isEmpty(tStudent.getPhone()) ? appUser.getPhone() : tStudent.getPhone());
                map.put("idcard", tStudent.getIdCard());
            }else{
                Participant participant = participantClient.getParticipant(participantId);
                if(ToolUtil.isNotEmpty(name) && participant.getName().indexOf(name) == -1){
                    continue;
                }
                if(ToolUtil.isNotEmpty(phone) && participant.getPhone().indexOf(phone) == -1){
                if(ToolUtil.isNotEmpty(phone) && (ToolUtil.isNotEmpty(participant.getPhone()) ? participant.getPhone() : appUser.getPhone()).indexOf(phone) == -1){
                    continue;
                }
                if(ToolUtil.isNotEmpty(idcard) && participant.getIdcard().indexOf(idcard) == -1){
@@ -427,14 +550,15 @@
                map.put("name", participant.getName());
                map.put("phone", ToolUtil.isNotEmpty(participant.getPhone()) ? participant.getPhone() : appUser.getPhone());
                map.put("idcard", participant.getIdcard());
            }
            list.add(map);
        }
        map1.put("total", mapList.size());
        map1.put("total", list.size());
        Integer offset = worldCupGameStatisticsInfoList.getOffset();
        Integer limit = worldCupGameStatisticsInfoList.getLimit();
        limit += offset;
        map1.put("rows", mapList.subList(offset, mapList.size() >= limit ? limit : mapList.size()));
        map1.put("rows", list.subList(offset, list.size() >= limit ? limit : list.size()));
        return map1;
    }
@@ -452,10 +576,10 @@
                .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());
            map.put("id", cupCompetitor.getId().toString());
            if(1 == participantType){
                TStudent tStudent = studentClient.queryById(participantId.intValue());
                if(ToolUtil.isNotEmpty(name) && tStudent.getName().indexOf(name) == -1){
@@ -471,10 +595,10 @@
                map.put("name", participant.getName());
            }
            map.put("startTime", sdf.format(cupCompetitor.getStartTime()));
            map.put("score", cupCompetitor.getOurScore().compareTo(cupCompetitor.getOpponentScore()) > 0 ?
                    cupCompetitor.getOurScore() + ":" + cupCompetitor.getOpponentScore() :
                    cupCompetitor.getOpponentScore() + ":" + cupCompetitor.getOurScore());
            map.put("matchResult", cupCompetitor.getMatchResult() == 1 ? "胜" : "负");
            map.put("score", cupCompetitor.getOurScore() + ":" + cupCompetitor.getOpponentScore());
            map.put("matchResult", cupCompetitor.getMatchResult() == 1 ? "胜" : cupCompetitor.getMatchResult() == 0 ? "平" : "负");
            map.put("blue", cupCompetitor.getParticipant() == 1 ? cupCompetitor.getOurScore() : cupCompetitor.getOpponentScore());
            map.put("red", cupCompetitor.getParticipant() == 2 ? cupCompetitor.getOurScore() : cupCompetitor.getOpponentScore());
            mapList.add(map);
        }
        Map<String, Object> map = new HashMap<>();
@@ -494,56 +618,120 @@
        Integer blue = changeScore.getBlue();
        Integer red = changeScore.getRed();
        WorldCupCompetitor worldCupCompetitor = this.getById(id);
        List<WorldCupCompetitor> blueList = this.list(new QueryWrapper<WorldCupCompetitor>().eq("code", worldCupCompetitor.getCode()).eq("participant", 1));
        List<WorldCupCompetitor> blueList = this.list(new QueryWrapper<WorldCupCompetitor>().eq("code", worldCupCompetitor.getCode())
                .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){
                AppUser appUser = appUserClient.getAppUser(cupCompetitor.getAppUserId());
                appUser.setIntegral(appUser.getIntegral() + worldCup.getWinIntegral());
                appUserClient.updateAppUser(appUser);
            //如果之前输了,现在赢/平了,需要增加积分
            if(cupCompetitor.getMatchResult() == -1 && (blue.compareTo(red) > 0 || blue.compareTo(red) == 0)){
                //增加积分明细
                SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo();
                vo.setAppUserId(cupCompetitor.getAppUserId());
                vo.setIntegral(worldCup.getWinIntegral());
                vo.setType(7);
                userIntegralChangesClient.saveUserIntegralChanges(vo);
                cupCompetitor.setMatchResult(1);
                cupCompetitor.setWinIntegral(worldCup.getWinIntegral());
            }
            //如果之前赢了,现在输了,需要扣减积分
            if(cupCompetitor.getMatchResult() == 1 && blue.compareTo(red) < 0){
                AppUser appUser = appUserClient.getAppUser(cupCompetitor.getAppUserId());
                appUser.setIntegral(appUser.getIntegral() - worldCup.getWinIntegral());
                appUserClient.updateAppUser(appUser);
                //增加积分明细
                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);
            cupCompetitor.setWorldCupId(null);
        }
        this.updateBatchById(blueList);
        List<WorldCupCompetitor> redList = this.list(new QueryWrapper<WorldCupCompetitor>().eq("code", worldCupCompetitor.getCode()).eq("participant", 2));
        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){
                AppUser appUser = appUserClient.getAppUser(cupCompetitor.getAppUserId());
                appUser.setIntegral(appUser.getIntegral() + worldCup.getWinIntegral());
                appUserClient.updateAppUser(appUser);
            //如果之前输了,现在赢/平了,需要增加积分
            if(cupCompetitor.getMatchResult() == -1 && (red.compareTo(blue) > 0 || red.compareTo(blue) == 0)){
                //增加积分明细
                SaveUserIntegralChangesVo vo = new SaveUserIntegralChangesVo();
                vo.setAppUserId(cupCompetitor.getAppUserId());
                vo.setIntegral(worldCup.getWinIntegral());
                vo.setType(7);
                userIntegralChangesClient.saveUserIntegralChanges(vo);
                cupCompetitor.setMatchResult(1);
                cupCompetitor.setWinIntegral(worldCup.getWinIntegral());
            }
            //如果之前赢了,现在输了,需要扣减积分
            if(cupCompetitor.getMatchResult() == 1 && red.compareTo(blue) < 0){
                AppUser appUser = appUserClient.getAppUser(cupCompetitor.getAppUserId());
                appUser.setIntegral(appUser.getIntegral() - worldCup.getWinIntegral());
                appUserClient.updateAppUser(appUser);
                //增加积分明细
                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 && red.compareTo(blue) < 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(red);
            cupCompetitor.setOpponentScore(blue);
            cupCompetitor.setWorldCupId(null);
        }
        this.updateBatchById(blueList);
        this.updateBatchById(redList);
        //修改勋章
        List<WorldCupCompetitor> worldCupCompetitors = this.list(new QueryWrapper<WorldCupCompetitor>().eq("code", worldCupCompetitor.getCode()));
        for (WorldCupCompetitor wcc : worldCupCompetitors) {
            Integer appUserId = wcc.getAppUserId();
            //常胜将军
            if(1 == wcc.getMatchResult()){
                int count = this.count(new QueryWrapper<WorldCupCompetitor>().eq("appUserId", appUserId).eq("matchResult", 1));
                StudentHonor studentHonor = new StudentHonor();
                studentHonor.setAppUserId(appUserId);
                studentHonor.setHonorType(5);
                studentHonor.setNumber(count);
                studentHonorClient.saveStudentHonor(studentHonor);
            }
            //越战越勇
            int count = this.count(new QueryWrapper<WorldCupCompetitor>().eq("appUserId", appUserId));
            StudentHonor studentHonor = new StudentHonor();
            studentHonor.setAppUserId(appUserId);
            studentHonor.setHonorType(6);
            studentHonor.setNumber(count);
            studentHonorClient.saveStudentHonor(studentHonor);
        }
    }
@@ -576,10 +764,8 @@
                }
                map.put("userName", participant.getName());
            }
            map.put("score", ourScore.compareTo(opponentScore) > 0 ?
                    ourScore + ":" + opponentScore :
                    opponentScore + ":" + ourScore);
            map.put("matchResult", matchResult == 1 ? "胜" : "负");
            map.put("score", ourScore + ":" + opponentScore);
            map.put("matchResult", matchResult == 1 ? "胜" : matchResult == 0 ? "平" :"负");
            mapList.add(map);
        }
        Map<String, Object> map = new HashMap<>();
@@ -590,4 +776,15 @@
        map.put("rows", mapList.subList(offset, mapList.size() >= limit ? limit : mapList.size()));
        return map;
    }
    /**
     * 获取比赛场次
     * @param worldCupId
     * @return
     */
    @Override
    public int getMatchTime(Integer worldCupId) {
        return this.baseMapper.getMatchTime(worldCupId);
    }
}