From 7cd3dea07f5b7cefad9dea9fd7daf992449aaac8 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期二, 12 三月 2024 18:24:38 +0800
Subject: [PATCH] 修改bug

---
 cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java |  132 ++++++++++++++++++++++++++++---------------
 1 files changed, 86 insertions(+), 46 deletions(-)

diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
index 84d093e..08d83a7 100644
--- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
+++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java
@@ -81,7 +81,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 +101,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);
@@ -145,7 +145,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);
@@ -196,9 +196,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);
@@ -242,9 +241,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);
@@ -288,12 +286,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 +303,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);
@@ -404,7 +396,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 +405,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 +420,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;
     }
 
@@ -445,17 +439,17 @@
      */
     @Override
     public Map<String, Object> worldCupGameStatisticsListInfo(WorldCupGameStatisticsListInfo worldCupGameStatisticsListInfo) {
-        Long id = worldCupGameStatisticsListInfo.getId();
+        Long participantId = worldCupGameStatisticsListInfo.getParticipantId();
+        Integer participantType = worldCupGameStatisticsListInfo.getParticipantType();
         String name = worldCupGameStatisticsListInfo.getName();
-        WorldCupCompetitor worldCupCompetitor = this.getById(id);
-        List<WorldCupCompetitor> list = this.list(new QueryWrapper<WorldCupCompetitor>().eq("code", worldCupCompetitor.getCode()));
+        List<WorldCupCompetitor> list = this.list(new QueryWrapper<WorldCupCompetitor>()
+                .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");
         for (WorldCupCompetitor cupCompetitor : list) {
             Map<String, Object> map = new HashMap<>();
             map.put("id", cupCompetitor.getId());
-            Integer participantType = cupCompetitor.getParticipantType();
-            Long participantId = cupCompetitor.getParticipantId();
             if(1 == participantType){
                 TStudent tStudent = studentClient.queryById(participantId.intValue());
                 if(ToolUtil.isNotEmpty(name) && tStudent.getName().indexOf(name) == -1){
@@ -474,7 +468,7 @@
             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("matchResult", cupCompetitor.getMatchResult() == 1 ? "胜" : cupCompetitor.getMatchResult() == 0 ? "平" : "负");
             mapList.add(map);
         }
         Map<String, Object> map = new HashMap<>();
@@ -494,23 +488,42 @@
         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));
         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);
@@ -522,20 +535,38 @@
 
         List<WorldCupCompetitor> redList = this.list(new QueryWrapper<WorldCupCompetitor>().eq("code", worldCupCompetitor.getCode()).eq("participant", 2));
         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);
@@ -576,10 +607,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 +619,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);
+    }
 }

--
Gitblit v1.7.1