|  | @@ -3675,6 +3675,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 | 
	
		
			
				|  |  |          //学员剩余课程价值
 | 
	
		
			
				|  |  |          Map<Integer,BigDecimal> classGroupTotalPrice = new HashMap<>();
 | 
	
		
			
				|  |  |          //主班剩余课程价值
 | 
	
		
			
				|  |  | +        Map<String, BigDecimal> masterTotalPriceMap = getMasterTotalPriceMap(masterClassGroupId);
 | 
	
		
			
				|  |  |          BigDecimal masterTotalPrice = getMasterTotalPrice(masterClassGroupId);
 | 
	
		
			
				|  |  |          for (Map<String, String> classGroupStudent : classGroupStudents) {
 | 
	
		
			
				|  |  |              for (String integer : classGroupStudent.keySet()) {
 | 
	
	
		
			
				|  | @@ -3702,6 +3703,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 | 
	
		
			
				|  |  |              if(bigDecimal == null){
 | 
	
		
			
				|  |  |                  bigDecimal = BigDecimal.ZERO;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +            //学员可带走的价值
 | 
	
		
			
				|  |  |              BigDecimal subCourseAmount;
 | 
	
		
			
				|  |  |              if(masterTotalPrice.doubleValue() >= totalPrice.doubleValue()){
 | 
	
		
			
				|  |  |                  subCourseAmount = totalPrice;
 | 
	
	
		
			
				|  | @@ -3711,25 +3713,21 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 | 
	
		
			
				|  |  |              if(subCourseAmount.doubleValue() >= bigDecimal.doubleValue()){
 | 
	
		
			
				|  |  |                  subCourseAmount = bigDecimal;
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -            BigDecimal subDecimal = subCourseAmount;
 | 
	
		
			
				|  |  | -            BigDecimal masterDecimal1 = masterTotalPrice;
 | 
	
		
			
				|  |  |              for (int i = 0; i < courseTypes.size(); i++) {
 | 
	
		
			
				|  |  | +                BigDecimal masterPrice = masterTotalPriceMap.get(courseTypes.get(i));
 | 
	
		
			
				|  |  |                  MusicGroupPaymentCalenderStudentDetail calenderDto = new MusicGroupPaymentCalenderStudentDetail();
 | 
	
		
			
				|  |  |                  calenderDto.setClassGroupId(studentCLassMap.get(studentId));
 | 
	
		
			
				|  |  | -                BigDecimal decimal = subCourseAmount.divide(new BigDecimal(courseTypes.size()),BigDecimal.ROUND_HALF_UP);
 | 
	
		
			
				|  |  | -                BigDecimal masterDecimal = masterTotalPrice.divide(new BigDecimal(courseTypes.size()),BigDecimal.ROUND_HALF_UP);
 | 
	
		
			
				|  |  | -                subDecimal = subDecimal.subtract(decimal);
 | 
	
		
			
				|  |  | -                masterDecimal1 = masterDecimal1.subtract(masterDecimal);
 | 
	
		
			
				|  |  | -                if(i == courseTypes.size() - 1){
 | 
	
		
			
				|  |  | -                    decimal =  decimal.add(subDecimal);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                if(i == courseTypes.size() - 1){
 | 
	
		
			
				|  |  | -                    masterDecimal =  masterDecimal.add(masterDecimal1);
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -                calenderDto.setMasterSubCoursePrice(masterDecimal);
 | 
	
		
			
				|  |  | -                calenderDto.setSubCourseAmount(decimal);
 | 
	
		
			
				|  |  | -                calenderDto.setCutAmount(decimal);
 | 
	
		
			
				|  |  | -                calenderDto.setCourseCurrentPrice(masterDecimal.subtract(decimal));
 | 
	
		
			
				|  |  | +                if(subCourseAmount.doubleValue() >= masterPrice.doubleValue()){
 | 
	
		
			
				|  |  | +                    calenderDto.setSubCourseAmount(masterPrice);
 | 
	
		
			
				|  |  | +                    calenderDto.setCutAmount(masterPrice);
 | 
	
		
			
				|  |  | +                    subCourseAmount = subCourseAmount.subtract(masterPrice);
 | 
	
		
			
				|  |  | +                }else {
 | 
	
		
			
				|  |  | +                    calenderDto.setSubCourseAmount(subCourseAmount);
 | 
	
		
			
				|  |  | +                    calenderDto.setCutAmount(subCourseAmount);
 | 
	
		
			
				|  |  | +                    subCourseAmount = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                calenderDto.setMasterSubCoursePrice(masterPrice);
 | 
	
		
			
				|  |  | +                calenderDto.setCourseCurrentPrice(masterPrice.subtract(calenderDto.getCutAmount()));
 | 
	
		
			
				|  |  |                  calenderDto.setCourseType(courseTypes.get(i));
 | 
	
		
			
				|  |  |                  calenderDto.setPhone(phoneMaps.get(studentId));
 | 
	
		
			
				|  |  |                  calenderDto.setUserId(studentId);
 | 
	
	
		
			
				|  | @@ -3771,6 +3769,34 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 | 
	
		
			
				|  |  |          return masterTotalPrice;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    public Map<String,BigDecimal> getMasterTotalPriceMap(Integer masterClassGroupId) {
 | 
	
		
			
				|  |  | +        //获取主班剩余时长
 | 
	
		
			
				|  |  | +        Map<String, BigDecimal> masterMap = MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseTimeMap(masterClassGroupId));
 | 
	
		
			
				|  |  | +        if(masterMap.size() == 0){
 | 
	
		
			
				|  |  | +            throw new BizException("操作失败:所选主班没有剩余时长");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Map<String,BigDecimal> resultMap = new HashMap<>();
 | 
	
		
			
				|  |  | +        //获取分布默认的课程类型单价
 | 
	
		
			
				|  |  | +        MusicGroup musicGroup = musicGroupDao.findByClassGroupId(masterClassGroupId);
 | 
	
		
			
				|  |  | +        Map<String, BigDecimal> unitPriceMap = MapUtil.convertIntegerMap(organizationCourseUnitPriceSettingsDao.queryMapByOrganIdAndChargeTypeId(musicGroup.getChargeTypeId(), musicGroup.getOrganId()));
 | 
	
		
			
				|  |  | +        Set<String> masterKeySet = masterMap.keySet();
 | 
	
		
			
				|  |  | +        //计算主班课程类型剩余价值
 | 
	
		
			
				|  |  | +        for (String s : masterKeySet) {
 | 
	
		
			
				|  |  | +            BigDecimal unitPrice = unitPriceMap.get(s);
 | 
	
		
			
				|  |  | +            if (unitPrice == null) {
 | 
	
		
			
				|  |  | +                throw new BizException("分部默认课程类型单价不存在,请设置");
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            BigDecimal courseTime = masterMap.get(s);
 | 
	
		
			
				|  |  | +            if(courseTime == null){
 | 
	
		
			
				|  |  | +                courseTime = BigDecimal.ZERO;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            //获取主班剩余课程价值,按分部默认单价计算
 | 
	
		
			
				|  |  | +            BigDecimal totalPrice = unitPrice.multiply(courseTime).setScale(0, BigDecimal.ROUND_HALF_UP);
 | 
	
		
			
				|  |  | +            resultMap.put(s,totalPrice);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return resultMap;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public Map<String, Long> querySubCourseTime(Integer classGroupId) {
 | 
	
		
			
				|  |  |          return MapUtil.convertIntegerMap(courseScheduleDao.querySubCourseNumMap(classGroupId));
 |