|
|
@@ -134,6 +134,10 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
private SysCouponCodeService sysCouponCodeService;
|
|
|
@Autowired
|
|
|
private VipGroupActivityDao vipGroupActivityDao;
|
|
|
+ @Autowired
|
|
|
+ private ActivityUserMapperDao activityUserMapperDao;
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
|
|
|
|
|
|
private static Map<Integer, Map<Integer, List<Integer>>> schoolSubjectTeachersMap;
|
|
|
|
|
|
@@ -4513,4 +4517,222 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
sysMessageService.batchSeoMessage(userIds,MessageTypeEnum.BACKSTAGE_TEACHER_APPLY_PRACTICE, JSONObject.toJSONString(memo),teacher.getRealName());
|
|
|
return BaseController.succeed(applyBaseInfoDto.getAuditStatus().getCode());
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
|
|
|
+ public Object createActivityPracticeGroup(PracticeGroupApplyDto practice) {
|
|
|
+ PracticeGroupApplyBaseInfoDto applyBaseInfo = practice.getPracticeGroupApplyBaseInfoDto();
|
|
|
+ if(applyBaseInfo.getVipGroupActivityId() == null){
|
|
|
+ throw new BizException("请选择活动");
|
|
|
+ }
|
|
|
+ VipGroupActivity activity = vipGroupActivityDao.get(applyBaseInfo.getVipGroupActivityId());
|
|
|
+ if (Objects.isNull(activity)){
|
|
|
+ throw new BizException("活动信息不存在");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(applyBaseInfo.getUserId())){
|
|
|
+ throw new BizException("请选择指导老师");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CourseSchedule> courseSchedules = practice.getCourseSchedules();
|
|
|
+ if(courseSchedules.size() != applyBaseInfo.getAllCourseNum()){
|
|
|
+ throw new BizException("建课失败,当前课程存在未排课课程,请调整相关设置");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(applyBaseInfo.getSubjectId() == null){
|
|
|
+ throw new BizException("请选择声部");
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer studentId = applyBaseInfo.getStudentId();
|
|
|
+ if(studentId == null){
|
|
|
+ throw new BizException("请选择学员");
|
|
|
+ }
|
|
|
+ Boolean giveFlag = practice.getGiveFlag();
|
|
|
+ //获取学员排课资格
|
|
|
+ List<ActivityUserMapper> activityUserMappers = activityUserMapperDao.findByStudentIdList(activity.getId(),studentId.toString(),giveFlag?"GIVE_PRACTICE":"PRACTICE");
|
|
|
+ if(activityUserMappers.size() == 0){
|
|
|
+ throw new BizException("所选学员暂无排课资格");
|
|
|
+ }
|
|
|
+ Date now = new Date();
|
|
|
+
|
|
|
+ //获取第一节课
|
|
|
+ CourseSchedule firstCourseSchedule = courseSchedules.stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
|
|
|
+ //获取最后一节课
|
|
|
+ CourseSchedule latestCourseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
|
|
|
+
|
|
|
+ if(firstCourseSchedule.getStartClassTime().before(now)){
|
|
|
+ throw new BizException("开课时间不能小于当前时间");
|
|
|
+ }
|
|
|
+
|
|
|
+ applyBaseInfo.setRegistrationStartTime(now);
|
|
|
+ applyBaseInfo.setPaymentExpireDate(now);
|
|
|
+
|
|
|
+ if(applyBaseInfo.getRegistrationStartTime().after(applyBaseInfo.getPaymentExpireDate())){
|
|
|
+ throw new BizException("报名开始时间必须在报名截至时间之前");
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断课程安排是否超出范围
|
|
|
+ if((Objects.nonNull(activity.getCoursesEndTime()) || Objects.nonNull(activity.getCoursesStartTime()))){
|
|
|
+ if(latestCourseSchedule.getEndClassTime().after(activity.getCoursesEndTime())
|
|
|
+ ||firstCourseSchedule.getStartClassTime().before(activity.getCoursesStartTime())){
|
|
|
+ throw new BizException("课时安排时间超出范围!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer allCourseNum = applyBaseInfo.getAllCourseNum();
|
|
|
+ if(Objects.nonNull(activity.getMinCourseNum()) && activity.getMinCourseNum() != -1 && Objects.nonNull(activity.getMaxCourseNum())
|
|
|
+ && activity.getMaxCourseNum()!=-1){
|
|
|
+ if(allCourseNum.compareTo(activity.getMinCourseNum())<0 || allCourseNum.compareTo(activity.getMaxCourseNum())>0){
|
|
|
+ throw new BizException("该活动课时数为{}节~{}节", activity.getMinCourseNum(), activity.getMaxCourseNum());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ int repeatVipGroups = practiceGroupDao.countUserRepeatPracticeGroupInCourseStartEndTime(applyBaseInfo.getUserId(), firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
|
|
|
+ if(repeatVipGroups>0){
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(applyBaseInfo.getUserId());
|
|
|
+ throw new BizException("{}课程时间冲突({}-{})", sysUser.getRealName(), DateUtil.dateToString(firstCourseSchedule.getStartClassTime(), "yyyy-MM-dd HH:mm:ss"), DateUtil.dateToString(latestCourseSchedule.getEndClassTime(), "HH:mm:ss"));
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成网管课信息
|
|
|
+ Subject subject = subjectDao.get(applyBaseInfo.getSubjectId());
|
|
|
+ Student student = studentDao.get(studentId);
|
|
|
+ StringBuffer className = new StringBuffer(subject.getName()).append("•").append(student.getUsername());
|
|
|
+ applyBaseInfo.setName(className.toString());
|
|
|
+ applyBaseInfo.setAuditStatus(AuditStatusEnum.PASS);
|
|
|
+ applyBaseInfo.setGroupStatus(GroupStatusEnum.NORMAL);
|
|
|
+
|
|
|
+ Teacher teacher = teacherService.get(applyBaseInfo.getUserId());
|
|
|
+ if(Objects.isNull(teacher)){
|
|
|
+ throw new BizException("教师不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ //开课时间为排课的第一节课的开始时间
|
|
|
+ applyBaseInfo.setCoursesStartDate(firstCourseSchedule.getStartClassTime());
|
|
|
+ //课程结束时间为排课的最后一节课的结束时间
|
|
|
+ applyBaseInfo.setCoursesExpireDate(latestCourseSchedule.getEndClassTime());
|
|
|
+
|
|
|
+ applyBaseInfo.setPaymentExpireDate(DateUtil.getLastSecondWithDay(applyBaseInfo.getPaymentExpireDate()));
|
|
|
+
|
|
|
+ practiceGroupDao.insert(applyBaseInfo);
|
|
|
+
|
|
|
+ //创建班级信息
|
|
|
+ ClassGroup classGroup=new ClassGroup();
|
|
|
+ classGroup.setSubjectIdList(applyBaseInfo.getSubjectId().toString());
|
|
|
+ classGroup.setExpectStudentNum(1);
|
|
|
+ classGroup.setStudentNum(1);
|
|
|
+ classGroup.setName(applyBaseInfo.getName());
|
|
|
+ classGroup.setTotalClassTimes(allCourseNum);
|
|
|
+ classGroup.setType(ClassGroupTypeEnum.PRACTICE);
|
|
|
+ classGroup.setDelFlag(0);
|
|
|
+ classGroup.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroup.setMusicGroupId(applyBaseInfo.getId().toString());
|
|
|
+ classGroup.setCreateTime(now);
|
|
|
+ classGroup.setUpdateTime(now);
|
|
|
+ classGroupDao.insert(classGroup);
|
|
|
+
|
|
|
+ //班级学员关联记录
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudentMapperList = new ArrayList<>();
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
+ classGroupStudentMapper.setMusicGroupId(applyBaseInfo.getId().toString());
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupStudentMapper.setUserId(studentId);
|
|
|
+ classGroupStudentMapper.setCreateTime(now);
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMapper.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroupStudentMapperList.add(classGroupStudentMapper);
|
|
|
+ classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMapperList);
|
|
|
+
|
|
|
+ //计算课程相关费用信息
|
|
|
+ Map<String, BigDecimal> costInfo = countPracticeGroupPredictFee(applyBaseInfo,applyBaseInfo.getUserId(), null);
|
|
|
+ if(practice.getGiveFlag()){
|
|
|
+ applyBaseInfo.setOnlineTeacherSalary(costInfo.get("giveOnlineTeacherSalary"));
|
|
|
+ }else {
|
|
|
+ applyBaseInfo.setOnlineTeacherSalary(costInfo.get("onlineTeacherSalary"));
|
|
|
+ }
|
|
|
+ practiceGroupDao.update(applyBaseInfo);
|
|
|
+
|
|
|
+ //创建班级老师关联记录
|
|
|
+ ClassGroupTeacherMapper classGroupTeacherMapper=new ClassGroupTeacherMapper();
|
|
|
+ classGroupTeacherMapper.setMusicGroupId(applyBaseInfo.getId().toString());
|
|
|
+ classGroupTeacherMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupTeacherMapper.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
+ classGroupTeacherMapper.setUserId(applyBaseInfo.getUserId());
|
|
|
+ classGroupTeacherMapper.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroupTeacherMapper.setCreateTime(now);
|
|
|
+ classGroupTeacherMapper.setUpdateTime(now);
|
|
|
+ classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
|
|
|
+
|
|
|
+ //创建班级与老师课酬记录
|
|
|
+ ClassGroupTeacherSalary classGroupTeacherSalary=new ClassGroupTeacherSalary();
|
|
|
+ classGroupTeacherSalary.setMusicGroupId(applyBaseInfo.getId().toString());
|
|
|
+ classGroupTeacherSalary.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupTeacherSalary.setTeacherRole(TeachTypeEnum.BISHOP);
|
|
|
+ classGroupTeacherSalary.setUserId(applyBaseInfo.getUserId());
|
|
|
+ classGroupTeacherSalary.setSalary(BigDecimal.ZERO);
|
|
|
+ classGroupTeacherSalary.setOnlineClassesSalary(applyBaseInfo.getOnlineTeacherSalary());
|
|
|
+ classGroupTeacherSalary.setGroupType(GroupType.PRACTICE);
|
|
|
+ classGroupTeacherSalary.setCreateTime(now);
|
|
|
+ classGroupTeacherSalary.setUpdateTime(now);
|
|
|
+ classGroupTeacherSalaryDao.insert(classGroupTeacherSalary);
|
|
|
+
|
|
|
+ //课程信息调整
|
|
|
+ courseSchedules.forEach(courseSchedule -> {
|
|
|
+ courseSchedule.setGroupType(GroupType.PRACTICE);
|
|
|
+ courseSchedule.setMusicGroupId(applyBaseInfo.getId().toString());
|
|
|
+ courseSchedule.setTeacherId(applyBaseInfo.getUserId());
|
|
|
+ courseSchedule.setActualTeacherId(applyBaseInfo.getUserId());
|
|
|
+ courseSchedule.setStatus(CourseStatusEnum.NOT_START);
|
|
|
+ courseSchedule.setType(CourseSchedule.CourseScheduleType.PRACTICE);
|
|
|
+ courseSchedule.setClassGroupId(classGroup.getId());
|
|
|
+ courseSchedule.setName(applyBaseInfo.getName());
|
|
|
+ courseSchedule.setOrganId(applyBaseInfo.getOrganId());
|
|
|
+ });
|
|
|
+
|
|
|
+ applyBaseInfo.setCourseScheduleJson(JSON.toJSONString(courseSchedules));
|
|
|
+ practiceGroupDao.update(applyBaseInfo);
|
|
|
+
|
|
|
+ //创建课程
|
|
|
+ courseScheduleService.batchAddCourseSchedule(courseSchedules);
|
|
|
+ //创建老师单节课课酬信息
|
|
|
+ courseScheduleTeacherSalaryService.createCourseScheduleTeacherPracticeSalary(courseSchedules,
|
|
|
+ classGroupTeacherSalary.getOnlineClassesSalary());
|
|
|
+
|
|
|
+ SysUser sysUser = sysUserFeignService.queryUserById(applyBaseInfo.getUserId());
|
|
|
+
|
|
|
+ List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findByClassGroup(classGroup.getId());
|
|
|
+
|
|
|
+ Map<Integer,String> userRoleMap = new HashMap<>();
|
|
|
+ if(Objects.nonNull(applyBaseInfo.getEducationalTeacherId())){
|
|
|
+ userRoleMap.put(applyBaseInfo.getEducationalTeacherId(),"乐团主管");
|
|
|
+ }
|
|
|
+ userRoleMap.put(applyBaseInfo.getUserId(),"指导老师");
|
|
|
+ SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
+ Integer practiceCourseMinutes = practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
+ TeacherDefaultPracticeGroupSalary teacherDefaultPracticeGroupSalary = teacherDefaultPracticeGroupSalaryDao.findByTeacherAndCourseMinutes(applyBaseInfo.getUserId(),practiceCourseMinutes);
|
|
|
+
|
|
|
+ //生成学生单课缴费信息
|
|
|
+ for (ClassGroupStudentMapper classGroupStudent : classGroupStudents) {
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPayments=new ArrayList<>();
|
|
|
+ for (CourseSchedule courseSchedule : courseSchedules) {
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
+ courseScheduleStudentPayment.setUserId(classGroupStudent.getUserId());
|
|
|
+ courseScheduleStudentPayment.setGroupType(courseSchedule.getGroupType());
|
|
|
+ courseScheduleStudentPayment.setMusicGroupId(courseSchedule.getMusicGroupId());
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(courseSchedule.getId());
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(courseSchedule.getClassGroupId());
|
|
|
+ if(practice.getGiveFlag()){
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(BigDecimal.ZERO);
|
|
|
+ courseScheduleStudentPayment.setOriginalPrice(BigDecimal.ZERO);
|
|
|
+ }else {
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(teacherDefaultPracticeGroupSalary.getMainTeacherSalary());
|
|
|
+ courseScheduleStudentPayment.setOriginalPrice(teacherDefaultPracticeGroupSalary.getMainTeacherSalary());
|
|
|
+ }
|
|
|
+ courseScheduleStudentPayment.setActualPrice(courseScheduleStudentPayment.getExpectPrice());
|
|
|
+ courseScheduleStudentPayments.add(courseScheduleStudentPayment);
|
|
|
+ }
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
|
|
|
+ userRoleMap.put(classGroupStudent.getUserId(),null);
|
|
|
+ studentDao.updateStudentServiceTag(classGroupStudent.getUserId(), null, YesOrNoEnum.YES.getCode());
|
|
|
+ }
|
|
|
+ courseScheduleService.checkNewCourseSchedules(courseSchedules, false,false);
|
|
|
+ return BaseController.succeed(applyBaseInfo.getAuditStatus().getCode());
|
|
|
+ }
|
|
|
}
|