puzhibing
2024-03-05 a8f90f717c73d7ff4d2355649f9f161a6f89aa9b
cloud-server-course/src/main/java/com/dsh/course/service/impl/CoursePackageOrderStudentServiceImpl.java
@@ -15,6 +15,7 @@
import com.dsh.course.mapper.*;
import com.dsh.course.model.DeductionClassHour;
import com.dsh.course.model.DeductionClassHourList;
import com.dsh.course.service.CourseCounsumService;
import com.dsh.course.service.ICoursePackageOrderStudentService;
import com.dsh.course.service.ICoursePackageSchedulingService;
import com.dsh.course.service.TCoursePackageService;
@@ -46,6 +47,9 @@
    @Autowired
    private ICoursePackageSchedulingService coursePackageSchedulingService;
    @Autowired
    private CourseCounsumService courseCounsumService;
    @Resource
    private TCoursePackageMapper tcpmapper;
@@ -212,7 +216,7 @@
     * @return
     */
    @Override
    public boolean deductionClassHour(DeductionClassHourList deductionClassHourList) {
    public DeductionClassHourList deductionClassHour(DeductionClassHourList deductionClassHourList) {
        try {
            List<DeductionClassHour> list = deductionClassHourList.getDeductionClassHourList();
            for (DeductionClassHour deductionClassHour : list) {
@@ -240,21 +244,52 @@
                    if(n != 0){
                        n += 1;
                        l = (codeTime * n) - clss;
                        coursePackageOrderStudent.setLaveClassHours(l);
                    }
                    coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() + l);
                    //删除已排的课程
                    List<CoursePackageScheduling> coursePackageSchedulings = packageSchedulings.subList(0, n);
                    List<Long> collect = coursePackageSchedulings.stream().map(CoursePackageScheduling::getId).collect(Collectors.toList());
                    coursePackageSchedulingService.removeByIds(collect);
                    deductionClassHour.setScheduledCourses(n);
                }
                this.updateById(coursePackageOrderStudent);
                CourseCounsum courseCounsum = new CourseCounsum();
                courseCounsum.setPaymentId(coursePackageOrderStudent.getId());
                courseCounsum.setChangeType(0);
                courseCounsum.setNum(deductionClassHour.getClassHour());
                courseCounsum.setInsertTime(new Date());
                courseCounsum.setReason("社区世界杯报名");
                courseCounsum.setAppUserId(coursePackageOrderStudent.getAppUserId());
                courseCounsumService.save(courseCounsum);
            }
            return true;
            return deductionClassHourList;
        }catch (Exception e){
            e.printStackTrace();
        }
        return false;
        return null;
    }
    /**
     * 回退课时和回退排课数据
     * @param deductionClassHourList
     */
    @Override
    public void backspaceClassHour(DeductionClassHourList deductionClassHourList) {
        List<DeductionClassHour> list = deductionClassHourList.getDeductionClassHourList();
        for (DeductionClassHour deductionClassHour : list) {
            CoursePackageOrderStudent coursePackageOrderStudent = this.getById(deductionClassHour.getId());
            Integer laveClassHours = coursePackageOrderStudent.getLaveClassHours();
            coursePackageOrderStudent.setLaveClassHours(coursePackageOrderStudent.getLaveClassHours() + deductionClassHour.getClassHour());
            //需要排课的节数
            Integer scheduledCourses = deductionClassHour.getScheduledCourses();
//            coursePackageService
        }
    }
}