From adf749e8da2bfce006390b008f6b9e8606b62180 Mon Sep 17 00:00:00 2001 From: liujie <1793218484@qq.com> Date: 星期四, 28 八月 2025 17:02:30 +0800 Subject: [PATCH] update --- cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java | 318 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 282 insertions(+), 36 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 aa85df4..6ec3abd 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 @@ -2,6 +2,7 @@ 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; @@ -29,6 +30,7 @@ import java.math.MathContext; import java.math.RoundingMode; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -192,6 +194,7 @@ 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()); + Integer participationIntegral = Integer.valueOf(null == map.get("participationIntegral") ? "0" : map.get("participationIntegral").toString()); //学员 if(participantType == 1){ TStudent tStudent = studentClient.queryById(participantId.intValue()); @@ -207,7 +210,7 @@ } } map.put("totalSession", num); - map.put("totalIntegral", winIntegral+drawIntegral+loseIntegral); + map.put("totalIntegral", winIntegral+drawIntegral+loseIntegral+participationIntegral); map.put("winRate", "0"); for (Map<String, Object> objectMap : lists1) { Integer participantType1 = Integer.valueOf(objectMap.get("participantType").toString()); @@ -691,8 +694,118 @@ .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>red){ + //先扣除 + 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()); @@ -701,31 +814,8 @@ 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); @@ -736,8 +826,15 @@ 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()); @@ -747,30 +844,113 @@ 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); @@ -858,8 +1038,74 @@ } @Override - public List<WorldCupListVo> getWorldCupListFromRank(Integer uid) { + public List<WorldCupListVo> getWorldCupListFromRank(MyWorldCupList myWorldCupList) { - return this.baseMapper.getWorldCupListFromRank(uid); + 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) + .and(w->w.isNull(WorldCupCompetitor::getEndTime).or(s->s.le(WorldCupCompetitor::getStartTime, new Date()).ge(WorldCupCompetitor::getEndTime, new Date())))) + ; + List<WorldCupCodeListVo> worldCupCodeListVos = new ArrayList<>(); + + // worldCupCompetitors 通过code分组 + Map<String, List<WorldCupCompetitor>> map = worldCupCompetitors.stream().collect(Collectors.groupingBy(WorldCupCompetitor::getCode)); + LocalDate now = LocalDate.now(); + for (Map.Entry<String, List<WorldCupCompetitor>> entry : map.entrySet()) { + WorldCupCodeListVo worldCupCodeListVo = new WorldCupCodeListVo(); + String code = entry.getKey(); + List<WorldCupCompetitor> value = entry.getValue(); + // 蓝队 + List<WorldCupCompetitor> collect1 = value.stream().filter(item -> item.getParticipant() == 1).collect(Collectors.toList()); + ArrayList<UserVo> objects = new ArrayList<>(); + for (WorldCupCompetitor competitor : collect1) { + UserVo userVo = new UserVo(); + TStudent tStudent = studentClient.queryById(competitor.getParticipantId().intValue()); + userVo.setUserName(tStudent.getName()); + userVo.setAvatar(tStudent.getHeadImg()); + // 当前日期和生日计算年龄 + Date birthday = tStudent.getBirthday(); + + if(birthday!=null){ + int age = now.getYear() - birthday.getYear(); + userVo.setAge(age); + } + objects.add(userVo); + } + worldCupCodeListVo.setBlue(objects); + // 红队 + List<WorldCupCompetitor> collect2 = value.stream().filter(item -> item.getParticipant() == 2).collect(Collectors.toList()); + ArrayList<UserVo> objects1 = new ArrayList<>(); + for (WorldCupCompetitor competitor : collect2) { + UserVo userVo = new UserVo(); + TStudent tStudent = studentClient.queryById(competitor.getParticipantId().intValue()); + userVo.setUserName(tStudent.getName()); + userVo.setAvatar(tStudent.getHeadImg()); + // 当前日期和生日计算年龄 + Date birthday = tStudent.getBirthday(); + + if(birthday!=null){ + int age = now.getYear() - birthday.getYear(); + userVo.setAge(age); + } + objects1.add(userVo); + } + worldCupCodeListVo.setRed(objects1); + + worldCupCodeListVo.setCode(code); + worldCupCodeListVo.setStartTime(value.get(0).getStartTime()); + Integer worldCupId1 = value.get(0).getWorldCupId(); + WorldCup byId = worldCupService.getById(worldCupId1); + worldCupCodeListVo.setWorldCupId(worldCupId1); + if(byId!=null){ + worldCupCodeListVo.setName(byId.getName()); + } + List<Long> collect = value.stream().map(WorldCupCompetitor::getId).collect(Collectors.toList()); + worldCupCodeListVo.setCustoms(collect); + worldCupCodeListVos.add(worldCupCodeListVo); + } + return worldCupCodeListVos; } } -- Gitblit v1.7.1