刘帅
2026-09-21 b48aadeea1f9ac8764a3a6f295bd53effca8faec
cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java
@@ -26,9 +26,11 @@
import com.dsh.course.model.vo.response.*;
import com.dsh.course.service.*;
import com.dsh.course.util.*;
import com.dsh.course.util.wx.WxV3PayConfig;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.obs.services.internal.ServiceException;
import com.wechat.pay.contrib.apache.httpclient.util.AesUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -44,8 +46,10 @@
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
@@ -133,10 +137,24 @@
    private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm");
    @Autowired
    private ICoursePackageOrderStudentService coursePackageOrderStudentService;
    @Autowired
    private ALiSendSms aLiSendSms;
    @Resource
    private AppUserClient appuClient;
    @Autowired
    private CourseCounsumService courseCounsumService;
    @Autowired
    private TCoursePackagePaymentService coursePackagePaymentService;
    /**
@@ -183,9 +201,12 @@
        coursePackageOrder.setOriginalPrice(packagePayment.getOriginalPrice());
        coursePackageOrder.setCashPayment(packagePayment.getCashPayment());
        coursePackageOrder.setPlayPaiCoin(packagePayment.getPlayPaiCoin());
        coursePackageOrder.setCode(packagePayment.getCode());
        coursePackageOrder.setPayStatus(1);
        coursePackageOrder.setStatus(1);
        coursePackageOrder.setState(1);
        coursePackageOrder.setInsertTime(new Date());
        coursePackageOrder.setOrderType(1);
        coursePackageOrder.setSalesName(packagePayment.getSalesName());
        coursePackageOrderService.save(coursePackageOrder);
        // 生成排课数据
@@ -242,11 +263,11 @@
                calendar.setTime(new Date());
                calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + validDays);
                coursePackageOrderStudent.setUseTime(calendar.getTime());
                coursePackageOrderStudent.setInsertTime(new Date());
                coursePackageOrderStudentService.saveOrUpdate(coursePackageOrderStudent);
                Integer studentId = Integer.valueOf(byId1.getStudentIds());
                //开始排课
                addPackageStudent1(byId, byId1.getAppUserId(), studentId, coursePackageOrderStudent);
                addPackageStudent1(byId, byId1.getAppUserId(), studentId, byId1, coursePackageOrderStudent);
            } else {
                Date useTime = coursePackageOrderStudent.getUseTime();
                coursePackageOrderStudent.setTotalClassHours(coursePackageOrderStudent.getTotalClassHours() + byId1.getClassHours());
@@ -275,16 +296,17 @@
                calendar9.add(Calendar.DAY_OF_MONTH, byId.getValidDays());
                Date time = calendar9.getTime();
                coursePackageOrderStudent.setUseTime(time);
                coursePackageOrderStudent.setInsertTime(new Date());
                coursePackageOrderStudentService.saveOrUpdate(coursePackageOrderStudent);
                Integer studentId = Integer.valueOf(byId1.getStudentIds());
                //中间断课,没有连续续费的情况需要重新排课
                if (useTime.compareTo(new Date()) < 0) {
                    addPackageStudent1(byId, byId1.getAppUserId(), studentId, coursePackageOrderStudent);
                    addPackageStudent1(byId, byId1.getAppUserId(), studentId, byId1, coursePackageOrderStudent);
                }
            }
        }
            if(byId.getType() == 2){
                addPackageStudent1(byId, byId1.getAppUserId(), Integer.valueOf(byId1.getStudentIds()), null);
                addPackageStudent1(byId, byId1.getAppUserId(), Integer.valueOf(byId1.getStudentIds()), byId1, null);
            }
        return packagePaymentService.changeState(dto);
    }
@@ -333,13 +355,19 @@
            }
            Store store = storeClient.queryStoreById(re.getStoreId());
            TAppUser appUser = appUserClient.queryAppUser1(re.getAppUserId());
            String studentId = re.getStudentId();
            String[] split = studentId.split(",");
            StringBuilder stringBuilder = new StringBuilder("");
            for (String s : split) {
                Student student = studentClient.queryStudentById(Integer.valueOf(s));
                stringBuilder.append(student.getName()+",");
            String studentId = re.getStudentId();
            if (studentId != null && !studentId.trim().isEmpty()) {
                String[] split = studentId.split(";");
                for (String s : split) {
                    if (s == null || s.trim().isEmpty()) {
                        continue;
                    }
                    Student student = studentClient.queryStudentById(Integer.valueOf(s));
                    if (student != null) {
                        stringBuilder.append(student.getName()).append(",");
                    }
                }
            }
            String string = stringBuilder.toString();
            if (string.length() > 0) {
@@ -469,10 +497,23 @@
                }
            }
            TAppUser appUser = appUserClient.queryAppUser1(re.getAppUserId());
            Student student = studentClient.queryStudentById(re.getStudentId());
            re.setPayStudent(student.getName());
            re.setPayUser(appUser.getName());
            re.setPhone(appUser.getPhone());
            // 统计接口只关心订单金额;历史订单可能没有关联学员或用户,不能因此整批查询失败。
            re.setPayStudent("无");
            if (re.getStudentIds() != null && !re.getStudentIds().trim().isEmpty()) {
                try {
                    String[] split = re.getStudentIds().split(",");
                    Student student = studentClient.queryStudentById(Integer.valueOf(split[0]));
                    if (student != null && student.getName() != null) {
                        re.setPayStudent(student.getName());
                    }
                } catch (NumberFormatException ignored) {
                    // 历史脏数据按“无学员”返回,避免影响其他有效订单。
                }
            }
            if (appUser != null) {
                re.setPayUser(appUser.getName());
                re.setPhone(appUser.getPhone());
            }
        }
        return res;
    }
@@ -584,7 +625,6 @@
                            storeVo.setLon(store.getLon());
                            storeVo.setCoursePrice(ToolUtil.isEmpty(paymentConfig.getCashPayment()) ? (double) paymentConfig.getPlayPaiCoin() : paymentConfig.getCashPayment());
                            storeVo.setStatus(1);
                            // 2.0
                            storeVo.setAllNum(tCoursePackagePayment.getTotalClassHours());
                            storeVo.setLastNum(tCoursePackagePayment.getLaveClassHours());
                            storeVo.setUseNum(tCoursePackagePayment.getTotalClassHours() - tCoursePackagePayment.getLaveClassHours());
@@ -672,7 +712,7 @@
                PurchaseRecordVo recordVo = new PurchaseRecordVo();
                recordVo.setPurchaseAmount("+" + cspackage.getClassHours());
                recordVo.setPurchaseTime(format.format(cspackage.getInsertTime()));
                recordVo.setPurchaseType("购买课包");
                recordVo.setPurchaseType("报名运动营");
                purchaseRecordVos.add(recordVo);
            });
        }
@@ -680,11 +720,7 @@
    }
    @Autowired
    private CourseCounsumService courseCounsumService;
    @Autowired
    private TCoursePackagePaymentService coursePackagePaymentService;
    @PostMapping("/base/coursePack/getRecord")
    public List<PurchaseRecordVo> getRecord(@RequestBody RecordTimeRequest recordTimeRequest) {
@@ -704,7 +740,8 @@
        );
        List<Long> collect = list1.stream().map(CoursePackageOrderStudent::getId).collect(Collectors.toList());
        QueryWrapper<CourseCounsum> in = new QueryWrapper<CourseCounsum>().in("paymentId", collect).in("changeType", changes);
        QueryWrapper<CourseCounsum> in = new QueryWrapper<CourseCounsum>()
                .in("paymentId", collect).in("changeType", changes);
        if (recordTimeRequest.getType() != null) {
            if (recordTimeRequest.getType() == 2) {
@@ -758,7 +795,6 @@
        return lisco;
    }
    @PostMapping("/base/coursePack/continuingCourse")
    public StudentOfCourseVo getStudentCourse(@RequestBody GetStudentCourse getStudentCourse) {
        StudentOfCourseVo courseVo = new StudentOfCourseVo();
@@ -767,7 +803,6 @@
                .eq("coursePackageId", getStudentCourse.getCourseId())
                .eq("studentId", getStudentCourse.getStuId()));
        if (tCoursePackagePayments.size() > 0) {
            List<CourseHoursType> typeList = new ArrayList<>();
            tCoursePackagePayments.forEach(cou -> {
                CourseHoursType hoursType = new CourseHoursType();
@@ -778,7 +813,6 @@
            TCoursePackagePayment tCoursePackagePayment = tCoursePackagePayments.get(0);
            courseVo.setCoursePackageId(tCoursePackagePayment.getCoursePackageId());
            courseVo.setTypeList(typeList);
            TCoursePackage coursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId());
            courseVo.setPackageImg(coursePackage.getCoverDrawing());
            courseVo.setCourseName(coursePackage.getName());
@@ -1030,7 +1064,7 @@
        }
    }
    // 2.0
    @ResponseBody
    @PostMapping("/api/startCource/payCourse")
    @ApiOperation(value = "课后练习-确认购课", tags = {"APP-开始上课"})
@@ -1161,15 +1195,16 @@
    })
    public ResultUtil continuationOperation(ClasspaymentRequest request) {
        try {
            Integer userIdFormRedis = tokenUtil.getUserIdFormRedis();
            if (null == userIdFormRedis) {
            Integer userId = tokenUtil.getUserIdFormRedis();
            System.err.println("续课参数"+request);
            if (null == userId) {
                return ResultUtil.tokenErr();
            }
            Integer couponId = request.getConponId();
            Long couponId = request.getConponId();
            if (couponId == null || couponId == 0) {
                request.setConponId(null);
            }
            return packagePaymentService.ContinuationOrpaymentCourse(userIdFormRedis, request);
            return packagePaymentService.ContinuationOrpaymentCourse(userId, request);
        } catch (Exception e) {
            return ResultUtil.runErr();
        }
@@ -1182,7 +1217,6 @@
     */
    @PostMapping("/base/coursePackage/alipayRegisteredCoursesCallback")
    public void alipayCallback(HttpServletRequest request, HttpServletResponse response) {
        System.err.println("========支付宝支付回调========");
        try {
            Map<String, String> map = payMoneyUtil.alipayCallback(request);
            if (null != map) {
@@ -1202,6 +1236,51 @@
    }
    /**
     * 课包续课微信支付回调接口
     */
    @PostMapping("/base/coursePackage/wechatRegisteredCoursesCallback1")
    public void weChatCallback1(HttpServletRequest request, HttpServletResponse response) {
        try {
            System.err.println("微信回调");
            System.err.println("请求" + request);
            BufferedReader reader = request.getReader();
            String string1 = reader.toString();
            System.err.println("请求reader" + string1);
            StringBuilder requestBody = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                requestBody.append(line);
            }
            System.err.println("全部请求体" + requestBody);
            com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject.parseObject(requestBody.toString());
            com.alibaba.fastjson.JSONObject resource = jsonObject.getJSONObject("resource");
            AesUtil aesUtil = new AesUtil(WxV3PayConfig.apiV3Key.getBytes(StandardCharsets.UTF_8));
            String decryptedData = aesUtil.decryptToString(resource.getString("associated_data").getBytes(StandardCharsets.UTF_8), resource.getString("nonce").getBytes(StandardCharsets.UTF_8),
                    resource.getString("ciphertext"));
            System.err.println("微信解密的字符串信息" + decryptedData);
            com.alibaba.fastjson.JSONObject jsonInfo = (com.alibaba.fastjson.JSONObject) com.alibaba.fastjson.JSONObject.parse(decryptedData);
            String out_trade_no = jsonInfo.getString("out_trade_no");
            String transaction_id = jsonInfo.getString("transaction_id");
            String trade_state = jsonInfo.getString("trade_state");
            if (trade_state.equals("SUCCESS")) {
                ResultUtil resultUtil = packagePaymentService.insertVipPaymentCallback(out_trade_no, transaction_id);
                if (resultUtil.getCode() == 200) {
                    PrintWriter out = response.getWriter();
                    out.write("SUCCESS");
                    out.flush();
                    out.close();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 课包续课微信支付回调接口
     */
    /**
     * 课包续课微信支付回调接口
     */
@@ -1225,8 +1304,6 @@
            e.printStackTrace();
        }
    }
    /**
     * 获取学员剩余课时
     *
@@ -1297,21 +1374,16 @@
    @PostMapping("/coursePackagePayment/paymentDeductionClassHour")
    public void paymentDeductionClassHour(@RequestBody PaymentDeductionClassHour paymentDeductionClassHour) {
        try {
            // 2.0 用id进行查询
//            TCoursePackagePayment coursePackagePayment = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("id", paymentDeductionClassHour.getCourseId()).eq("payStatus", 2)
//                    .eq("status", 1).eq("state", 1).gt("laveClassHours", 0));
//            Integer classHour = paymentDeductionClassHour.getClassHour();
//            for (TCoursePackagePayment coursePackagePayment : list) {
            CoursePackageOrderStudent coursePackageOrderStudent = coursePackageOrderStudentService.getById(paymentDeductionClassHour.getCourseId());
//            if (paymentDeductionClassHour.getClassHour() > coursePackageOrderStudent.getLaveClassHours()) {
//                return ResultUtil.error("当前课包课时数不足");
//            }
            TCoursePackage coursePackage = coursePackageService.getById(coursePackageOrderStudent.getCoursePackageId());
            coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() - paymentDeductionClassHour.getClassHour());
            coursePackageOrderStudentService.updateById(coursePackageOrderStudent);
            Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours();
            if(3 >= laveClassHours){
                AppUser appUser = appuClient.queryAppUser(coursePackageOrderStudent.getAppUserId());
                //发送短信提醒
                aLiSendSms.sendSms(appUser.getPhone(), "SMS_463646317", "");
            }
            //判断剩余课时是否已经全部进行排课,如果排课需要删除已经排好的记录
            List<CoursePackageScheduling> list1 = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>()
                    .eq("studentId", coursePackageOrderStudent.getStudentId()).eq("status", 1)
@@ -1331,131 +1403,14 @@
                }
            }
//            if (coursePackagePayment.getLaveClassHours().compareTo(classHour) >= 0) {
//                coursePackagePayment.setLaveClassHours(coursePackagePayment.getLaveClassHours() - classHour);
//                coursePackagePayment.setAppUserId(null);
//                packagePaymentService.updateById(coursePackagePayment);
//
//                CourseCounsum courseCounsum = new CourseCounsum();
//                courseCounsum.setPaymentId(coursePackagePayment.getId());
//                courseCounsum.setChangeType(0);
//                courseCounsum.setNum(classHour);
//                courseCounsum.setInsertTime(new Date());
//                courseCounsum.setReason("报名赛事");
//                courseCounsumService.save(courseCounsum);
//
//
//                List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", coursePackagePayment.getStudentId()).eq("coursePackageId", coursePackagePayment.getCoursePackageId()));
//                List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList());
//                coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id", collect));
//                coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", paymentDeductionClassHour.getId()).eq("coursePackageId", coursePackagePayment.getCoursePackageId()));
//
//
//                TCoursePackage tCoursePackage = packageService.getById(coursePackagePayment.getCoursePackageId());
//                String classWeeks = tCoursePackage.getClassWeeks();
//                List<Integer> week = week(classWeeks);
//
//                TCoursePackagePayment pay = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", coursePackagePayment.getCoursePackageId()).eq("studentId", coursePackagePayment.getStudentId()));
//
//                Date today = new Date();
//                Calendar calendar = Calendar.getInstance();
//                calendar.add(Calendar.DATE, -1);
//                today = calendar.getTime();
//
//
//                Integer laveClassHours = pay.getLaveClassHours();
//                Integer codeTime = tCoursePackage.getCodeTime();
//                Integer can = laveClassHours / codeTime;
//
//                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");
//
//                Date[] dates = generateDateArray(14, today);
//                for (Date date : dates) {
//                    if (count == can) {
//                        break;
//                    }
//                    int wei = cn.hutool.core.date.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(pay.getAppUserId());
//                            student1.setStudentId(pay.getStudentId());
//                            student1.setCoursePackageId(pay.getCoursePackageId());
//                            student1.setCoursePackagePaymentId(pay.getId());
//                            student1.setCoursePackageSchedulingId(coursePackageScheduling.getId());
//                            student1.setSignInOrNot(1);
//                            student1.setReservationStatus(1);
//                            student1.setInsertTime(new Date());
//                            studentService.save(student1);
//                            count++;
//                        }
//                    }
//                }
//
//
//                // 2.0 少于3课时 推送
//                if (coursePackagePayment.getLaveClassHours() <= 3) {
//                    Integer appUserId = coursePackagePayment.getAppUserId();
//
//                    //调用推送
//                    HttpHeaders headers = new HttpHeaders();
//                    // 以表单的方式提交
//                    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//                    String s1 = appUserId + "_" + "Three";
//                    //定时修改排课状态
//                    String s = internalRestTemplate.getForObject("http://mb-cloud-gateway/netty/sendMsgToClient?id=" + s1, String.class);
//                    JSONObject jsonObject1 = JSON.parseObject(s, JSONObject.class);
//                    if (jsonObject1.getIntValue("code") != 200) {
//                        System.err.println(jsonObject1.getString("msg"));
//                    }
//                }
//
//                CancelledClasses cancelledClasses = new CancelledClasses();
//                cancelledClasses.setType(2);
//                cancelledClasses.setVoucher(paymentDeductionClassHour.getCode());
//                cancelledClasses.setCoursePackageId(coursePackagePayment.getCoursePackageId());
//                cancelledClasses.setCoursePackagePaymentId(coursePackagePayment.getId());
//                cancelledClasses.setCancelledClassesNumber(classHour);
//                cancelledClasses.setInsertTime(new Date());
//                cancelledClassesService.save(cancelledClasses);
//
//            } else {
//                CancelledClasses cancelledClasses = new CancelledClasses();
//                cancelledClasses.setType(2);
//                cancelledClasses.setVoucher(paymentDeductionClassHour.getCode());
//                cancelledClasses.setCoursePackageId(coursePackagePayment.getCoursePackageId());
//                cancelledClasses.setCoursePackagePaymentId(coursePackagePayment.getId());
//                cancelledClasses.setCancelledClassesNumber(coursePackagePayment.getLaveClassHours());
//                cancelledClasses.setInsertTime(new Date());
//                cancelledClassesService.save(cancelledClasses);
//
//                coursePackagePayment.setLaveClassHours(0);
//                packagePaymentService.updateById(coursePackagePayment);
//
//                classHour -= cancelledClasses.getCancelledClassesNumber();
//            }
//                }
            CourseCounsum courseCounsum = new CourseCounsum();
            courseCounsum.setPaymentId(coursePackageOrderStudent.getId());
            courseCounsum.setChangeType(0);
            courseCounsum.setNum(paymentDeductionClassHour.getClassHour());
            courseCounsum.setInsertTime(new Date());
            courseCounsum.setReason("赛事报名");
            courseCounsum.setAppUserId(coursePackageOrderStudent.getAppUserId());
            courseCounsumService.save(courseCounsum);
        } catch (Exception e) {
            e.printStackTrace();
@@ -1618,7 +1573,6 @@
            appUser.setPlayPaiCoins(appUser.getPlayPaiCoins() - paymentConfig.getPlayPaiCoin());
            auClitn.updateAppUser(appUser);
            // 2.0
            TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord();
            tCourseInfoRecord.setUserId(userIdFormRedis);
            tCourseInfoRecord.setCourseId(coursePackage.getCoursePackageId());
@@ -1633,7 +1587,7 @@
            courseCounsum.setChangeType(1);
            courseCounsum.setNum(packagePayment.getClassHours());
            courseCounsum.setInsertTime(new Date());
            courseCounsum.setReason("购买课包");
            courseCounsum.setReason("报名运动营");
            courseCounsumService.save(courseCounsum);
        } catch (Exception e) {
@@ -1667,7 +1621,6 @@
        boolean id = packagePaymentService.update(packagePayment, new QueryWrapper<TCoursePackagePayment>()
                .eq("id", packagePayment.getId()));
        if (id) {
            // 2.0
            TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord();
            tCourseInfoRecord.setNum(packagePayment.getTotalClassHours());
            tCourseInfoRecord.setName("续课");
@@ -1691,9 +1644,9 @@
    }
    @PostMapping("/base/coursePack/savePaymentCoursePackage")
    public boolean savePaymentCoursePackage(@RequestBody TCoursePackagePayment packagePayment) {
        return packagePaymentService.save(packagePayment);
    public Long savePaymentCoursePackage(@RequestBody CoursePackageOrder coursePackageOrder) {
        coursePackageOrderService.save(coursePackageOrder);
        return coursePackageOrder.getId();
    }
@@ -1729,7 +1682,7 @@
                if (student != null) {
                    sId = student.getId();
                }
                addPackageStudent(orderDto.getClassId(), orderDto.getAppUserId(), Integer.valueOf(s), coursePackagePayment.getId());
                addPackageStudent(orderDto.getClassId(), orderDto.getAppUserId(), Integer.valueOf(s), coursePackagePayment, coursePackagePayment.getId());
                CourseCounsum courseCounsum = new CourseCounsum();
@@ -1752,7 +1705,7 @@
                if (student != null) {
                    sId = student.getId();
                }
                addPackageStudent(orderDto.getClassId(), orderDto.getAppUserId(), Integer.valueOf(s), coursePackagePaymentServiceOne.getId());
                addPackageStudent(orderDto.getClassId(), orderDto.getAppUserId(), Integer.valueOf(s), coursePackagePaymentServiceOne, coursePackagePaymentServiceOne.getId());
                CourseCounsum courseCounsum = new CourseCounsum();
@@ -1761,6 +1714,7 @@
                courseCounsum.setNum(orderDto.getClassHours());
                courseCounsum.setInsertTime(new Date());
                courseCounsum.setReason("积分兑换");
                courseCounsum.setInsertTime(new Date());
                courseCounsumService.save(courseCounsum);
@@ -1810,7 +1764,6 @@
                // 其他星期减一即可得到1-6的数字表示
                dayOfWeek -= 1;
            }
            // todo
            if (weeks.contains(String.valueOf(dayOfWeek))){
                // 限时折扣判断是否在有效期
                try {
@@ -1902,7 +1855,8 @@
    @Autowired
    private TCoursePackageService coursePackageService;
    private void addPackageStudent1(TCoursePackage tCoursePackage, Integer userId, Integer sId, CoursePackageOrderStudent coursePackageOrderStudent) {
    private void addPackageStudent1(TCoursePackage tCoursePackage, Integer userId, Integer sId, CoursePackageOrder coursePackageOrder, CoursePackageOrderStudent coursePackageOrderStudent) {
        try {
            //1常规 2假期 3体验
            if (tCoursePackage.getType() == 1) {
@@ -2044,7 +1998,7 @@
            e.printStackTrace();
        }
    }
    private void addPackageStudent(Integer courseId, Integer userId, Integer sId, Long paymentId) throws ParseException {
    private void addPackageStudent(Integer courseId, Integer userId, Integer sId, TCoursePackagePayment coursePackagePayment, Long paymentId) throws ParseException {
        // 课包
        TCoursePackage tCoursePackage = coursePackageService.getById(courseId);
@@ -2179,7 +2133,6 @@
                }
            }
        }
        // 2.0
        TCourseInfoRecord tCourseInfoRecord = new TCourseInfoRecord();
        tCourseInfoRecord.setUserId(userId);
        tCourseInfoRecord.setCourseId(courseId);
@@ -2193,12 +2146,7 @@
    @ResponseBody
    @PostMapping("/base/coursePack/obtainStudentClassDetails")
    public List<RecordAppoint> obtainStudentClassDetailsData(@RequestBody WeeksOfCourseRest stuId) {
//        try {
        return coursePackageOrderStudentService.obtainStuClassDetails(stuId.getStuId(), stuId.getAppUserId(), stuId.getPageNum());
//        }catch (Exception e){
//            e.printStackTrace();
//            throw new RuntimeException();
//        }
    }
@@ -2216,16 +2164,16 @@
    }
    // 2.0 送课时
    @PostMapping("/base/coursePack/sendHours")
    public Integer sendHours(@RequestBody String s) throws ParseException {
        String[] split2 = s.split("_");
        TCoursePackagePayment byId = packagePaymentService.getById(Long.valueOf(split2[0]));
        byId.setTotalClassHours(byId.getTotalClassHours() + Integer.valueOf(split2[2]));
        boolean b = packagePaymentService.updateHoursById(byId, Integer.valueOf(split2[2]));
        CoursePackageOrderStudent coursePackageOrderStudent = coursePackageOrderStudentService.getById(Long.valueOf(split2[0]));
        coursePackageOrderStudent.setTotalClassHours(coursePackageOrderStudent.getTotalClassHours() + Integer.valueOf(split2[2]));
        coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() + Integer.valueOf(split2[2]));
        coursePackageOrderStudentService.updateById(coursePackageOrderStudent);
        CourseCounsum courseCounsum = new CourseCounsum();
        courseCounsum.setPaymentId(byId.getId());
        courseCounsum.setPaymentId(coursePackageOrderStudent.getId());
        courseCounsum.setChangeType(1);
        courseCounsum.setNum(Integer.valueOf(split2[2]));
        courseCounsum.setInsertTime(new Date());
@@ -2233,17 +2181,17 @@
        courseCounsumService.save(courseCounsum);
        List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", byId.getStudentId()).eq("coursePackageId", byId.getCoursePackageId()));
        List<CoursePackageStudent> studentCourse = coursePackageStudentService.list(new QueryWrapper<CoursePackageStudent>().eq("studentId", coursePackageOrderStudent.getStudentId()).eq("coursePackageId", coursePackageOrderStudent.getCoursePackageId()));
        List<Long> collect = studentCourse.stream().map(CoursePackageStudent::getCoursePackageSchedulingId).collect(Collectors.toList());
        coursePackageSchedulingService.remove(new QueryWrapper<CoursePackageScheduling>().in("id", collect));
        coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", byId.getStudentId()).eq("coursePackageId", byId.getCoursePackageId()));
        coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("studentId", coursePackageOrderStudent.getStudentId()).eq("coursePackageId", coursePackageOrderStudent.getCoursePackageId()));
        TCoursePackage tCoursePackage = packageService.getById(byId.getCoursePackageId());
        TCoursePackage tCoursePackage = packageService.getById(coursePackageOrderStudent.getCoursePackageId());
        String classWeeks = tCoursePackage.getClassWeeks();
        List<Integer> week = week(classWeeks);
        TCoursePackagePayment pay = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", byId.getCoursePackageId()).eq("studentId", byId.getStudentId()));
        TCoursePackagePayment pay = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", coursePackageOrderStudent.getCoursePackageId()).eq("studentId", coursePackageOrderStudent.getStudentId()));
        Date today = new Date();
@@ -2290,14 +2238,7 @@
                }
            }
        }
        if (b) {
            return 1;
        } else {
            return 0;
        }
        return 1;
    }
@@ -2378,6 +2319,13 @@
        }
        coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours()-coursePackage.getNeedNum());
        orderStudentService.updateById(coursePackageOrderStudent);
        Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours();
        if(3 >= laveClassHours){
            AppUser appUser = appuClient.queryAppUser(coursePackageOrderStudent.getAppUserId());
            //发送短信提醒
            aLiSendSms.sendSms(appUser.getPhone(), "SMS_463646317", "");
        }
        CourseCounsum courseCounsum = new CourseCounsum();
        courseCounsum.setPaymentId(coursePackageOrderStudent.getId());
        courseCounsum.setChangeType(0);
@@ -2392,7 +2340,7 @@
    @ResponseBody
    @PostMapping("/coursePackagePayment/CountqueryByClassId")
    public Integer CountqueryByClassId(@RequestBody Integer id) {
        int coursePackageId = packagePaymentService.count(new QueryWrapper<TCoursePackagePayment>().eq("coursePackageId", id));
        int coursePackageId = coursePackageOrderStudentService.count(new QueryWrapper<CoursePackageOrderStudent>().eq("coursePackageId", id));
        return coursePackageId;
@@ -2410,7 +2358,6 @@
        coursePackagePayment.setAppUserId(null);
        packagePaymentService.updateById(coursePackagePayment);
    }
    /**
     * 修改数据
@@ -2441,7 +2388,7 @@
     */
    @ResponseBody
    @PostMapping("/api/startCource/reverse")
    @ApiOperation(value = "上课主页-预约操作--2.0改请假操作", tags = {"APP-开始上课"})
    @ApiOperation(value = "上课主页-预约操作--改请假操作", tags = {"APP-开始上课"})
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
            @ApiImplicitParam(value = "课包id", name = "courseID", required = true, dataType = "String"),
@@ -2499,14 +2446,28 @@
    @PostMapping("/base/coursePack/getConsumes")
    List<CourseCounsum> getConsumes(@RequestBody BillingDataRequestVo requestVo) {
        Integer[] integers = {2, 3};
        QueryWrapper<CourseCounsum> courseCounsumQueryWrapper = new QueryWrapper<CourseCounsum>().in("changeType", integers).eq("appUserId", requestVo.getAppUserId());
        QueryWrapper<CourseCounsum> courseCounsumQueryWrapper = new QueryWrapper<CourseCounsum>()
                .in("changeType", integers).eq("appUserId", requestVo.getAppUserId());
        if (requestVo.getMonthEnd() != null) {
            courseCounsumQueryWrapper.ge("insertTime", requestVo.getMonthStart());
            courseCounsumQueryWrapper.le("insertTime", requestVo.getMonthEnd());
        }
        return courseCounsumService.list(courseCounsumQueryWrapper);
    }
    @ResponseBody
    @PostMapping("/base/coursePack/getCoursePackageOrder")
    public List<CoursePackageOrder> getCoursePackageOrder(@RequestBody BillingDataRequestVo requestVo){
        QueryWrapper<CoursePackageOrder> wrapper = new QueryWrapper<CoursePackageOrder>().eq("appUserId", requestVo.getAppUserId())
                .in("payType", Arrays.asList(1, 2, 5, 6)).eq("payStatus", 2).eq("state", 1).eq("orderType", 1);
        return coursePackageOrderService.list(wrapper);
    }
    @ResponseBody
@@ -2536,7 +2497,8 @@
        // 找出门店的所有课程 排出体验
        List<TCoursePackage> list = tcpService.list(new LambdaQueryWrapper<TCoursePackage>()
                .eq(TCoursePackage::getStoreId, courseDetailReq.getStoreId()).ne(TCoursePackage::getType, 3)
                .eq(TCoursePackage::getState, 1).like(TCoursePackage::getClassWeeks, week));
                .eq(TCoursePackage::getState, 1).like(TCoursePackage::getClassWeeks, week)
                .eq(TCoursePackage::getAuditStatus, 2));
        List<Integer> collect = list.stream().map(TCoursePackage::getId).collect(Collectors.toList());
        if (collect.size() == 0) {
            collect.add(-1);
@@ -2548,21 +2510,6 @@
                .in(CoursePackageScheduling::getCoursePackageId, collect)
        );
        List<Integer> collect1 = list8.stream().map(CoursePackageScheduling::getCoursePackageId).collect(Collectors.toList());
//        // 找出购买的课包
//        List<CoursePackageOrderStudent> list1 = coursePackageOrderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>()
//                .eq("appUserId", courseDetailReq.getAppUserId())
//                .eq("studentId", courseDetailReq.getStuId())
//                .in("coursePackageId", collect1)
//                .eq("status", 1)
//                .eq("state", 1)
//        );
//        List<Integer> collect1 = list1.stream().map(CoursePackageOrderStudent::getCoursePackageId).collect(Collectors.toList());
//        List<Long> ids = list1.stream().map(CoursePackageOrderStudent::getId).collect(Collectors.toList());
        for (TCoursePackage tCoursePackage : list) {
            DetailsListVo detailsListVo = new DetailsListVo();
            detailsListVo.setId(tCoursePackage.getId());
@@ -2610,6 +2557,7 @@
                        .eq(CoursePackageScheduling::getCoursePackageId, tCoursePackage.getId())
                        .like(CoursePackageScheduling::getClassDate, courseDetailReq.getTime())
                );
                if (list3.isEmpty()) {
                    detailsListVo.setType(2);
                    objects.add(detailsListVo);
@@ -2652,6 +2600,13 @@
                        if (signInOrNot1 == 2) {
                            detailsListVo.setType(3);
                        }
                        //体验购课去掉按钮
                        if(coursePackageScheduling.getType() == 3){
                            detailsListVo.setCourseType(3);
                            detailsListVo.setType(2);
                        }
                        detailsListVo.setIsType(coursePackageStudent.getType());
                        Date classDate = coursePackageScheduling.getClassDate();
                        Date endDate = coursePackageScheduling.getEndDate();
@@ -2681,6 +2636,10 @@
                detailsListVo.setType(2);
                objects.add(detailsListVo);
            }
            //课程暂停
            if(tCoursePackage.getState() == 4){
                detailsListVo.setType(4);
            }
        }
        map.put("data", objects);
@@ -2721,23 +2680,24 @@
    @PostMapping("/coursePackagePayment/queryCourseData")
    public List<Map<String, Object>> queryCourseData(@RequestBody List<Integer> ids) {
        // 找出课程类型  找出剩余的课时数
        List<TCoursePackageType> list = coursePackageTypeService.list();
        List<TCoursePackageType> list = coursePackageTypeService.list(
                new LambdaQueryWrapper<TCoursePackageType>().ne(TCoursePackageType::getState, 3));
        if (ids.size() == 0) {
            ids.add(-1);
        }
        List<TCoursePackagePayment> list1 = packagePaymentService.listOne(ids);
        List<Integer> collect = list1.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList());
        if (collect.size() == 0) {
            collect.add(-1);
        }
        List<TCoursePackage> list2 = tcpService.list(new LambdaQueryWrapper<TCoursePackage>().in(TCoursePackage::getId, collect));
        for (TCoursePackagePayment tCoursePackagePayment : list1) {
            for (TCoursePackage tCoursePackage : list2) {
                if (tCoursePackagePayment.getCoursePackageId().equals(tCoursePackage.getId())) {
                    tCoursePackagePayment.setType(tCoursePackage.getType());
                }
            }
        }
//        List<Integer> collect = list1.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList());
//        if (collect.size() == 0) {
//            collect.add(-1);
//        }
//        List<TCoursePackage> list2 = tcpService.list(new LambdaQueryWrapper<TCoursePackage>().in(TCoursePackage::getId, collect));
//        for (TCoursePackagePayment tCoursePackagePayment : list1) {
//            for (TCoursePackage tCoursePackage : list2) {
//                if (tCoursePackagePayment.getCoursePackageId().equals(tCoursePackage.getId())) {
//                    tCoursePackagePayment.setType(tCoursePackage.getType());
//                }
//            }
//        }
        List<Map<String, Object>> mapList = new ArrayList<>();
@@ -2746,7 +2706,7 @@
            map.put("name", tCoursePackageType.getName());
            int a = 0;
            for (TCoursePackagePayment tCoursePackagePayment : list1) {
                if (tCoursePackagePayment.getType().equals(tCoursePackageType.getId())) {
                if (null != tCoursePackagePayment.getType() && tCoursePackagePayment.getType().equals(tCoursePackageType.getId())) {
                    a += tCoursePackagePayment.getLaveClassHours();
                }
            }
@@ -2773,7 +2733,8 @@
        map.put("allCourse",sum-sum1);
        //所有课包
        List<TCoursePackage> coursePackages = tcpService.list();
        List<TCoursePackage> coursePackages = tcpService.list(
                new LambdaQueryWrapper<TCoursePackage>().ne(TCoursePackage::getState, 3));
        // 年
@@ -2923,7 +2884,156 @@
        map.put("allCourse", sum - sum1);
        //所有课包
        List<TCoursePackage> coursePackages = tcpService.list();
        List<TCoursePackage> coursePackages = tcpService.list(
                new LambdaQueryWrapper<TCoursePackage>().ne(TCoursePackage::getState, 3));
        // 年
        List<CoursePackageStudent> list = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>().in(CoursePackageStudent::getAppUserId, userPt));
        for (CoursePackageStudent coursePackageStudent : list) {
            for (TCoursePackage coursePackage : coursePackages) {
                if (coursePackageStudent.getCoursePackageId().equals(coursePackage.getId())) {
                    if (ToolUtil.isEmpty(coursePackage.getNeedNum())) {
                        coursePackageStudent.setNeedNum(0);
                    } else {
                        coursePackageStudent.setNeedNum(coursePackage.getNeedNum());
                    }
                }
            }
        }
        ArrayList<Object> integers = new ArrayList<>();
        int year = cn.hutool.core.date.DateUtil.year(new Date());
        for (int i = 0; i < 10; i++) {
            integers.add(year - i);
        }
        List<Object> collect = integers.stream().sorted().collect(Collectors.toList());
        // 年
        ArrayList<Integer> years = new ArrayList<>();
        for (Object o : collect) {
            String s = o.toString();
            List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList());
            int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum();
            years.add(sum2);
        }
        map.put("yearData", years);
        ArrayList<Integer> months = new ArrayList<>();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 月
        for (int i = 1; i <= 12; i++) {
            String m = i + "";
            if (i < 10) {
                m = "0" + i;
            }
            String s = year + "-" + m;
            List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList());
            int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum();
            months.add(sum2);
        }
        map.put("monthData", months);
        // 周
        // 获取最近四周
        LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX);
        // 周度数据
        LocalDateTime s1 = minNow.minusDays(6);
        LocalDateTime s2 = maxNow;
        LocalDateTime s3 = minNow.minusDays(13);
        LocalDateTime s4 = maxNow.minusDays(6);
        LocalDateTime s5 = minNow.minusDays(20);
        LocalDateTime s6 = maxNow.minusDays(13);
        LocalDateTime s7 = minNow.minusDays(27);
        LocalDateTime s8 = maxNow.minusDays(20);
        ArrayList<Object> weekData = new ArrayList<>();
        int count = 0;
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        for (CoursePackageStudent coursePackageStudent : list) {
            if (coursePackageStudent.getNeedNum() == null) {
                continue;
            }
            // 如果到课状态为否 则不计算
            if (coursePackageStudent.getSignInOrNot() != 0) {
                Date insertTime = coursePackageStudent.getInsertTime();
                Instant instant = insertTime.toInstant();
                ZoneId zoneId = ZoneId.systemDefault();
                LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime();
                if (dateTime.isAfter(s1) && dateTime.isBefore(s2)) {
                    count += coursePackageStudent.getNeedNum();
                } else if (dateTime.isAfter(s3) && dateTime.isBefore(s4)) {
                    count1 += coursePackageStudent.getNeedNum();
                } else if (dateTime.isAfter(s5) && dateTime.isBefore(s6)) {
                    count2 += coursePackageStudent.getNeedNum();
                } else if (dateTime.isAfter(s7) && dateTime.isBefore(s8)) {
                    count3 += coursePackageStudent.getNeedNum();
                }
            }
        }
        weekData.add(count3);
        weekData.add(count2);
        weekData.add(count1);
        weekData.add(count);
        map.put("weekData", weekData);
        LocalDateTime currentDateTime = LocalDateTime.now();
        List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7, 0));
        for (CoursePackageStudent coursePackageStudent : list) {
            Date insertTime = coursePackageStudent.getInsertTime();
            // 将 Date 转换为 LocalDateTime
            LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault());
            // 计算日期与当前日期的差距
            long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate());
            // 如果日期在七天内,累加金额
            if (daysDifference >= 0 && daysDifference < 7) {
                int index = (int) (6 - daysDifference); // 计算对应的索引位置
                Integer needNum = coursePackageStudent.getNeedNum();
                if (needNum != null) {
                    int i = amountByDay.get(index) + needNum;
                    amountByDay.set(index, i);
                }
            }
        }
        map.put("dayData", amountByDay);
        return map;
    }
    @ResponseBody
    @PostMapping("/coursePackagePayment/courseStore")
    HashMap<String, Object> courseStore(@RequestBody List<Integer> userPt) {
        if (userPt.size() == 0) {
            userPt.add(-1);
        }
        HashMap<String, Object> map = new HashMap<>();
        List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.listOne(userPt);
        int sum = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getTotalClassHours).sum();
        int sum1 = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getLaveClassHours).sum();
        map.put("allCourse", sum - sum1);
        //所有课包
        List<TCoursePackage> coursePackages = tcpService.list(
                new LambdaQueryWrapper<TCoursePackage>().ne(TCoursePackage::getState, 3));
        // 年
