From b74277583bf9b2b89247061bf08c17a03b71c76e Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 10 四月 2025 14:16:43 +0800
Subject: [PATCH] 惠民卡代码
---
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupCompetitorServiceImpl.java | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 108 insertions(+), 8 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 da91d5d..4ac941c 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
@@ -115,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<>();
@@ -168,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());
@@ -363,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", 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;
}
@@ -476,7 +576,7 @@
.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());
--
Gitblit v1.7.1