From eb6b6dbb35a9f029e0b7d269773685c19fd40976 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 11 七月 2024 10:47:51 +0800 Subject: [PATCH] 玩湃微信商户认证代码 --- cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java | 129 ++++++++++++++++++++++++++++++++++--------- 1 files changed, 102 insertions(+), 27 deletions(-) diff --git a/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java b/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java index e21498e..45d3a29 100644 --- a/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java +++ b/cloud-server-competition/src/main/java/com/dsh/competition/service/impl/PaymentCompetitionServiceImpl.java @@ -10,11 +10,13 @@ import com.dsh.competition.feignclient.account.StudentClient; import com.dsh.competition.feignclient.account.model.AppUser; import com.dsh.competition.feignclient.account.model.Student; +import com.dsh.competition.feignclient.account.model.TStudent; import com.dsh.competition.feignclient.course.CoursePackagePaymentClient; import com.dsh.competition.feignclient.course.model.PaymentDeductionClassHour; import com.dsh.competition.feignclient.model.BillingRequest; 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.mapper.PaymentCompetitionMapper; import com.dsh.competition.model.*; import com.dsh.competition.service.CompetitionService; @@ -30,10 +32,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; /** @@ -70,10 +69,12 @@ private PaymentCompetitionMapper paymentCompetitionMapper; - + @Resource + private CompetitionMapper competitionMapper; /** * 获取我的报名赛事记录 + * * @param uid * @param type * @param pageSize @@ -84,15 +85,21 @@ @Override public List<CompetitionListVo> queryMyCompetitionList(Integer uid, Integer type, Integer pageSize, Integer pageNo) throws Exception { pageNo = (pageNo - 1) * pageSize; - if(0 == type){ + if (0 == type) { type = null; } - return this.baseMapper.queryMyCompetitionList(uid, type, pageSize, pageNo); + List<CompetitionListVo> competitionListVos = this.baseMapper.queryMyCompetitionList(uid, type, pageSize, pageNo); + for (CompetitionListVo competitionListVo : competitionListVos) { + Integer counts = competitionMapper.counts(competitionListVo.getPId()); + competitionListVo.setHeat(competitionListVo.getHeat() + counts); + } + return competitionListVos; } /** * 获取我报名的赛事详情 + * * @param id * @return * @throws Exception @@ -119,16 +126,65 @@ competitionInfo.setAge(competition.getStartAge() + "-" + competition.getEndAge()); competitionInfo.setProvince(competition.getEntryProvince()); competitionInfo.setCity(competition.getEntryCity()); - competitionInfo.setAddress(competition.getEntryAddress()); + + 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()); competitionInfo.setIntroduction(competition.getIntroduction()); competitionInfo.setRegistrationNotes(competition.getRegistrationNotes()); competitionInfo.setApply(1); + 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<>(); + Store store1 = storeClient.queryStoreById(Integer.valueOf(s)); + map.put("name", store1.getName()); + + + String str1 = store1.getAddress(); + str1 = str1.substring(str1.indexOf("省") + 1); + + // 去掉第一个“市”及之前的字符串 + str1 = str1.substring(str1.indexOf("市") + 1); + + // 去掉第一个“区”及之前的字符串 + str1 = str1.substring(str1.indexOf("区") + 1); + + map.put("address", str1); + 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); + + List<ParticipantVo> participant = new ArrayList<>(); List<UserCompetition> list = userCompetitionService.list(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.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) { @@ -138,11 +194,29 @@ participantVo.setIdcard(participant1.getIdcard()); Integer age = Integer.valueOf(sdf_year.format(new Date())) - Integer.valueOf(sdf_year.format(participant1.getBirthday())); participantVo.setAge(age); + participantVo.setPhone(participant1.getPhone()); participant.add(participantVo); } + + + for (Integer i : collect) { + TStudent tStudent = studentClient.queryById(i); + if (tStudent != null) { + ParticipantVo participantVo = new ParticipantVo(); + participantVo.setId(tStudent.getId()); + participantVo.setName(tStudent.getName()); + participantVo.setIdcard(tStudent.getIdCard()); + Integer age = Integer.valueOf(sdf_year.format(new Date())) - Integer.valueOf(sdf_year.format(tStudent.getBirthday())); + participantVo.setAge(age); + participantVo.setPhone(tStudent.getPhone()); + participant.add(participantVo); + } + + } + competitionInfo.setParticipant(participant); competitionInfo.setStatus(competition.getStatus()); - if(paymentCompetition.getPayStatus() == 3){ + if (paymentCompetition.getPayStatus() == 3) { competitionInfo.setStatus(4); } competitionInfo.setPayMoney(paymentCompetition.getAmount()); @@ -153,6 +227,7 @@ /** * 取消赛事报名 + * * @param id * @return * @throws Exception @@ -160,35 +235,35 @@ @Override public ResultUtil cancelMyCompetition(Long id) throws Exception { PaymentCompetition paymentCompetition = this.getById(id); - if(paymentCompetition.getPayStatus() == 3){ + if (paymentCompetition.getPayStatus() == 3) { return ResultUtil.error("不能重复取消"); } String code = paymentCompetition.getCode(); Double amount = paymentCompetition.getAmount(); Competition competition = competitionService.getById(paymentCompetition.getCompetitionId()); - if(System.currentTimeMillis() >= competition.getRegisterEndTime().getTime()){ + if (System.currentTimeMillis() >= competition.getRegisterEndTime().getTime()) { return ResultUtil.error("赛事已结束报名,无法取消"); } String payOrderNo = paymentCompetition.getPayOrderNo(); - if(paymentCompetition.getPayType() == 1){//微信支付 + if (paymentCompetition.getPayType() == 1) {//微信支付 Map<String, String> map = payMoneyUtil.wxRefund(payOrderNo, code, amount.toString(), amount.toString(), "/base/competition/weChatCancelPaymentCompetitionCallback"); String return_code = map.get("return_code"); - if(!"SUCCESS".equals(return_code)){ + if (!"SUCCESS".equals(return_code)) { return ResultUtil.error(map.get("return_msg")); } String refund_id = map.get("refund_id"); paymentCompetition.setRefundOrderNo(refund_id); this.updateById(paymentCompetition); - storeClient.addBackRecord(paymentCompetition.getAmount()+"_"+paymentCompetition.getAppUserId()); + storeClient.addBackRecord(paymentCompetition.getAmount() + "_" + paymentCompetition.getAppUserId()); } - if(paymentCompetition.getPayType() == 2){//支付宝支付 + if (paymentCompetition.getPayType() == 2) {//支付宝支付 Map<String, String> map = payMoneyUtil.aliRefund(payOrderNo, amount.toString()); String return_code = map.get("code"); - if(!"10000".equals(return_code)){ + if (!"10000".equals(return_code)) { return ResultUtil.error(map.get("msg")); } String refund_id = map.get("trade_no"); @@ -198,10 +273,10 @@ paymentCompetition.setAppUserId(null); this.updateById(paymentCompetition); - competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); +// competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); competitionService.updateById(competition); } - if(paymentCompetition.getPayType() == 3){//玩湃币支付 + if (paymentCompetition.getPayType() == 3) {//玩湃币支付 AppUser appUser = appUserClient.queryAppUser(paymentCompetition.getAppUserId()); appUser.setPlayPaiCoins(appUser.getPlayPaiCoins() + amount.intValue()); appUserClient.updateAppUser(appUser); @@ -212,16 +287,16 @@ paymentCompetition.setAppUserId(null); this.updateById(paymentCompetition); - competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); +// competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); competitionService.updateById(competition); } - if(paymentCompetition.getPayType() == 4){//课程支付 + if (paymentCompetition.getPayType() == 4) {//课程支付 List<UserCompetition> list = userCompetitionService.list(new QueryWrapper<UserCompetition>().eq("paymentCompetitionId", paymentCompetition.getId())); for (UserCompetition userCompetition : list) { - Participant participant = participantService.getById(userCompetition.getId()); - Student student = studentClient.queryStudentByPhone(participant.getPhone()); +// Participant participant = participantService.getById(userCompetition.getId()); +// Student student = studentClient.queryStudentByPhone(participant.getPhone()); PaymentDeductionClassHour paymentDeductionClassHour = new PaymentDeductionClassHour(); - paymentDeductionClassHour.setId(student.getId()); + paymentDeductionClassHour.setId(userCompetition.getParticipantId()); paymentDeductionClassHour.setClassHour(competition.getClassPrice()); paymentDeductionClassHour.setCode(code); coursePackagePaymentClient.rollbackPaymentDeductionClassHour(paymentDeductionClassHour); @@ -233,7 +308,7 @@ paymentCompetition.setAppUserId(null); this.updateById(paymentCompetition); - competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); +// competition.setApplicantsNumber(competition.getApplicantsNumber() - 1); competitionService.updateById(competition); } return ResultUtil.success(); @@ -241,12 +316,12 @@ @Override public List<BillingRequest> queryDatas(Integer appUserId, String monthStart, String monthEnd) { - return this.baseMapper.queryDatas(appUserId,monthStart,monthEnd); + return this.baseMapper.queryDatas(appUserId, monthStart, monthEnd); } @Override public List<BillingRequest> queryCancelDatas(Integer appUserId, String monthStart, String monthEnd) { - return this.baseMapper.queryCancelDatas(appUserId,monthStart,monthEnd); + return this.baseMapper.queryCancelDatas(appUserId, monthStart, monthEnd); } @Override @@ -258,7 +333,7 @@ ETime = query.getTime().split(" - ")[1] + " 23:59:59"; } - return paymentCompetitionMapper.listAll(query,STime,ETime,query.getAmount()); + return paymentCompetitionMapper.listAll(query, STime, ETime, query.getAmount()); } @Override -- Gitblit v1.7.1