|  | @@ -102,6 +102,7 @@ import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.collection.MapUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.http.HttpUtil;
 | 
	
		
			
				|  |  | +import org.springframework.util.Assert;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> implements MusicGroupService {
 | 
	
	
		
			
				|  | @@ -243,7 +244,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |      private SubjectDao subjectDao;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private SysUserCashAccountDao sysUserCashAccountDao;
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private StudentPreRegistrationDao studentPreRegistrationDao;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -284,7 +285,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          if (musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT) {
 | 
	
		
			
				|  |  |              Set<Integer> roleIds = new HashSet<>(1);
 | 
	
		
			
				|  |  |              roleIds.add(SysUserRole.SECTION_MANAGER);
 | 
	
		
			
				|  |  | -            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getUsername());
 | 
	
		
			
				|  |  | +            sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(),musicGroup.getName());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 保存乐团付费主体列表
 | 
	
		
			
				|  |  |          //批量新增
 | 
	
	
		
			
				|  | @@ -376,112 +377,112 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  | -	public boolean preRegister(StudentPreRegistration studentPreRegistration) {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		String musicGroupId = studentPreRegistration.getMusicGroupId();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		// 查询乐团状态
 | 
	
		
			
				|  |  | -		MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 | 
	
		
			
				|  |  | -		if (musicGroup == null) {
 | 
	
		
			
				|  |  | -			throw new BizException("乐团信息查询失败");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		if (musicGroup.getStatus() != MusicGroupStatusEnum.PRE_APPLY) {
 | 
	
		
			
				|  |  | -			throw new BizException("乐团当前状态不能预报名");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		StudentPreRegistration originRegistration = studentPreRegistrationDao.queryByMusicGroupIdAndPhone(studentPreRegistration.getPhone(), musicGroupId);
 | 
	
		
			
				|  |  | -		if (originRegistration != null) {
 | 
	
		
			
				|  |  | -			throw new BizException("您已预报名成功,请勿重复提交资料");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		Date date = new Date();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		// 判断用户是否存在
 | 
	
		
			
				|  |  | -		SysUser user = sysUserFeignService.queryUserByMobile(studentPreRegistration.getPhone());
 | 
	
		
			
				|  |  | -		if (user == null || user.getId() == null) {
 | 
	
		
			
				|  |  | -			user = new SysUser();
 | 
	
		
			
				|  |  | -			user.setPhone(studentPreRegistration.getPhone());
 | 
	
		
			
				|  |  | -			user.setUsername(studentPreRegistration.getUserName());
 | 
	
		
			
				|  |  | -			user.setOrganId(musicGroup.getOrganId());
 | 
	
		
			
				|  |  | -			user.setUserType("STUDENT");
 | 
	
		
			
				|  |  | -			user.setCreateTime(date);
 | 
	
		
			
				|  |  | -			user.setUpdateTime(date);
 | 
	
		
			
				|  |  | -			// 注册账户信息
 | 
	
		
			
				|  |  | -			HttpResponseResult<Integer> result = sysUserFeignService.addUser(user);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -			Integer userId = result.getData();
 | 
	
		
			
				|  |  | -			user.setId(userId);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -			Student student = new Student();
 | 
	
		
			
				|  |  | -			student.setUserId(userId);
 | 
	
		
			
				|  |  | -			student.setCreateTime(date);
 | 
	
		
			
				|  |  | -			student.setUpdateTime(date);
 | 
	
		
			
				|  |  | -			student.setIsNewUser(true);
 | 
	
		
			
				|  |  | -			studentDao.insert(student);
 | 
	
		
			
				|  |  | -			sysUserCashAccountDao.insert(new SysUserCashAccount(userId, "CNY"));
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		studentPreRegistration.setCreateTime(date);
 | 
	
		
			
				|  |  | -		studentPreRegistration.setUserId(user.getId());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		studentPreRegistrationDao.insert(studentPreRegistration);
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		// 添加成员
 | 
	
		
			
				|  |  | -		imGroupMemberService.join(Long.parseLong(musicGroupId), user.getId(), null, false);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		return true;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	public boolean finishPreApply(String musicGroupId, boolean isCheckStudentNum) {
 | 
	
		
			
				|  |  | -		MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 | 
	
		
			
				|  |  | -		if (musicGroup == null) {
 | 
	
		
			
				|  |  | -			throw new BizException("乐团信息查询失败");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		if (musicGroup.getStatus() != MusicGroupStatusEnum.PRE_APPLY) {
 | 
	
		
			
				|  |  | -			throw new BizException("操作失败:只有乐团在[{}]状态才能操作", MusicGroupStatusEnum.PRE_APPLY.getMsg());
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		if (isCheckStudentNum) {
 | 
	
		
			
				|  |  | -			// 查询乐团已报名人数
 | 
	
		
			
				|  |  | -			List<StudentPreRegistration> studentPreRegistrationList = studentPreRegistrationDao.queryByMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  | -			if (studentPreRegistrationList == null || studentPreRegistrationList.size() < 120) {
 | 
	
		
			
				|  |  | -				throw new BizException("操作失败:报名人数没有达到120人");
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		musicGroup.setStatus(MusicGroupStatusEnum.PRE_BUILD_FEE);
 | 
	
		
			
				|  |  | -		musicGroup.setUpdateTime(new Date());
 | 
	
		
			
				|  |  | -		musicGroupDao.update(musicGroup);
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | -		if(sysUser == null || sysUser.getId() == null){
 | 
	
		
			
				|  |  | -			throw new BizException("请重新登录");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		//记录操作日志
 | 
	
		
			
				|  |  | -		musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目失败(预报名 -> 准备创建缴费)", sysUser.getId(), ""));
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		return true;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | -	public boolean sendParentMeetingNotice(Integer userId, String musicGroupId, Date meetingDate, String address) {
 | 
	
		
			
				|  |  | -		MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 | 
	
		
			
				|  |  | -		if (musicGroup == null) {
 | 
	
		
			
				|  |  | -			throw new BizException("乐团信息查询失败");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		if (musicGroup.getStatus() != MusicGroupStatusEnum.PRE_APPLY) {
 | 
	
		
			
				|  |  | -			throw new BizException("操作失败:只有乐团在[{}]状态才能操作", MusicGroupStatusEnum.PRE_APPLY.getMsg());
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		List<StudentPreRegistration> studentPreRegistrationList = studentPreRegistrationDao.queryByMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  | -		Map<Integer,String> receiverList = studentPreRegistrationList.stream().collect(Collectors.toMap(StudentPreRegistration :: getUserId, StudentPreRegistration :: getPhone));
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -		String meetingDateStr = sdf_ymdhms.format(meetingDate);
 | 
	
		
			
				|  |  | -		sysMessageService.batchSendImGroupMessage(MessageTypeEnum.SMS_MUSIC_GROUP_PARENT_MEETING_NOTICE, userId + "", null, new String[]{musicGroupId}, null, meetingDateStr, address);
 | 
	
		
			
				|  |  | -		sysMessageService.batchSendMessage(MessageSender.AWSMS, MessageTypeEnum.SMS_MUSIC_GROUP_PARENT_MEETING_NOTICE, receiverList, null, 1, null, null, meetingDateStr, address);
 | 
	
		
			
				|  |  | -		return true;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | +    public boolean preRegister(StudentPreRegistration studentPreRegistration) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String musicGroupId = studentPreRegistration.getMusicGroupId();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 查询乐团状态
 | 
	
		
			
				|  |  | +        MusicGroup musicGroup = musicGroupDao.getLocked(musicGroupId);
 | 
	
		
			
				|  |  | +        if (musicGroup == null) {
 | 
	
		
			
				|  |  | +            throw new BizException("乐团信息查询失败");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (musicGroup.getStatus() != MusicGroupStatusEnum.PRE_APPLY) {
 | 
	
		
			
				|  |  | +            throw new BizException("乐团当前状态不能预报名");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        StudentPreRegistration originRegistration = studentPreRegistrationDao.queryByMusicGroupIdAndPhone(studentPreRegistration.getPhone(), musicGroupId);
 | 
	
		
			
				|  |  | +        if (originRegistration != null) {
 | 
	
		
			
				|  |  | +            throw new BizException("您已预报名成功,请勿重复提交资料");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Date date = new Date();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 判断用户是否存在
 | 
	
		
			
				|  |  | +        SysUser user = sysUserFeignService.queryUserByMobile(studentPreRegistration.getPhone());
 | 
	
		
			
				|  |  | +        if (user == null || user.getId() == null) {
 | 
	
		
			
				|  |  | +            user = new SysUser();
 | 
	
		
			
				|  |  | +            user.setPhone(studentPreRegistration.getPhone());
 | 
	
		
			
				|  |  | +            user.setUsername(studentPreRegistration.getUserName());
 | 
	
		
			
				|  |  | +            user.setOrganId(musicGroup.getOrganId());
 | 
	
		
			
				|  |  | +            user.setUserType("STUDENT");
 | 
	
		
			
				|  |  | +            user.setCreateTime(date);
 | 
	
		
			
				|  |  | +            user.setUpdateTime(date);
 | 
	
		
			
				|  |  | +            // 注册账户信息
 | 
	
		
			
				|  |  | +            HttpResponseResult<Integer> result = sysUserFeignService.addUser(user);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            Integer userId = result.getData();
 | 
	
		
			
				|  |  | +            user.setId(userId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            Student student = new Student();
 | 
	
		
			
				|  |  | +            student.setUserId(userId);
 | 
	
		
			
				|  |  | +            student.setCreateTime(date);
 | 
	
		
			
				|  |  | +            student.setUpdateTime(date);
 | 
	
		
			
				|  |  | +            student.setIsNewUser(true);
 | 
	
		
			
				|  |  | +            studentDao.insert(student);
 | 
	
		
			
				|  |  | +            sysUserCashAccountDao.insert(new SysUserCashAccount(userId, "CNY"));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        studentPreRegistration.setCreateTime(date);
 | 
	
		
			
				|  |  | +        studentPreRegistration.setUserId(user.getId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        studentPreRegistrationDao.insert(studentPreRegistration);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 添加成员
 | 
	
		
			
				|  |  | +        imGroupMemberService.join(Long.parseLong(musicGroupId), user.getId(), null, false);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return true;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public boolean finishPreApply(String musicGroupId, boolean isCheckStudentNum) {
 | 
	
		
			
				|  |  | +        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 | 
	
		
			
				|  |  | +        if (musicGroup == null) {
 | 
	
		
			
				|  |  | +            throw new BizException("乐团信息查询失败");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (musicGroup.getStatus() != MusicGroupStatusEnum.PRE_APPLY) {
 | 
	
		
			
				|  |  | +            throw new BizException("操作失败:只有乐团在[{}]状态才能操作", MusicGroupStatusEnum.PRE_APPLY.getMsg());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (isCheckStudentNum) {
 | 
	
		
			
				|  |  | +            // 查询乐团已报名人数
 | 
	
		
			
				|  |  | +            List<StudentPreRegistration> studentPreRegistrationList = studentPreRegistrationDao.queryByMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  | +            if (studentPreRegistrationList == null || studentPreRegistrationList.size() < 120) {
 | 
	
		
			
				|  |  | +                throw new BizException("操作失败:报名人数没有达到120人");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        musicGroup.setStatus(MusicGroupStatusEnum.PRE_BUILD_FEE);
 | 
	
		
			
				|  |  | +        musicGroup.setUpdateTime(new Date());
 | 
	
		
			
				|  |  | +        musicGroupDao.update(musicGroup);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | +        if (sysUser == null || sysUser.getId() == null) {
 | 
	
		
			
				|  |  | +            throw new BizException("请重新登录");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //记录操作日志
 | 
	
		
			
				|  |  | +        musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroup.getId(), "报名缴费项目失败(预报名 -> 准备创建缴费)", sysUser.getId(), ""));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        return true;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  | +    public boolean sendParentMeetingNotice(Integer userId, String musicGroupId, Date meetingDate, String address) {
 | 
	
		
			
				|  |  | +        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 | 
	
		
			
				|  |  | +        if (musicGroup == null) {
 | 
	
		
			
				|  |  | +            throw new BizException("乐团信息查询失败");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (musicGroup.getStatus() != MusicGroupStatusEnum.PRE_APPLY) {
 | 
	
		
			
				|  |  | +            throw new BizException("操作失败:只有乐团在[{}]状态才能操作", MusicGroupStatusEnum.PRE_APPLY.getMsg());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<StudentPreRegistration> studentPreRegistrationList = studentPreRegistrationDao.queryByMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  | +        Map<Integer, String> receiverList = studentPreRegistrationList.stream().collect(Collectors.toMap(StudentPreRegistration::getUserId, StudentPreRegistration::getPhone));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        String meetingDateStr = sdf_ymdhms.format(meetingDate);
 | 
	
		
			
				|  |  | +        sysMessageService.batchSendImGroupMessage(MessageTypeEnum.SMS_MUSIC_GROUP_PARENT_MEETING_NOTICE, userId + "", null, new String[]{musicGroupId}, null, meetingDateStr, address);
 | 
	
		
			
				|  |  | +        sysMessageService.batchSendMessage(MessageSender.AWSMS, MessageTypeEnum.SMS_MUSIC_GROUP_PARENT_MEETING_NOTICE, receiverList, null, 1, null, null, meetingDateStr, address);
 | 
	
		
			
				|  |  | +        return true;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public Map sporadicPay(SporadicPayDto sporadicPayDto) throws Exception {
 | 
	
		
			
				|  |  |          //获取收费项价格
 | 
	
	
		
			
				|  | @@ -547,7 +548,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          studentPaymentOrder.setVersion(0);
 | 
	
		
			
				|  |  |          BigDecimal balance = BigDecimal.ZERO;
 | 
	
		
			
				|  |  |          if (sporadicPayDto.getUseBalancePayment() && amount.compareTo(BigDecimal.ZERO) > 0) {
 | 
	
		
			
				|  |  | -            if (chargeInfo.getChargeType().getCode().equals(9) || chargeInfo.getChargeType().getCode().equals(13)) {
 | 
	
		
			
				|  |  | +            if (chargeInfo.getChargeType().getCode().equals(9) ||
 | 
	
		
			
				|  |  | +                    chargeInfo.getChargeType().getCode().equals(13) ||
 | 
	
		
			
				|  |  | +                    chargeInfo.getChargeType().getCode().equals(14)) {
 | 
	
		
			
				|  |  |                  throw new BizException(chargeInfo.getChargeType().getMsg() + "不支持余额支付");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              SysUserCashAccount userCashAccount = sysUserCashAccountService.get(userId);
 | 
	
	
		
			
				|  | @@ -1089,8 +1092,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |          if (waringSubjectIds.size() > 0) {
 | 
	
		
			
				|  |  |              List<Subject> waringSubjects = subjectDao.findBySubjectIds(waringSubjectIds);
 | 
	
		
			
				|  |  | -            String waringSubjectStr  = waringSubjects.stream().map(Subject::getName).collect(Collectors.joining(","));
 | 
	
		
			
				|  |  | -            throw new BizException(waringSubjectStr+"存在学生,不能删除");
 | 
	
		
			
				|  |  | +            String waringSubjectStr = waringSubjects.stream().map(Subject::getName).collect(Collectors.joining(","));
 | 
	
		
			
				|  |  | +            throw new BizException(waringSubjectStr + "存在学生,不能删除");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if (musicGroup.getStatus() == MusicGroupStatusEnum.DRAFT || musicGroup.getStatus() == MusicGroupStatusEnum.AUDIT_FAILED) {
 | 
	
	
		
			
				|  | @@ -1104,14 +1107,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          musicGroupSubjectPlanDao.delByMusicGroupId(musicGroupId);
 | 
	
		
			
				|  |  |          //删除原有的声部商品组合
 | 
	
		
			
				|  |  |          musicGroupSubjectGoodsGroupDao.delByMusicGroupId(subFeeSettingDto.getMusicGroupId());
 | 
	
		
			
				|  |  | -        //如果是进行中,补充缴费信息
 | 
	
		
			
				|  |  | -//            if(musicGroup.getStatus() == MusicGroupStatusEnum.PROGRESS){
 | 
	
		
			
				|  |  | -//                List<MusicGroupStudentFee> musicGroupStudentFees = musicGroupStudentFeeDao.initMusicGroupStudentFee(musicGroupId);
 | 
	
		
			
				|  |  | -//                if(musicGroupStudentFees != null && musicGroupStudentFees.size() > 0){
 | 
	
		
			
				|  |  | -//                    Date nextPaymentDate = musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId, null,null);
 | 
	
		
			
				|  |  | -//                    musicGroupStudentFeeDao.batchInsert(musicGroupStudentFees,nextPaymentDate,"PAID_COMPLETED");
 | 
	
		
			
				|  |  | -//                }
 | 
	
		
			
				|  |  | -//            }
 | 
	
		
			
				|  |  |          if (musicGroupSubjectPlans != null && musicGroupSubjectPlans.size() > 0) {
 | 
	
		
			
				|  |  |              musicGroupSubjectPlans.forEach(e -> {
 | 
	
		
			
				|  |  |                  //修改课程费用
 | 
	
	
		
			
				|  | @@ -1133,6 +1128,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              musicGroupSubjectGoodsGroupDao.batchInsert(subFeeSettingDto.getMusicGroupSubjectGoodsGroups(), musicGroupId);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | +        Set<Integer> roleIds = new HashSet<>(1);
 | 
	
		
			
				|  |  | +        roleIds.add(SysUserRole.SECTION_MANAGER);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(),musicGroup.getName());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
	
		
			
				|  | @@ -1183,13 +1183,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          List<ClassGroup> classGroups = classGroupDao.queryClassGroups(musicGroupId, "MUSIC");
 | 
	
		
			
				|  |  |          for (ClassGroup classGroup : classGroups) {
 | 
	
		
			
				|  |  |              //获取班级关联的老师列表
 | 
	
		
			
				|  |  | -            Set<Integer> teacherIds = classGroupTeacherMapperDao.queryTeacherIdsByClassGroupId(classGroup.getId(),null,null);
 | 
	
		
			
				|  |  | +            Set<Integer> teacherIds = classGroupTeacherMapperDao.queryTeacherIdsByClassGroupId(classGroup.getId(), null, null);
 | 
	
		
			
				|  |  |              //获取班级关联的学员列表
 | 
	
		
			
				|  |  | -            Set<Integer> studentIds = classGroupStudentMapperDao.queryStudentIdsByClassGroupId(classGroup.getId(),null,null);
 | 
	
		
			
				|  |  | +            Set<Integer> studentIds = classGroupStudentMapperDao.queryStudentIdsByClassGroupId(classGroup.getId(), null, null);
 | 
	
		
			
				|  |  |              //创建IM群组
 | 
	
		
			
				|  |  |              classGroupService.addImGroup(classGroup, new ArrayList<>(studentIds), new ArrayList<>(teacherIds));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        imUserFriendService.refreshGroupImUserFriend(musicGroupId,GroupType.MUSIC);
 | 
	
		
			
				|  |  | +        imUserFriendService.refreshGroupImUserFriend(musicGroupId, GroupType.MUSIC);
 | 
	
		
			
				|  |  |          //给老师发送乐团成立通知
 | 
	
		
			
				|  |  |          Map<Integer, String> map = JSONObject.parseObject(JSONObject.toJSONString(MapUtil.convertMybatisMap(musicGroupDao.queryTeacherIdMap(musicGroupId))), HashMap.class);
 | 
	
		
			
				|  |  |          if (map != null && map.size() > 0) {
 | 
	
	
		
			
				|  | @@ -1234,7 +1234,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          Set<Integer> roleIds = new HashSet<>(1);
 | 
	
		
			
				|  |  |          roleIds.add(SysUserRole.SECTION_MANAGER);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getUsername());
 | 
	
		
			
				|  |  | +        sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()), MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_APPLY, "", sysUser.getRealName(),musicGroup.getName());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
	
		
			
				|  | @@ -1272,24 +1273,33 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "审核通过(审核中 -> 预报名)", sysUser.getId(), ""));
 | 
	
		
			
				|  |  |          musicGroup.setStatus(MusicGroupStatusEnum.PRE_APPLY);
 | 
	
		
			
				|  |  |          musicGroupDao.update(musicGroup);
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          // 创建群
 | 
	
		
			
				|  |  |          imGroupService.create(Long.parseLong(musicGroupId), null, "乐团预报名", null, musicGroup.getName(), musicGroup.getName(), null, GroupType.MUSIC.getCode());
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        Map<Integer,String> userRoleMap = new HashMap<Integer, String>();
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        if(musicGroup.getTeamTeacherId() != null){
 | 
	
		
			
				|  |  | -        	userRoleMap.put(musicGroup.getTeamTeacherId(), "运营主管");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Map<Integer, String> userRoleMap = new HashMap<Integer, String>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (musicGroup.getTeamTeacherId() != null) {
 | 
	
		
			
				|  |  | +            userRoleMap.put(musicGroup.getTeamTeacherId(), "运营主管");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if(musicGroup.getEducationalTeacherId() != null){
 | 
	
		
			
				|  |  | -        	userRoleMap.put(musicGroup.getEducationalTeacherId(), "乐团主管");
 | 
	
		
			
				|  |  | +        if (musicGroup.getEducationalTeacherId() != null) {
 | 
	
		
			
				|  |  | +            userRoleMap.put(musicGroup.getEducationalTeacherId(), "乐团主管");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if(musicGroup.getDirectorUserId() != null){
 | 
	
		
			
				|  |  | -        	userRoleMap.put(musicGroup.getDirectorUserId(), "乐队指导");
 | 
	
		
			
				|  |  | +        if (musicGroup.getDirectorUserId() != null) {
 | 
	
		
			
				|  |  | +            userRoleMap.put(musicGroup.getDirectorUserId(), "乐队指导");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          // 添加成员
 | 
	
		
			
				|  |  |          imGroupMemberService.join(Long.parseLong(musicGroupId), userRoleMap);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        Set<Integer> roleIds = new HashSet<>(1);
 | 
	
		
			
				|  |  | +        roleIds.add(SysUserRole.EDUCATIONAL_TEACHER);
 | 
	
		
			
				|  |  | +        sysMessageService.batchSeoMessage(musicGroupDao.queryUserIdByRoleId(roleIds, musicGroup.getOrganId()),
 | 
	
		
			
				|  |  | +                MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_ADJUST_SUCCESS, "",musicGroup.getName());
 | 
	
		
			
				|  |  | +        Map<Integer, String> map = new HashMap<>(1);
 | 
	
		
			
				|  |  | +        map.put(musicGroup.getEducationalTeacherId(),musicGroup.getEducationalTeacherId().toString());
 | 
	
		
			
				|  |  | +        if (map != null && map.size() > 0) {
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.BACKSTAGE_CREATE_MUSIC_GROUP_ADJUST_SUCCESS,
 | 
	
		
			
				|  |  | +                    map, null, 0, null, "SYSTEM", musicGroup.getName());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
	
		
			
				|  | @@ -1658,8 +1668,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -	public boolean extensionPreApplyExpireDate(String musicGroupId, Date expireDate) {
 | 
	
		
			
				|  |  | -    	SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  | +    public boolean extensionPreApplyExpireDate(String musicGroupId, Date expireDate) {
 | 
	
		
			
				|  |  | +        SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
		
			
				|  |  |          if (sysUser == null) {
 | 
	
		
			
				|  |  |              throw new BizException("用户信息获取失败");
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -1683,9 +1693,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          musicGroupDao.update(musicGroup);
 | 
	
		
			
				|  |  |          musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "延长预报名时间", sysUser.getId(), ""));
 | 
	
		
			
				|  |  |          return true;
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@Override
 | 
	
		
			
				|  |  | +    @Override
 | 
	
		
			
				|  |  |      @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public boolean applyQuitMusicGroup(String musicGroupId, String reason) {
 | 
	
		
			
				|  |  |          SysUser sysUser = sysUserFeignService.queryUserInfo();
 | 
	
	
		
			
				|  | @@ -1752,9 +1762,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          if (musicGroup == null) {
 | 
	
		
			
				|  |  |              throw new BizException("乐团不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -		if (musicGroupQuit.getStatus() != ApprovalStatus.PROCESSING) {
 | 
	
		
			
				|  |  | -			throw new BizException("当前状态下不能取消");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +        if (musicGroupQuit.getStatus() != ApprovalStatus.PROCESSING) {
 | 
	
		
			
				|  |  | +            throw new BizException("当前状态下不能取消");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          musicGroupQuit.setStatus(ApprovalStatus.CANCELED);
 | 
	
		
			
				|  |  |          musicGroupQuit.setReason(reason);
 | 
	
		
			
				|  |  |          musicGroupQuit.setQuitDate(new Date());
 | 
	
	
		
			
				|  | @@ -1771,6 +1781,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |      @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public boolean approveQuitMusicGroup(Long id, ApprovalStatus status, String reason, boolean isRefundCourseFee, boolean isRefundInstrumentFee,
 | 
	
		
			
				|  |  |                                           boolean isRefundTeachingAssistantsFee) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          MusicGroupQuit musicGroupQuit = musicGroupQuitDao.get(id);
 | 
	
		
			
				|  |  |          if (musicGroupQuit == null) {
 | 
	
		
			
				|  |  |              throw new BizException("数据不存在");
 | 
	
	
		
			
				|  | @@ -1789,12 +1800,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              throw new BizException("申请失败,乐团状态[已取消]或[已暂停]");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// 有进行中的课程不能退团
 | 
	
		
			
				|  |  | -		List<CourseSchedule> courseScheduleList = courseScheduleDao.findMusicGroupCourseSchedulesWithStudent(musicGroupId, GroupType.MUSIC.getCode(),
 | 
	
		
			
				|  |  | -				"UNDERWAY", userId);
 | 
	
		
			
				|  |  | -		if (courseScheduleList != null && courseScheduleList.size() > 0) {
 | 
	
		
			
				|  |  | -			throw new BizException("退团失败,存在[进行中]的课程");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +        // 有进行中的课程不能退团
 | 
	
		
			
				|  |  | +        List<CourseSchedule> courseScheduleList = courseScheduleDao.findMusicGroupCourseSchedulesWithStudent(musicGroupId, GroupType.MUSIC.getCode(),
 | 
	
		
			
				|  |  | +                "UNDERWAY", userId);
 | 
	
		
			
				|  |  | +        if (courseScheduleList != null && courseScheduleList.size() > 0) {
 | 
	
		
			
				|  |  | +            throw new BizException("退团失败,存在[进行中]的课程");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          musicGroupQuit.setStatus(status);
 | 
	
		
			
				|  |  |          musicGroupQuit.setReason(reason);
 | 
	
	
		
			
				|  | @@ -1833,7 +1844,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              studentRegistrationDao.update(studentRegistration);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //更新服务指标、运营指标
 | 
	
		
			
				|  |  | -            int remainCourseNum = courseScheduleStudentPaymentDao.countStudentNotStartCourseNumWithCourseType(userId, null);
 | 
	
		
			
				|  |  | +            /*int remainCourseNum = courseScheduleStudentPaymentDao.countStudentNotStartCourseNumWithCourseType(userId, null);
 | 
	
		
			
				|  |  |              if (remainCourseNum == 0) {
 | 
	
		
			
				|  |  |                  Student student = studentDao.get(userId);
 | 
	
		
			
				|  |  |                  if (student == null) {
 | 
	
	
		
			
				|  | @@ -1844,31 +1855,31 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  student.setOperatingTempTag(0);
 | 
	
		
			
				|  |  |                  student.setUpdateTime(date);
 | 
	
		
			
				|  |  |                  studentDao.update(student);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            }*/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //删除进行中加学生,且在审批中或拒绝的缴费
 | 
	
		
			
				|  |  |              List<Long> paymentCalenderIdList = musicGroupPaymentCalenderDao.findStudentNoPaymentCalender(userId, musicGroupId);
 | 
	
		
			
				|  |  | -            if(paymentCalenderIdList != null && paymentCalenderIdList.size() > 0){
 | 
	
		
			
				|  |  | -            	musicGroupPaymentCalenderDao.delByIds(paymentCalenderIdList);
 | 
	
		
			
				|  |  | +            if (paymentCalenderIdList != null && paymentCalenderIdList.size() > 0) {
 | 
	
		
			
				|  |  | +                musicGroupPaymentCalenderDao.delByIds(paymentCalenderIdList);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              //查询未交费的项目
 | 
	
		
			
				|  |  |              List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryNotPaymentStudentByUserIdAndMusicGroupId(userId, musicGroupId);
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -			for (MusicGroupPaymentCalenderDetail mgpcd : musicGroupPaymentCalenderDetailList) {
 | 
	
		
			
				|  |  | -				MusicGroupPaymentCalender mgpc = musicGroupPaymentCalenderDao.get(mgpcd.getMusicGroupPaymentCalenderId());
 | 
	
		
			
				|  |  | -				if (mgpc != null) {
 | 
	
		
			
				|  |  | -					if (mgpc.getPaymentType() == PaymentType.ADD_STUDENT) {
 | 
	
		
			
				|  |  | -						musicGroupPaymentCalenderDao.delete(mgpc.getId());
 | 
	
		
			
				|  |  | -					} else {
 | 
	
		
			
				|  |  | -						// 缴费项目预计人数减一
 | 
	
		
			
				|  |  | -						mgpc.setExpectNum(mgpc.getExpectNum() - 1);
 | 
	
		
			
				|  |  | -						mgpc.setUpdateTime(date);
 | 
	
		
			
				|  |  | -						musicGroupPaymentCalenderDao.update(mgpc);
 | 
	
		
			
				|  |  | -					}
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -				musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            for (MusicGroupPaymentCalenderDetail mgpcd : musicGroupPaymentCalenderDetailList) {
 | 
	
		
			
				|  |  | +                MusicGroupPaymentCalender mgpc = musicGroupPaymentCalenderDao.get(mgpcd.getMusicGroupPaymentCalenderId());
 | 
	
		
			
				|  |  | +                if (mgpc != null) {
 | 
	
		
			
				|  |  | +                    if (mgpc.getPaymentType() == PaymentType.ADD_STUDENT) {
 | 
	
		
			
				|  |  | +                        musicGroupPaymentCalenderDao.delete(mgpc.getId());
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        // 缴费项目预计人数减一
 | 
	
		
			
				|  |  | +                        mgpc.setExpectNum(mgpc.getExpectNum() - 1);
 | 
	
		
			
				|  |  | +                        mgpc.setUpdateTime(date);
 | 
	
		
			
				|  |  | +                        musicGroupPaymentCalenderDao.update(mgpc);
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |              //删除用户购买的课程记录
 | 
	
		
			
				|  |  |              musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1881,11 +1892,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  musicGroupSubjectPlan.setUpdateTime(date);
 | 
	
		
			
				|  |  |                  musicGroupSubjectPlanDao.update(musicGroupSubjectPlan);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | -            if(currentStudentMusicGroupStatus != StudentMusicGroupStatusEnum.NORMAL){
 | 
	
		
			
				|  |  | -            	return true;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            if (currentStudentMusicGroupStatus != StudentMusicGroupStatusEnum.NORMAL) {
 | 
	
		
			
				|  |  | +                return true;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              if (isRefundCourseFee) {
 | 
	
		
			
				|  |  |                  // 退课程费用
 | 
	
		
			
				|  |  |                  amount = amount.add(surplusCourseFee);
 | 
	
	
		
			
				|  | @@ -1894,7 +1905,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (studentPaymentOrder != null) {
 | 
	
		
			
				|  |  | -            	List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  | +                List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  SubjectChange studentLastChange = null;
 | 
	
		
			
				|  |  |                  if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
 | 
	
	
		
			
				|  | @@ -1930,7 +1941,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              if (amount.doubleValue() > 0) {
 | 
	
		
			
				|  |  |                  // 增加交易流水
 | 
	
		
			
				|  |  |                  sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
 | 
	
	
		
			
				|  | @@ -1957,12 +1968,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              throw new BizException("退团失败,乐团状态[已取消]或[已暂停]");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		// 有进行中的课程不能退团
 | 
	
		
			
				|  |  | -		List<CourseSchedule> courseScheduleList = courseScheduleDao.findMusicGroupCourseSchedulesWithStudent(musicGroupId, GroupType.MUSIC.getCode(),
 | 
	
		
			
				|  |  | -				"UNDERWAY", userId);
 | 
	
		
			
				|  |  | -		if (courseScheduleList != null && courseScheduleList.size() > 0) {
 | 
	
		
			
				|  |  | -			throw new BizException("退团失败,存在[进行中]的课程");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +        // 有进行中的课程不能退团
 | 
	
		
			
				|  |  | +        List<CourseSchedule> courseScheduleList = courseScheduleDao.findMusicGroupCourseSchedulesWithStudent(musicGroupId, GroupType.MUSIC.getCode(),
 | 
	
		
			
				|  |  | +                "UNDERWAY", userId);
 | 
	
		
			
				|  |  | +        if (courseScheduleList != null && courseScheduleList.size() > 0) {
 | 
	
		
			
				|  |  | +            throw new BizException("退团失败,存在[进行中]的课程");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          courseScheduleStudentPaymentService.updateCourseActualPrice(Arrays.asList(musicGroupId), Arrays.asList(userId), GroupType.MUSIC);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1970,7 +1981,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
 | 
	
		
			
				|  |  |          if (studentRegistration == null) {
 | 
	
		
			
				|  |  |              throw new BizException("用户注册信息不存在");
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          Date date = new Date();
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2008,7 +2019,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          studentRegistrationDao.update(studentRegistration);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //更新服务指标、运营指标
 | 
	
		
			
				|  |  | -        int remainCourseNum = courseScheduleStudentPaymentDao.countStudentNotStartCourseNumWithCourseType(userId, null);
 | 
	
		
			
				|  |  | +        /*int remainCourseNum = courseScheduleStudentPaymentDao.countStudentNotStartCourseNumWithCourseType(userId, null);
 | 
	
		
			
				|  |  |          if (remainCourseNum == 0) {
 | 
	
		
			
				|  |  |              Student student = studentDao.get(userId);
 | 
	
		
			
				|  |  |              if (student == null) {
 | 
	
	
		
			
				|  | @@ -2019,34 +2030,34 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              student.setOperatingTempTag(0);
 | 
	
		
			
				|  |  |              student.setUpdateTime(date);
 | 
	
		
			
				|  |  |              studentDao.update(student);
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +        }*/
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //删除进行中加学生,且在审批中或拒绝的缴费
 | 
	
		
			
				|  |  |          List<Long> paymentCalenderIdList = musicGroupPaymentCalenderDao.findStudentNoPaymentCalender(userId, musicGroupId);
 | 
	
		
			
				|  |  | -        if(paymentCalenderIdList != null && paymentCalenderIdList.size() > 0){
 | 
	
		
			
				|  |  | -        	musicGroupPaymentCalenderDao.delByIds(paymentCalenderIdList);
 | 
	
		
			
				|  |  | +        if (paymentCalenderIdList != null && paymentCalenderIdList.size() > 0) {
 | 
	
		
			
				|  |  | +            musicGroupPaymentCalenderDao.delByIds(paymentCalenderIdList);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          //查询未交费的项目
 | 
	
		
			
				|  |  |          List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = musicGroupPaymentCalenderDetailDao.queryNotPaymentStudentByUserIdAndMusicGroupId(userId, musicGroupId);
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -		for (MusicGroupPaymentCalenderDetail mgpcd : musicGroupPaymentCalenderDetailList) {
 | 
	
		
			
				|  |  | -			MusicGroupPaymentCalender mgpc = musicGroupPaymentCalenderDao.get(mgpcd.getMusicGroupPaymentCalenderId());
 | 
	
		
			
				|  |  | -			if (mgpc != null) {
 | 
	
		
			
				|  |  | -				if (mgpc.getPaymentType() == PaymentType.ADD_STUDENT) {
 | 
	
		
			
				|  |  | -					musicGroupPaymentCalenderDao.delete(mgpc.getId());
 | 
	
		
			
				|  |  | -				} else {
 | 
	
		
			
				|  |  | -					// 缴费项目预计人数减一
 | 
	
		
			
				|  |  | -					mgpc.setExpectNum(mgpc.getExpectNum() - 1);
 | 
	
		
			
				|  |  | -					mgpc.setUpdateTime(date);
 | 
	
		
			
				|  |  | -					musicGroupPaymentCalenderDao.update(mgpc);
 | 
	
		
			
				|  |  | -				}
 | 
	
		
			
				|  |  | -			}
 | 
	
		
			
				|  |  | -			musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        for (MusicGroupPaymentCalenderDetail mgpcd : musicGroupPaymentCalenderDetailList) {
 | 
	
		
			
				|  |  | +            MusicGroupPaymentCalender mgpc = musicGroupPaymentCalenderDao.get(mgpcd.getMusicGroupPaymentCalenderId());
 | 
	
		
			
				|  |  | +            if (mgpc != null) {
 | 
	
		
			
				|  |  | +                if (mgpc.getPaymentType() == PaymentType.ADD_STUDENT) {
 | 
	
		
			
				|  |  | +                    musicGroupPaymentCalenderDao.delete(mgpc.getId());
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    // 缴费项目预计人数减一
 | 
	
		
			
				|  |  | +                    mgpc.setExpectNum(mgpc.getExpectNum() - 1);
 | 
	
		
			
				|  |  | +                    mgpc.setUpdateTime(date);
 | 
	
		
			
				|  |  | +                    musicGroupPaymentCalenderDao.update(mgpc);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            musicGroupPaymentCalenderDetailDao.delete(mgpcd.getId());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          //删除用户购买的课程记录
 | 
	
		
			
				|  |  |          musicGroupPaymentStudentCourseDetailDao.deleteByUserIdAndMusicGroupId(userId, musicGroupId);
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          BigDecimal amount = new BigDecimal(0);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          // 判断乐器是否是租赁
 | 
	
	
		
			
				|  | @@ -2056,11 +2067,11 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              musicGroupSubjectPlan.setUpdateTime(date);
 | 
	
		
			
				|  |  |              musicGroupSubjectPlanDao.update(musicGroupSubjectPlan);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        if(currentStudentMusicGroupStatus != StudentMusicGroupStatusEnum.NORMAL){
 | 
	
		
			
				|  |  | -        	return true;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (currentStudentMusicGroupStatus != StudentMusicGroupStatusEnum.NORMAL) {
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          if (isRefundCourseFee) {
 | 
	
		
			
				|  |  |              // 退课程费用
 | 
	
		
			
				|  |  |              amount = amount.add(surplusCourseFee);
 | 
	
	
		
			
				|  | @@ -2069,7 +2080,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if (studentPaymentOrder != null) {
 | 
	
		
			
				|  |  | -        	List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  | +            List<StudentPaymentOrderDetail> orderDetailList = studentPaymentOrderDetailDao.findApplyOrderGoods(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              SubjectChange studentLastChange = null;
 | 
	
		
			
				|  |  |              if (isRefundInstrumentFee || isRefundTeachingAssistantsFee) {
 | 
	
	
		
			
				|  | @@ -2105,7 +2116,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          if (amount.doubleValue() > 0) {
 | 
	
		
			
				|  |  |              // 增加交易流水
 | 
	
		
			
				|  |  |              sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
 | 
	
	
		
			
				|  | @@ -2269,7 +2280,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              //如果是进行中加学员
 | 
	
		
			
				|  |  |              MusicGroupPaymentCalender paymentCalender = musicGroupPaymentCalenderDao.get(calenderDetail.getMusicGroupPaymentCalenderId());
 | 
	
		
			
				|  |  | -            if(paymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT){
 | 
	
		
			
				|  |  | +            if (paymentCalender.getPaymentType() == MusicGroupPaymentCalender.PaymentType.ADD_STUDENT) {
 | 
	
		
			
				|  |  |                  studentRegistration.setPaymentStatus(YES);
 | 
	
		
			
				|  |  |                  studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
 | 
	
		
			
				|  |  |                  studentRegistrationDao.update(studentRegistration);
 | 
	
	
		
			
				|  | @@ -2303,7 +2314,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              List<StudentPaymentOrderDetail> paymentOrderDetails = new ArrayList<>();
 | 
	
		
			
				|  |  |              List<MusicGroupPaymentCalenderCourseSettings> courseSettings = musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettings(calenderDetail.getMusicGroupPaymentCalenderId());
 | 
	
		
			
				|  |  |              //跨团合班没有settings
 | 
	
		
			
				|  |  | -            if(courseSettings.size() == 0){
 | 
	
		
			
				|  |  | +            if (courseSettings.size() == 0) {
 | 
	
		
			
				|  |  |                  List<MusicGroupPaymentCalenderStudentDetail> studentDetails = musicGroupPaymentCalenderStudentDetailDao.findByBatchNoAndUserId(paymentCalender.getBatchNo(), userId);
 | 
	
		
			
				|  |  |                  for (MusicGroupPaymentCalenderStudentDetail studentDetail : studentDetails) {
 | 
	
		
			
				|  |  |                      StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
 | 
	
	
		
			
				|  | @@ -2314,7 +2325,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                      studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  |                      paymentOrderDetails.add(studentPaymentOrderDetail);
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -            }else {
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  |                  courseSettings.forEach(e -> {
 | 
	
		
			
				|  |  |                      StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
 | 
	
		
			
				|  |  |                      studentPaymentOrderDetail.setType(OrderDetailTypeEnum.valueOf(e.getCourseType().getCode()));
 | 
	
	
		
			
				|  | @@ -2325,7 +2336,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |                      paymentOrderDetails.add(studentPaymentOrderDetail);
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            studentPaymentOrderDetailService.batchAdd(paymentOrderDetails);
 | 
	
		
			
				|  |  | +            if (paymentOrderDetails.size() > 0) {
 | 
	
		
			
				|  |  | +                studentPaymentOrderDetailService.batchAdd(paymentOrderDetails);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              //缴费
 | 
	
		
			
				|  |  |              SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
 | 
	
	
		
			
				|  | @@ -2381,9 +2394,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          if (courseSchedule == null) {
 | 
	
		
			
				|  |  |              throw new BizException("课程信息不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        if(salary == null){
 | 
	
		
			
				|  |  | -        	throw new BizException("请设置老师课酬");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (salary == null) {
 | 
	
		
			
				|  |  | +            throw new BizException("请设置老师课酬");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if ("all".equals(scope)) {
 | 
	
	
		
			
				|  | @@ -2515,7 +2528,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          Integer teamTeacherId = newMusicGroup.getTeamTeacherId();
 | 
	
		
			
				|  |  |          Integer educationalTeacherId = newMusicGroup.getEducationalTeacherId();
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          Integer oldDirectorUserId = oldMusicGroup.getDirectorUserId();
 | 
	
		
			
				|  |  |          if (oldDirectorUserId == null) {
 | 
	
		
			
				|  |  |              oldDirectorUserId = teamTeacherId;
 | 
	
	
		
			
				|  | @@ -2530,14 +2543,14 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          quitUserIdList.add(oldMusicGroup.getEducationalTeacherId());
 | 
	
		
			
				|  |  |          quitUserIdList.add(oldDirectorUserId);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        Map<Integer,String> userRoleMap = new HashMap<Integer, String>();
 | 
	
		
			
				|  |  | +        Map<Integer, String> userRoleMap = new HashMap<Integer, String>();
 | 
	
		
			
				|  |  |          userRoleMap.put(directorUserId, "乐队指导");
 | 
	
		
			
				|  |  |          userRoleMap.put(educationalTeacherId, "乐团主管");
 | 
	
		
			
				|  |  |          userRoleMap.put(teamTeacherId, "运营主管");
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          classGroups.forEach(e -> {
 | 
	
		
			
				|  |  | -        	imGroupMemberService.quit(e.getId().longValue(), quitUserIdList);
 | 
	
		
			
				|  |  | -        	imGroupMemberService.join(e.getId().longValue(), userRoleMap);
 | 
	
		
			
				|  |  | +            imGroupMemberService.quit(e.getId().longValue(), quitUserIdList);
 | 
	
		
			
				|  |  | +            imGroupMemberService.join(e.getId().longValue(), userRoleMap);
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2565,7 +2578,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              //如果已生成课表,那么修改未上课时教学点
 | 
	
		
			
				|  |  |              courseScheduleDao.updateCourseScheduleSchool("MUSIC", musicGroupId, musicGroup.getSchoolId());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if(group.getStatus() == MusicGroupStatusEnum.PROGRESS){
 | 
	
		
			
				|  |  | +        if (group.getStatus() == MusicGroupStatusEnum.PROGRESS) {
 | 
	
		
			
				|  |  |              updateTeamTeacher(group, musicGroup);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -2593,8 +2606,8 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          if (subFeeSettingDto.getMusicGroupPaymentEntities() != null && subFeeSettingDto.getMusicGroupPaymentEntities().size() > 0) {
 | 
	
		
			
				|  |  |              musicGroupPaymentEntitiesDao.batchAdd(subFeeSettingDto.getMusicGroupPaymentEntities(), musicGroupId);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if(group.getStatus() == MusicGroupStatusEnum.PROGRESS){
 | 
	
		
			
				|  |  | -            imUserFriendService.refreshGroupImUserFriend(musicGroupId,GroupType.MUSIC);
 | 
	
		
			
				|  |  | +        if (group.getStatus() == MusicGroupStatusEnum.PROGRESS) {
 | 
	
		
			
				|  |  | +            imUserFriendService.refreshGroupImUserFriend(musicGroupId, GroupType.MUSIC);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //记录操作日志
 | 
	
		
			
				|  |  |          musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId, "修改乐团基本信息数据", sysUser.getId(), JSONObject.toJSONString(subFeeSettingDto)));
 | 
	
	
		
			
				|  | @@ -2806,7 +2819,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              hasUsers.add(studentRegistration.getUserId());
 | 
	
		
			
				|  |  |              newRegs.add(studentRegistration);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if(registerIds.size() >0 && newRegs.size()<=0){
 | 
	
		
			
				|  |  | +        if (registerIds.size() > 0 && newRegs.size() <= 0) {
 | 
	
		
			
				|  |  |              throw new BizException("添加的学员,乐团已存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          studentRegistrations = newRegs;
 | 
	
	
		
			
				|  | @@ -2879,7 +2892,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //有进行中的课不能关闭乐团
 | 
	
		
			
				|  |  |          Integer underwayCourseNum = courseScheduleDao.getUnderwayCourseNum(musicGroup.getId(), GroupType.MUSIC, CourseStatusEnum.UNDERWAY);
 | 
	
		
			
				|  |  | -        if(underwayCourseNum >0){
 | 
	
		
			
				|  |  | +        if (underwayCourseNum > 0) {
 | 
	
		
			
				|  |  |              throw new BizException("乐团有进行的课程,不能关闭");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          musicGroup.setStatus(MusicGroupStatusEnum.CLOSE);
 |