|  | @@ -2,17 +2,13 @@ package com.ym.mec.web.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dao.ClassGroupDao;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dao.EmployeeDao;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dao.TeacherDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.ClassDateAdjustDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.VipGroupApplyBaseInfoDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dto.VipGroupApplyDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.StudentApplyRefunds.StudentApplyRefundsStatus;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.enums.AuditStatusEnum;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.enums.VipGroupStatusEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.VipGroupAttendanceQueryInfo;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.VipGroupQueryInfo;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.VipGroupSalaryQueryInfo;
 | 
	
	
		
			
				|  | @@ -21,6 +17,7 @@ import com.ym.mec.biz.service.*;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.controller.BaseController;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.HttpResponseResult;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  | +import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  |  import com.yonge.log.model.AuditLogAnnotation;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.Api;
 | 
	
		
			
				|  |  |  import io.swagger.annotations.ApiOperation;
 | 
	
	
		
			
				|  | @@ -56,6 +53,12 @@ public class VipGroupManageController extends BaseController {
 | 
	
		
			
				|  |  |      private EmployeeDao employeeDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private ClassGroupDao classGroupDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ImGroupMemberService imGroupMemberService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ImUserFriendService imUserFriendService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ImGroupService imGroupService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentApplyRefundsService studentApplyRefundsService;
 | 
	
	
		
			
				|  | @@ -64,6 +67,12 @@ public class VipGroupManageController extends BaseController {
 | 
	
		
			
				|  |  |      private StudentPaymentOrderService studentPaymentOrderService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private ClassGroupStudentMapperDao classGroupStudentMapperDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private CourseScheduleDao courseScheduleDao;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @GetMapping("/teacherSalarySettlement")
 | 
	
		
			
				|  |  |      public Object teacherSalarySettlement(){
 | 
	
	
		
			
				|  | @@ -80,22 +89,50 @@ public class VipGroupManageController extends BaseController {
 | 
	
		
			
				|  |  |              if(Objects.isNull(oldVipGroup)){
 | 
	
		
			
				|  |  |                  throw new BizException("此课程组不存在");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            if(!VipGroupStatusEnum.PROGRESS.equals(oldVipGroup.getStatus())&&!VipGroupStatusEnum.PAUSE.equals(oldVipGroup.getStatus())){
 | 
	
		
			
				|  |  | +            if(!VipGroupStatusEnum.PROGRESS.equals(oldVipGroup.getStatus())&&!VipGroupStatusEnum.FINISHED.equals(oldVipGroup.getStatus())&&!VipGroupStatusEnum.PAUSE.equals(oldVipGroup.getStatus())){
 | 
	
		
			
				|  |  |                  throw new BizException("此课程组状态暂不支持修改");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(oldVipGroup.getId().toString(), ClassGroupTypeEnum.VIP.getCode());
 | 
	
		
			
				|  |  | +        if(Objects.isNull(classGroup)){
 | 
	
		
			
				|  |  | +            throw new BizException("课程信息错误");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          if(Objects.isNull(oldVipGroup.getVipGroupActivityId())){
 | 
	
		
			
				|  |  | -            if(VipGroupStatusEnum.PROGRESS.equals(vipGroup.getStatus())&&oldVipGroup.getStatus().getCode()>VipGroupStatusEnum.PROGRESS.getCode()){
 | 
	
		
			
				|  |  | +            if(VipGroupStatusEnum.PROGRESS.equals(vipGroup.getStatus())&&!VipGroupStatusEnum.FINISHED.equals(oldVipGroup.getStatus())&&oldVipGroup.getStatus().getCode()>VipGroupStatusEnum.PROGRESS.getCode()){
 | 
	
		
			
				|  |  |                  throw new BizException("此课程组状态暂不支持修改");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            ClassGroup classGroup = classGroupDao.findByMusicGroupAndType(oldVipGroup.getId().toString(), ClassGroupTypeEnum.VIP.getCode());
 | 
	
		
			
				|  |  | -            if(Objects.isNull(classGroup)){
 | 
	
		
			
				|  |  | -                throw new BizException("课程信息错误");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  |              if(classGroup.getStudentNum()<3){
 | 
	
		
			
				|  |  |                  throw new BizException("班级人数未达到3人");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        Date now = new Date();
 | 
	
		
			
				|  |  | +        if(VipGroupStatusEnum.FINISHED.equals(oldVipGroup.getStatus())&&(vipGroup.getCoursesExpireDate().compareTo(now)>=0|| DateUtil.isSameDay(vipGroup.getCoursesExpireDate(), now))){
 | 
	
		
			
				|  |  | +            vipGroup.setStatus(VipGroupStatusEnum.PROGRESS);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            Map<Integer,String> userRoleMap = new HashMap<>();
 | 
	
		
			
				|  |  | +            if(Objects.nonNull(vipGroup.getEducationalTeacherId())){
 | 
	
		
			
				|  |  | +                userRoleMap.put(vipGroup.getEducationalTeacherId(),"乐团主管");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            CourseSchedule lastCourse = courseScheduleDao.findLastCourseWithGroup(vipGroup.getId().toString(), GroupType.VIP);
 | 
	
		
			
				|  |  | +            if(Objects.isNull(lastCourse)){
 | 
	
		
			
				|  |  | +                userRoleMap.put(vipGroup.getUserId(),"指导老师");
 | 
	
		
			
				|  |  | +            }else{
 | 
	
		
			
				|  |  | +                userRoleMap.put(lastCourse.getActualTeacherId(),"指导老师");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findByClassGroup(classGroup.getId());
 | 
	
		
			
				|  |  | +            if(!CollectionUtils.isEmpty(classGroupStudents)){
 | 
	
		
			
				|  |  | +                //生成学生单课缴费信息
 | 
	
		
			
				|  |  | +                for (ClassGroupStudentMapper classGroupStudent : classGroupStudents) {
 | 
	
		
			
				|  |  | +                    userRoleMap.put(classGroupStudent.getUserId(),null);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            imGroupService.create(classGroup.getId().longValue(), null, classGroup.getName(), classGroup.getName(), vipGroup.getName(), null, null, GroupType.VIP.getCode());
 | 
	
		
			
				|  |  | +            imGroupMemberService.join(classGroup.getId().longValue(), userRoleMap);
 | 
	
		
			
				|  |  | +            imUserFriendService.refreshGroupImUserFriend(classGroup.getMusicGroupId(),classGroup.getGroupType());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          vipGroupService.update(vipGroup);
 | 
	
		
			
				|  |  |          return succeed();
 | 
	
		
			
				|  |  |      }
 |