@@ -3060,153 +3170,20 @@
    }
    @ResponseBody
    @PostMapping("/coursePackagePayment/courseStore")
    HashMap<String, Object> courseStore(@RequestBody List<Integer> userPt) {
        if (userPt.size() == 0) {
            userPt.add(-1);
    @PostMapping("/coursePackagePayment/queryPaymentCoursePackage")
    public List<Integer> queryPaymentCoursePackage(@RequestBody List<Integer> storeIds){
        if(storeIds.size() == 0){
            return new ArrayList<>();
        }
        HashMap<String, Object> map = new HashMap<>();
        List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.listOne(userPt);
        int sum = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getTotalClassHours).sum();
        int sum1 = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getLaveClassHours).sum();
        map.put("allCourse", sum - sum1);
        //所有课包
        List<TCoursePackage> coursePackages = tcpService.list();
        // 年
        List<CoursePackageStudent> list = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>().in(CoursePackageStudent::getAppUserId, userPt));
        for (CoursePackageStudent coursePackageStudent : list) {
            for (TCoursePackage coursePackage : coursePackages) {
                if (coursePackageStudent.getCoursePackageId().equals(coursePackage.getId())) {
                    if (ToolUtil.isEmpty(coursePackage.getNeedNum())) {
                        coursePackageStudent.setNeedNum(0);
                    } else {
                        coursePackageStudent.setNeedNum(coursePackage.getNeedNum());
                    }
                }
            }
        List<TCoursePackage> list = coursePackageService.list(new QueryWrapper<TCoursePackage>().eq("auditStatus", 2)
                .ne("status", 4).eq("state", 1).in("storeId", storeIds));
        List<Integer> collect = list.stream().map(TCoursePackage::getId).collect(Collectors.toList());
        if(collect.size() == 0){
            return new ArrayList<>();
        }
        ArrayList<Object> integers = new ArrayList<>();
        int year = cn.hutool.core.date.DateUtil.year(new Date());
        for (int i = 0; i < 10; i++) {
            integers.add(year - i);
        }
        List<Object> collect = integers.stream().sorted().collect(Collectors.toList());
        // 年
        ArrayList<Integer> years = new ArrayList<>();
        for (Object o : collect) {
            String s = o.toString();
            List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList());
            int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum();
            years.add(sum2);
        }
        map.put("yearData", years);
        ArrayList<Integer> months = new ArrayList<>();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 月
        for (int i = 1; i <= 12; i++) {
            String m = i + "";
            if (i < 10) {
                m = "0" + i;
            }
            String s = year + "-" + m;
            List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList());
            int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum();
            months.add(sum2);
        }
        map.put("monthData", months);
        // 周
        // 获取最近四周
        LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX);
        // 周度数据
        LocalDateTime s1 = minNow.minusDays(6);
        LocalDateTime s2 = maxNow;
        LocalDateTime s3 = minNow.minusDays(13);
        LocalDateTime s4 = maxNow.minusDays(6);
        LocalDateTime s5 = minNow.minusDays(20);
        LocalDateTime s6 = maxNow.minusDays(13);
        LocalDateTime s7 = minNow.minusDays(27);
        LocalDateTime s8 = maxNow.minusDays(20);
        ArrayList<Object> weekData = new ArrayList<>();
        int count = 0;
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        for (CoursePackageStudent coursePackageStudent : list) {
            if (coursePackageStudent.getNeedNum() == null) {
                continue;
            }
            // 如果到课状态为否 则不计算
            if (coursePackageStudent.getSignInOrNot() != 0) {
                Date insertTime = coursePackageStudent.getInsertTime();
                Instant instant = insertTime.toInstant();
                ZoneId zoneId = ZoneId.systemDefault();
                LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime();
                if (dateTime.isAfter(s1) && dateTime.isBefore(s2)) {
                    count += coursePackageStudent.getNeedNum();
                } else if (dateTime.isAfter(s3) && dateTime.isBefore(s4)) {
                    count1 += coursePackageStudent.getNeedNum();
                } else if (dateTime.isAfter(s5) && dateTime.isBefore(s6)) {
                    count2 += coursePackageStudent.getNeedNum();
                } else if (dateTime.isAfter(s7) && dateTime.isBefore(s8)) {
                    count3 += coursePackageStudent.getNeedNum();
                }
            }
        }
        weekData.add(count3);
        weekData.add(count2);
        weekData.add(count1);
        weekData.add(count);
        map.put("weekData", weekData);
        LocalDateTime currentDateTime = LocalDateTime.now();
        List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7, 0));
        for (CoursePackageStudent coursePackageStudent : list) {
            Date insertTime = coursePackageStudent.getInsertTime();
            // 将 Date 转换为 LocalDateTime
            LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault());
            // 计算日期与当前日期的差距
            long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate());
            // 如果日期在七天内,累加金额
            if (daysDifference >= 0 && daysDifference < 7) {
                int index = (int) (6 - daysDifference); // 计算对应的索引位置
                Integer needNum = coursePackageStudent.getNeedNum();
                if (needNum != null) {
                    int i = amountByDay.get(index) + needNum;
                    amountByDay.set(index, i);
                }
            }
        }
        map.put("dayData", amountByDay);
        return map;
        List<CoursePackageOrder> list1 = coursePackageOrderService.list(new QueryWrapper<CoursePackageOrder>().in("coursePackageId", collect).eq("payStatus", 2).eq("status", 1));
        return list1.stream().map(CoursePackageOrder::getAppUserId).collect(Collectors.toList());
    }
}