|  | @@ -19,6 +19,8 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 | 
	
		
			
				|  |  |  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.string.MessageFormatter;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
	
		
			
				|  | @@ -110,6 +112,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  |  	private SysMessageConfigDao sysMessageConfigDao;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private SysConfigDao sysConfigDao;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public BaseDAO<String, MusicGroup> getDAO() {
 | 
	
		
			
				|  |  |          return musicGroupDao;
 | 
	
	
		
			
				|  | @@ -195,9 +200,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          //乐团状态是否正确
 | 
	
		
			
				|  |  |          MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 | 
	
		
			
				|  |  |          if(musicGroup != null){
 | 
	
		
			
				|  |  | -            if(musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT || musicGroup.getStatus() != MusicGroupStatusEnum.AUDIT_FAILED){
 | 
	
		
			
				|  |  | +            if(musicGroup.getStatus() != MusicGroupStatusEnum.DRAFT && musicGroup.getStatus() != MusicGroupStatusEnum.AUDIT_FAILED){
 | 
	
		
			
				|  |  |                  throw new Exception("当前乐团状态不支持此操作");
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            if(subFeeSettingDto.getMusicGroupStatus() == null){
 | 
	
		
			
				|  |  | +                throw new Exception("参数校验异常");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            musicGroup.setStatus(subFeeSettingDto.getMusicGroupStatus());
 | 
	
		
			
				|  |  | +            musicGroup.setUpdateTime(new Date());
 | 
	
		
			
				|  |  | +            musicGroupDao.update(musicGroup);
 | 
	
		
			
				|  |  |              //记录日志信息
 | 
	
		
			
				|  |  |              musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId,"修改乐团计划声部、乐器",sysUser.getId(), JSONObject.toJSONString(subFeeSettingDto)));
 | 
	
		
			
				|  |  |              //删除原有的乐团声部规划
 | 
	
	
		
			
				|  | @@ -363,7 +374,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //获取当前乐团所有已报名学员
 | 
	
		
			
				|  |  |          List<StudentRegistration> registrations = studentRegistrationDao.findClassGroupStu(musicGroupId, null);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        Map<Integer,String> map = new HashMap<>(registrations.size());
 | 
	
		
			
				|  |  | +        registrations.forEach(e->{
 | 
	
		
			
				|  |  | +            map.put(e.getUserId(),e.getUserId() + "");
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        if(map.size() > 0){
 | 
	
		
			
				|  |  | +            String content = sysMessageConfigDao.findContent(MessageTypeEnum.STUDENT_PUSH_MUSIC_GROUP_CLOSE.getCode());
 | 
	
		
			
				|  |  | +            content = MessageFormatter.arrayFormat(content,sysConfigDao.findConfigValue(SysConfigService.REFUND_PERIOD));
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSender.JIGUANG,"",content,map,new Date(),0,"");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          //记录建团日志
 | 
	
		
			
				|  |  |          musicGroupBuildLogDao.insert(new MusicGroupBuildLog(musicGroupId,"取消乐团",sysUser.getId(),""));
 | 
	
		
			
				|  |  |          return true;
 | 
	
	
		
			
				|  | @@ -633,26 +652,64 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          if(musicGroupStudentFee == null){
 | 
	
		
			
				|  |  |              throw new BizException("系统数据异常,找不到学员预缴费信息");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          Date date = new Date();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        musicGroupStudentFee.setUpdateTime(date);
 | 
	
		
			
				|  |  | -        musicGroupStudentFee.setLatestPaidTime(date);
 | 
	
		
			
				|  |  | -        musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
 | 
	
		
			
				|  |  | -        musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
 | 
	
		
			
				|  |  | -        musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        musicGroupStudentFeeDao.update(musicGroupStudentFee);
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -		SysUser user = sysUserFeignService.queryUserById(userId);
 | 
	
		
			
				|  |  | -        Map<Integer, String> receivers = new HashMap<Integer, String>();
 | 
	
		
			
				|  |  | -        receivers.put(user.getId(), userId + "");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		// 发送续费结果通知
 | 
	
		
			
				|  |  | -		sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_MUSIC_GROUP_RENEW_RESULT, receivers, null, 0, "",
 | 
	
		
			
				|  |  | -				user.getRealName());
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        return true;
 | 
	
		
			
				|  |  | +        Map<Integer, String> receivers = new HashMap<Integer, String>(1);
 | 
	
		
			
				|  |  | +        StudentRegistration studentRegistration = studentRegistrationDao.queryByUserIdAndMusicGroupId(userId, musicGroupId);
 | 
	
		
			
				|  |  | +        receivers.put(userId, studentRegistration.getParentsPhone());
 | 
	
		
			
				|  |  | +        if(studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS){
 | 
	
		
			
				|  |  | +            musicGroupStudentFee.setUpdateTime(date);
 | 
	
		
			
				|  |  | +            musicGroupStudentFee.setLatestPaidTime(date);
 | 
	
		
			
				|  |  | +            musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
 | 
	
		
			
				|  |  | +            musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
 | 
	
		
			
				|  |  | +            musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
 | 
	
		
			
				|  |  | +            musicGroupStudentFeeDao.update(musicGroupStudentFee);
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            //插入交易明细
 | 
	
		
			
				|  |  | +            SysUserCashAccount cashAccount = sysUserCashAccountService.get(userId);
 | 
	
		
			
				|  |  | +            BigDecimal amount = studentPaymentOrder.getActualAmount();
 | 
	
		
			
				|  |  | +            //充值
 | 
	
		
			
				|  |  | +            SysUserCashAccountDetail rechargeDetail = new SysUserCashAccountDetail();
 | 
	
		
			
				|  |  | +            rechargeDetail.setAmount(amount);
 | 
	
		
			
				|  |  | +            rechargeDetail.setBalance(cashAccount.getBalance().add(amount));
 | 
	
		
			
				|  |  | +            rechargeDetail.setComment("缴费前充值");
 | 
	
		
			
				|  |  | +            rechargeDetail.setCreateTime(date);
 | 
	
		
			
				|  |  | +            rechargeDetail.setStatus(DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | +            rechargeDetail.setTransNo(studentPaymentOrder.getTransNo());
 | 
	
		
			
				|  |  | +            rechargeDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
 | 
	
		
			
				|  |  | +            rechargeDetail.setUpdateTime(date);
 | 
	
		
			
				|  |  | +            rechargeDetail.setUserId(userId);
 | 
	
		
			
				|  |  | +            sysUserCashAccountDetailService.insert(rechargeDetail);
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            //缴费
 | 
	
		
			
				|  |  | +            SysUserCashAccountDetail paymentDetail = new SysUserCashAccountDetail();
 | 
	
		
			
				|  |  | +            paymentDetail.setAmount(amount);
 | 
	
		
			
				|  |  | +            paymentDetail.setBalance(cashAccount.getBalance());
 | 
	
		
			
				|  |  | +            paymentDetail.setComment("缴费");
 | 
	
		
			
				|  |  | +            paymentDetail.setCreateTime(date);
 | 
	
		
			
				|  |  | +            paymentDetail.setStatus(DealStatusEnum.SUCCESS);
 | 
	
		
			
				|  |  | +            paymentDetail.setTransNo(studentPaymentOrder.getTransNo());
 | 
	
		
			
				|  |  | +            paymentDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
 | 
	
		
			
				|  |  | +            paymentDetail.setUpdateTime(date);
 | 
	
		
			
				|  |  | +            paymentDetail.setUserId(userId);
 | 
	
		
			
				|  |  | +            sysUserCashAccountDetailService.insert(paymentDetail);
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  | +            // 发送续费结果通知
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_SMS_MUSIC_GROUP_RENEW_SUCCESS, receivers, null, 0, "",
 | 
	
		
			
				|  |  | +                    studentRegistration.getParentsName(),studentPaymentOrder.getActualAmount());
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSender.YIMEI, MessageTypeEnum.STUDENT_SMS_MUSIC_GROUP_RENEW_SUCCESS, receivers, null, 0, "",
 | 
	
		
			
				|  |  | +                    studentRegistration.getParentsName(),studentPaymentOrder.getActualAmount());
 | 
	
		
			
				|  |  | +            return true;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(studentPaymentOrder.getStatus() == DealStatusEnum.CLOSE || studentPaymentOrder.getStatus() == DealStatusEnum.FAilED){
 | 
	
		
			
				|  |  | +            String studentApplyUrl = sysConfigDao.findConfigValue(SysConfigService.STUDENT_APPLY_URL + musicGroupId);
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSender.JIGUANG, MessageTypeEnum.STUDENT_PUSH_MUSIC_GROUP_RENEW_FAILED, receivers, null, 0, "",
 | 
	
		
			
				|  |  | +                    studentApplyUrl);
 | 
	
		
			
				|  |  | +            sysMessageService.batchSendMessage(MessageSender.YIMEI, MessageTypeEnum.STUDENT_PUSH_MUSIC_GROUP_RENEW_FAILED, receivers, null, 0, "",
 | 
	
		
			
				|  |  | +                    studentApplyUrl);
 | 
	
		
			
				|  |  | +            return false;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return false;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
	
		
			
				|  | @@ -743,9 +800,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |              throw new Exception("用户信息获取失败");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          String musicGroupId = subFeeSettingDto.getMusicGroup().getId();
 | 
	
		
			
				|  |  | -        MusicGroup musicGroup = saveLog(musicGroupId,MusicGroupStatusEnum.DRAFT);
 | 
	
		
			
				|  |  | -        if(musicGroup.getStatus() != MusicGroupStatusEnum.AUDIT_FAILED){
 | 
	
		
			
				|  |  | -            throw new Exception("当前乐团状态不支持此操作");
 | 
	
		
			
				|  |  | +        MusicGroup musicGroup = musicGroupDao.get(musicGroupId);
 | 
	
		
			
				|  |  | +        if(musicGroup == null){
 | 
	
		
			
				|  |  | +            throw new Exception("乐团信息不存在");
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          Date date = new Date();
 | 
	
	
		
			
				|  | @@ -902,8 +959,9 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 | 
	
		
			
				|  |  |          //获取所有家长电话
 | 
	
		
			
				|  |  |          Set<String> parentsPhones = students.stream().map(StudentRegistration::getParentsPhone).collect(Collectors.toSet());
 | 
	
		
			
				|  |  |          //获取对应家长的用户编号
 | 
	
		
			
				|  |  | -//        Map<Integer,String> userIds = MapUtil.convertMybatisMap(studentRegistrationService.findParentId(StringUtils.join(parentsPhones,",")));
 | 
	
		
			
				|  |  | -//        String content = sysMessageConfigDao.findContent(MessageTypeEnum.SMS_BASICS_SKILL_APPLY_MESSAGE.getCode());
 | 
	
		
			
				|  |  | -//        sysMessageService.batchSendMessage(MessageSender.YIMEI,"",content,userIds,date,0,"");
 | 
	
		
			
				|  |  | +        Map<Integer,String> userIds = MapUtil.convertMybatisMap(studentRegistrationDao.findParentId(StringUtils.join(parentsPhones,",")));
 | 
	
		
			
				|  |  | +        userIds = JSONObject.parseObject(JSONObject.toJSONString(userIds),HashMap.class);
 | 
	
		
			
				|  |  | +        String content = sysMessageConfigDao.findContent(MessageTypeEnum.SMS_BASICS_SKILL_APPLY_MESSAGE.getCode());
 | 
	
		
			
				|  |  | +        sysMessageService.batchSendMessage(MessageSender.YIMEI,"",content,userIds,new Date(),0,"");
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |