From acad524bfb7f376c09ff8e6600fab207780156e1 Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期四, 23 十一月 2023 18:46:05 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/PlayPai --- cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java | 73 ++++++++++++++++++++++++++++-------- 1 files changed, 56 insertions(+), 17 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 0e35e4b..e8a2393 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 @@ -21,6 +21,7 @@ import com.dsh.competition.feignclient.account.model.Student; import com.dsh.competition.feignclient.course.CoursePackagePaymentClient; import com.dsh.competition.feignclient.course.model.PaymentDeductionClassHour; +import com.dsh.competition.feignclient.model.CompetitionUser; import com.dsh.competition.feignclient.other.StoreClient; import com.dsh.competition.feignclient.other.model.Store; import com.dsh.competition.mapper.CompetitionMapper; @@ -30,6 +31,7 @@ import com.dsh.competition.service.IPaymentCompetitionService; import com.dsh.competition.service.UserCompetitionService; import com.dsh.competition.util.*; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -96,6 +98,13 @@ @Override public List<CompetitionListVo> queryCompetitionList(String cityCode, String content, Integer registerCondition, String heat) throws Exception { List<CompetitionListVo> competitionListVos = this.baseMapper.queryCompetitionList(cityCode, content, registerCondition, heat); + + for (CompetitionListVo competitionListVo : competitionListVos) { + Integer counts = this.baseMapper.counts(competitionListVo.getId()); + competitionListVo.setHeat(competitionListVo.getHeat()+counts); + } + + return competitionListVos; } @@ -120,7 +129,6 @@ // 2.0 ArrayList<Map<String,Object>> objects = new ArrayList<>(); if(null != competition.getStoreId()){ - String storeId = competition.getStoreId(); for (String s : storeId.split(",")) { HashMap<String, Object> map = new HashMap<>(); @@ -155,11 +163,22 @@ competitionInfo.setRegisterEndTime(sdf.format(competition.getRegisterEndTime())); competitionInfo.setStartTime(sdf.format(competition.getStartTime())); + competitionInfo.setIsReal(competition.getRealName()); competitionInfo.setEndTime(sdf.format(competition.getEndTime())); competitionInfo.setAge(competition.getStartAge() + "-" + competition.getEndAge()); - competitionInfo.setProvince(competition.getEntryProvince()); - competitionInfo.setCity(competition.getEntryCity()); - competitionInfo.setAddress(competition.getEntryAddress()); + competitionInfo.setProvince(competition.getProvince()); + competitionInfo.setCity(competition.getCity()); + String str = competition.getAddress(); + str = str.substring(str.indexOf("省") + 1); + + // 去掉第一个“市”及之前的字符串 + str = str.substring(str.indexOf("市") + 1); + + // 去掉第一个“区”及之前的字符串 + str = str.substring(str.indexOf("区") + 1); + + + competitionInfo.setAddress(str); competitionInfo.setCashPrice(competition.getCashPrice()); competitionInfo.setPlayPaiCoin(competition.getPlayPaiCoin()); competitionInfo.setClassPrice(competition.getClassPrice()); @@ -196,6 +215,7 @@ } + /** * 赛事报名 * @param uid @@ -208,9 +228,10 @@ AppUser appUser = appUserClient.queryAppUser(uid); String[] split = paymentCompetitionVo.getIds().split(";"); Competition competition = this.getById(paymentCompetitionVo.getId()); - if ((competition.getBaseNumber()+split.length)>competition.getApplicantsNumber()){ - return ResultUtil.error("报名人数超过最大限制"); + int competitionId = userCompetitionService.count(new QueryWrapper<UserCompetition>().eq("competitionId", paymentCompetitionVo.getId())); + if ((competitionId+split.length)>competition.getApplicantsNumber()){ + return ResultUtil.error("报名人数超过最大限制"); } BigDecimal money = null; if(paymentCompetitionVo.getPayType() == 1 || paymentCompetitionVo.getPayType() == 2){ @@ -219,21 +240,23 @@ if(paymentCompetitionVo.getPayType() == 3){//玩湃币 money = new BigDecimal(competition.getPlayPaiCoin()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN); if(money.compareTo(new BigDecimal(appUser.getPlayPaiCoins())) > 0){ - return ResultUtil.error("报名失败,玩湃币不足,请充值"); + + return new ResultUtil(2,"报名失败,玩湃币不足,请充值"); } } if(paymentCompetitionVo.getPayType() == 4){//课程 money = new BigDecimal(competition.getClassPrice()).multiply(new BigDecimal(split.length)).setScale(2, RoundingMode.HALF_EVEN); for (String s : split) { - Participant participant = participantService.getById(s); - Student student = studentClient.queryStudentByPhone(participant.getPhone()); - if(null == student){ - return ResultUtil.error(participant.getName() + "不是学员,无法使用课时支付。"); - } +// Participant participant = participantService.getById(s); +// Student student = studentClient.queryStudentByPhone(participant.getPhone()); +// if(null == student){ +// return ResultUtil.error(participant.getName() + "不是学员,无法使用课时支付。"); +// } // 2.0 Integer integer = coursePackagePaymentClient.queryResidueClassHourById(paymentCompetitionVo.getCoursePaymentId()); if(new BigDecimal(integer).compareTo(new BigDecimal(competition.getClassPrice())) < 0){ - return ResultUtil.error(participant.getName() + "剩余课时不足,无法完成支付。"); + return new ResultUtil(3,"剩余课时不足,无法完成支付。"); + } } } @@ -278,18 +301,19 @@ paymentCompetition.setPayOrderNo(""); paymentCompetitionService.updateById(paymentCompetition); - competition.setApplicantsNumber(competition.getApplicantsNumber() + 1); +// competition.setApplicantsNumber(competition.getApplicantsNumber() + 1); this.updateById(competition); } if(paymentCompetitionVo.getPayType() == 4){//课程 for (String s : split) { - Participant participant = participantService.getById(s); - Student student = studentClient.queryStudentByPhone(participant.getPhone()); +// Participant participant = participantService.getById(s); +// Student student = studentClient.queryStudentByPhone(participant.getPhone()); PaymentDeductionClassHour paymentDeductionClassHour = new PaymentDeductionClassHour(); - paymentDeductionClassHour.setId(student.getId()); + paymentDeductionClassHour.setId(Integer.valueOf(s)); paymentDeductionClassHour.setClassHour(competition.getClassPrice()); paymentDeductionClassHour.setCode(code); paymentDeductionClassHour.setCourseId(paymentCompetitionVo.getCoursePaymentId()); + paymentDeductionClassHour.setUid(uid); coursePackagePaymentClient.paymentDeductionClassHour(paymentDeductionClassHour); } paymentCompetition = paymentCompetitionService.getById(paymentCompetition.getId()); @@ -535,10 +559,25 @@ /** * 定时任务修改赛事状态 */ + @Override public void taskSetStatus() { this.baseMapper.taskSetStatusStart(); this.baseMapper.taskSetStatusEnd(); + + Date currentTime = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(currentTime); + calendar.add(Calendar.MINUTE, -10); + Date tenMinutesAgo = calendar.getTime(); + List<PaymentCompetition> payStatus = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>().eq("payStatus", 1).le("insertTime", tenMinutesAgo)); + List<Long> pays = new ArrayList<>(); + for (PaymentCompetition status : payStatus) { + pays.add(status.getId()); + } + if (!pays.isEmpty()) { + this.baseMapper.deleteTenMinutes(pays); + } } @Override -- Gitblit v1.7.1