From db3e6f6d5a8f29a5dc576aba2eab76a8133ce03c Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期五, 08 三月 2024 21:46:10 +0800
Subject: [PATCH] 11.27,9
---
cloud-server-communityWorldCup/src/main/java/com/dsh/communityWorldCup/service/impl/WorldCupPaymentParticipantServiceImpl.java | 296 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 294 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 c9d0723..506e666 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,14 +1,38 @@
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.entity.WorldCupStore;
+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.feignclient.other.StoreClient;
+import com.dsh.communityWorldCup.feignclient.other.model.Store;
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 com.dsh.communityWorldCup.service.IWorldCupStoreService;
+import com.dsh.communityWorldCup.util.GeodesyUtil;
+import com.dsh.communityWorldCup.util.ToolUtil;
+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.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
/**
* @author zhibing.pu
@@ -16,6 +40,29 @@
*/
@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;
+
+ @Autowired
+ private IWorldCupPaymentParticipantService worldCupPaymentParticipantService;
+
+ @Autowired
+ private IWorldCupStoreService worldCupStoreService;
+
+ @Resource
+ private StoreClient storeClient;
+
+
/**
@@ -41,6 +88,251 @@
int pageNo = (myWorldCupList.getPageNo() - 1) * myWorldCupList.getPageSize();
myWorldCupList.setPageNo(pageNo);
myWorldCupList.setIsStudent(myWorldCupList.getIsStudent() == 0 ? 2 : 1);
- return this.baseMapper.getMyWorldCupList(myWorldCupList);
+ List<WorldCupListVo> myWorldCupList1 = this.baseMapper.getMyWorldCupList(myWorldCupList);
+ for (WorldCupListVo worldCupListVo : myWorldCupList1) {
+ Integer worldCupId = worldCupListVo.getWorldCupId();
+ List<WorldCupPayment> list = worldCupPaymentService.list(new QueryWrapper<WorldCupPayment>().eq("worldCupId", worldCupId).eq("payStatus", 2).eq("state", 1));
+ List<Long> collect = list.stream().map(WorldCupPayment::getId).collect(Collectors.toList());
+ Integer heat = worldCupListVo.getHeat();
+ if(collect.size() > 0){
+ int count = worldCupPaymentParticipantService.count(new QueryWrapper<WorldCupPaymentParticipant>().in("worldCupPaymentId", collect));
+ heat += count;
+ }
+ worldCupListVo.setHeat(heat);
+ }
+ return myWorldCupList1;
+ }
+
+
+ /**
+ * 获取已报名的世界杯详情
+ * @param id 社区世界杯支付对应的参与者记录id
+ * @return
+ */
+ @Override
+ public MyWorldCupInfo getMyWorldCupInfo(String id, String lon, String lat) {
+ 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);
+ myWorldCupInfo.setProvince(worldCup.getProvince());
+ myWorldCupInfo.setCity(worldCup.getCity());
+ myWorldCupInfo.setPayType(worldCupPayment.getPayType());
+ //开始前一天不能取消
+ 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);
+ List<WorldCupStore> worldCupStores = worldCupStoreService.list(new QueryWrapper<WorldCupStore>().eq("worldCupId", id));
+ ArrayList<Map<String, Object>> objects = new ArrayList<>();
+ for (WorldCupStore worldCupStore : worldCupStores) {
+ HashMap<String, Object> map = new HashMap<>();
+ Store store = storeClient.queryStoreById(worldCupStore.getStoreId());
+ map.put("name", store.getName());
+
+
+ String str = store.getAddress();
+ str = str.substring(str.indexOf("省") + 1);
+
+ // 去掉第一个“市”及之前的字符串
+ str = str.substring(str.indexOf("市") + 1);
+
+ // 去掉第一个“区”及之前的字符串
+ str = str.substring(str.indexOf("区") + 1);
+
+ map.put("address", str);
+ map.put("storeLon", store.getLon());
+ map.put("storeLat", store.getLat());
+ map.put("storeCoverDrawing", store.getCoverDrawing());
+ if (ToolUtil.isNotEmpty(lon) && ToolUtil.isNotEmpty(lat)) {
+ Map<String, Double> distance = GeodesyUtil.getDistance(lon + "," + lat, store.getLon() + "," + store.getLat());
+ double wgs84 = new BigDecimal(distance.get("WGS84")).divide(new BigDecimal(1000)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
+ map.put("distance", wgs84);
+ }
+ objects.add(map);
+ }
+ worldCupInfo.setStoreInfos(objects);
+ 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;
+ }
+
+
+ /**
+ * 获取 已报名人员列表
+ * @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<>();
+ if(on.getParticipantType() == 1){
+ TStudent tStudent = studentClient.queryById(on.getParticipantId());
+ if(ToolUtil.isNotEmpty(name) && tStudent.getName().indexOf(name) == -1){
+ continue;
+ }
+ if(ToolUtil.isNotEmpty(phone) && 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", 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) && participant.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", participant.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 : list.size()));
+ map.put("total", list2.size());
+ return map;
+ }
+
+ @Override
+ public int getCount(Integer worldCupId, List<Long> worldCupPaymentId) {
+ return this.baseMapper.getCount(worldCupId, worldCupPaymentId);
}
}
--
Gitblit v1.7.1