From a4d873761dd03a74950d05f204171255509bd5fb Mon Sep 17 00:00:00 2001
From: zhibing.pu <393733352@qq.com>
Date: 星期一, 17 六月 2024 16:03:35 +0800
Subject: [PATCH] 修改 bug
---
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 213 insertions(+), 8 deletions(-)
diff --git a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java
index 11d20b5..e88601b 100644
--- a/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java
+++ b/cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java
@@ -6,12 +6,15 @@
import com.dsh.communityWorldCup.entity.WorldCupPayment;
import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant;
import com.dsh.communityWorldCup.entity.WorldCupStore;
+import com.dsh.communityWorldCup.feignclient.account.AppUserClient;
import com.dsh.communityWorldCup.feignclient.account.StudentClient;
+import com.dsh.communityWorldCup.feignclient.account.model.AppUser;
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.feignclient.other.model.Store;
+import com.dsh.communityWorldCup.mapper.WorldCupCompetitorMapper;
import com.dsh.communityWorldCup.mapper.WorldCupPaymentParticipantMapper;
import com.dsh.communityWorldCup.model.MyWorldCupInfo;
import com.dsh.communityWorldCup.model.MyWorldCupList;
@@ -29,6 +32,7 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
+import java.math.MathContext;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -62,6 +66,12 @@
@Resource
private StoreClient storeClient;
+ @Resource
+ private AppUserClient appUserClient;
+
+ @Resource
+ private WorldCupCompetitorMapper worldCupCompetitorMapper;
+
@@ -73,7 +83,7 @@
* @return
*/
@Override
- public WorldCupPaymentParticipant getWorldCupPaymentParticipant(Integer worldCupId, Integer participantType, Integer participantId) {
+ public WorldCupPaymentParticipant getWorldCupPaymentParticipant(Integer worldCupId, Integer participantType, Long participantId) {
return this.baseMapper.getWorldCupPaymentParticipant(worldCupId, participantType, participantId);
}
@@ -110,7 +120,7 @@
* @return
*/
@Override
- public MyWorldCupInfo getMyWorldCupInfo(String id, String lon, String lat) {
+ public MyWorldCupInfo getMyWorldCupInfo(Long id, String lon, String lat) {
WorldCupPaymentParticipant worldCupPaymentParticipant = this.getById(id);
Integer worldCupId = worldCupPaymentParticipant.getWorldCupId();
WorldCupPayment worldCupPayment = worldCupPaymentService.getById(worldCupPaymentParticipant.getWorldCupPaymentId());
@@ -118,6 +128,7 @@
WorldCup worldCup = worldCupService.getById(worldCupId);
MyWorldCupInfo myWorldCupInfo = new MyWorldCupInfo();
BeanUtils.copyProperties(worldCupInfo, myWorldCupInfo);
+ myWorldCupInfo.setId(worldCupPaymentParticipant.getId());
myWorldCupInfo.setUnitPrice(worldCupPayment.getUnitPrice().doubleValue());
myWorldCupInfo.setExpense(worldCupPayment.getAmount().doubleValue());
myWorldCupInfo.setStatus(worldCup.getStatus());
@@ -134,11 +145,11 @@
List<WorldCupPaymentParticipant> list1 = this.list(new QueryWrapper<WorldCupPaymentParticipant>().eq("worldCupPaymentId", worldCupPaymentParticipant.getWorldCupPaymentId()));
for (WorldCupPaymentParticipant wcpp : list1) {
Integer participantType = wcpp.getParticipantType();
- Integer participantId = wcpp.getParticipantId();
+ Long participantId = wcpp.getParticipantId();
ParticipantVo participantVo = new ParticipantVo();
//学员
if(1 == participantType){
- TStudent tStudent = studentClient.queryById(participantId);
+ TStudent tStudent = studentClient.queryById(participantId.intValue());
participantVo.setId(tStudent.getId());
participantVo.setName(tStudent.getName());
int age = Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(tStudent.getBirthday()));
@@ -192,6 +203,24 @@
objects.add(map);
}
worldCupInfo.setStoreInfos(objects);
+ String address = worldCupInfo.getAddress();
+ String province = worldCupInfo.getProvince();
+ String city = worldCupInfo.getCity();
+ int index = address.indexOf("市");
+ if(index != -1){
+ address = address.substring(index + 1);
+ worldCupInfo.setAddress(address);
+ }
+ index = province.indexOf("省");
+ if(index != -1){
+ province = province.substring(0, index - 1);
+ worldCupInfo.setProvince(province);
+ }
+ index = city.indexOf("市");
+ if(index != -1){
+ city = city.substring(0, index - 1);
+ worldCupInfo.setCity(city);
+ }
return myWorldCupInfo;
}
@@ -207,41 +236,217 @@
.eq("payStatus", 2).eq("state", 1));
List<Long> collect = list.stream().map(WorldCupPayment::getId).collect(Collectors.toList());
List<ParticipantVo> datas = new ArrayList<>();
- Set<Integer> csry = new HashSet<>();
- Set<Integer> xy = new HashSet<>();
+ Set<Long> csry = new HashSet<>();
+ Set<Long> xy = new HashSet<>();
if(collect.size() > 0){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
List<WorldCupPaymentParticipant> list1 = this.list(new QueryWrapper<WorldCupPaymentParticipant>().in("worldCupPaymentId", collect));
for (WorldCupPaymentParticipant worldCupPaymentParticipant : list1) {
Integer participantType = worldCupPaymentParticipant.getParticipantType();
- Integer participantId = worldCupPaymentParticipant.getParticipantId();
+ Long participantId = worldCupPaymentParticipant.getParticipantId();
ParticipantVo participantVo = new ParticipantVo();
+ AppUser appUser = appUserClient.getAppUser(worldCupPaymentParticipant.getAppUserId());
//学员
if(1 == participantType && !xy.contains(participantId)){
- TStudent tStudent = studentClient.queryById(participantId);
+ TStudent tStudent = studentClient.queryById(participantId.intValue());
participantVo.setId(tStudent.getId());
participantVo.setName(tStudent.getName());
+ participantVo.setAvatar(tStudent.getHeadImg());
int age = Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(tStudent.getBirthday()));
participantVo.setAge(age);
participantVo.setIdcard(tStudent.getIdCard());
participantVo.setPhone(tStudent.getPhone());
participantVo.setIsStudent(1);
datas.add(participantVo);
+ xy.add(participantId);
}
//参赛人员
if(2 == participantType && !csry.contains(participantId)){
Participant participant = participantClient.getParticipant(participantId);
participantVo.setId(participant.getId());
participantVo.setName(participant.getName());
+ participantVo.setAvatar(participant.getHeadImg());
int age = Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(participant.getBirthday()));
participantVo.setAge(age);
participantVo.setIdcard(participant.getIdcard());
participantVo.setPhone(participant.getPhone());
participantVo.setIsStudent(0);
datas.add(participantVo);
+ csry.add(participantId);
}
}
}
return datas;
}
+
+
+ /**
+ * 获取 已报名人员列表
+ * @param registeredPersonnel
+ * @return
+ */
+ @Override
+ public Map<String, Object> getRegisteredPersonnel(RegisteredPersonnel registeredPersonnel) {
+ Integer id = registeredPersonnel.getId();
+ String idcode = registeredPersonnel.getIdcode();
+ String name = registeredPersonnel.getName();
+ String phone = registeredPersonnel.getPhone();
+ Integer status = registeredPersonnel.getStatus();
+ Integer offset = registeredPersonnel.getOffset();
+ Integer limit = registeredPersonnel.getLimit();
+ QueryWrapper<WorldCupPayment> queryWrapper = new QueryWrapper<WorldCupPayment>()
+ .eq("worldCupId", id).eq("state", 1);
+ if(null == status){
+ queryWrapper.in("payStatus", Arrays.asList(2, 3));
+ }else if(status == 1){
+ queryWrapper.eq("payStatus", 2);
+ }else{
+ queryWrapper.eq("payStatus", 3);
+ }
+ List<WorldCupPayment> list = worldCupPaymentService.list(queryWrapper);
+ List<Long> collect = list.stream().map(WorldCupPayment::getId).collect(Collectors.toList());
+ Map<String, Object> map = new HashMap<>();
+ if(collect.size() == 0){
+ map.put("rows", new ArrayList<>());
+ map.put("total", 0);
+ return map;
+ }
+ List<WorldCupPaymentParticipant> list1 = this.list(new QueryWrapper<WorldCupPaymentParticipant>().in("worldCupPaymentId", collect));
+ List<Map<String, Object>> list2 = new ArrayList<>();
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
+ for (WorldCupPaymentParticipant on : list1) {
+ WorldCupPayment worldCupPayment = worldCupPaymentService.getById(on.getWorldCupPaymentId());
+ Map<String, Object> map1 = new HashMap<>();
+ AppUser appUser = appUserClient.getAppUser(on.getAppUserId());
+ if(on.getParticipantType() == 1){
+ TStudent tStudent = studentClient.queryById(on.getParticipantId().intValue());
+ if(ToolUtil.isNotEmpty(name) && tStudent.getName().indexOf(name) == -1){
+ continue;
+ }
+ if(ToolUtil.isNotEmpty(phone) && (ToolUtil.isEmpty(tStudent.getPhone()) ? appUser.getPhone() : tStudent.getPhone()).indexOf(phone) == -1){
+ continue;
+ }
+ if(ToolUtil.isNotEmpty(idcode) && tStudent.getIdCard().indexOf(idcode) == -1){
+ continue;
+ }
+ map1.put("id", tStudent.getId());
+ map1.put("isStudent", 1);
+ map1.put("name", tStudent.getName());
+ map1.put("gender", tStudent.getSex() == 1 ? "男" : "女");
+ map1.put("age", Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(tStudent.getBirthday())));
+ map1.put("phone", ToolUtil.isEmpty(tStudent.getPhone()) ? appUser.getPhone() : tStudent.getPhone());
+ map1.put("idcard", tStudent.getIdCard());
+ map1.put("state", worldCupPayment.getPayStatus() - 1);
+ }else{
+ Participant participant = participantClient.getParticipant(on.getParticipantId());
+ if(ToolUtil.isNotEmpty(name) && participant.getName().indexOf(name) == -1){
+ continue;
+ }
+ if(ToolUtil.isNotEmpty(phone) && (ToolUtil.isNotEmpty(participant.getPhone()) ? participant.getPhone() : appUser.getPhone()).indexOf(phone) == -1){
+ continue;
+ }
+ if(ToolUtil.isNotEmpty(idcode) && participant.getIdcard().indexOf(idcode) == -1){
+ continue;
+ }
+ map1.put("id", participant.getId());
+ map1.put("isStudent", 0);
+ map1.put("name", participant.getName());
+ map1.put("gender", participant.getGender() == 1 ? "男" : "女");
+ map1.put("age", Integer.valueOf(sdf.format(new Date())) - Integer.valueOf(sdf.format(participant.getBirthday())));
+ map1.put("phone", ToolUtil.isNotEmpty(participant.getPhone()) ? participant.getPhone() : appUser.getPhone());
+ map1.put("idcard", participant.getIdcard());
+ map1.put("state", worldCupPayment.getPayStatus() - 1);
+ }
+ list2.add(map1);
+ }
+
+ limit += offset;
+ map.put("rows", list2.subList(offset, list2.size() >= limit ? limit : list2.size()));
+ map.put("total", list2.size());
+ return map;
+ }
+
+ @Override
+ public int getCount(Integer worldCupId, List<Long> worldCupPaymentId) {
+ return this.baseMapper.getCount(worldCupId, worldCupPaymentId);
+ }
+
+
+ /**
+ * 获取用户列表
+ * @param worldCupGameStatisticsInfoList
+ * @return
+ */
+ @Override
+ public Map<String, Object> getUserGameRecordList(WorldCupGameStatisticsInfoList worldCupGameStatisticsInfoList) {
+ Map<String, Object> map1 = new HashMap<>();
+ String name = worldCupGameStatisticsInfoList.getName();
+ String phone = worldCupGameStatisticsInfoList.getPhone();
+ String idcard = worldCupGameStatisticsInfoList.getIdcard();
+ List<Map<String, Object>> mapList = this.baseMapper.getUserGameRecordList();
+ List<Map<String, Object>> 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());
+ Map<String, Object> userGameRecordList = worldCupCompetitorMapper.getUserGameRecordList(participantType, participantId);
+ Map<String, Object> userGameRecordList1 = worldCupCompetitorMapper.getUserGameRecordList1(participantType, participantId);
+ Integer totalSession = 0;
+ Integer win = 0;
+ if(null != userGameRecordList){
+ totalSession = Integer.valueOf(null != userGameRecordList && null != userGameRecordList.get("num") ? userGameRecordList.get("num").toString() : "0");
+ win = Integer.valueOf(null != userGameRecordList1 && null != userGameRecordList1.get("num") ? userGameRecordList1.get("num").toString() : "0");
+ }else{
+ userGameRecordList = new HashMap<>();
+ }
+ userGameRecordList.put("totalSession", totalSession);
+ userGameRecordList.put("win", win);
+ Integer lose = totalSession - win;
+ userGameRecordList.put("lose", lose);
+ userGameRecordList.put("winRate", totalSession == 0 ? 0 : new BigDecimal(win).divide(new BigDecimal(totalSession), new MathContext(4, RoundingMode.HALF_EVEN)).multiply(new BigDecimal(100)).doubleValue());
+ userGameRecordList.put("participantType", participantType);
+ userGameRecordList.put("participantId", participantId);
+ AppUser appUser = appUserClient.getAppUser(appUserId);
+ userGameRecordList.put("province", appUser.getProvince() + appUser.getCity());
+ if(1 == participantType){
+ TStudent tStudent = studentClient.queryById(participantId.intValue());
+ if(ToolUtil.isNotEmpty(name) && tStudent.getName().indexOf(name) == -1){
+ continue;
+ }
+ 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){
+ continue;
+ }
+
+ userGameRecordList.put("name", tStudent.getName());
+ userGameRecordList.put("phone", ToolUtil.isEmpty(tStudent.getPhone()) ? appUser.getPhone() : tStudent.getPhone());
+ userGameRecordList.put("idcard", tStudent.getIdCard());
+ }else{
+ Participant participant = participantClient.getParticipant(participantId);
+ if(ToolUtil.isNotEmpty(name) && participant.getName().indexOf(name) == -1){
+ continue;
+ }
+ 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){
+ continue;
+ }
+
+ userGameRecordList.put("name", participant.getName());
+ userGameRecordList.put("phone", ToolUtil.isNotEmpty(participant.getPhone()) ? participant.getPhone() : appUser.getPhone());
+ userGameRecordList.put("idcard", participant.getIdcard());
+ }
+ list.add(userGameRecordList);
+ }
+ map1.put("total", list.size());
+ Integer offset = worldCupGameStatisticsInfoList.getOffset();
+ Integer limit = worldCupGameStatisticsInfoList.getLimit();
+ limit += offset;
+ map1.put("rows", list.subList(offset, list.size() >= limit ? limit : list.size()));
+ return map1;
+ }
}
--
Gitblit v1.7.1