From 062fb1ed6efcaac5d75bbe184524c4929dff7fcd Mon Sep 17 00:00:00 2001
From: nickchange <126672920+nickchange@users.noreply.github.com>
Date: 星期三, 18 十月 2023 15:25:35 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java | 63 +++++++++++++++++++++----------
1 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java b/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java
index 74c35c7..5522269 100644
--- a/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java
+++ b/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java
@@ -16,10 +16,7 @@
import com.dsh.competition.feignclient.other.StoreClient;
import com.dsh.competition.feignclient.other.model.Store;
import com.dsh.competition.mapper.CompetitionMapper;
-import com.dsh.competition.model.CompetitionInfo;
-import com.dsh.competition.model.CompetitionListVo;
-import com.dsh.competition.model.ParticipantVo;
-import com.dsh.competition.model.PaymentCompetitionVo;
+import com.dsh.competition.model.*;
import com.dsh.competition.service.CompetitionService;
import com.dsh.competition.service.IParticipantService;
import com.dsh.competition.service.IPaymentCompetitionService;
@@ -32,10 +29,7 @@
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -84,7 +78,8 @@
*/
@Override
public List<CompetitionListVo> queryCompetitionList(String cityCode, String content, Integer registerCondition, String heat) throws Exception {
- return this.baseMapper.queryCompetitionList(cityCode, content, registerCondition, heat);
+ List<CompetitionListVo> competitionListVos = this.baseMapper.queryCompetitionList(cityCode, content, registerCondition, heat);
+ return competitionListVos;
}
@@ -104,19 +99,32 @@
competitionInfo.setImgs(competition.getImgs());
competitionInfo.setName(competition.getName());
competitionInfo.setRegisterCondition(competition.getRegisterCondition());
+
+ // 2.0
+ ArrayList<Map<String,Object>> objects = new ArrayList<>();
if(null != competition.getStoreId()){
- Store store = storeClient.queryStoreById(competition.getStoreId());
- competitionInfo.setStoreName(store.getName());
- competitionInfo.setStoreAddress(store.getAddress());
- competitionInfo.setStoreLon(store.getLon());
- competitionInfo.setStoreLat(store.getLat());
- competitionInfo.setStoreCoverDrawing(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();
- competitionInfo.setDistance(wgs84);
+
+ String storeId = competition.getStoreId();
+ for (String s : storeId.split(",")) {
+ HashMap<String, Object> map = new HashMap<>();
+ Store store = storeClient.queryStoreById(Integer.valueOf(s));
+ map.put("name",store.getName());
+ map.put("address",store.getAddress());
+ 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);
}
+
}
+ competitionInfo.setStoreInfos(objects);
+
+
competitionInfo.setRegisterEndTime(sdf.format(competition.getRegisterEndTime()));
competitionInfo.setStartTime(sdf.format(competition.getStartTime()));
competitionInfo.setEndTime(sdf.format(competition.getEndTime()));
@@ -137,6 +145,9 @@
List<ParticipantVo> participant = new ArrayList<>();
List<UserCompetition> list = userCompetitionService.list(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", one.getId()));
List<Integer> collect = list.stream().map(UserCompetition::getParticipantId).collect(Collectors.toList());
+ if(collect.size()==0){
+ collect.add(-1);
+ }
List<Participant> participants = participantService.listByIds(collect);
SimpleDateFormat sdf_year = new SimpleDateFormat("yyyy");
for (Participant participant1 : participants) {
@@ -187,7 +198,8 @@
if(null == student){
return ResultUtil.error(participant.getName() + "不是学员,无法使用课时支付。");
}
- Integer integer = coursePackagePaymentClient.queryResidueClassHour(student.getId());
+ // 2.0
+ Integer integer = coursePackagePaymentClient.queryResidueClassHourById(paymentCompetitionVo.getCoursePaymentId());
if(new BigDecimal(integer).compareTo(new BigDecimal(competition.getClassPrice())) < 0){
return ResultUtil.error(participant.getName() + "剩余课时不足,无法完成支付。");
}
@@ -245,6 +257,7 @@
paymentDeductionClassHour.setId(student.getId());
paymentDeductionClassHour.setClassHour(competition.getClassPrice());
paymentDeductionClassHour.setCode(code);
+ paymentDeductionClassHour.setCourseId(paymentCompetitionVo.getCoursePaymentId());
coursePackagePaymentClient.paymentDeductionClassHour(paymentDeductionClassHour);
}
paymentCompetition = paymentCompetitionService.getById(paymentCompetition.getId());
@@ -400,4 +413,14 @@
this.baseMapper.taskSetStatusStart();
this.baseMapper.taskSetStatusEnd();
}
+
+ @Override
+ public ResultUtil paymentCompetitionCourseList(Integer uid, Integer id) {
+ Competition competition = this.baseMapper.selectById(id);
+ // 获取门店id 找出符合这些门店的课包
+ String storeId = competition.getStoreId();
+
+ List<PayCourseRes> list = coursePackagePaymentClient.paymentCompetitionCourseList(uid+"_"+storeId);
+ return ResultUtil.success(list);
+ }
}
--
Gitblit v1.7.1