|  | @@ -27,6 +27,7 @@ import java.util.Objects;
 | 
	
		
			
				|  |  |  import java.util.Set;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.*;
 | 
	
		
			
				|  |  |  import org.apache.commons.collections.CollectionUtils;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
	
		
			
				|  | @@ -82,20 +83,6 @@ import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.SysUserCashAccountLogDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.TeacherAttendanceDao;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.dao.TeacherDao;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.BasicUserDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.CloseMusicGroupDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.CourseScheduleTeachersDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.HighClassGroupDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.MusicCardDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.MusicGroupApplyGoodsDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.MusicGroupBasicDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.RegisterPayDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.SporadicPayDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.StudentApplyInstrumentDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.StudentImportDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.SubjectRegisterDto;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.UpdateExpectedNumDto;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.ApprovalStatus;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.ChargeType;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.entity.ClassGroup;
 | 
	
	
		
			
				|  | @@ -2348,6 +2335,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          musicGroupQuit.setUserComment(reqMusicGroupQuit.getUserComment());
 | 
	
		
			
				|  |  |          musicGroupQuit.setApplyUserId(userId);
 | 
	
		
			
				|  |  |          musicGroupQuit.setReason(reason);
 | 
	
		
			
				|  |  | +		musicGroupQuit.setReasonEnum(reqMusicGroupQuit.getReasonEnum());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          MusicGroupReturnFeeDto returnFeeDto = reqMusicGroupQuit.getReturnFeeDto();
 | 
	
		
			
				|  |  |          if (returnFeeDto != null) {
 | 
	
	
		
			
				|  | @@ -2761,11 +2749,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | -    public boolean directQuitMusicGroup(String musicGroupId, Integer userId, String reason, boolean isRefundCourseFee, boolean isRefundInstrumentFee,
 | 
	
		
			
				|  |  | -                                        boolean isRefundTeachingAssistantsFee, boolean isRefundMemberFee, BigDecimal maintenanceFee) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        SysUser sysUser = sysUserFeignService.queryUserById(userId);
 | 
	
		
			
				|  |  | +    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | +    public boolean directQuitMusicGroup(MusicGroupQuitDto musicGroupQuitDto) {
 | 
	
		
			
				|  |  | +		Integer userId = musicGroupQuitDto.getUserId();
 | 
	
		
			
				|  |  | +		String musicGroupId = musicGroupQuitDto.getMusicGroupId();
 | 
	
		
			
				|  |  | +		SysUser sysUser = sysUserFeignService.queryUserById(userId);
 | 
	
		
			
				|  |  |          if (sysUser == null) {
 | 
	
		
			
				|  |  |              throw new BizException("获取用户信息失败");
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -2815,21 +2803,20 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          MusicGroupQuit musicGroupQuit = musicGroupQuitDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
 | 
	
		
			
				|  |  |          if (musicGroupQuit != null && musicGroupQuit.getStatus() == PROCESSING) {
 | 
	
		
			
				|  |  |              musicGroupQuit.setStatus(ApprovalStatus.APPROVED);
 | 
	
		
			
				|  |  | -            musicGroupQuit.setReason(reason);
 | 
	
		
			
				|  |  | +            musicGroupQuit.setReason(musicGroupQuitDto.getReason());
 | 
	
		
			
				|  |  | +			musicGroupQuit.setReasonEnum(musicGroupQuitDto.getReasonEnum());
 | 
	
		
			
				|  |  |              musicGroupQuit.setQuitDate(date);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              musicGroupQuitDao.update(musicGroupQuit);
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              musicGroupQuit = new MusicGroupQuit();
 | 
	
		
			
				|  |  |              musicGroupQuit.setCreateTime(date);
 | 
	
		
			
				|  |  |              musicGroupQuit.setJoinDate(studentRegistration.getCreateTime());
 | 
	
		
			
				|  |  |              musicGroupQuit.setMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  |              musicGroupQuit.setUserId(sysUser.getId());
 | 
	
		
			
				|  |  |              musicGroupQuit.setStatus(ApprovalStatus.APPROVED);
 | 
	
		
			
				|  |  | -            musicGroupQuit.setReason(reason);
 | 
	
		
			
				|  |  | +			musicGroupQuit.setReason(musicGroupQuitDto.getReason());
 | 
	
		
			
				|  |  | +			musicGroupQuit.setReasonEnum(musicGroupQuitDto.getReasonEnum());
 | 
	
		
			
				|  |  |              musicGroupQuit.setQuitDate(date);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              musicGroupQuitDao.insert(musicGroupQuit);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2854,20 +2841,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          studentRegistration.setUpdateTime(date);
 | 
	
		
			
				|  |  |          studentRegistrationDao.update(studentRegistration);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        //更新服务指标、运营指标
 | 
	
		
			
				|  |  | -        /*int remainCourseNum = courseScheduleStudentPaymentDao.countStudentNotStartCourseNumWithCourseType(userId, null);
 | 
	
		
			
				|  |  | -        if (remainCourseNum == 0) {
 | 
	
		
			
				|  |  | -            Student student = studentDao.get(userId);
 | 
	
		
			
				|  |  | -            if (student == null) {
 | 
	
		
			
				|  |  | -                throw new BizException("学生信息查询失败");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            student.setServiceTag(0);
 | 
	
		
			
				|  |  | -            student.setOperatingTag(0);
 | 
	
		
			
				|  |  | -            student.setOperatingTempTag(0);
 | 
	
		
			
				|  |  | -            student.setUpdateTime(date);
 | 
	
		
			
				|  |  | -            studentDao.update(student);
 | 
	
		
			
				|  |  | -        }*/
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          //删除进行中加学生,且在审批中或拒绝的缴费
 | 
	
		
			
				|  |  |          List<Long> paymentCalenderIdList = musicGroupPaymentCalenderDao.findStudentNoPaymentCalender(userId, musicGroupId);
 | 
	
		
			
				|  |  |          if (paymentCalenderIdList != null && paymentCalenderIdList.size() > 0) {
 | 
	
	
		
			
				|  | @@ -2935,64 +2908,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              //统计变更学员数
 | 
	
		
			
				|  |  |              groupEventSource.musicGroupStudentChangeEvent(musicGroupId, StudentMusicGroupStatusEnum.QUIT, new ArrayList<>(Arrays.asList(userId)));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -/*
 | 
	
		
			
				|  |  | -        if (isRefundMemberFee){
 | 
	
		
			
				|  |  | -            if(musicGroup.getCourseViewType() != CourseViewTypeEnum.MEMBER_FEE){
 | 
	
		
			
				|  |  | -                throw new BizException("非会员乐团不允许退云教练");
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            //删除乐团会员时长
 | 
	
		
			
				|  |  | -            studentRegistrationDao.cleanMusicMember(userId,musicGroupId);
 | 
	
		
			
				|  |  | -            //退云教练费用
 | 
	
		
			
				|  |  | -            if (cloudTeacherAmount != null) {
 | 
	
		
			
				|  |  | -                Date nowDate = new Date();
 | 
	
		
			
				|  |  | -                List<CloudTeacherOrder> cloudTeacherOrders = cloudTeacherOrderService.getStudentCloudTeacherOrder(userId,musicGroupId);
 | 
	
		
			
				|  |  | -                BigDecimal orderAmount = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | -                Student student = studentDao.get(userId);
 | 
	
		
			
				|  |  | -                if(cloudTeacherOrders.size() > 0){
 | 
	
		
			
				|  |  | -                    Integer subMemberDay = 0;
 | 
	
		
			
				|  |  | -                    List<CloudTeacherOrder> quitCloudTeacherOrders = new ArrayList<>();
 | 
	
		
			
				|  |  | -                    for (CloudTeacherOrder cloudTeacherOrder : cloudTeacherOrders) {
 | 
	
		
			
				|  |  | -                        if (cloudTeacherOrder.getEndTime() == null || DateUtil.stringToDate(DateUtil.format(cloudTeacherOrder.getEndTime(),DateUtil.ISO_EXPANDED_DATE_FORMAT),DateUtil.ISO_EXPANDED_DATE_FORMAT).compareTo(
 | 
	
		
			
				|  |  | -                                DateUtil.stringToDate(DateUtil.format(nowDate,DateUtil.ISO_EXPANDED_DATE_FORMAT),DateUtil.ISO_EXPANDED_DATE_FORMAT)) >= 0) {
 | 
	
		
			
				|  |  | -                            quitCloudTeacherOrders.add(cloudTeacherOrder);
 | 
	
		
			
				|  |  | -                            orderAmount = orderAmount.add(cloudTeacherOrder.getAmount());
 | 
	
		
			
				|  |  | -                            subMemberDay =  subMemberDay + DateUtil.daysBetween(cloudTeacherOrder.getStartTime(), cloudTeacherOrder.getEndTime());
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                    cloudTeacherOrderService.quitCloudTeacherOrders(quitCloudTeacherOrders, cloudTeacherAmount);
 | 
	
		
			
				|  |  | -                    Date memberEndTime = DateUtil.addDays(studentRegistration.getMembershipEndTime(), subMemberDay);
 | 
	
		
			
				|  |  | -                    if(memberEndTime.compareTo(nowDate) < 0){
 | 
	
		
			
				|  |  | -                        //清除学员云教练
 | 
	
		
			
				|  |  | -                        studentService.cleanMember(userId);
 | 
	
		
			
				|  |  | -                        //如果有试用会员,不清除
 | 
	
		
			
				|  |  | -                        if(student.getExperienceMemberRankSettingId() != null){
 | 
	
		
			
				|  |  | -                            student.setMemberRankSettingId(student.getExperienceMemberRankSettingId());
 | 
	
		
			
				|  |  | -                            student.setMembershipStartTime(student.getExperienceMembershipStartTime());
 | 
	
		
			
				|  |  | -                            student.setMembershipEndTime(student.getExperienceMembershipEndTime());
 | 
	
		
			
				|  |  | -                            studentDao.update(student);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }else {
 | 
	
		
			
				|  |  | -                        if(student.getExperienceMemberRankSettingId() != null){
 | 
	
		
			
				|  |  | -                            if(memberEndTime.compareTo(student.getExperienceMembershipEndTime()) > 0){
 | 
	
		
			
				|  |  | -                                student.setMembershipEndTime(memberEndTime);
 | 
	
		
			
				|  |  | -                            }else {
 | 
	
		
			
				|  |  | -                                student.setMembershipEndTime(student.getExperienceMembershipEndTime());
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                            studentDao.update(student);
 | 
	
		
			
				|  |  | -                        }
 | 
	
		
			
				|  |  | -                    }
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if (cloudTeacherAmount.compareTo(orderAmount) > 0) {
 | 
	
		
			
				|  |  | -                    throw new BizException("云教练退费金额不能大于原始订单金额");
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                amount = amount.add(cloudTeacherAmount);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }else {
 | 
	
		
			
				|  |  | -            //删除乐团会员时长
 | 
	
		
			
				|  |  | -            studentRegistrationDao.cleanMusicMember(userId,musicGroupId);
 | 
	
		
			
				|  |  | -        }*/
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        if (isRefundCourseFee) {
 | 
	
		
			
				|  |  | +        if (musicGroupQuitDto.getIsRefundCourseFee()) {
 | 
	
		
			
				|  |  |              // 退课程费用
 | 
	
		
			
				|  |  |              amount = amount.add(surplusCourseFee);
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -3006,12 +2922,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.getWithIds(paymentOrderIdList);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              SubjectChange studentLastChange = null;
 | 
	
		
			
				|  |  | -            if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
 | 
	
		
			
				|  |  | +            if (musicGroupQuitDto.getIsRefundInstrumentFee() || musicGroupQuitDto.getIsRefundTeachingAssistantsFee()) {
 | 
	
		
			
				|  |  |                  studentLastChange = subjectChangeDao.getStudentLastChange(userId, musicGroupId);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (studentLastChange != null && minPaymentOrderId <= studentLastChange.getOriginalOrderId()) {
 | 
	
		
			
				|  |  | -                if (isRefundInstrumentFee) {
 | 
	
		
			
				|  |  | +                if (musicGroupQuitDto.getIsRefundInstrumentFee()) {
 | 
	
		
			
				|  |  |                      amount = amount.add(studentLastChange.getChangeMusicalPrice());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      StudentInstrument studentMaintenance = studentInstrumentDao.getByOrderId(studentLastChange.getOrderId().longValue());
 | 
	
	
		
			
				|  | @@ -3021,14 +2937,14 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -                if (isRefundTeachingAssistantsFee) {
 | 
	
		
			
				|  |  | +                if (musicGroupQuitDto.getIsRefundTeachingAssistantsFee()) {
 | 
	
		
			
				|  |  |                      amount = amount.add(studentLastChange.getChangeAccessoriesPrice());
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  for (StudentPaymentOrderDetail detail : orderDetailList) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      // 退乐器费用
 | 
	
		
			
				|  |  | -                    if (isRefundInstrumentFee && detail.getType() == MUSICAL) {
 | 
	
		
			
				|  |  | +                    if (musicGroupQuitDto.getIsRefundInstrumentFee() && detail.getType() == MUSICAL) {
 | 
	
		
			
				|  |  |                          amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                          StudentInstrument studentMaintenance = studentInstrumentDao.getStudentMaintenance(userId, musicGroupId);
 | 
	
	
		
			
				|  | @@ -3039,7 +2955,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      // 退教辅费用
 | 
	
		
			
				|  |  | -                    if (isRefundTeachingAssistantsFee
 | 
	
		
			
				|  |  | +                    if (musicGroupQuitDto.getIsRefundTeachingAssistantsFee()
 | 
	
		
			
				|  |  |                              && (detail.getType() == ACCESSORIES || detail.getType() == TEACHING)) {
 | 
	
		
			
				|  |  |                          amount = amount.add(detail.getPrice()).subtract(detail.getRemitFee());
 | 
	
		
			
				|  |  |                      }
 | 
	
	
		
			
				|  | @@ -3049,15 +2965,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //退乐保费用
 | 
	
		
			
				|  |  | -        if (maintenanceFee != null) {
 | 
	
		
			
				|  |  | +        if (musicGroupQuitDto.getMaintenanceFee() != null) {
 | 
	
		
			
				|  |  |              StudentInstrument studentMaintenance = studentInstrumentDao.getStudentMaintenance(userId, musicGroupId);
 | 
	
		
			
				|  |  | -            if (maintenanceFee.compareTo(BigDecimal.ZERO) > 0) {
 | 
	
		
			
				|  |  | +            if (musicGroupQuitDto.getMaintenanceFee().compareTo(BigDecimal.ZERO) > 0) {
 | 
	
		
			
				|  |  |                  if (studentMaintenance == null) {
 | 
	
		
			
				|  |  |                      throw new BizException("学生没有有效期内的乐保,不能退乐保费用");
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            amount = amount.add(maintenanceFee);
 | 
	
		
			
				|  |  | -            if (maintenanceFee.compareTo(BigDecimal.ZERO) > 0 && studentMaintenance != null) {
 | 
	
		
			
				|  |  | +            amount = amount.add(musicGroupQuitDto.getMaintenanceFee());
 | 
	
		
			
				|  |  | +            if (musicGroupQuitDto.getMaintenanceFee().compareTo(BigDecimal.ZERO) > 0 && studentMaintenance != null) {
 | 
	
		
			
				|  |  |                  studentMaintenance.setStatus(0);
 | 
	
		
			
				|  |  |                  studentMaintenance.setStartTime(null);
 | 
	
		
			
				|  |  |                  studentMaintenance.setEndTime(null);
 |