From ceacc612529f38c632d85d91bb5309baa5ebb82a Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期一, 11 三月 2024 16:04:54 +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 | 114 ++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 69 insertions(+), 45 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 88902cb..84d093e 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,15 +7,19 @@ 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.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.competition.ParticipantClient; import com.dsh.communityWorldCup.feignclient.competition.model.Participant; import com.dsh.communityWorldCup.feignclient.other.StoreClient; import com.dsh.communityWorldCup.mapper.WorldCupCompetitorMapper; +import com.dsh.communityWorldCup.mapper.WorldCupPaymentParticipantMapper; import com.dsh.communityWorldCup.model.*; import com.dsh.communityWorldCup.service.IWorldCupCompetitorService; +import com.dsh.communityWorldCup.service.IWorldCupPaymentParticipantService; import com.dsh.communityWorldCup.service.IWorldCupService; import com.dsh.communityWorldCup.util.ToolUtil; import org.springframework.beans.factory.annotation.Autowired; @@ -47,6 +51,9 @@ @Autowired private IWorldCupService worldCupService; + @Resource + private UserIntegralChangesClient userIntegralChangesClient; + @@ -65,7 +72,7 @@ entrantRankVo.setName(participant.getName()); }else{ //学员 - TStudent tStudent = studentClient.queryById(entrantRank.getId()); + TStudent tStudent = studentClient.queryById(entrantRank.getId().intValue()); entrantRankVo.setName(tStudent.getName()); } //全国排名---直接数据库分组查询后排序 @@ -164,7 +171,7 @@ for (int i = 0; i < lists.size(); i++) { Map<String, Object> map = lists.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 appUserId = Integer.valueOf(map.get("appUserId").toString()); Integer totalSession = Integer.valueOf(map.get("totalSession").toString()); Double winRate = Double.valueOf(map.get("winRate").toString()); @@ -177,7 +184,7 @@ worldCupRankVo.setWinRate(winRate); //学员 if(participantType == 1){ - TStudent tStudent = studentClient.queryById(participantId); + TStudent tStudent = studentClient.queryById(participantId.intValue()); worldCupRankVo.setAvatar(tStudent.getHeadImg()); String name = tStudent.getName(); if(name.length() > 2){ @@ -223,7 +230,7 @@ worldCupRankVo.setWinRate(winRate); //学员 if(participantType == 1){ - TStudent tStudent = studentClient.queryById(participantId); + TStudent tStudent = studentClient.queryById(participantId.intValue()); worldCupRankVo.setAvatar(tStudent.getHeadImg()); String name = tStudent.getName(); if(name.length() > 2){ @@ -261,43 +268,60 @@ * 比赛结束后通知处理逻辑 * @param custom 开始比赛接口上传的自定义参数 * @param red_score 红方分数 - * @param blue 蓝方分数 + * @param blue_score 蓝方分数 */ @Override - public void endWorldCupCallback(String custom, Integer red_score, Integer blue) { + public void endWorldCupCallback(String custom, Integer red_score, Integer blue_score) { List<Long> ids = JSON.parseArray(custom, Long.class); List<WorldCupCompetitor> worldCupCompetitors = this.listByIds(ids); - WorldCupCompetitor worldCupCompetitor1 = worldCupCompetitors.get(0); - WorldCup worldCup = worldCupService.getById(worldCupCompetitor1.getWorldCupId()); - for (WorldCupCompetitor worldCupCompetitor : worldCupCompetitors) { - //蓝方 - if(worldCupCompetitor.getParticipant() == 1){ - worldCupCompetitor.setMatchResult(blue.compareTo(red_score)); - worldCupCompetitor.setOurScore(blue); - worldCupCompetitor.setOpponentScore(red_score); - worldCupCompetitor.setEndTime(new Date()); - worldCupCompetitor.setWinIntegral(0); - if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && blue.compareTo(red_score) >= 0){ - worldCupCompetitor.setWinIntegral(worldCup.getWinIntegral()); - AppUser appUser = appUserClient.getAppUser(worldCupCompetitor.getAppUserId()); - appUser.setIntegral(appUser.getIntegral() + worldCup.getWinIntegral()); - appUserClient.updateAppUser(appUser); + try { + WorldCupCompetitor worldCupCompetitor1 = worldCupCompetitors.get(0); + WorldCup worldCup = worldCupService.getById(worldCupCompetitor1.getWorldCupId()); + for (WorldCupCompetitor worldCupCompetitor : worldCupCompetitors) { + worldCupCompetitor.setWorldCupId(null); + //蓝方 + if(worldCupCompetitor.getParticipant() == 1){ + worldCupCompetitor.setMatchResult(blue_score.compareTo(red_score)); + worldCupCompetitor.setOurScore(blue_score); + worldCupCompetitor.setOpponentScore(red_score); + worldCupCompetitor.setEndTime(new Date()); + 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.setIntegral(worldCup.getWinIntegral()); + vo.setType(7); + userIntegralChangesClient.saveUserIntegralChanges(vo); + } + } + //红方 + if(worldCupCompetitor.getParticipant() == 2){ + worldCupCompetitor.setMatchResult(red_score.compareTo(blue_score)); + worldCupCompetitor.setOurScore(red_score); + worldCupCompetitor.setOpponentScore(blue_score); + worldCupCompetitor.setEndTime(new Date()); + 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.setIntegral(worldCup.getWinIntegral()); + vo.setType(7); + userIntegralChangesClient.saveUserIntegralChanges(vo); + } } } - //红方 - if(worldCupCompetitor.getParticipant() == 2){ - worldCupCompetitor.setMatchResult(red_score.compareTo(blue)); - worldCupCompetitor.setOurScore(red_score); - worldCupCompetitor.setOpponentScore(blue); - worldCupCompetitor.setEndTime(new Date()); - worldCupCompetitor.setWinIntegral(0); - if(null != worldCup.getWinIntegral() && 0 < worldCup.getWinIntegral() && red_score.compareTo(blue) >= 0){ - worldCupCompetitor.setWinIntegral(worldCup.getWinIntegral()); - AppUser appUser = appUserClient.getAppUser(worldCupCompetitor.getAppUserId()); - appUser.setIntegral(appUser.getIntegral() + worldCup.getWinIntegral()); - appUserClient.updateAppUser(appUser); - } - } + }catch (Exception e){ + e.printStackTrace(); } this.updateBatchById(worldCupCompetitors); @@ -320,7 +344,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 appUserId = Integer.valueOf(map.get("appUserId").toString()); Integer totalSession = Integer.valueOf(map.get("totalSession").toString()); Integer win = Integer.valueOf(map.get("win").toString()); @@ -329,7 +353,7 @@ AppUser appUser = appUserClient.getAppUser(appUserId); map.put("province", appUser.getProvince() + appUser.getCity()); if(1 == participantType){ - TStudent tStudent = studentClient.queryById(participantId); + TStudent tStudent = studentClient.queryById(participantId.intValue()); map.put("name", tStudent.getName()); map.put("phone", tStudent.getPhone()); }else{ @@ -365,7 +389,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 appUserId = Integer.valueOf(map.get("appUserId").toString()); Integer totalSession = Integer.valueOf(map.get("totalSession").toString()); Integer win = Integer.valueOf(map.get("win").toString()); @@ -376,7 +400,7 @@ AppUser appUser = appUserClient.getAppUser(appUserId); map.put("province", appUser.getProvince() + appUser.getCity()); if(1 == participantType){ - TStudent tStudent = studentClient.queryById(participantId); + TStudent tStudent = studentClient.queryById(participantId.intValue()); if(ToolUtil.isNotEmpty(name) && tStudent.getName().indexOf(name) == -1){ continue; } @@ -388,7 +412,7 @@ } map.put("name", tStudent.getName()); - map.put("phone", tStudent.getPhone()); + map.put("phone", ToolUtil.isEmpty(tStudent.getPhone()) ? appUser.getPhone() : tStudent.getPhone()); }else{ Participant participant = participantClient.getParticipant(participantId); if(ToolUtil.isNotEmpty(name) && participant.getName().indexOf(name) == -1){ @@ -402,7 +426,7 @@ } map.put("name", participant.getName()); - map.put("phone", participant.getPhone()); + map.put("phone", ToolUtil.isNotEmpty(participant.getPhone()) ? participant.getPhone() : appUser.getPhone()); } list.add(map); } @@ -431,9 +455,9 @@ Map<String, Object> map = new HashMap<>(); map.put("id", cupCompetitor.getId()); Integer participantType = cupCompetitor.getParticipantType(); - Integer participantId = cupCompetitor.getParticipantId(); + Long participantId = cupCompetitor.getParticipantId(); if(1 == participantType){ - TStudent tStudent = studentClient.queryById(participantId); + TStudent tStudent = studentClient.queryById(participantId.intValue()); if(ToolUtil.isNotEmpty(name) && tStudent.getName().indexOf(name) == -1){ continue; } @@ -535,12 +559,12 @@ List<Map<String, Object>> mapList = new ArrayList<>(); for (Map<String, Object> map : list) { Long participantType = Long.valueOf(map.get("participantType").toString()); - Integer participantId = Integer.valueOf(map.get("participantId").toString()); + Long participantId = Long.valueOf(map.get("participantId").toString()); Integer ourScore = Integer.valueOf(map.get("ourScore").toString()); Integer opponentScore = Integer.valueOf(map.get("opponentScore").toString()); Integer matchResult = Integer.valueOf(map.get("matchResult").toString()); if(1 == participantType){ - TStudent tStudent = studentClient.queryById(participantId); + TStudent tStudent = studentClient.queryById(participantId.intValue()); if(ToolUtil.isNotEmpty(name) && tStudent.getName().indexOf(name) == -1){ continue; } -- Gitblit v1.7.1