nickchange
2023-11-17 a9564eae9f0169ca39329b2f14a8f13d13358a0a
cloud-server-course/src/main/java/com/dsh/course/service/impl/TCoursePackageServiceImpl.java
@@ -1,5 +1,6 @@
package com.dsh.course.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@@ -35,6 +36,7 @@
import com.dsh.course.model.*;
import com.dsh.course.service.*;
import com.dsh.course.util.*;
import io.vertx.core.json.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -42,6 +44,9 @@
import java.math.RoundingMode;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
@@ -122,8 +127,11 @@
        Map<String, String> geocode = gdMapGeocodingUtil.geocode(coursePackageList.getLon(), coursePackageList.getLat());
        String provinceCode = geocode.get("provinceCode");
        String cityCode = geocode.get("cityCode");
//        QueryWrapper<TCoursePackage> wrapper = new QueryWrapper<TCoursePackage>().in("status", Arrays.asList(1, 2))
//                .eq("auditStatus", 2).eq("state", 1).eq("provinceCode", provinceCode).eq("cityCode", cityCode);
        QueryWrapper<TCoursePackage> wrapper = new QueryWrapper<TCoursePackage>().in("status", Arrays.asList(1, 2))
                .eq("auditStatus", 2).eq("state", 1).eq("provinceCode", provinceCode).eq("cityCode", cityCode);
                .eq("auditStatus", 2).eq("state", 1);
        if(null != coursePackageList.getCoursePackageTypeId()){
            wrapper.eq("coursePackageTypeId", coursePackageList.getCoursePackageTypeId());
        }
@@ -141,7 +149,14 @@
                wrapper.or().in("storeId", collect);
            }
        }
        List<TCoursePackage> list = this.list(wrapper.last(" order by sort, insertTime desc"));
        List<TCoursePackage> list1 = this.list(wrapper.last(" order by sort desc, insertTime desc"));
        Date currentTime = new Date();
