44323
2024-03-15 57fd465068d99fffd31c03806de3d5691e8048ee
cloud-server-competition/src/main/java/com/dsh/competition/service/impl/CompetitionServiceImpl.java
@@ -232,7 +232,8 @@
        JSONArray jsonArray = JSON.parseArray(paymentCompetitionVo.getIds());
        Competition competition = this.getById(paymentCompetitionVo.getId());
        List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>().eq("competitionId", paymentCompetitionVo.getId()).ne("payStatus", 3));
        List<PaymentCompetition> list = paymentCompetitionService.list(new QueryWrapper<PaymentCompetition>()
                .eq("competitionId", paymentCompetitionVo.getId()).ne("payStatus", 3));
        List<Long> pays = new ArrayList<>();
        for (PaymentCompetition paymentCompetition : list) {
            pays.add(paymentCompetition.getId());
@@ -259,18 +260,9 @@
        }
        if (paymentCompetitionVo.getPayType() == 4) {//课程
            money = new BigDecimal(competition.getClassPrice()).multiply(new BigDecimal(jsonArray.size())).setScale(2, RoundingMode.HALF_EVEN);
            for (int i = 0; i < jsonArray.size(); i++) {
//                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 new ResultUtil(3, "剩余课时不足,无法完成支付。");
                }
            Integer integer = coursePackagePaymentClient.queryResidueClassHourById(paymentCompetitionVo.getCoursePaymentId());
            if (new BigDecimal(integer).compareTo(money) < 0) {
                return new ResultUtil(3, "剩余课时不足,无法完成支付。");
            }
        }
@@ -327,7 +319,6 @@
            paymentCompetition.setPayOrderNo("");
            paymentCompetitionService.updateById(paymentCompetition);
//            competition.setApplicantsNumber(competition.getApplicantsNumber() + 1);
            this.updateById(competition);
        }
        if (paymentCompetitionVo.getPayType() == 4) {//课程
@@ -338,6 +329,7 @@
                if(isStudent == 0){
                    continue;
                }
                //扣减课时
                PaymentDeductionClassHour paymentDeductionClassHour = new PaymentDeductionClassHour();
                paymentDeductionClassHour.setId(id);
                paymentDeductionClassHour.setClassHour(competition.getClassPrice());
@@ -346,6 +338,7 @@
                paymentDeductionClassHour.setUid(uid);
                coursePackagePaymentClient.paymentDeductionClassHour(paymentDeductionClassHour);
            }
            paymentCompetition = paymentCompetitionService.getById(paymentCompetition.getId());
            paymentCompetition.setAppUserId(null);
            paymentCompetition.setPayStatus(2);
@@ -381,7 +374,8 @@
                            int min = 5000;
                            wait += (min * num);
                            Thread.sleep(wait);
                            PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>().eq("code", code).eq("payType", 1));
                            PaymentCompetition paymentCompetition = paymentCompetitionService.getOne(new QueryWrapper<PaymentCompetition>()
                                    .eq("code", code).eq("payType", 1));
                            if (paymentCompetition.getPayStatus() == 2) {
                                break;
                            }