|  | @@ -2,7 +2,16 @@ package com.ym.mec.biz.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.io.IOException;
 | 
	
		
			
				|  |  |  import java.math.BigDecimal;
 | 
	
		
			
				|  |  | -import java.util.*;
 | 
	
		
			
				|  |  | +import java.util.ArrayList;
 | 
	
		
			
				|  |  | +import java.util.Arrays;
 | 
	
		
			
				|  |  | +import java.util.Date;
 | 
	
		
			
				|  |  | +import java.util.HashMap;
 | 
	
		
			
				|  |  | +import java.util.HashSet;
 | 
	
		
			
				|  |  | +import java.util.Iterator;
 | 
	
		
			
				|  |  | +import java.util.List;
 | 
	
		
			
				|  |  | +import java.util.Map;
 | 
	
		
			
				|  |  | +import java.util.Objects;
 | 
	
		
			
				|  |  | +import java.util.Set;
 | 
	
		
			
				|  |  |  import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.annotation.Resource;
 | 
	
	
		
			
				|  | @@ -12,18 +21,88 @@ import org.slf4j.Logger;
 | 
	
		
			
				|  |  |  import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Isolation;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  |  import com.ym.mec.auth.api.entity.SysUserRole;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dao.*;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.dto.*;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.entity.*;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.dal.enums.*;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.GoodsDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.MusicGroupDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderCourseSettingsDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.MusicGroupPaymentStudentCourseDetailDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.MusicGroupStudentFeeDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.MusicGroupSubjectPlanDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.StudentCourseFeeDetailDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.StudentDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.StudentPaymentOrderDetailDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.SubjectChangeDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.SubjectDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.SysConfigDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dao.TeacherDao;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.CourseFormDto;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.StudentAddDto;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.StudentFeeDetailDto;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.StudentInfo;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.dto.StudentMusicDetailDto;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.ClassGroup;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.ClassGroupStudentMapper;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.CooperationOrgan;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.CourseSchedule;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.Goods;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroup;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalender;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderCourseSettings;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroupPaymentStudentCourseDetail;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.Student;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.StudentCourseFeeDetail;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.StudentRegistration;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.Subject;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.SubjectChange;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.SysUserCashAccount;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.entity.SysUserCashAccountDetail;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.ClassGroupStudentStatusEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.ClassGroupTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.DealStatusEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.GoodsType;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.GroupType;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.dal.enums.StudentMusicGroupStatusEnum;
 | 
	
		
			
				|  |  |  import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo;
 | 
	
		
			
				|  |  | -import com.ym.mec.biz.service.*;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.ClassGroupService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.ClassGroupStudentMapperService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.ContractService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.CourseScheduleService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.CourseScheduleStudentPaymentService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.MusicGroupPaymentCalenderService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.MusicGroupSubjectPlanService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SellOrderService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentPaymentOrderService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.StudentRegistrationService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SubjectService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysConfigService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysMessageService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysUserCashAccountDetailService;
 | 
	
		
			
				|  |  | +import com.ym.mec.biz.service.SysUserCashAccountService;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.dal.BaseDAO;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.ImGroupMember;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.ImGroupModel;
 | 
	
	
		
			
				|  | @@ -31,15 +110,11 @@ import com.ym.mec.common.entity.ImResult;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.entity.ImUserModel;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.exception.BizException;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.page.PageInfo;
 | 
	
		
			
				|  |  | -import com.ym.mec.common.redis.service.RedisCache;
 | 
	
		
			
				|  |  |  import com.ym.mec.common.service.impl.BaseServiceImpl;
 | 
	
		
			
				|  |  |  import com.ym.mec.im.ImFeignService;
 | 
	
		
			
				|  |  | -import com.ym.mec.thirdparty.eseal.ESealPlugin;
 | 
	
		
			
				|  |  |  import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.collection.MapUtil;
 | 
	
		
			
				|  |  | -import com.ym.mec.util.date.DateUtil;
 | 
	
		
			
				|  |  |  import com.ym.mec.util.http.HttpUtil;
 | 
	
		
			
				|  |  | -import org.springframework.transaction.annotation.Isolation;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @Service
 | 
	
		
			
				|  |  |  public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, StudentRegistration> implements StudentRegistrationService {
 | 
	
	
		
			
				|  | @@ -863,15 +938,26 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |          MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
 | 
	
		
			
				|  |  | -            MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
 | 
	
		
			
				|  |  | +            MusicGroup musicGroup = musicGroupDao.getLocked(studentRegistration.getMusicGroupId());
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              if (studentRegistration.getTemporaryCourseFee() != null) {
 | 
	
		
			
				|  |  |                  studentRegistration.setTemporaryCourseFee(new BigDecimal(0));
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              studentRegistration.setPaymentStatus(PaymentStatusEnum.YES);
 | 
	
		
			
				|  |  |              studentRegistration.setMusicGroupStatus(StudentMusicGroupStatusEnum.NORMAL);
 | 
	
		
			
				|  |  | +            //累加充值金额
 | 
	
		
			
				|  |  | +            studentRegistration.setSurplusCourseFee(studentRegistration.getSurplusCourseFee().add(studentPaymentOrder.getExpectAmount()));
 | 
	
		
			
				|  |  |              studentRegistrationDao.update(studentRegistration);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            //添加日志
 | 
	
		
			
				|  |  | +            StudentCourseFeeDetail studentCourseFeeDetail = new StudentCourseFeeDetail();
 | 
	
		
			
				|  |  | +            studentCourseFeeDetail.setStudentRegistrationId(studentRegistration.getId());
 | 
	
		
			
				|  |  | +            studentCourseFeeDetail.setAmount(studentPaymentOrder.getExpectAmount());
 | 
	
		
			
				|  |  | +            studentCourseFeeDetail.setSurplusCourseFee(studentRegistration.getSurplusCourseFee());
 | 
	
		
			
				|  |  | +            studentCourseFeeDetail.setMemo("充值");
 | 
	
		
			
				|  |  | +            studentCourseFeeDetail.setOperator(studentPaymentOrder.getUserId());
 | 
	
		
			
				|  |  | +            studentCourseFeeDetailDao.insert(studentCourseFeeDetail);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              //当前乐团报名是否赠送乐团网管课
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |              MusicGroupStudentFee musicGroupStudentFee = musicGroupStudentFeeDao.findByUser(studentRegistration.getUserId(), studentRegistration.getMusicGroupId());
 | 
	
	
		
			
				|  | @@ -1003,59 +1089,91 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 | 
	
		
			
				|  |  |          musicGroupStudentFee.setIsLock(0);
 | 
	
		
			
				|  |  |          musicGroupStudentFee.setMusicGroupId(studentRegistration.getMusicGroupId());
 | 
	
		
			
				|  |  |          musicGroupStudentFee.setUserId(studentRegistration.getUserId());
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        String currentMusicGroupId = studentRegistration.getMusicGroupId();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          //缴费详情 calender detail
 | 
	
		
			
				|  |  | -        MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(studentRegistration.getMusicGroupId());
 | 
	
		
			
				|  |  | +        MusicGroupPaymentCalender musicGroupRegCalender = musicGroupPaymentCalenderService.findByMusicGroupRegCalender(currentMusicGroupId);
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        String batchNo = musicGroupRegCalender.getBatchNo();
 | 
	
		
			
				|  |  | +        Long currentPaymentCalenderId = musicGroupRegCalender.getId();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        List<MusicGroupPaymentCalender> musicGroupPaymentCalenderList = musicGroupPaymentCalenderDao.findByBatchNo(batchNo);
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  |          if (musicGroupRegCalender.getIsGiveMusicNetwork() != null && musicGroupRegCalender.getIsGiveMusicNetwork()) {
 | 
	
		
			
				|  |  |              //赠送网管课
 | 
	
		
			
				|  |  | -            musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + 1);
 | 
	
		
			
				|  |  | +            musicGroupStudentFee.setRemainNetworkClassTimes(musicGroupStudentFee.getRemainNetworkClassTimes() + musicGroupPaymentCalenderList.size());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          musicGroupStudentFeeDao.insert(musicGroupStudentFee);
 | 
	
		
			
				|  |  | -        //更新实际缴费人数
 | 
	
		
			
				|  |  | -        int actualNum = musicGroupRegCalender.getActualNum() == null ? 0 : musicGroupRegCalender.getActualNum();
 | 
	
		
			
				|  |  | -        musicGroupRegCalender.setExpectNum(actualNum + 1);
 | 
	
		
			
				|  |  | -        musicGroupRegCalender.setActualNum(actualNum + 1);
 | 
	
		
			
				|  |  | -        musicGroupRegCalender.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDao.update(musicGroupRegCalender);
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +        for(MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList){
 | 
	
		
			
				|  |  | +        	if(currentPaymentCalenderId == musicGroupPaymentCalender.getId()){
 | 
	
		
			
				|  |  | +                //更新实际缴费人数
 | 
	
		
			
				|  |  | +        		musicGroupPaymentCalender.setActualNum(musicGroupPaymentCalender.getActualNum() + 1);
 | 
	
		
			
				|  |  | +        	}
 | 
	
		
			
				|  |  | +        	musicGroupPaymentCalender.setExpectNum(musicGroupPaymentCalender.getExpectNum() + 1);
 | 
	
		
			
				|  |  | +        	musicGroupPaymentCalender.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if(musicGroupPaymentCalenderList.size() > 0){
 | 
	
		
			
				|  |  | +        	musicGroupPaymentCalenderDao.batchUpdate(musicGroupPaymentCalenderList);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<String> orderDetailTypes = studentPaymentOrderDetailDao.getOrderDetailType(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  |          List<MusicGroupPaymentCalenderCourseSettings> courseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalender(musicGroupRegCalender.getId());
 | 
	
		
			
				|  |  |          BigDecimal courseTotalPrice = courseSettings.stream().filter(e -> orderDetailTypes.contains(e.getCourseType().getCode())).map(MusicGroupPaymentCalenderCourseSettings::getCourseCurrentPrice).reduce(BigDecimal.ZERO, BigDecimal::add);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setUserId(studentPaymentOrder.getUserId());
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setExpectAmount(courseTotalPrice);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setActualAmount(courseTotalPrice);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setUserStatus(null);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setPayTime(nowDate);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupRegCalender.getDeadlinePaymentDate());
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupRegCalender.getStartPaymentDate());
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setOpen(1);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setCreateTime(nowDate);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setPaymentOrderId(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetail.setUseInCourse(0);
 | 
	
		
			
				|  |  | -        musicGroupPaymentCalenderDetailDao.insert(musicGroupPaymentCalenderDetail);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList = new ArrayList<MusicGroupPaymentCalenderDetail>();
 | 
	
		
			
				|  |  |          List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = new ArrayList<>();
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettings) {
 | 
	
		
			
				|  |  | -            if (musicGroupRegCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT) && !orderDetailTypes.contains(courseSetting.getCourseType().getCode()))
 | 
	
		
			
				|  |  | -                continue;
 | 
	
		
			
				|  |  | -            MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
 | 
	
		
			
				|  |  | -            musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
 | 
	
		
			
				|  |  | -            musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
 | 
	
		
			
				|  |  | -            musicGroupPaymentStudentCourseDetail.setUserId(studentPaymentOrder.getUserId());
 | 
	
		
			
				|  |  | -            musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
 | 
	
		
			
				|  |  | -            musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
 | 
	
		
			
				|  |  | -            musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
 | 
	
		
			
				|  |  | -            musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
 | 
	
		
			
				|  |  | -            musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | -            musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +		for (MusicGroupPaymentCalender musicGroupPaymentCalender : musicGroupPaymentCalenderList) {
 | 
	
		
			
				|  |  | +			MusicGroupPaymentCalenderDetail musicGroupPaymentCalenderDetail = new MusicGroupPaymentCalenderDetail();
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetail.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetail.setUserId(studentPaymentOrder.getUserId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			if (currentPaymentCalenderId == musicGroupPaymentCalender.getId()) {
 | 
	
		
			
				|  |  | +				musicGroupPaymentCalenderDetail.setExpectAmount(courseTotalPrice);
 | 
	
		
			
				|  |  | +				musicGroupPaymentCalenderDetail.setActualAmount(courseTotalPrice);
 | 
	
		
			
				|  |  | +				musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
 | 
	
		
			
				|  |  | +				musicGroupPaymentCalenderDetail.setPayTime(nowDate);
 | 
	
		
			
				|  |  | +				musicGroupPaymentCalenderDetail.setPaymentOrderId(studentPaymentOrder.getId());
 | 
	
		
			
				|  |  | +				musicGroupPaymentCalenderDetail.setUseInCourse(0);
 | 
	
		
			
				|  |  | +				musicGroupPaymentCalenderDetail.setOpen(1);
 | 
	
		
			
				|  |  | +			} else {
 | 
	
		
			
				|  |  | +				musicGroupPaymentCalenderDetail.setExpectAmount(musicGroupPaymentCalender.getPaymentAmount());
 | 
	
		
			
				|  |  | +				musicGroupPaymentCalenderDetail.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.NON_PAYMENT);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetail.setUserStatus(null);
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetail.setDeadlinePaymentDate(musicGroupRegCalender.getDeadlinePaymentDate());
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetail.setStartPaymentDate(musicGroupRegCalender.getStartPaymentDate());
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetail.setCreateTime(nowDate);
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetail.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			musicGroupPaymentCalenderDetailList.add(musicGroupPaymentCalenderDetail);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			List<MusicGroupPaymentCalenderCourseSettings> courseSettingsList = musicGroupPaymentCalenderCourseSettingsDao
 | 
	
		
			
				|  |  | +					.getWithPaymentCalender(musicGroupPaymentCalender.getId());
 | 
	
		
			
				|  |  | +			for (MusicGroupPaymentCalenderCourseSettings courseSetting : courseSettingsList) {
 | 
	
		
			
				|  |  | +				if (musicGroupRegCalender.getPayUserType().equals(MusicGroupPaymentCalender.PayUserType.STUDENT)
 | 
	
		
			
				|  |  | +						&& !orderDetailTypes.contains(courseSetting.getCourseType().getCode()))
 | 
	
		
			
				|  |  | +					continue;
 | 
	
		
			
				|  |  | +				MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail = new MusicGroupPaymentStudentCourseDetail();
 | 
	
		
			
				|  |  | +				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderId(musicGroupRegCalender.getId());
 | 
	
		
			
				|  |  | +				musicGroupPaymentStudentCourseDetail.setMusicGroupPaymentCalenderDetailId(musicGroupPaymentCalenderDetail.getId());
 | 
	
		
			
				|  |  | +				musicGroupPaymentStudentCourseDetail.setUserId(studentPaymentOrder.getUserId());
 | 
	
		
			
				|  |  | +				musicGroupPaymentStudentCourseDetail.setCourseType(courseSetting.getCourseType());
 | 
	
		
			
				|  |  | +				musicGroupPaymentStudentCourseDetail.setTotalCourseMinutes(courseSetting.getCourseTotalMinuties());
 | 
	
		
			
				|  |  | +				musicGroupPaymentStudentCourseDetail.setUsedCourseMinutes(0);
 | 
	
		
			
				|  |  | +				musicGroupPaymentStudentCourseDetail.setCreateTime(nowDate);
 | 
	
		
			
				|  |  | +				musicGroupPaymentStudentCourseDetail.setUpdateTime(nowDate);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +				musicGroupPaymentStudentCourseDetails.add(musicGroupPaymentStudentCourseDetail);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if(musicGroupPaymentCalenderDetailList.size()> 0){
 | 
	
		
			
				|  |  | +        	musicGroupPaymentCalenderDetailDao.batchInsert(musicGroupPaymentCalenderDetailList);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          if (musicGroupPaymentStudentCourseDetails.size() > 0) {
 | 
	
		
			
				|  |  |              musicGroupPaymentStudentCourseDetailDao.batchInsert(musicGroupPaymentStudentCourseDetails);
 | 
	
		
			
				|  |  |          }
 |