nickchange
2023-11-28 b3bf5a0b4fac7ba6bc85b2bdce5e05d55cdeb69f
cloud-server-course/src/main/java/com/dsh/course/controller/CourseStudentController.java
@@ -450,8 +450,10 @@
            CourseCounsum courseCounsum = new CourseCounsum();
            courseCounsum.setInsertTime(new Date());
            if (orinPay.getAppUserId().compareTo(studentPay.getAppUserId()) != 0) {
                courseCounsum.setReason("课时赠送");
            Integer appUserId = orinPay.getAppUserId();
            Integer appUserId1 = studentPay.getAppUserId();
            if (appUserId.compareTo(appUserId1) != 0) {
                courseCounsum.setReason("赠课");
            } else {
                courseCounsum.setReason("课时转移");
            }
@@ -466,20 +468,10 @@
            courseCounsum.setPaymentId(orinPay.getId());
            counsumService.save(courseCounsum);
            Integer laveClassHours1 = studentPay.getLaveClassHours();
            Integer totalClassHours1 = studentPay.getTotalClassHours();
            int total = totalClassHours + totalClassHours1;
            int lave = laveClassHours + laveClassHours1;
            studentPay.setAppUserId(null);
            studentPay.setLaveClassHours(lave);
            studentPay.setTotalClassHours(total);
            orderStudentService.updateById(studentPay);
            CourseCounsum courseCounsum1 = new CourseCounsum();
            courseCounsum1.setInsertTime(new Date());
            if (orinPay.getAppUserId().compareTo(studentPay.getAppUserId()) != 0) {
                courseCounsum1.setReason("课时赠送");
            if (appUserId.compareTo(appUserId1) != 0) {
                courseCounsum1.setReason("赠课");
            } else {
                courseCounsum1.setReason("课时转移");
            }
@@ -488,10 +480,10 @@
            courseCounsum1.setPaymentId(studentPay.getId());
            counsumService.save(courseCounsum1);
            schedulingService.addNewCoursePackageScheduling(studentPay.getId(),laveClassHours);
            schedulingService.addNewCoursePackageScheduling(studentPay.getId(), laveClassHours);
            //删除原排课数据
            List<CoursePackageScheduling> coursePackageSchedulings = coursePackageSchedulingService.selectList(new QueryWrapper<CoursePackageScheduling>()
                    .eq("type", 1).eq("appUserId", orinPay.getAppUserId())
                    .eq("type", 1).eq("appUserId", appUserId)
                    .eq("studentId", orinPay.getStudentId()).eq("coursePackageId", orinPay.getCoursePackageId())
                    .orderByAsc("classDate"));
            int num = totalClassHours - laveClassHours;
@@ -501,12 +493,13 @@
                coursePackageStudentService.remove(new QueryWrapper<CoursePackageStudent>().eq("coursePackageSchedulingId", packageScheduling.getId()));
            }
        } else {
            Integer totalClassHours = orinPay.getTotalClassHours();
            Integer laveClassHours = orinPay.getLaveClassHours();
            Student student = studentClient.queryStudentById(toClassDto.getToStudentId());
            CoursePackageOrderStudent to = new CoursePackageOrderStudent();
            to.setStudentId(toClassDto.getToStudentId());
            to.setTotalClassHours(totalClassHours);
            to.setTotalClassHours(laveClassHours);
            to.setLaveClassHours(laveClassHours);
            to.setCoursePackageId(orinPay.getCoursePackageId());
            to.setState(1);
@@ -519,10 +512,17 @@
            calendar.setTime(new Date());
            calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) + validDays);
            to.setUseTime(calendar.getTime());
            orderStudentService.save(to);
            if(null == student.getValidity()){
                student.setValidity(calendar.getTime());
            }else if(student.getValidity().getTime() < calendar.getTime().getTime()){
                student.setValidity(calendar.getTime());
            }
            studentClient.frozen(student);
            Integer laveClassHours1 = orinPay.getLaveClassHours();
            Integer appUserId = orinPay.getAppUserId();
            orinPay.setLaveClassHours(0);
            orinPay.setAppUserId(null);
            orinPay.setStatus(6);
@@ -531,8 +531,8 @@
            CourseCounsum courseCounsum = new CourseCounsum();
            courseCounsum.setInsertTime(new Date());
            courseCounsum.setReason("课时赠送");
            courseCounsum.setNum(orinPay.getLaveClassHours());
            courseCounsum.setReason("赠课");
            courseCounsum.setNum(laveClassHours1);
            courseCounsum.setChangeType(0);
            courseCounsum.setPaymentId(orinPay.getId());
            counsumService.save(courseCounsum);
@@ -540,17 +540,17 @@
            CourseCounsum courseCounsum1 = new CourseCounsum();
            courseCounsum1.setInsertTime(new Date());
            courseCounsum1.setReason("课时赠送");
            courseCounsum1.setNum(orinPay.getLaveClassHours());
            courseCounsum1.setReason("赠课");
            courseCounsum1.setNum(laveClassHours1);
            courseCounsum1.setChangeType(1);
            courseCounsum1.setPaymentId(to.getId());
            counsumService.save(courseCounsum);
            counsumService.save(courseCounsum1);
            //开始排课
             addPackageStudent(coursePackage, to.getAppUserId(), to.getStudentId(), to);
            //删除原排课数据
            List<CoursePackageScheduling> coursePackageSchedulings = coursePackageSchedulingService.selectList(new QueryWrapper<CoursePackageScheduling>()
                    .eq("type", 1).eq("appUserId", orinPay.getAppUserId())
                    .eq("type", 1).eq("appUserId", appUserId)
                    .eq("studentId", orinPay.getStudentId()).eq("coursePackageId", orinPay.getCoursePackageId())
                    .orderByAsc("classDate"));
            int num = totalClassHours - laveClassHours;
@@ -599,7 +599,9 @@
                int day_week = calendar.get(Calendar.DAY_OF_WEEK);
                day_week = day_week - 1 == 0 ? 7 : day_week - 1;
                int num = 8 - day_week + 7;
                Date useTime = coursePackageOrderStudent.getUseTime();
                Student student = studentClient.queryStudentById(coursePackageOrderStudent.getStudentId());
                Date useTime = student.getValidity();
                for (int i = 0; i < num; i++) {
                    Date time = calendar.getTime();