From 48f8fffb3df2d8fd77c0a52df0e56e04eb5931ae Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期六, 02 三月 2024 10:03:22 +0800
Subject: [PATCH] 合并代码
---
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java | 137 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 135 insertions(+), 2 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 6054af7..295f885 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
@@ -1,15 +1,30 @@
package com.dsh.communityWorldCup.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dsh.communityWorldCup.entity.WorldCup;
+import com.dsh.communityWorldCup.entity.WorldCupPayment;
import com.dsh.communityWorldCup.entity.WorldCupPaymentParticipant;
+import com.dsh.communityWorldCup.feignclient.account.StudentClient;
+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.mapper.WorldCupPaymentParticipantMapper;
import com.dsh.communityWorldCup.model.MyWorldCupInfo;
import com.dsh.communityWorldCup.model.MyWorldCupList;
import com.dsh.communityWorldCup.model.WorldCupListVo;
+import com.dsh.communityWorldCup.model.*;
import com.dsh.communityWorldCup.service.IWorldCupPaymentParticipantService;
+import com.dsh.communityWorldCup.service.IWorldCupPaymentService;
+import com.dsh.communityWorldCup.service.IWorldCupService;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.List;
+import javax.annotation.Resource;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* @author zhibing.pu
@@ -17,6 +32,20 @@
*/
@Service
public class WorldCupPaymentParticipantServiceImpl extends ServiceImpl<WorldCupPaymentParticipantMapper, WorldCupPaymentParticipant> implements IWorldCupPaymentParticipantService {
+
+ @Autowired
+ private IWorldCupPaymentService worldCupPaymentService;
+
+ @Resource
+ private StudentClient studentClient;
+
+ @Resource
+ private ParticipantClient participantClient;
+
+ @Autowired
+ private IWorldCupService worldCupService;
+
+
/**
@@ -46,8 +75,112 @@
}
+ /**
+ * 获取已报名的世界杯详情
+ * @param id 社区世界杯支付对应的参与者记录id
+ * @return
+ */
@Override
public MyWorldCupInfo getMyWorldCupInfo(String id) {
- return null;
+ WorldCupPaymentParticipant worldCupPaymentParticipant = this.getById(id);
+ Integer worldCupId = worldCupPaymentParticipant.getWorldCupId();
+ WorldCupPayment worldCupPayment = worldCupPaymentService.getById(worldCupPaymentParticipant.getWorldCupPaymentId());
+ WorldCupInfo worldCupInfo = worldCupService.getWorldCupInfo(worldCupId, null, null);
+ WorldCup worldCup = worldCupService.getById(worldCupId);
+ MyWorldCupInfo myWorldCupInfo = new MyWorldCupInfo();
+ BeanUtils.copyProperties(worldCupInfo, myWorldCupInfo);
+ myWorldCupInfo.setUnitPrice(worldCupPayment.getUnitPrice().doubleValue());
+ myWorldCupInfo.setExpense(worldCupPayment.getAmount().doubleValue());
+ myWorldCupInfo.setStatus(worldCup.getStatus());
+ myWorldCupInfo.setRevocable(1);
+ //开始前一天不能取消
+ if(worldCup.getStartTime().getTime() < System.currentTimeMillis() + 86400000L){
+ myWorldCupInfo.setRevocable(0);
+ }
+ List<ParticipantVo> datas = new ArrayList<>();
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
+ List<WorldCupPaymentParticipant> list1 = this.list(new QueryWrapper<WorldCupPaymentParticipant>().eq("worldCupPaymentId", worldCupPaymentParticipant.getWorldCupPaymentId()));
+ for (WorldCupPaymentParticipant wcpp : list1) {
+ Integer participantType = wcpp.getParticipantType();
+ Integer participantId = wcpp.getParticipantId();
+ ParticipantVo participantVo = new ParticipantVo();
+ //学员
+ if(1 == participantType){
+ TStudent tStudent = studentClient.queryById(participantId);
+ participantVo.setId(tStudent.getId());
+ participantVo.setName(tStudent.getName());
+ 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);
+ }
+ //参赛人员
+ if(2 == participantType){
+ Participant participant = participantClient.getParticipant(participantId);
+ participantVo.setId(participant.getId());
+ participantVo.setName(participant.getName());
+ 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);
+ }
+ }
+
+ myWorldCupInfo.setParticipants(datas);
+ return myWorldCupInfo;
+ }
+
+
+ /**
+ * 获取已报过名的参赛人员
+ * @param uid 当前用户
+ * @return
+ */
+ @Override
+ public List<ParticipantVo> getParticipant(Integer uid) {
+ List<WorldCupPayment> list = worldCupPaymentService.list(new QueryWrapper<WorldCupPayment>().eq("appUserId", uid)
+ .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<>();
+ 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();
+ ParticipantVo participantVo = new ParticipantVo();
+ //学员
+ if(1 == participantType && !xy.contains(participantId)){
+ TStudent tStudent = studentClient.queryById(participantId);
+ participantVo.setId(tStudent.getId());
+ participantVo.setName(tStudent.getName());
+ 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);
+ }
+ //参赛人员
+ if(2 == participantType && !csry.contains(participantId)){
+ Participant participant = participantClient.getParticipant(participantId);
+ participantVo.setId(participant.getId());
+ participantVo.setName(participant.getName());
+ 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);
+ }
+ }
+ }
+ return datas;
}
}
--
Gitblit v1.7.1