From c77909ffc32e43ccde9e530cc746161a61f16b30 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期四, 21 三月 2024 14:45:00 +0800
Subject: [PATCH] Merge branch '2.0' of http://120.76.84.145:10101/gitblit/r/java/PlayPai into 2.0

---
 cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java |  117 ++++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 88 insertions(+), 29 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 109a553..a08600c 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
@@ -7,11 +7,9 @@
 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 +52,9 @@
     @Resource
     private UserIntegralChangesClient userIntegralChangesClient;
 
+    @Resource
+    private StudentHonorClient studentHonorClient;
+
 
 
 
@@ -81,7 +82,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 +102,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 +146,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 +197,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 +208,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 +223,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 +242,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);
@@ -319,6 +318,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);
+        }
+
     }
 
 
@@ -349,11 +370,11 @@
             if(1 == participantType){
                 TStudent tStudent = studentClient.queryById(participantId.intValue());
                 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);
                 map.put("name", participant.getName());
-                map.put("phone", participant.getPhone());
+                map.put("phone", ToolUtil.isNotEmpty(participant.getPhone()) ? participant.getPhone() : appUser.getPhone());
             }
         }
         Integer offset = worldCupRecords.getOffset();
@@ -398,7 +419,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){
@@ -407,12 +428,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){
@@ -421,14 +443,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;
     }
 
@@ -449,7 +472,7 @@
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy.HH.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){
@@ -465,10 +488,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("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<>();
@@ -489,7 +512,7 @@
         Integer red = changeScore.getRed();
         WorldCupCompetitor worldCupCompetitor = this.getById(id);
         List<WorldCupCompetitor> blueList = this.list(new QueryWrapper<WorldCupCompetitor>().eq("code", worldCupCompetitor.getCode())
-                .eq("participant", 1));
+                .eq("participant", 1).eq("worldCupId", worldCupCompetitor.getWorldCupId()));
         WorldCup worldCup = worldCupService.getById(blueList.get(0).getWorldCupId());
         for (WorldCupCompetitor cupCompetitor : blueList) {
             //如果之前输了,现在赢/平了,需要增加积分
@@ -530,10 +553,12 @@
             }
             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 || red.compareTo(blue) == 0)){
@@ -573,8 +598,33 @@
             }
             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);
+        }
+
     }
 
 
@@ -607,9 +657,7 @@
                 }
                 map.put("userName", participant.getName());
             }
-            map.put("score", ourScore.compareTo(opponentScore) > 0 ?
-                    ourScore + ":" + opponentScore :
-                    opponentScore + ":" + ourScore);
+            map.put("score", ourScore + ":" + opponentScore);
             map.put("matchResult", matchResult == 1 ? "胜" : matchResult == 0 ? "平" :"负");
             mapList.add(map);
         }
@@ -621,4 +669,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