puzhibing
2024-02-05 640ff18d2d7f4be02ddb7f8f75e899f05545eb98
cloud-server-course/src/main/java/com/dsh/course/controller/CourseStudentController.java
@@ -389,9 +389,9 @@
            courseCounsum.setReason("退费");
            courseCounsum.setPaymentId(o.getId());
            courseCounsum.setInsertTime(new Date());
            courseCounsum.setAppUserId(o.getAppUserId());
            counsumService.save(courseCounsum);
            o.setTotalClassHours(0);
            o.setLaveClassHours(0);
            o.setStatus(2);
            o.setAppUserId(null);
@@ -509,6 +509,7 @@
            courseCounsum.setNum(laveClassHours);
            courseCounsum.setChangeType(0);
            courseCounsum.setPaymentId(orinPay.getId());
            courseCounsum.setAppUserId(orinPay.getAppUserId());
            counsumService.save(courseCounsum);
            CourseCounsum courseCounsum1 = new CourseCounsum();
@@ -521,6 +522,7 @@
            courseCounsum1.setNum(laveClassHours);
            courseCounsum1.setChangeType(1);
            courseCounsum1.setPaymentId(studentPay.getId());
            courseCounsum1.setAppUserId(studentPay.getAppUserId());
            counsumService.save(courseCounsum1);
            schedulingService.addNewCoursePackageScheduling(studentPay.getId(), laveClassHours);
@@ -578,6 +580,7 @@
            courseCounsum.setNum(laveClassHours1);
            courseCounsum.setChangeType(0);
            courseCounsum.setPaymentId(orinPay.getId());
            courseCounsum.setAppUserId(orinPay.getAppUserId());
            counsumService.save(courseCounsum);
@@ -587,6 +590,7 @@
            courseCounsum1.setNum(laveClassHours1);
            courseCounsum1.setChangeType(1);
            courseCounsum1.setPaymentId(to.getId());
            courseCounsum1.setAppUserId(to.getAppUserId());
            counsumService.save(courseCounsum1);
            //开始排课
@@ -790,7 +794,6 @@
        // 添加购买课时 paytyoe为7
        // 排课可期  判断课程时间段  添加排课表  添加上课记录表
        // 找到原来的课包 扣课时
//        CoursePackageOrderStudent coursePackageOrderStudent = orderStudentService.getById(toHoliDto.getId());
        CoursePackageOrderStudent coursePackageOrderStudent = orderStudentService.getOne(new QueryWrapper<CoursePackageOrderStudent>().eq("coursePackageId",toHoliDto.getId()).eq("studentId",stuId));
        TCoursePackage coursePackage = coursePackageService.getById(coursePackageOrderStudent.getCoursePackageId());
@@ -826,6 +829,16 @@
            coursePackageOrderStudent.setAppUserId(null);
        coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours()-toHoliDto.getClassNum());
            orderStudentService.updateById(coursePackageOrderStudent);
            CourseCounsum courseCounsum = new CourseCounsum();
            courseCounsum.setPaymentId(coursePackageOrderStudent.getId());
            courseCounsum.setChangeType(0);
            courseCounsum.setNum(toHoliDto.getClassNum());
            courseCounsum.setInsertTime(new Date());
            courseCounsum.setReason("报名假期班");
            courseCounsum.setAppUserId(coursePackageOrderStudent.getAppUserId());
            courseCounsumService.save(courseCounsum);
            Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours();
            if(3 >= laveClassHours){
                AppUser appUser = appUserClient.queryAppUser(coursePackageOrderStudent.getAppUserId());
@@ -890,18 +903,6 @@
                //增加日期,用于判断
                calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + 1);
            }
        CourseCounsum courseCounsum = new CourseCounsum();
        courseCounsum.setPaymentId(coursePackageOrderStudent.getId());
        courseCounsum.setChangeType(0);
        courseCounsum.setNum(toHoliDto.getClassNum());
        courseCounsum.setInsertTime(new Date());
        courseCounsum.setReason("报名假期班");
//        courseCounsum.setAppUserId(userId);
        courseCounsumService.save(courseCounsum);
        }
        return "报名成功";
@@ -966,23 +967,8 @@
    @ResponseBody
    public String toTrans(@RequestBody ToHoliDto toHoliDto) throws ParseException {
        String[] stuIds = toHoliDto.getIds();
//        //查询出学员ids对应的棵树,判断剩余课时数是否够
//        List<CoursePackageOrderStudent> list = orderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>().eq("coursePackageId", toHoliDto.getClassId()).in("studentId", stuIds));
//        List<String> notStudent = new ArrayList<>();
//        for (CoursePackageOrderStudent coursePackageOrderStudent : list) {
//            if (coursePackageOrderStudent.getLaveClassHours() < toHoliDto.getClassNum()) {
//                notStudent.add(studentClient.queryStudentById(coursePackageOrderStudent.getStudentId()).getName());
//            }
//        }
//        if (!notStudent.isEmpty()) {
//            String notStudentStr = String.join(",", notStudent);
//            return notStudentStr+":课时数不足";
//        }
        //转移课程
        for (String stuId : stuIds) {
//            CoursePackageOrderStudent orinPay = orderStudentService.getById(toHoliDto.getId());
            CoursePackageOrderStudent orinPay = orderStudentService.getOne(new QueryWrapper<CoursePackageOrderStudent>()
                    .eq("studentId", stuId)
                    .eq("coursePackageId", toHoliDto.getId()));
@@ -999,10 +985,7 @@
                courseCounsum.setInsertTime(new Date());
                Integer appUserId = orinPay.getAppUserId();
                Integer appUserId1 = studentPay.getAppUserId();
                    courseCounsum.setReason("换课");
                orinPay.setLaveClassHours(0);
                orinPay.setStatus(3);
                orinPay.setAppUserId(null);
@@ -1011,18 +994,16 @@
                courseCounsum.setNum(laveClassHours);
                courseCounsum.setChangeType(0);
                courseCounsum.setPaymentId(orinPay.getId());
                courseCounsum.setAppUserId(orinPay.getAppUserId());
                counsumService.save(courseCounsum);
                CourseCounsum courseCounsum1 = new CourseCounsum();
                courseCounsum1.setInsertTime(new Date());
//                if (appUserId.compareTo(appUserId1) != 0) {
//                    courseCounsum1.setReason("赠课");
//                } else {
                    courseCounsum1.setReason("换课");
//                }
                courseCounsum1.setNum(laveClassHours);
                courseCounsum1.setChangeType(1);
                courseCounsum1.setPaymentId(studentPay.getId());
                courseCounsum1.setAppUserId(studentPay.getAppUserId());
                counsumService.save(courseCounsum1);
                schedulingService.addNewCoursePackageScheduling(studentPay.getId(), laveClassHours);