// Filter the list based on the conditions
        List<TCoursePackage> list = list1.stream()
                .filter(coursePackage -> coursePackage.getType() != 2 || currentTime.before(coursePackage.getEndTime()))
                .collect(Collectors.toList());
        List<CoursePackageListVo> listVos = new ArrayList<>();
        for (TCoursePackage coursePackage : list) {
            Store store = storeClient.queryStoreById(coursePackage.getStoreId());
@@ -188,9 +203,9 @@
                coursePackageListVo.setPlayPaiCoin(coursePackagePaymentConfig.getPlayPaiCoin());
            }
            //会员显示原价和会员价(最低)。非会员显示会员价和支付价(最低)
            if(appUser.getIsVip() == 0){//非会员
//            if(appUser.getIsVip() == 0){//非会员
                List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
                        .eq("type", 1).eq("auditStatus", 2));
                        .eq("type", 1).eq("auditStatus", 2).eq("status",1));
                Double vipPrice = coursePackagePaymentConfig.getCashPayment();
                for (TCoursePackageDiscount coursePackageDiscount : list2) {
                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember");
@@ -199,10 +214,11 @@
                    }
                }
                coursePackageListVo.setVipPrice(vipPrice);
                coursePackageListVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
                Double paymentPrice = coursePackagePaymentConfig.getCashPayment();
                List<TCoursePackageDiscount> list3 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
                        .eq("type", 3).eq("auditStatus", 2));
                    List<TCoursePackageDiscount> list3 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
                        .eq("type", 3).eq("auditStatus", 2).eq("status",1));
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                for (TCoursePackageDiscount coursePackageDiscount : list3) {
                    /**
@@ -277,19 +293,31 @@
                    }
                }
                coursePackageListVo.setPaymentPrice(paymentPrice);
            }else{
                List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
                        .eq("type", 1).eq("auditStatus", 2));
                Double vipPrice = coursePackagePaymentConfig.getCashPayment();
                for (TCoursePackageDiscount coursePackageDiscount : list2) {
                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember");
                    if(vipPrice.compareTo(num1) > 0){
                        vipPrice = num1;
                    }
                }
                coursePackageListVo.setPaymentPrice(vipPrice);
                coursePackageListVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
            }
            double vipPrice1 = coursePackageListVo.getVipPrice();
            double originalPrice1 = coursePackageListVo.getOriginalPrice();
            double paymentPrice1 = coursePackageListVo.getPaymentPrice();
            double minPrice = Math.min(vipPrice1, Math.min(originalPrice1, paymentPrice1));
            double maxPrice = Math.max(vipPrice1, Math.max(originalPrice1, paymentPrice1));
            coursePackageListVo.setPaymentPrice(minPrice);
            coursePackageListVo.setOriginalPrice(maxPrice);
            System.out.println("Minimum price: " + minPrice);
            System.out.println("Maximum price: " + maxPrice);
//            }
//            else{
//                List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
//                        .eq("type", 1).eq("auditStatus", 2).eq("status",1));
//                Double vipPrice = coursePackagePaymentConfig.getCashPayment();
//                for (TCoursePackageDiscount coursePackageDiscount : list2) {
//                    Double num1 = JSON.parseObject(coursePackageDiscount.getContent()).getDouble("discountMember");
//                    if(vipPrice.compareTo(num1) > 0){
//                        vipPrice = num1;
//                    }
//                }
//                coursePackageListVo.setPaymentPrice(vipPrice);
//                coursePackageListVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
//            }
            Map<String, Double> distance = GeodesyUtil.getDistance(coursePackageList.getLon() + "," + coursePackageList.getLat(), store.getLon() + "," + store.getLat());
            coursePackageListVo.setDistance(distance.get("WGS84") / 1000);
@@ -297,21 +325,41 @@
        }
        //销量排行
        if(ToolUtil.isNotEmpty(coursePackageList.getSalesRanking())){
        if(ToolUtil.isNotEmpty(coursePackageList.getSalesRanking())&&coursePackageList.getSalesRanking().equals("asc")){
            Collections.sort(listVos, new Comparator<CoursePackageListVo>() {
                public int compare(CoursePackageListVo s1, CoursePackageListVo s2) {
                    return Integer.compare(s1.getApplicantsNumber(), s2.getApplicantsNumber());
                }
            });
        }
        if(ToolUtil.isNotEmpty(coursePackageList.getSalesRanking())&&coursePackageList.getSalesRanking().equals("desc")){
            Collections.sort(listVos, new Comparator<CoursePackageListVo>() {
                public int compare(CoursePackageListVo s1, CoursePackageListVo s2) {
                    return Integer.compare(s2.getApplicantsNumber(), s1.getApplicantsNumber());
                }
            });
        }
        //距离排行
        if(ToolUtil.isNotEmpty(coursePackageList.getDistanceSort())){
        if(ToolUtil.isNotEmpty(coursePackageList.getDistanceSort())&&coursePackageList.getDistanceSort().equals("asc")){
            Collections.sort(listVos, new Comparator<CoursePackageListVo>() {
                public int compare(CoursePackageListVo s1, CoursePackageListVo s2) {
                    return Double.compare(s1.getDistance(), s2.getDistance());
                }
            });
        }
        if (ToolUtil.isNotEmpty(coursePackageList.getDistanceSort())&&coursePackageList.getDistanceSort().equals("desc")) {
            Collections.sort(listVos, new Comparator<CoursePackageListVo>() {
                public int compare(CoursePackageListVo s1, CoursePackageListVo s2) {
                    return Double.compare(s2.getDistance(), s1.getDistance());
                }
            });
        }
        return listVos;
    }
@@ -353,7 +401,18 @@
            coursePackageListVo.setId(coursePackage.getId());
            coursePackageListVo.setName(coursePackage.getName());
            coursePackageListVo.setStoreName(null != store ? store.getName() : "");
//            coursePackageListVo.setPayType();
            coursePackageListVo.setCoverDrawing(coursePackage.getCoverDrawing());
            Double cashPayment1 = coursePackagePaymentConfig.getCashPayment();
            Integer playPaiCoin = coursePackagePaymentConfig.getPlayPaiCoin();
            if(ToolUtil.isNotEmpty(cashPayment1) && cashPayment1>0 && ToolUtil.isNotEmpty(playPaiCoin) && playPaiCoin>0){
                coursePackageListVo.setPayType(3);
            }else if(ToolUtil.isNotEmpty(cashPayment1) && cashPayment1>0){
                coursePackageListVo.setPayType(1);
            }else if(ToolUtil.isNotEmpty(playPaiCoin) && playPaiCoin>0){
                coursePackageListVo.setPayType(2);
            }
            // 2.0修改
            String classStartTime = coursePackage.getClassStartTime();
@@ -558,6 +617,8 @@
            coursePackageInfo.setDetailDrawing(coursePackage.getDetailDrawing());
            coursePackageInfo.setIntroduceDrawing(coursePackage.getIntroduceDrawing());
            List<CoursePackagePaymentConfigVo> list = new ArrayList<>();
            List<CoursePackagePaymentConfig> list1 = coursePackagePaymentConfigService.list(new QueryWrapper<CoursePackagePaymentConfig>().eq("coursePackageId", id).orderByAsc("classHours"));
            list1.forEach(coursePackagePaymentConfig -> {
@@ -587,7 +648,6 @@
                        }
                    }
                    coursePackagePaymentConfigVo.setVipPrice(vipPrice);
                    Double paymentPrice = coursePackagePaymentConfig.getCashPayment();
                    List<TCoursePackageDiscount> list3 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
                            .eq("type", 3).eq("auditStatus", 2));
@@ -665,7 +725,14 @@
                        }
                    }
                    coursePackagePaymentConfigVo.setPaymentPrice(paymentPrice);
                }else{
                    if (coursePackagePaymentConfigVo.getPaymentPrice()<coursePackagePaymentConfigVo.getVipPrice()){
                        coursePackagePaymentConfigVo.setOriginalPrice(coursePackagePaymentConfig.getCashPayment());
                        coursePackagePaymentConfigVo.setVipPrice(null);
                    }
                }
                else{
                    List<TCoursePackageDiscount> list2 = coursePackageDiscountService.list(new QueryWrapper<TCoursePackageDiscount>().eq("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId())
                            .eq("type", 1).eq("auditStatus", 2));
                    Double vipPrice = coursePackagePaymentConfig.getCashPayment();
@@ -707,8 +774,16 @@
    public ResultUtil paymentCourse(Integer uid, PaymentCourseVo paymentCourseVo) throws Exception {
        AppUser appUser = appUserClient.queryAppUser(uid);
        CoursePackageInfo coursePackageInfo = queryCourseInfo(uid, paymentCourseVo.getId(), null, null);
        List<CoursePackagePaymentConfigVo> list = coursePackageInfo.getList();
        //校验是否已经报满
        Integer integer = coursePackagePaymentService.queryCountNumber(paymentCourseVo.getId());
        TCoursePackage course = coursePackageService.getById(paymentCourseVo.getId());
        if (course.getType()!=3) {
            if (integer + paymentCourseVo.getStudentIds().split(";").length > course.getMaxSubscribeNumber()) {
                return ResultUtil.error("报名失败,已达最大报名人数");
            }
        }
        List<CoursePackagePaymentConfigVo> list = coursePackageInfo.getList();
        String[] students = paymentCourseVo.getStudentIds().split(";");
        for (CoursePackagePaymentConfigVo coursePackagePaymentConfigVo : list) {
            if(paymentCourseVo.getCoursePackagePaymentConfigId().compareTo(coursePackagePaymentConfigVo.getId()) == 0){
@@ -725,7 +800,6 @@
                if((cashPayment!=null || cashPayment>0) &&(playPaiCoin1!=null || playPaiCoin1>0)){
                    payType=3;
                }
                if(cashPayment!=null && cashPayment>0 && playPaiCoin1 !=null && playPaiCoin1>0){
                }else {
                    if(payType == 1 && paymentCourseVo.getPayType() == 3){//现金支付
@@ -735,12 +809,11 @@
                        return ResultUtil.error("支付方式错误,请刷新后重试");
                    }
                }
                Double paymentPrice = coursePackagePaymentConfigVo.getPaymentPrice();//支付价
                paymentPrice = new BigDecimal(students.length).multiply(new BigDecimal(paymentPrice)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
                Double playPaiCoin = coursePackagePaymentConfigVo.getPlayPaiCoin().doubleValue();//支付币
                playPaiCoin = new BigDecimal(students.length).multiply(new BigDecimal(playPaiCoin)).setScale(2, RoundingMode.HALF_EVEN).doubleValue();
                if(paymentCourseVo.getPayType() != 3 && paymentPrice.compareTo(paymentCourseVo.getPrice()) != 0){
                if(paymentCourseVo.getPayType() != 3 && paymentPrice.compareTo(paymentCourseVo.getPrice()) != 0&&paymentCourseVo.getCouponId()!=null){
                    return ResultUtil.error("支付金额异常,请刷新后重试");
                }
                if(paymentCourseVo.getPayType() == 3 && playPaiCoin.compareTo(paymentCourseVo.getPrice()) != 0){
@@ -748,9 +821,7 @@
                }
            }
        }
        Double price = paymentCourseVo.getPrice();//支付金额
        //校验优惠券
        Long couponId = paymentCourseVo.getCouponId();
        if(null != couponId && paymentCourseVo.getPayType() != 3){
@@ -836,6 +907,15 @@
            coursePackagePayment.setState(1);
            coursePackagePayment.setInsertTime(new Date());
            coursePackagePaymentService.save(coursePackagePayment);
            CourseCounsum courseCounsum = new CourseCounsum();
            courseCounsum.setPaymentId(coursePackagePayment.getId());
            courseCounsum.setChangeType(1);
            courseCounsum.setNum(coursePackagePaymentConfig.getClassHours());
            courseCounsum.setInsertTime(new Date());
            courseCounsum.setReason("购买课包");
            courseCounsumService.save(courseCounsum);
        }
        Student student = studentClient.queryDefaultStudent(uid);
@@ -891,7 +971,7 @@
                                    // 2.0
                                    userCouponClient.sendUserCoupon(new SendCouponReq(uid,coursePackagePaymentConfig.getCouponIds()));
                                    addPackageStudent(paymentCourseVo.getId(),uid, finalSid,one.getId());
                                    addPackageStudent(paymentCourseVo.getId(),uid, finalSid,one.getId(),null);
                                    break;
                                }
                                if("USERPAYING".equals(s)){
@@ -923,26 +1003,106 @@
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);
        for (String s : split) {
            TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment();
            coursePackagePayment.setCode(code);
            coursePackagePayment.setAppUserId(uid);
            coursePackagePayment.setStudentId(Integer.valueOf(s));
            coursePackagePayment.setCoursePackageId(paymentCourseVo.getId());
            coursePackagePayment.setPayType(paymentCourseVo.getPayType());
            coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours());
            coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice());
            coursePackagePayment.setUserCouponId(paymentCourseVo.getCouponId());
            coursePackagePayment.setCashPayment(new BigDecimal(paymentPrice));
            coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours());
            coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours());
            coursePackagePayment.setAbsencesNumber(0);
            coursePackagePayment.setPayUserType(1);
            coursePackagePayment.setPayStatus(1);
            coursePackagePayment.setPayUserId(uid);
            coursePackagePayment.setStatus(1);
            coursePackagePayment.setState(1);
            coursePackagePayment.setInsertTime(new Date());
            coursePackagePaymentService.save(coursePackagePayment);
//            TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment();
//            coursePackagePayment.setCode(code);
//            coursePackagePayment.setAppUserId(uid);
//            coursePackagePayment.setStudentId(Integer.valueOf(s));
//            coursePackagePayment.setCoursePackageId(paymentCourseVo.getId());
//            coursePackagePayment.setPayType(paymentCourseVo.getPayType());
//            coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours());
//            coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice());
//            coursePackagePayment.setUserCouponId(paymentCourseVo.getCouponId());
//            coursePackagePayment.setCashPayment(new BigDecimal(paymentPrice));
//            coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours());
//            coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours());
//            coursePackagePayment.setAbsencesNumber(0);
//            coursePackagePayment.setPayUserType(1);
//            coursePackagePayment.setPayStatus(1);
//            coursePackagePayment.setPayUserId(uid);
//            coursePackagePayment.setStatus(1);
//            coursePackagePayment.setState(1);
//            coursePackagePayment.setInsertTime(new Date());
//            coursePackagePaymentService.save(coursePackagePayment);
//
//
//            CourseCounsum courseCounsum = new CourseCounsum();
//            courseCounsum.setPaymentId(coursePackagePayment.getId());
//            courseCounsum.setChangeType(1);
//            courseCounsum.setNum(coursePackagePaymentConfig.getClassHours());
//            courseCounsum.setInsertTime(new Date());
//            courseCounsum.setReason("购买课包");
//            courseCounsumService.save(courseCounsum);
            TCoursePackagePayment coursePackagePaymentServiceOne = coursePackagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", s).eq("coursePackageId", paymentCourseVo.getId()));
            if (coursePackagePaymentServiceOne==null) {
                TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment();
                coursePackagePayment.setCode(code);
                coursePackagePayment.setAppUserId(uid);
                coursePackagePayment.setStudentId(Integer.valueOf(s));
                coursePackagePayment.setCoursePackageId(paymentCourseVo.getId());
                coursePackagePayment.setPayType(paymentCourseVo.getPayType());
                coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours());
                coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice());
                coursePackagePayment.setPlayPaiCoin(paymentPrice.intValue());
                coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours());
                coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours());
                coursePackagePayment.setAbsencesNumber(0);
                coursePackagePayment.setPayUserType(1);
                coursePackagePayment.setPayStatus(1);
                coursePackagePayment.setPayUserId(uid);
                coursePackagePayment.setStatus(1);
                coursePackagePayment.setState(1);
                coursePackagePayment.setInsertTime(new Date());
                coursePackagePaymentService.save(coursePackagePayment);
                Integer sId = null;
                Student student = studentClient.queryDefaultStudent(uid);
                if (student != null) {
                    sId = student.getId();
                }
//                coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue());
//                addPackageStudent(paymentCourseVo.getId(), uid, Integer.valueOf(s), coursePackagePayment.getId());
                CourseCounsum courseCounsum = new CourseCounsum();
                courseCounsum.setPaymentId(coursePackagePayment.getId());
                courseCounsum.setChangeType(1);
                courseCounsum.setNum(coursePackagePaymentConfig.getClassHours());
                courseCounsum.setInsertTime(new Date());
                courseCounsum.setReason("购买课包");
                courseCounsumService.save(courseCounsum);
            }else {
//                coursePackagePaymentServiceOne.setClassHours(coursePackagePaymentServiceOne.getClassHours()+coursePackagePaymentConfig.getClassHours());
//                coursePackagePaymentServiceOne.setOriginalPrice(coursePackagePaymentServiceOne.getOriginalPrice()+paymentCourseVo.getPrice());
//                coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue());
//                coursePackagePaymentServiceOne.setTotalClassHours(coursePackagePaymentServiceOne.getTotalClassHours()+coursePackagePaymentConfig.getClassHours());
//                coursePackagePaymentServiceOne.setLaveClassHours(coursePackagePaymentServiceOne.getLaveClassHours()+coursePackagePaymentConfig.getClassHours());
//                coursePackagePaymentServiceOne.setCode(code);
//
//                coursePackagePaymentServiceOne.setAppUserId(null);
//                coursePackagePaymentServiceOne.setPayStatus(2);
//                coursePackagePaymentService.updateById(coursePackagePaymentServiceOne);
//
//                Integer sId = null;
//                Student student = studentClient.queryDefaultStudent(uid);
//                if (student != null) {
//                    sId = student.getId();
//                }
//                coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue());
//
//
//                CourseCounsum courseCounsum = new CourseCounsum();
//                courseCounsum.setPaymentId(coursePackagePaymentServiceOne.getId());
//                courseCounsum.setChangeType(1);
//                courseCounsum.setNum(coursePackagePaymentConfig.getClassHours());
//                courseCounsum.setInsertTime(new Date());
//                courseCounsum.setReason("续课");
//                courseCounsumService.save(courseCounsum);
            }
        }
        Student student = studentClient.queryDefaultStudent(uid);
@@ -993,17 +1153,57 @@
                                        coursePackagePayment.setOrderNumber(tradeNo);
                                        coursePackagePayment.setAppUserId(null);
                                    }
                                    for (String s1 : split) {
                                        TCoursePackagePayment coursePackagePaymentServiceOne = coursePackagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", s).eq("coursePackageId", paymentCourseVo.getId()));
                                        if (coursePackagePaymentServiceOne!=null) {
                                            coursePackagePaymentServiceOne.setClassHours(coursePackagePaymentServiceOne.getClassHours()+coursePackagePaymentConfig.getClassHours());
                                            coursePackagePaymentServiceOne.setOriginalPrice(coursePackagePaymentServiceOne.getOriginalPrice()+paymentCourseVo.getPrice());
                                            coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue());
                                            coursePackagePaymentServiceOne.setTotalClassHours(coursePackagePaymentServiceOne.getTotalClassHours()+coursePackagePaymentConfig.getClassHours());
                                            coursePackagePaymentServiceOne.setLaveClassHours(coursePackagePaymentServiceOne.getLaveClassHours()+coursePackagePaymentConfig.getClassHours());
                                            coursePackagePaymentServiceOne.setCode(code);
                                            coursePackagePaymentServiceOne.setAppUserId(null);
                                            coursePackagePaymentServiceOne.setPayStatus(2);
                                            coursePackagePaymentService.updateById(coursePackagePaymentServiceOne);
                                            Integer sId = null;
                                            Student student = studentClient.queryDefaultStudent(uid);
                                            if (student != null) {
                                                sId = student.getId();
                                            }
                                            coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue());
                                            CourseCounsum courseCounsum = new CourseCounsum();
                                            courseCounsum.setPaymentId(coursePackagePaymentServiceOne.getId());
                                            courseCounsum.setChangeType(1);
                                            courseCounsum.setNum(coursePackagePaymentConfig.getClassHours());
                                            courseCounsum.setInsertTime(new Date());
                                            courseCounsum.setReason("续课");
                                            courseCounsumService.save(courseCounsum);
                                        }
                                    }
                                    coursePackagePaymentService.updateBatchById(list);
                                System.out.println("===========到达支付");
                                    // 2.0
                                    String[] coupons = coursePackagePaymentConfig.getCouponIds().split(",");
                                    userCouponClient.sendUserCoupon(new SendCouponReq(uid,coursePackagePaymentConfig.getCouponIds()));
                                    for (TCoursePackagePayment coursePackagePayment : list) {
                                        addPackageStudent(paymentCourseVo.getId(),uid, finalSid,coursePackagePayment.getId(),paymentCourseVo.getPrice());
                                    }
                                    moneyOut(tradeNo,tradeNo);
@@ -1013,7 +1213,6 @@
                                    if(student!=null){
                                    }
                                    addPackageStudent(paymentCourseVo.getId(),uid, finalSid,one.getId());
                                    break;
                                }
                                if("WAIT_BUYER_PAY".equals(s)){
@@ -1117,6 +1316,10 @@
    @Autowired
    private  CourseCounsumService courseCounsumService;
    /**
     * 玩湃币支付课程
@@ -1131,32 +1334,100 @@
        String[] split = paymentCourseVo.getStudentIds().split(";");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String code = sdf.format(new Date()) + UUIDUtil.getNumberRandom(5);
        for (String s : split) {
            TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment();
            coursePackagePayment.setCode(code);
            coursePackagePayment.setAppUserId(appUser.getId());
            coursePackagePayment.setStudentId(Integer.valueOf(s));
            coursePackagePayment.setCoursePackageId(paymentCourseVo.getId());
            coursePackagePayment.setPayType(paymentCourseVo.getPayType());
            coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours());
            coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice());
            coursePackagePayment.setPlayPaiCoin(paymentPrice.intValue());
            coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours());
            coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours());
            coursePackagePayment.setAbsencesNumber(0);
            coursePackagePayment.setPayUserType(1);
            coursePackagePayment.setPayStatus(2);
            coursePackagePayment.setPayUserId(appUser.getId());
            coursePackagePayment.setStatus(1);
            coursePackagePayment.setState(1);
            coursePackagePayment.setInsertTime(new Date());
            coursePackagePaymentService.save(coursePackagePayment);
            Integer sId=null;
            Student student = studentClient.queryDefaultStudent(appUser.getId());
            if(student!=null){
                sId=student.getId();
        //赠送课时
        int weekday = DateUtil.dayOfWeek(new Date()) - 1;
        TCoursePackageDiscount discount = coursePackageDiscountService.getOne(new QueryWrapper<TCoursePackageDiscount>().eq("type",4).eq("coursePackageId", paymentCourseVo.getId()).last("limit 1"));
        Integer hour = 0;
        if (discount!=null) {
            JSONArray objects = JSONObject.parseArray(discount.getContent());
            JSONObject parse = JSONObject.parseObject(JSONObject.toJSONString(objects.get(0)));
             hour = parse.getInteger("hour");
            if (hour == null) {
                hour = 0;
            }
            addPackageStudent(paymentCourseVo.getId(),appUser.getId(),sId,coursePackagePayment.getId());
        }
        for (String s : split) {
            TCoursePackagePayment coursePackagePaymentServiceOne = coursePackagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", s).eq("coursePackageId", paymentCourseVo.getId()));
            if (coursePackagePaymentServiceOne==null) {
                TCoursePackagePayment coursePackagePayment = new TCoursePackagePayment();
                coursePackagePayment.setCode(code);
                coursePackagePayment.setAppUserId(appUser.getId());
                coursePackagePayment.setStudentId(Integer.valueOf(s));
                coursePackagePayment.setCoursePackageId(paymentCourseVo.getId());
                coursePackagePayment.setPayType(paymentCourseVo.getPayType());
                coursePackagePayment.setClassHours(coursePackagePaymentConfig.getClassHours()+hour);
                coursePackagePayment.setOriginalPrice(paymentCourseVo.getPrice());
                coursePackagePayment.setPlayPaiCoin(paymentPrice.intValue());
                coursePackagePayment.setTotalClassHours(coursePackagePaymentConfig.getClassHours()+hour);
                coursePackagePayment.setLaveClassHours(coursePackagePaymentConfig.getClassHours()+hour);
                coursePackagePayment.setAbsencesNumber(0);
                coursePackagePayment.setPayUserType(1);
                coursePackagePayment.setPayStatus(2);
                coursePackagePayment.setPayUserId(appUser.getId());
                coursePackagePayment.setStatus(1);
                coursePackagePayment.setState(1);
                coursePackagePayment.setInsertTime(new Date());
                coursePackagePaymentService.save(coursePackagePayment);
                Integer sId = null;
                Student student = studentClient.queryDefaultStudent(appUser.getId());
                if (student != null) {
                    sId = student.getId();
                }
                addPackageStudent(paymentCourseVo.getId(), appUser.getId(), Integer.valueOf(s), coursePackagePayment.getId(),null);
                //课时记录
                CourseCounsum courseCounsum = new CourseCounsum();
                courseCounsum.setPaymentId(coursePackagePayment.getId());
                courseCounsum.setChangeType(1);
                courseCounsum.setNum(coursePackagePaymentConfig.getClassHours());
                courseCounsum.setInsertTime(new Date());
                courseCounsum.setReason("购买课包");
                courseCounsumService.save(courseCounsum);
            }else{
                coursePackagePaymentServiceOne.setClassHours(coursePackagePaymentServiceOne.getClassHours()+coursePackagePaymentConfig.getClassHours()+hour);
                if (coursePackagePaymentServiceOne.getOriginalPrice()!=null) {
                    coursePackagePaymentServiceOne.setOriginalPrice(coursePackagePaymentServiceOne.getOriginalPrice() + paymentCourseVo.getPrice());
                }else {
                    coursePackagePaymentServiceOne.setOriginalPrice(paymentCourseVo.getPrice());
                }
                if (coursePackagePaymentServiceOne.getPlayPaiCoin()==null){
                    coursePackagePaymentServiceOne.setPlayPaiCoin(paymentPrice.intValue());
                }else {
                coursePackagePaymentServiceOne.setPlayPaiCoin(coursePackagePaymentServiceOne.getPlayPaiCoin()+paymentPrice.intValue());}
                coursePackagePaymentServiceOne.setTotalClassHours(coursePackagePaymentServiceOne.getTotalClassHours()+coursePackagePaymentConfig.getClassHours()+hour);
                coursePackagePaymentServiceOne.setLaveClassHours(coursePackagePaymentServiceOne.getLaveClassHours()+coursePackagePaymentConfig.getClassHours()+hour);
                coursePackagePaymentServiceOne.setAppUserId(null);
                coursePackagePaymentService.updateById(coursePackagePaymentServiceOne);
//                coursePackagePaymentService.save(coursePackagePayment);
                Integer sId = null;
                Student student = studentClient.queryDefaultStudent(appUser.getId());
                if (student != null) {
                    sId = student.getId();
                }
                addPackageStudent(paymentCourseVo.getId(), appUser.getId(), Integer.valueOf(s), coursePackagePaymentServiceOne.getId(),null);
                CourseCounsum courseCounsum = new CourseCounsum();
                courseCounsum.setPaymentId(coursePackagePaymentServiceOne.getId());
                courseCounsum.setChangeType(1);
                courseCounsum.setNum(coursePackagePaymentConfig.getClassHours());
                courseCounsum.setInsertTime(new Date());
                courseCounsum.setReason("续课");
                courseCounsumService.save(courseCounsum);
            }
        }
        Integer playPaiCoins = appUser.getPlayPaiCoins();
@@ -1173,70 +1444,90 @@
    }
    private void addPackageStudent(Integer courseId, Integer userId, Integer sId,Long paymentId) throws ParseException {
    private void addPackageStudent(Integer courseId, Integer userId, Integer sId,Long paymentId,Double price) throws ParseException {
        // 课包
        TCoursePackage tCoursePackage = this.baseMapper.selectById(courseId);
        String classWeeks = tCoursePackage.getClassWeeks();
        List<Integer> week = week(classWeeks);
        if (tCoursePackage.getType()==1) {
            String classWeeks = tCoursePackage.getClassWeeks();
        String[] split = tCoursePackage.getClassStartTime().split(",");
        String[] split1 = tCoursePackage.getClassEndTime().split(",");
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        // 本周周几
        int i = DateUtil.dayOfWeek(new Date())-1;
        for (Integer integer : week) {
            if(integer<i){
                // 找下一周的时间
                Calendar instance = Calendar.getInstance();
                instance.add(Calendar.DATE,7-(i-integer));
                Date time = instance.getTime();
            List<Integer> week = week(classWeeks);
                for (int i1 = 0; i1 < split.length; i1++) {
            String[] split = tCoursePackage.getClassStartTime().split(",");
            String[] split1 = tCoursePackage.getClassEndTime().split(",");
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                    CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling();
                    coursePackageScheduling.setCoursePackageId(tCoursePackage.getId());
                                            Date parse = format1.parse(format.format(time) + " " + split[i1]);
                        Date parse1 = format1.parse(format.format(time) + " " + split1[i1]);
            //查出当前用户当前学员当前课包最后一天的排课数据
            List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", sId).eq("coursePackageId", courseId));
            List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList());
            //拿到最后一天的排课记录
            if (collect.size() > 0){
                coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id", collect));
                coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", sId).eq("coursePackageId", courseId));
                if (price!=null) {
                    CourseCounsum courseCounsum = new CourseCounsum();
                    courseCounsum.setPaymentId(paymentId);
                    courseCounsum.setChangeType(3);
                    courseCounsum.setInsertTime(new Date());
                    courseCounsum.setReason("续课;" + price);
                    courseCounsum.setAppUserId(userId);
                    courseCounsumService.save(courseCounsum);
                }
            }else {
                if (price!=null) {
                    CourseCounsum courseCounsum = new CourseCounsum();
                    courseCounsum.setPaymentId(paymentId);
                    courseCounsum.setChangeType(3);
                    courseCounsum.setInsertTime(new Date());
                    courseCounsum.setReason("报名课程;" + price);
                    courseCounsum.setAppUserId(userId);
                    courseCounsumService.save(courseCounsum);
                }
            }
            Date today = new Date();
            TCoursePackagePayment pay = coursePackagePaymentService.getById(paymentId);
            Integer laveClassHours = pay.getLaveClassHours();
            Integer codeTime = tCoursePackage.getCodeTime();
            Integer can = 0;
            int count = 0;
            // 本周周几
            Date[] dates = generateDateArray(14, today);
            if (tCoursePackage.getType() == 1) {
                can = laveClassHours / codeTime;
            }
            if (tCoursePackage.getType() == 2) {
                Date startDate = tCoursePackage.getStartTime();
                Date endDate = tCoursePackage.getEndTime();
                dates = generateDateArray1(startDate, endDate);
                can = 999;
            }
            for (Date date : dates) {
                if (count == can) {
                    break;
                }
                int wei = DateUtil.dayOfWeek(date);
                if (week.contains(wei)) {
                    for (int i1 = 0; i1 < split.length; i1++) {
                        if (count == can) {
                            break;
                        }
                        CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling();
                        coursePackageScheduling.setCoursePackageId(tCoursePackage.getId());
                        Date parse = format1.parse(format.format(date) + " " + split[i1]);
                        Date parse1 = format1.parse(format.format(date) + " " + split1[i1]);
                        coursePackageScheduling.setClassDate(parse);
                        coursePackageScheduling.setEndDate(parse1);
                        coursePackageScheduling.setStatus(1);
                        coursePackageSchedulingService.save(coursePackageScheduling);
                    CoursePackageStudent student1 = new CoursePackageStudent();
                    student1.setAppUserId(userId);
                    student1.setStudentId(sId);
                    student1.setCoursePackageId(tCoursePackage.getId());
                    student1.setCoursePackagePaymentId(paymentId);
                    student1.setCoursePackageSchedulingId(coursePackageScheduling.getId());
                    student1.setSignInOrNot(1);
                    student1.setReservationStatus(1);
                    student1.setInsertTime(new Date());
                    cpsMapper.insert(student1);
                }
            }else if(integer>i) {
                Calendar instance = Calendar.getInstance();
                instance.add(Calendar.DATE,integer-i);
                Date time1 = instance.getTime();
                List<Date> list = new ArrayList<>();
                list.add(time1);
                instance.add(Calendar.DATE,7);
                Date time2 = instance.getTime();
                list.add(time2);
                for (Date time : list) {
                    for (int i1 = 0; i1 < split.length; i1++) {
                        CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling();
                        coursePackageScheduling.setCoursePackageId(tCoursePackage.getId());
                                                    Date parse = format1.parse(format.format(time) + " " + split[i1]);
                            Date parse1 = format1.parse(format.format(time) + " " + split1[i1]);
                            coursePackageScheduling.setClassDate(parse);
                            coursePackageScheduling.setEndDate(parse1);
                            coursePackageScheduling.setStatus(1);
                            coursePackageSchedulingService.save(coursePackageScheduling);
                        CoursePackageStudent student1 = new CoursePackageStudent();
                        student1.setAppUserId(userId);
                        student1.setStudentId(sId);
@@ -1247,42 +1538,102 @@
                        student1.setReservationStatus(1);
                        student1.setInsertTime(new Date());
                        cpsMapper.insert(student1);
                        count++;
                    }
                }
            }
            }else {
                Calendar instance = Calendar.getInstance();
                instance.add(Calendar.DATE,7);
                Date time = instance.getTime();
        }else if (tCoursePackage.getType()==2){
            String classWeeks = tCoursePackage.getClassWeeks();
            List<Integer> week = week(classWeeks);
                for (int i1 = 0; i1 < split.length; i1++) {
                    CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling();
                    coursePackageScheduling.setCoursePackageId(tCoursePackage.getId());
                                            Date parse = format1.parse(format.format(time) + " " + split[i1]);
                        Date parse1 = format1.parse(format.format(time) + " " + split1[i1]);
            Date today = new Date();
            Date startTime = tCoursePackage.getStartTime();
            Date endTime = tCoursePackage.getEndTime();
            LocalDate startDate = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
            LocalDate endDate = endTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
            Period period = Period.between(startDate, endDate);
            int days = period.getDays() + 1;
            Integer can =999;
            int count = 0;
            String[] split = tCoursePackage.getClassStartTime().split(",");
            String[] split1 = tCoursePackage.getClassEndTime().split(",");
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(startTime);
            calendar.add(Calendar.DAY_OF_MONTH, -1);
            TCoursePackagePayment pay = coursePackagePaymentService.getById(paymentId);
            Date[] dates = generateDateArray(days,calendar.getTime());
            for (Date date : dates) {
                if (count==can){
                    break;
                }
                int wei =  cn.hutool.core.date.DateUtil.dayOfWeek(date)-1;
                if (wei == 0){
                    wei =7;
                }
                if (week.contains(wei)){
                    for (int i1 = 0; i1 < split.length; i1++) {
                        if (count==can){
                            break;
                        }
                        CoursePackageScheduling coursePackageScheduling = new CoursePackageScheduling();
                        coursePackageScheduling.setCoursePackageId(tCoursePackage.getId());
                        Date parse = format1.parse(format.format(date) + " " + split[i1]);
                        Date parse1 = format1.parse(format.format(date) + " " + split1[i1]);
                        coursePackageScheduling.setClassDate(parse);
                        coursePackageScheduling.setEndDate(parse1);
                        coursePackageScheduling.setStatus(1);
                        coursePackageSchedulingService.save(coursePackageScheduling);
                    CoursePackageStudent student1 = new CoursePackageStudent();
                    student1.setAppUserId(userId);
                    student1.setStudentId(sId);
                    student1.setCoursePackageId(tCoursePackage.getId());
                    student1.setCoursePackagePaymentId(paymentId);
                    student1.setCoursePackageSchedulingId(coursePackageScheduling.getId());
                    student1.setSignInOrNot(1);
                    student1.setReservationStatus(1);
                    student1.setInsertTime(new Date());
                    cpsMapper.insert(student1);
                        CoursePackageStudent student1 = new CoursePackageStudent();
                        student1.setAppUserId(userId);
                        student1.setStudentId(sId);
                        student1.setCoursePackageId(tCoursePackage.getId());
                        student1.setCoursePackagePaymentId(pay.getId());
                        student1.setCoursePackageSchedulingId(coursePackageScheduling.getId());
                        student1.setSignInOrNot(1);
                        student1.setReservationStatus(1);
                        student1.setInsertTime(new Date());
                        cpsMapper.insert(student1);
                        count++;
                    }
                }
            }
        }else if (tCoursePackage.getType()==3){
            if (price!=null) {
                CourseCounsum courseCounsum = new CourseCounsum();
                courseCounsum.setPaymentId(paymentId);
                courseCounsum.setChangeType(3);
                courseCounsum.setInsertTime(new Date());
                courseCounsum.setReason("购买体验课;" + price);
                courseCounsum.setAppUserId(userId);
                courseCounsumService.save(courseCounsum);
            }
            //生成当天的排课记录
            //生成学员的上课表
        }
        // 2.0
        TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord();
        tCourseInfoRecord.setUserId(userId);
        tCourseInfoRecord.setCourseId(courseId);
        tCourseInfoRecord.setName("报名假期班");
        tCourseInfoRecord.setName("报名运动营");
        tCourseInfoRecord.setNum(tCoursePackage.getNeedNum());
        tCourseInfoRecord.setTime(new Date());
        tCourseInfoRecord.setType(2);
@@ -1290,6 +1641,28 @@
    }
    public static Date[] generateDateArray1(Date startDate, Date endDate) {
        List<Date> dateList = new ArrayList<>();
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(startDate);
        while (!calendar.getTime().after(endDate)) {
            Date currentDate = calendar.getTime();
            dateList.add(currentDate);
            calendar.add(Calendar.DAY_OF_MONTH, 1);
        }
        return dateList.toArray(new Date[0]);
    }
    public static Date createDate1(int year, int month, int day) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(year, month - 1, day);
        return calendar.getTime();
    }
    private List<Integer> week(String week){
        String[] split = week.split(";");
        ArrayList<Integer> integers = new ArrayList<>();
@@ -1322,6 +1695,20 @@
    }
    public static Date[] generateDateArray(int numDays,Date date) {
//        LocalDate tomorrow = LocalDate.now().plusDays(1);
        LocalDate tomorrow = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(1);
        Date[] dates = new Date[numDays];
        for (int i = 0; i < numDays; i++) {
            LocalDate currentDate = tomorrow.plusDays(i);
            dates[i] = Date.from(currentDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
        }
        return dates;
    }
    /**
     * 获取课包管理列表数据
     * @param queryCoursePackageLists
@@ -1360,7 +1747,7 @@
    @Override
    public Integer addCoursePackage(TCoursePackage coursePackage) {
        try {
            coursePackage.setAuditStatus(2);
            this.baseMapper.insert(coursePackage);
            if (coursePackage.getClassStartTime()!=null&&coursePackage.getClassStartTime()!="") {
@@ -1556,28 +1943,33 @@
    }
    @Override
    public String getHours(Integer coursePackageId) {
    public List<Integer> getHours(Integer coursePackageId) {
        return this.baseMapper.getHours(coursePackageId);
    }
    @Override
    public ResultUtil paymentCourseCouponList(Integer uid, Integer coursePackagePaymentConfigId) {
        CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(coursePackagePaymentConfigId);
        if(ToolUtil.isEmpty(coursePackagePaymentConfig.getCouponIds())){
            coursePackagePaymentConfig.setCouponIds("-1");
        }
        List<Coupon> coupons = couponClient.getCoupons(coursePackagePaymentConfig.getCouponIds());
//        CoursePackagePaymentConfig coursePackagePaymentConfig = coursePackagePaymentConfigService.getById(coursePackagePaymentConfigId);
//        if(ToolUtil.isEmpty(coursePackagePaymentConfig.getCouponIds())){
//            coursePackagePaymentConfig.setCouponIds("-1");
//        }
//        List<Coupon> coupons = couponClient.getCoupons(coursePackagePaymentConfig.getCouponIds());
        for (Coupon coupon : coupons) {
            Date date1 = coupon.getStartTime(); // 2023-10-01 00:00:00
            Date date2 = coupon.getEndTime(); // 2023-10-12 00:00:00
        List<Coupon> coupons = couponClient.queryCouponByUid(uid);
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
            String dateString1 = sdf.format(date1);
            String dateString2 = sdf.format(date2);
            String result = dateString1 + "-" + dateString2;
            coupon.setTimePeriod(result);
        if (CollectionUtil.isNotEmpty(coupons)) {
            for (Coupon coupon : coupons){
                Date date1 = coupon.getStartTime(); // 2023-10-01 00:00:00
                Date date2 = coupon.getEndTime(); // 2023-10-12 00:00:00
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
                String dateString1 = sdf.format(date1);
                String dateString2 = sdf.format(date2);
                String result = dateString1 + "-" + dateString2;
                coupon.setTimePeriod(result);
            }
        }
        return ResultUtil.success(coupons);
    }