|  | @@ -149,6 +149,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  	private GroupClassService groupClassService;
 |  |  	private GroupClassService groupClassService;
 | 
											
												
													
														|  |  	@Autowired
 |  |  	@Autowired
 | 
											
												
													
														|  |  	private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
 |  |  	private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
 | 
											
												
													
														|  | 
 |  | +	@Autowired
 | 
											
												
													
														|  | 
 |  | +	private VipGroupStudentCoursePriceDao vipGroupStudentCoursePriceDao;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	private static final Logger LOGGER = LoggerFactory
 |  |  	private static final Logger LOGGER = LoggerFactory
 | 
											
												
													
														|  |  			.getLogger(VipGroup.class);
 |  |  			.getLogger(VipGroup.class);
 | 
											
										
											
												
													
														|  | @@ -205,23 +207,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          if(Objects.isNull(vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice())
 |  |          if(Objects.isNull(vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice())
 | 
											
												
													
														|  |              &&Objects.isNull(vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice())){
 |  |              &&Objects.isNull(vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice())){
 | 
											
												
													
														|  | -            throw new BizException("请设置教师课酬");
 |  | 
 | 
											
												
													
														|  | 
 |  | +            throw new BizException("请设置课程单价");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		if(StringUtils.isBlank(vipGroupApplyBaseInfoDto.getStudentIdList())){
 |  |  		if(StringUtils.isBlank(vipGroupApplyBaseInfoDto.getStudentIdList())){
 | 
											
												
													
														|  |  			throw new BizException("请选择学员");
 |  |  			throw new BizException("请选择学员");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        if(Objects.isNull(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary())){
 |  | 
 | 
											
												
													
														|  | -        	vipGroupApplyBaseInfoDto.setOnlineTeacherSalary(new BigDecimal(0));
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -		if(Objects.isNull(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary())){
 |  | 
 | 
											
												
													
														|  | -			vipGroupApplyBaseInfoDto.setOfflineTeacherSalary(new BigDecimal(0));
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if(Objects.isNull(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary())||Objects.isNull(vipGroupApplyBaseInfoDto.getOfflineTeacherSalary())){
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("请设置教师课酬");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		//获取活动信息
 |  | 
 | 
											
												
													
														|  | -		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId().intValue());
 |  | 
 | 
											
												
													
														|  |  		Integer totalClassTimes=vipGroupApplyBaseInfoDto.getOnlineClassesNum()+vipGroupApplyBaseInfoDto.getOfflineClassesNum();
 |  |  		Integer totalClassTimes=vipGroupApplyBaseInfoDto.getOnlineClassesNum()+vipGroupApplyBaseInfoDto.getOfflineClassesNum();
 | 
											
												
													
														|  |  		//获取第一节课
 |  |  		//获取第一节课
 | 
											
												
													
														|  |  		CourseSchedule firstCourseSchedule = vipGroup.getCourseSchedules().stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
 |  |  		CourseSchedule firstCourseSchedule = vipGroup.getCourseSchedules().stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
 | 
											
										
											
												
													
														|  | @@ -241,8 +237,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  		    throw new BizException("创建失败,报名截止时间必须在开课时间前一天");
 |  |  		    throw new BizException("创建失败,报名截止时间必须在开课时间前一天");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +		List<Integer> canBuyStudentIds = Arrays.stream(vipGroupApplyBaseInfoDto.getStudentIdList().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +		List<VipGroupStudentCoursePrice> vscps = vipGroup.getVipGroupApplyBaseInfo().getVipGroupStudentCoursePrices();
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		//获取活动信息
 | 
											
												
													
														|  | 
 |  | +		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupApplyBaseInfo().getVipGroupActivityId());
 | 
											
												
													
														|  |  		//判断课程安排是否超出范围
 |  |  		//判断课程安排是否超出范围
 | 
											
												
													
														|  | -		if(Objects.nonNull(vipGroupActivity.getCoursesEndTime())||Objects.nonNull(vipGroupActivity.getCoursesStartTime())){
 |  | 
 | 
											
												
													
														|  | 
 |  | +		if(Objects.nonNull(vipGroupActivity)&&(Objects.nonNull(vipGroupActivity.getCoursesEndTime())||Objects.nonNull(vipGroupActivity.getCoursesStartTime()))){
 | 
											
												
													
														|  |  			if(latestCourseSchedule.getEndClassTime().after(vipGroupActivity.getCoursesEndTime())
 |  |  			if(latestCourseSchedule.getEndClassTime().after(vipGroupActivity.getCoursesEndTime())
 | 
											
												
													
														|  |  					||firstCourseSchedule.getStartClassTime().before(vipGroupActivity.getCoursesStartTime())){
 |  |  					||firstCourseSchedule.getStartClassTime().before(vipGroupActivity.getCoursesStartTime())){
 | 
											
												
													
														|  |  				throw new BizException("课时安排时间超出范围!");
 |  |  				throw new BizException("课时安排时间超出范围!");
 | 
											
										
											
												
													
														|  | @@ -267,47 +268,23 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  		if(Objects.isNull(vipGroupCategory)){
 |  |  		if(Objects.isNull(vipGroupCategory)){
 | 
											
												
													
														|  |  			throw new BizException("课程形式不存在");
 |  |  			throw new BizException("课程形式不存在");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -		List<Integer> canBuyStudentIds = Arrays.stream(vipGroupApplyBaseInfoDto.getStudentIdList().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toList());
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  		List<String> studentNames = studentDao.getStudentNames(canBuyStudentIds);
 |  |  		List<String> studentNames = studentDao.getStudentNames(canBuyStudentIds);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		//生成vip课信息
 |  |  		//生成vip课信息
 | 
											
												
													
														|  |  		List<String> bySubIds = subjectDao.findBySubIds(vipGroupApplyBaseInfoDto.getSubjectIdList());
 |  |  		List<String> bySubIds = subjectDao.findBySubIds(vipGroupApplyBaseInfoDto.getSubjectIdList());
 | 
											
												
													
														|  | -		StringBuffer className=new StringBuffer(StringUtils.join(bySubIds,","));
 |  | 
 | 
											
												
													
														|  | -		className.append(vipGroupCategory.getName());
 |  | 
 | 
											
												
													
														|  | 
 |  | +		StringBuffer className=new StringBuffer();
 | 
											
												
													
														|  | 
 |  | +		if(Objects.isNull(vipGroupCategory.getMusicTheory())||!vipGroupCategory.getMusicTheory()){
 | 
											
												
													
														|  | 
 |  | +			className.append(StringUtils.join(bySubIds,","));
 | 
											
												
													
														|  | 
 |  | +			className.append(vipGroupCategory.getName());
 | 
											
												
													
														|  | 
 |  | +		}else{
 | 
											
												
													
														|  | 
 |  | +			className.append("乐理课•");
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  		className.append(StringUtils.join(studentNames, ","));
 |  |  		className.append(StringUtils.join(studentNames, ","));
 | 
											
												
													
														|  |  		vipGroupApplyBaseInfoDto.setName(className.toString());
 |  |  		vipGroupApplyBaseInfoDto.setName(className.toString());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		//计算课程相关费用信息
 |  |  		//计算课程相关费用信息
 | 
											
												
													
														|  |  		Map<String, BigDecimal> costInfo = countVipGroupPredictFee(vipGroupApplyBaseInfoDto,
 |  |  		Map<String, BigDecimal> costInfo = countVipGroupPredictFee(vipGroupApplyBaseInfoDto,
 | 
											
												
													
														|  | -				vipGroupApplyBaseInfoDto.getUserId(),
 |  | 
 | 
											
												
													
														|  | -				vipGroupApplyBaseInfoDto.getOnlineClassesUnitPrice(),
 |  | 
 | 
											
												
													
														|  | -				vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice());
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -//		BigDecimal offlineClassNum=new BigDecimal(vipGroupApplyBaseInfoDto.getOfflineClassesNum());
 |  | 
 | 
											
												
													
														|  | -//		BigDecimal onlineClassNum=new BigDecimal(vipGroupApplyBaseInfoDto.getOnlineClassesNum());
 |  | 
 | 
											
												
													
														|  | -//
 |  | 
 | 
											
												
													
														|  | -//		if(vipGroupActivity.getType().equals(VipGroupActivityTypeEnum.GIVE_CLASS)){
 |  | 
 | 
											
												
													
														|  | -//			if(vipGroupApplyBaseInfoDto.getGiveTeachMode()==TeachModeEnum.OFFLINE){
 |  | 
 | 
											
												
													
														|  | -//				if(new BigDecimal(totalClassTimes).compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
 |  | 
 | 
											
												
													
														|  | -//					offlineClassNum=offlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
 |  | 
 | 
											
												
													
														|  | -//				}
 |  | 
 | 
											
												
													
														|  | -//			}else if(vipGroupApplyBaseInfoDto.getGiveTeachMode()==TeachModeEnum.ONLINE){
 |  | 
 | 
											
												
													
														|  | -//				if(new BigDecimal(totalClassTimes).compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
 |  | 
 | 
											
												
													
														|  | -//					onlineClassNum=onlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
 |  | 
 | 
											
												
													
														|  | -//				}
 |  | 
 | 
											
												
													
														|  | -//			}else{
 |  | 
 | 
											
												
													
														|  | -//				throw new BizException("请指定赠送课程类型!");
 |  | 
 | 
											
												
													
														|  | -//			}
 |  | 
 | 
											
												
													
														|  | -//		}
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -//		BigDecimal tempFee = costInfo.get("totalPrice").multiply(new BigDecimal(0.6));
 |  | 
 | 
											
												
													
														|  | -//		BigDecimal totalSalary = vipGroupApplyBaseInfoDto.getOfflineTeacherSalary().multiply(offlineClassNum)
 |  | 
 | 
											
												
													
														|  | -//				.add(vipGroupApplyBaseInfoDto.getOnlineTeacherSalary().multiply(onlineClassNum));
 |  | 
 | 
											
												
													
														|  | -//		if(totalSalary.compareTo(tempFee)>0){
 |  | 
 | 
											
												
													
														|  | -//			throw new BizException("教师总课酬不能高于课程总价60%");
 |  | 
 | 
											
												
													
														|  | -//		}
 |  | 
 | 
											
												
													
														|  | 
 |  | +				vipGroupApplyBaseInfoDto.getUserId());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
 |  |          vipGroupApplyBaseInfoDto.setAuditStatus(AuditStatusEnum.PASS);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -324,6 +301,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  		}else{
 |  |  		}else{
 | 
											
												
													
														|  |  			vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.APPLYING);
 |  |  			vipGroupApplyBaseInfoDto.setStatus(VipGroupStatusEnum.APPLYING);
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | 
 |  | +		if(CollectionUtils.isEmpty(vscps)){
 | 
											
												
													
														|  | 
 |  | +			for (Integer canBuyStudentId : canBuyStudentIds) {
 | 
											
												
													
														|  | 
 |  | +				vscps.add(new VipGroupStudentCoursePrice(canBuyStudentId, vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(), vipGroupApplyBaseInfoDto.getOfflineClassesUnitPrice(), vipGroupApplyBaseInfoDto.getTotalPrice()));
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |          Teacher teacher = teacherService.get(vipGroupApplyBaseInfoDto.getUserId());
 |  |          Teacher teacher = teacherService.get(vipGroupApplyBaseInfoDto.getUserId());
 | 
											
												
													
														|  |  		if(Objects.isNull(teacher)){
 |  |  		if(Objects.isNull(teacher)){
 | 
											
												
													
														|  |  		    throw new BizException("教师不存在");
 |  |  		    throw new BizException("教师不存在");
 | 
											
										
											
												
													
														|  | @@ -360,6 +342,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		vipGroupDao.insert(vipGroupApplyBaseInfoDto);
 |  |  		vipGroupDao.insert(vipGroupApplyBaseInfoDto);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +		vscps.forEach(e->e.setVipGroupId(vipGroupApplyBaseInfoDto.getId()));
 | 
											
												
													
														|  | 
 |  | +		vipGroupStudentCoursePriceDao.batchInsert(vscps);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |          vipGroup.getVipGroupApplyBaseInfo().setId(vipGroupApplyBaseInfoDto.getId());
 |  |          vipGroup.getVipGroupApplyBaseInfo().setId(vipGroupApplyBaseInfoDto.getId());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		//创建班级信息
 |  |  		//创建班级信息
 | 
											
										
											
												
													
														|  | @@ -948,9 +933,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public <K extends VipGroup> Map<String,BigDecimal> countVipGroupPredictFee(K vipGroup,
 |  |      public <K extends VipGroup> Map<String,BigDecimal> countVipGroupPredictFee(K vipGroup,
 | 
											
												
													
														|  | -																			   Integer teacherId,
 |  | 
 | 
											
												
													
														|  | -																			   BigDecimal onlineClassesUnitPrice,
 |  | 
 | 
											
												
													
														|  | -																			   BigDecimal offlineClassesUnitPrice){
 |  | 
 | 
											
												
													
														|  | 
 |  | +																			   Integer teacherId){
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		if(Objects.isNull(teacherId)){
 |  |  		if(Objects.isNull(teacherId)){
 | 
											
												
													
														|  |  			throw new BizException("请指定教师");
 |  |  			throw new BizException("请指定教师");
 | 
											
										
											
												
													
														|  | @@ -962,7 +945,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		VipGroupCategory vipGroupCategory = vipGroupCategoryDao.get(vipGroup.getVipGroupCategoryId().intValue());
 |  |  		VipGroupCategory vipGroupCategory = vipGroupCategoryDao.get(vipGroup.getVipGroupCategoryId().intValue());
 | 
											
												
													
														|  |  		if(Objects.isNull(vipGroupCategory)){
 |  |  		if(Objects.isNull(vipGroupCategory)){
 | 
											
												
													
														|  | -			throw new BizException("未找到课程形式");
 |  | 
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("课程形式不存在");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(teacherId,
 |  |  		TeacherDefaultVipGroupSalary teacherDefaultVipGroupSalary = teacherDefaultVipGroupSalaryDao.findByTeacherAndCategory(teacherId,
 | 
											
										
											
												
													
														|  | @@ -972,172 +955,181 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  			throw new BizException("请设置教师课酬");
 |  |  			throw new BizException("请设置教师课酬");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		if(Objects.isNull(vipGroup.getVipGroupActivityId())){
 |  | 
 | 
											
												
													
														|  | -			throw new BizException("请指定活动方案");
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -		if(Objects.isNull(vipGroupActivity)){
 |  | 
 | 
											
												
													
														|  | -			throw new BizException("指定的活动方案不存在");
 |  | 
 | 
											
												
													
														|  | 
 |  | +		if(Objects.isNull(teacherDefaultVipGroupSalary)||Objects.isNull(teacherDefaultVipGroupSalary.getOfflineClassesSalary())){
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("请设置教师VIP课课酬");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(), VipGroupSalarySettlementDto.class);
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -		if(Objects.isNull(vipGroupSalarySettlementDto)){
 |  | 
 | 
											
												
													
														|  | -			throw new BizException("课酬结算方案错误");
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | 
 |  | +		VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		Map<String,BigDecimal> results=new HashMap<>(1);
 |  |  		Map<String,BigDecimal> results=new HashMap<>(1);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		BigDecimal offlineClassNum=new BigDecimal(vipGroup.getOfflineClassesNum());
 |  | 
 | 
											
												
													
														|  | -		BigDecimal onlineClassNum=new BigDecimal(vipGroup.getOnlineClassesNum());
 |  | 
 | 
											
												
													
														|  | -		onlineClassesUnitPrice=Objects.isNull(onlineClassesUnitPrice)?vipGroup.getOnlineClassesUnitPrice():onlineClassesUnitPrice;
 |  | 
 | 
											
												
													
														|  | -		if(Objects.isNull(onlineClassesUnitPrice)){
 |  | 
 | 
											
												
													
														|  | -			onlineClassesUnitPrice = BigDecimal.ZERO;
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | -		BigDecimal onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
 |  | 
 | 
											
												
													
														|  | -		offlineClassesUnitPrice=Objects.isNull(offlineClassesUnitPrice)?vipGroup.getOfflineClassesUnitPrice():offlineClassesUnitPrice;
 |  | 
 | 
											
												
													
														|  | -		if(Objects.isNull(offlineClassesUnitPrice)){
 |  | 
 | 
											
												
													
														|  | -			offlineClassesUnitPrice = BigDecimal.ZERO;
 |  | 
 | 
											
												
													
														|  | 
 |  | +		int normalStudentNum = 0;
 | 
											
												
													
														|  | 
 |  | +		if(Objects.nonNull(vipGroup.getId())){
 | 
											
												
													
														|  | 
 |  | +			normalStudentNum = classGroupStudentMapperDao.countGroupNormalStudentNum(GroupType.VIP, vipGroup.getId().toString());
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -		BigDecimal offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
 |  | 
 | 
											
												
													
														|  | -		BigDecimal totalClassNum=offlineClassNum.add(onlineClassNum);
 |  | 
 | 
											
												
													
														|  | -		BigDecimal teacherOnlineSalary=null,teacherOfflineSalary=null;
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		if(Objects.isNull(vipGroupActivity.getType())){
 |  | 
 | 
											
												
													
														|  | -			throw new BizException("此活动未设置活动类型");
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | 
 |  | +		if(Objects.nonNull(vipGroupActivity)){
 | 
											
												
													
														|  | 
 |  | +			VipGroupSalarySettlementDto vipGroupSalarySettlementDto = JSON.parseObject(vipGroupActivity.getSalarySettlementJson(), VipGroupSalarySettlementDto.class);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		//课程购买费用计算
 |  | 
 | 
											
												
													
														|  | -		BigDecimal totalPrice;
 |  | 
 | 
											
												
													
														|  | -		switch (vipGroupActivity.getType()){
 |  | 
 | 
											
												
													
														|  | -			case BASE_ACTIVITY:
 |  | 
 | 
											
												
													
														|  | -				totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
 |  | 
 | 
											
												
													
														|  | -				break;
 |  | 
 | 
											
												
													
														|  | -			case DISCOUNT:
 |  | 
 | 
											
												
													
														|  | -				BigDecimal discount=new BigDecimal(vipGroupActivity.getAttribute1());
 |  | 
 | 
											
												
													
														|  | -				totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
 |  | 
 | 
											
												
													
														|  | -				totalPrice=totalPrice.multiply(discount).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
 |  | 
 | 
											
												
													
														|  | -				break;
 |  | 
 | 
											
												
													
														|  | -			case GIVE_CLASS:
 |  | 
 | 
											
												
													
														|  | -				if(totalClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))<0){
 |  | 
 | 
											
												
													
														|  | 
 |  | +			if(Objects.isNull(vipGroupSalarySettlementDto)){
 | 
											
												
													
														|  | 
 |  | +				throw new BizException("课酬结算方案错误");
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -				}else if(vipGroup.getGiveTeachMode()==TeachModeEnum.OFFLINE){
 |  | 
 | 
											
												
													
														|  | -					if(totalClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
 |  | 
 | 
											
												
													
														|  | -						offlineClassNum=offlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
 |  | 
 | 
											
												
													
														|  | -					}
 |  | 
 | 
											
												
													
														|  | -					offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
 |  | 
 | 
											
												
													
														|  | -				}else if(vipGroup.getGiveTeachMode()==TeachModeEnum.ONLINE){
 |  | 
 | 
											
												
													
														|  | -					if(totalClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
 |  | 
 | 
											
												
													
														|  | -						onlineClassNum=onlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
 |  | 
 | 
											
												
													
														|  | -					}
 |  | 
 | 
											
												
													
														|  | -					onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
 |  | 
 | 
											
												
													
														|  | -				}else{
 |  | 
 | 
											
												
													
														|  | -					throw new BizException("请指定赠送课程类型!");
 |  | 
 | 
											
												
													
														|  | -				}
 |  | 
 | 
											
												
													
														|  | -				totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
 |  | 
 | 
											
												
													
														|  | -				break;
 |  | 
 | 
											
												
													
														|  | -			default:
 |  | 
 | 
											
												
													
														|  | -				throw new BizException("活动类型错误!");
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | 
 |  | +			BigDecimal offlineClassNum=new BigDecimal(vipGroup.getOfflineClassesNum());
 | 
											
												
													
														|  | 
 |  | +			BigDecimal onlineClassNum=new BigDecimal(vipGroup.getOnlineClassesNum());
 | 
											
												
													
														|  | 
 |  | +			BigDecimal onlineClassesUnitPrice=vipGroup.getOnlineClassesUnitPrice();
 | 
											
												
													
														|  | 
 |  | +			if(Objects.isNull(onlineClassesUnitPrice)){
 | 
											
												
													
														|  | 
 |  | +				throw new BizException("课程单价异常");
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			BigDecimal onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		results.put("totalPrice",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
 |  | 
 | 
											
												
													
														|  | 
 |  | +			BigDecimal offlineClassesUnitPrice=vipGroup.getOfflineClassesUnitPrice();
 | 
											
												
													
														|  | 
 |  | +			if(Objects.isNull(offlineClassesUnitPrice)){
 | 
											
												
													
														|  | 
 |  | +				throw new BizException("课程单价异常");
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			BigDecimal offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
 | 
											
												
													
														|  | 
 |  | +			BigDecimal totalClassNum=offlineClassNum.add(onlineClassNum);
 | 
											
												
													
														|  | 
 |  | +			BigDecimal teacherOnlineSalary=null,teacherOfflineSalary=null;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			//课程购买费用计算
 | 
											
												
													
														|  | 
 |  | +			BigDecimal totalPrice;
 | 
											
												
													
														|  | 
 |  | +			switch (vipGroupActivity.getType()){
 | 
											
												
													
														|  | 
 |  | +				case BASE_ACTIVITY:
 | 
											
												
													
														|  | 
 |  | +					totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
 | 
											
												
													
														|  | 
 |  | +					break;
 | 
											
												
													
														|  | 
 |  | +				case DISCOUNT:
 | 
											
												
													
														|  | 
 |  | +					BigDecimal discount=new BigDecimal(vipGroupActivity.getAttribute1());
 | 
											
												
													
														|  | 
 |  | +					totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
 | 
											
												
													
														|  | 
 |  | +					totalPrice=totalPrice.multiply(discount).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
 | 
											
												
													
														|  | 
 |  | +					break;
 | 
											
												
													
														|  | 
 |  | +				case GIVE_CLASS:
 | 
											
												
													
														|  | 
 |  | +					if(totalClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))<0){
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +					}else if(vipGroup.getGiveTeachMode()==TeachModeEnum.OFFLINE){
 | 
											
												
													
														|  | 
 |  | +						if(totalClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
 | 
											
												
													
														|  | 
 |  | +							offlineClassNum=offlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
 | 
											
												
													
														|  | 
 |  | +						}
 | 
											
												
													
														|  | 
 |  | +						offlineVipGroupCharge = offlineClassesUnitPrice.multiply(offlineClassNum);
 | 
											
												
													
														|  | 
 |  | +					}else if(vipGroup.getGiveTeachMode()==TeachModeEnum.ONLINE){
 | 
											
												
													
														|  | 
 |  | +						if(totalClassNum.compareTo(new BigDecimal(vipGroupActivity.getAttribute1()))>-1){
 | 
											
												
													
														|  | 
 |  | +							onlineClassNum=onlineClassNum.subtract(new BigDecimal(vipGroupActivity.getAttribute2()));
 | 
											
												
													
														|  | 
 |  | +						}
 | 
											
												
													
														|  | 
 |  | +						onlineVipGroupCharge = onlineClassesUnitPrice.multiply(onlineClassNum);
 | 
											
												
													
														|  | 
 |  | +					}else{
 | 
											
												
													
														|  | 
 |  | +						throw new BizException("请指定赠送课程类型!");
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +					totalPrice=onlineVipGroupCharge.add(offlineVipGroupCharge);
 | 
											
												
													
														|  | 
 |  | +					break;
 | 
											
												
													
														|  | 
 |  | +				default:
 | 
											
												
													
														|  | 
 |  | +					throw new BizException("活动类型错误!");
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		int normalStudentNum = 0;
 |  | 
 | 
											
												
													
														|  | -		if(Objects.nonNull(vipGroup.getId())){
 |  | 
 | 
											
												
													
														|  | -			normalStudentNum = classGroupStudentMapperDao.countGroupNormalStudentNum(GroupType.VIP, vipGroup.getId().toString());
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | 
 |  | +			results.put("totalPrice",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -//		if(JobNatureEnum.PART_TIME.equals(teacher.getJobNature())){
 |  | 
 | 
											
												
													
														|  | -//			BigDecimal ots = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 |  | 
 | 
											
												
													
														|  | -//			BigDecimal ofts = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 |  | 
 | 
											
												
													
														|  | -//			if(normalStudentNum>0&&normalStudentNum!=vipGroupCategory.getStudentNum()){
 |  | 
 | 
											
												
													
														|  | -//				ots = ots.divide(new BigDecimal(vipGroupCategory.getStudentNum()),CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
 |  | 
 | 
											
												
													
														|  | -//				ofts = ofts.divide(new BigDecimal(vipGroupCategory.getStudentNum()),CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
 |  | 
 | 
											
												
													
														|  | -//			}
 |  | 
 | 
											
												
													
														|  | -//
 |  | 
 | 
											
												
													
														|  | -//			results.put("onlineTeacherSalary", ots);
 |  | 
 | 
											
												
													
														|  | -//			results.put("offlineTeacherSalary", ofts);
 |  | 
 | 
											
												
													
														|  | -//			return results;
 |  | 
 | 
											
												
													
														|  | -//		}
 |  | 
 | 
											
												
													
														|  | 
 |  | +			if(vipGroup instanceof VipGroupApplyBaseInfoDto && !CollectionUtils.isEmpty(((VipGroupApplyBaseInfoDto)vipGroup).getVipGroupStudentCoursePrices())){
 | 
											
												
													
														|  | 
 |  | +				for (VipGroupStudentCoursePrice vscp : ((VipGroupApplyBaseInfoDto)vipGroup).getVipGroupStudentCoursePrices()) {
 | 
											
												
													
														|  | 
 |  | +					if(Objects.isNull(vscp.getOnlineClassesUnitPrice())||Objects.isNull(vscp.getOfflineClassesUnitPrice())){
 | 
											
												
													
														|  | 
 |  | +						throw new BizException("请设置课程单价");
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +					vscp.setPaymentPrice(vscp.getOfflineClassesUnitPrice().multiply(new BigDecimal(vipGroup.getOfflineClassesNum())).add(vscp.getOnlineClassesUnitPrice().multiply(new BigDecimal(vipGroup.getOnlineClassesNum()))));
 | 
											
												
													
														|  | 
 |  | +					vipGroup.setTotalPrice(vipGroup.getTotalPrice().add(vscp.getPaymentPrice()));
 | 
											
												
													
														|  | 
 |  | +					results.put(vscp.getStudentId().toString(), vscp.getPaymentPrice());
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		//教师课酬线上单课酬计算
 |  | 
 | 
											
												
													
														|  | -		if(Objects.nonNull(vipGroupSalarySettlementDto.getOnlineSalarySettlement())){
 |  | 
 | 
											
												
													
														|  | -			if(Objects.isNull(teacherOnlineSalary)){
 |  | 
 | 
											
												
													
														|  | -				switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
 |  | 
 | 
											
												
													
														|  | -					case TEACHER_DEFAULT:
 |  | 
 | 
											
												
													
														|  | -						if(Objects.isNull(teacherDefaultVipGroupSalary)||Objects.isNull(teacherDefaultVipGroupSalary.getOfflineClassesSalary())){
 |  | 
 | 
											
												
													
														|  | -							teacherOnlineSalary=new BigDecimal(0);
 |  | 
 | 
											
												
													
														|  | -						}else{
 |  | 
 | 
											
												
													
														|  | 
 |  | +			//教师课酬线上单课酬计算
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(vipGroupSalarySettlementDto.getOnlineSalarySettlement())){
 | 
											
												
													
														|  | 
 |  | +				if(Objects.isNull(teacherOnlineSalary)){
 | 
											
												
													
														|  | 
 |  | +					switch (vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSalarySettlementType()){
 | 
											
												
													
														|  | 
 |  | +						case TEACHER_DEFAULT:
 | 
											
												
													
														|  |  							teacherOnlineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 |  |  							teacherOnlineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 | 
											
												
													
														|  | -						}
 |  | 
 | 
											
												
													
														|  | -						results.put("onlineTeacherSalary",teacherOnlineSalary.setScale(0, BigDecimal.ROUND_HALF_UP));
 |  | 
 | 
											
												
													
														|  | -						break;
 |  | 
 | 
											
												
													
														|  | -					case RATIO_DISCOUNT:
 |  | 
 | 
											
												
													
														|  | -						results.put("onlineTeacherSalary",totalPrice.multiply(new BigDecimal(vipGroupCategory.getStudentNum()))
 |  | 
 | 
											
												
													
														|  | -								.divide(totalClassNum, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN)
 |  | 
 | 
											
												
													
														|  | -								.multiply(vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue())
 |  | 
 | 
											
												
													
														|  | -								.divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN)
 |  | 
 | 
											
												
													
														|  | -								.setScale(0,BigDecimal.ROUND_HALF_UP));
 |  | 
 | 
											
												
													
														|  | 
 |  | +							results.put("onlineTeacherSalary",teacherOnlineSalary.setScale(0, BigDecimal.ROUND_HALF_UP));
 | 
											
												
													
														|  | 
 |  | +							break;
 | 
											
												
													
														|  | 
 |  | +						case RATIO_DISCOUNT:
 | 
											
												
													
														|  | 
 |  | +							results.put("onlineTeacherSalary",totalPrice.multiply(new BigDecimal(vipGroupCategory.getStudentNum()))
 | 
											
												
													
														|  | 
 |  | +									.divide(totalClassNum, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN)
 | 
											
												
													
														|  | 
 |  | +									.multiply(vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue())
 | 
											
												
													
														|  | 
 |  | +									.divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN)
 | 
											
												
													
														|  | 
 |  | +									.setScale(0,BigDecimal.ROUND_HALF_UP));
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -						break;
 |  | 
 | 
											
												
													
														|  | -					case FIXED_SALARY:
 |  | 
 | 
											
												
													
														|  | -						results.put("onlineTeacherSalary",vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue().setScale(0, BigDecimal.ROUND_HALF_UP));
 |  | 
 | 
											
												
													
														|  | -						break;
 |  | 
 | 
											
												
													
														|  | -					default:
 |  | 
 | 
											
												
													
														|  | -						throw new BizException("未指定课酬结算标准!");
 |  | 
 | 
											
												
													
														|  | -				}
 |  | 
 | 
											
												
													
														|  | 
 |  | +							break;
 | 
											
												
													
														|  | 
 |  | +						case FIXED_SALARY:
 | 
											
												
													
														|  | 
 |  | +							results.put("onlineTeacherSalary",vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue().setScale(0, BigDecimal.ROUND_HALF_UP));
 | 
											
												
													
														|  | 
 |  | +							break;
 | 
											
												
													
														|  | 
 |  | +						default:
 | 
											
												
													
														|  | 
 |  | +							throw new BizException("未指定课酬结算标准!");
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		//教师线下单课酬计算
 |  | 
 | 
											
												
													
														|  | -		if(Objects.nonNull(vipGroupSalarySettlementDto.getOfflineSalarySettlement())){
 |  | 
 | 
											
												
													
														|  | -			if(Objects.isNull(teacherOfflineSalary)){
 |  | 
 | 
											
												
													
														|  | -				switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
 |  | 
 | 
											
												
													
														|  | -					case TEACHER_DEFAULT:
 |  | 
 | 
											
												
													
														|  | -						if(Objects.isNull(teacherDefaultVipGroupSalary)||Objects.isNull(teacherDefaultVipGroupSalary.getOfflineClassesSalary())){
 |  | 
 | 
											
												
													
														|  | -							teacherOfflineSalary=new BigDecimal(0);
 |  | 
 | 
											
												
													
														|  | -						}else{
 |  | 
 | 
											
												
													
														|  | 
 |  | +			//教师线下单课酬计算
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(vipGroupSalarySettlementDto.getOfflineSalarySettlement())){
 | 
											
												
													
														|  | 
 |  | +				if(Objects.isNull(teacherOfflineSalary)){
 | 
											
												
													
														|  | 
 |  | +					switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
 | 
											
												
													
														|  | 
 |  | +						case TEACHER_DEFAULT:
 | 
											
												
													
														|  |  							teacherOfflineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 |  |  							teacherOfflineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 | 
											
												
													
														|  | -						}
 |  | 
 | 
											
												
													
														|  | -						results.put("offlineTeacherSalary",teacherOfflineSalary.setScale(0, BigDecimal.ROUND_HALF_UP));
 |  | 
 | 
											
												
													
														|  | -						break;
 |  | 
 | 
											
												
													
														|  | -					case RATIO_DISCOUNT:
 |  | 
 | 
											
												
													
														|  | -						results.put("offlineTeacherSalary",totalPrice.multiply(new BigDecimal(vipGroupCategory.getStudentNum())).divide(totalClassNum, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).setScale(0,BigDecimal.ROUND_HALF_UP));
 |  | 
 | 
											
												
													
														|  | 
 |  | +							results.put("offlineTeacherSalary",teacherOfflineSalary.setScale(0, BigDecimal.ROUND_HALF_UP));
 | 
											
												
													
														|  | 
 |  | +							break;
 | 
											
												
													
														|  | 
 |  | +						case RATIO_DISCOUNT:
 | 
											
												
													
														|  | 
 |  | +							results.put("offlineTeacherSalary",totalPrice.multiply(new BigDecimal(vipGroupCategory.getStudentNum())).divide(totalClassNum, CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).setScale(0,BigDecimal.ROUND_HALF_UP));
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -						break;
 |  | 
 | 
											
												
													
														|  | -					case FIXED_SALARY:
 |  | 
 | 
											
												
													
														|  | -						results.put("offlineTeacherSalary",vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue().setScale(0, BigDecimal.ROUND_HALF_UP));
 |  | 
 | 
											
												
													
														|  | -						break;
 |  | 
 | 
											
												
													
														|  | -					default:
 |  | 
 | 
											
												
													
														|  | -						throw new BizException("未指定课酬结算标准!");
 |  | 
 | 
											
												
													
														|  | 
 |  | +							break;
 | 
											
												
													
														|  | 
 |  | +						case FIXED_SALARY:
 | 
											
												
													
														|  | 
 |  | +							results.put("offlineTeacherSalary",vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSettlementValue().setScale(0, BigDecimal.ROUND_HALF_UP));
 | 
											
												
													
														|  | 
 |  | +							break;
 | 
											
												
													
														|  | 
 |  | +						default:
 | 
											
												
													
														|  | 
 |  | +							throw new BizException("未指定课酬结算标准!");
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		BigDecimal ots = results.get("onlineTeacherSalary");
 |  | 
 | 
											
												
													
														|  | -		if(Objects.isNull(ots)){
 |  | 
 | 
											
												
													
														|  | -			ots = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | -		if(Objects.isNull(ots)){
 |  | 
 | 
											
												
													
														|  | -			ots = BigDecimal.ZERO;
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | -		BigDecimal ofts = results.get("offlineTeacherSalary");
 |  | 
 | 
											
												
													
														|  | -		if(Objects.isNull(ofts)){
 |  | 
 | 
											
												
													
														|  | -			ofts = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  | -		if(Objects.isNull(ofts)){
 |  | 
 | 
											
												
													
														|  | -			ofts = BigDecimal.ZERO;
 |  | 
 | 
											
												
													
														|  | 
 |  | +			BigDecimal ots = results.get("onlineTeacherSalary");
 | 
											
												
													
														|  | 
 |  | +			if(Objects.isNull(ots)){
 | 
											
												
													
														|  | 
 |  | +				ots = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.isNull(ots)){
 | 
											
												
													
														|  | 
 |  | +				ots = BigDecimal.ZERO;
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			BigDecimal ofts = results.get("offlineTeacherSalary");
 | 
											
												
													
														|  | 
 |  | +			if(Objects.isNull(ofts)){
 | 
											
												
													
														|  | 
 |  | +				ofts = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.isNull(ofts)){
 | 
											
												
													
														|  | 
 |  | +				ofts = BigDecimal.ZERO;
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(vipGroup.getStatus())&&normalStudentNum!=vipGroupCategory.getStudentNum()){
 | 
											
												
													
														|  | 
 |  | +				ots = ots.divide(new BigDecimal(vipGroupCategory.getStudentNum()),CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
 | 
											
												
													
														|  | 
 |  | +				ofts = ofts.divide(new BigDecimal(vipGroupCategory.getStudentNum()),CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			results.put("onlineTeacherSalary", ots);
 | 
											
												
													
														|  | 
 |  | +			results.put("offlineTeacherSalary", ofts);
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -		if(Objects.nonNull(vipGroup.getStatus())&&normalStudentNum!=vipGroupCategory.getStudentNum()){
 |  | 
 | 
											
												
													
														|  | -			ots = ots.divide(new BigDecimal(vipGroupCategory.getStudentNum()),CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
 |  | 
 | 
											
												
													
														|  | -			ofts = ofts.divide(new BigDecimal(vipGroupCategory.getStudentNum()),CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +		if(Objects.isNull(vipGroupActivity)||vipGroupCategory.getMusicTheory()){
 | 
											
												
													
														|  | 
 |  | +			BigDecimal ots = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 | 
											
												
													
														|  | 
 |  | +			BigDecimal ofts = teacherDefaultVipGroupSalary.getOfflineClassesSalary();
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(vipGroup.getStatus())&&normalStudentNum!=vipGroupCategory.getStudentNum()){
 | 
											
												
													
														|  | 
 |  | +				ots = ots.multiply(new BigDecimal(normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
 | 
											
												
													
														|  | 
 |  | +				ofts = ofts.multiply(new BigDecimal(normalStudentNum>5?5:normalStudentNum)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			results.put("totalPrice",vipGroup.getTotalPrice());
 | 
											
												
													
														|  | 
 |  | +			results.put("onlineTeacherSalary",ots);
 | 
											
												
													
														|  | 
 |  | +			results.put("offlineTeacherSalary",ofts);
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		results.put("onlineTeacherSalary", ots);
 |  | 
 | 
											
												
													
														|  | -		results.put("offlineTeacherSalary", ofts);
 |  | 
 | 
											
												
													
														|  | 
 |  | +		if(vipGroup instanceof VipGroupApplyBaseInfoDto&&!CollectionUtils.isEmpty(((VipGroupApplyBaseInfoDto)vipGroup).getVipGroupStudentCoursePrices())){
 | 
											
												
													
														|  | 
 |  | +			vipGroup.setTotalPrice(new BigDecimal(0));
 | 
											
												
													
														|  | 
 |  | +			for (VipGroupStudentCoursePrice vscp : ((VipGroupApplyBaseInfoDto)vipGroup).getVipGroupStudentCoursePrices()) {
 | 
											
												
													
														|  | 
 |  | +				if(Objects.isNull(vscp.getOnlineClassesUnitPrice())||Objects.isNull(vscp.getOfflineClassesUnitPrice())){
 | 
											
												
													
														|  | 
 |  | +					throw new BizException("请设置课程单价");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				vscp.setPaymentPrice(vscp.getOfflineClassesUnitPrice().multiply(new BigDecimal(vipGroup.getOfflineClassesNum())).add(vscp.getOnlineClassesUnitPrice().multiply(new BigDecimal(vipGroup.getOnlineClassesNum()))));
 | 
											
												
													
														|  | 
 |  | +				vipGroup.setTotalPrice(vipGroup.getTotalPrice().add(vscp.getPaymentPrice()));
 | 
											
												
													
														|  | 
 |  | +				results.put(vscp.getStudentId().toString(), vscp.getPaymentPrice());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          return results;
 |  |          return results;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
										
											
												
													
														|  | @@ -2085,7 +2077,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  				classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
 |  |  				classGroupTeacherMapperDao.insert(classGroupTeacherMapper);
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -			Map<String, BigDecimal> salaryMap = countVipGroupPredictFee(vipGroup, vipGroup.getUserId(), null, null);
 |  | 
 | 
											
												
													
														|  | 
 |  | +			Map<String, BigDecimal> salaryMap = countVipGroupPredictFee(vipGroup, vipGroup.getUserId());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  			//创建老师单节课课酬信息
 |  |  			//创建老师单节课课酬信息
 | 
											
												
													
														|  |  			courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroup,
 |  |  			courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroup,
 | 
											
										
											
												
													
														|  | @@ -2736,7 +2728,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		courseScheduleService.batchAddCourseSchedule(vipGroupApplyDto.getCourseSchedules());
 |  |  		courseScheduleService.batchAddCourseSchedule(vipGroupApplyDto.getCourseSchedules());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		Map<String, BigDecimal> map = countVipGroupPredictFee(vipGroup, vipGroup.getUserId(), null, null);
 |  | 
 | 
											
												
													
														|  | 
 |  | +		Map<String, BigDecimal> map = countVipGroupPredictFee(vipGroup, vipGroup.getUserId());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		BigDecimal teacherSalary=BigDecimal.ZERO;
 |  |  		BigDecimal teacherSalary=BigDecimal.ZERO;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -2806,7 +2798,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  	@Override
 |  |  	@Override
 | 
											
												
													
														|  |  	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 |  |  	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 | 
											
												
													
														|  | -	public void addVipGroupStudents(Long vipGroupId, List<Integer> studentIds) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +	public void addVipGroupStudents(Long vipGroupId, List<Integer> studentIds, Map<Integer, VipGroupStudentCoursePrice> studentCoursePriceMap) {
 | 
											
												
													
														|  |  		if(CollectionUtils.isEmpty(studentIds)){
 |  |  		if(CollectionUtils.isEmpty(studentIds)){
 | 
											
												
													
														|  |  			throw new BizException("请选择学生");
 |  |  			throw new BizException("请选择学生");
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
										
											
												
													
														|  | @@ -2857,7 +2849,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  			if(courseNum==0){
 |  |  			if(courseNum==0){
 | 
											
												
													
														|  |  				courseScheduleService.batchAddCourseSchedule(courseSchedules);
 |  |  				courseScheduleService.batchAddCourseSchedule(courseSchedules);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -				Map<String, BigDecimal> salaryMap = countVipGroupPredictFee(vipGroup, vipGroup.getUserId(), null, null);
 |  | 
 | 
											
												
													
														|  | 
 |  | +				Map<String, BigDecimal> salaryMap = countVipGroupPredictFee(vipGroup, vipGroup.getUserId());
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  				//创建老师单节课课酬信息
 |  |  				//创建老师单节课课酬信息
 | 
											
												
													
														|  |  				courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroup,
 |  |  				courseScheduleTeacherSalaryService.createCourseScheduleTeacherVipSalary(vipGroup,
 | 
											
										
											
												
													
														|  | @@ -2933,7 +2925,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  			vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
 |  |  			vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId().intValue());
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -		BigDecimal surplusCourseNum = new BigDecimal(surplusCourses.size());
 |  | 
 | 
											
												
													
														|  |  		BigDecimal surplusCoursesPrice=new BigDecimal(0);
 |  |  		BigDecimal surplusCoursesPrice=new BigDecimal(0);
 | 
											
												
													
														|  |  		boolean hasGiveClass=false;
 |  |  		boolean hasGiveClass=false;
 | 
											
												
													
														|  |  		int onlineCourseTimes=0,
 |  |  		int onlineCourseTimes=0,
 | 
											
										
											
												
													
														|  | @@ -2947,7 +2938,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  			&&surplusCourses.size()>=Integer.parseInt(vipGroupActivity.getAttribute1())){
 |  |  			&&surplusCourses.size()>=Integer.parseInt(vipGroupActivity.getAttribute1())){
 | 
											
												
													
														|  |  			hasGiveClass=true;
 |  |  			hasGiveClass=true;
 | 
											
												
													
														|  |  			giveClassTimes=Integer.parseInt(vipGroupActivity.getAttribute2());
 |  |  			giveClassTimes=Integer.parseInt(vipGroupActivity.getAttribute2());
 | 
											
												
													
														|  | -			surplusCourseNum=surplusCourseNum.subtract(new BigDecimal(giveClassTimes));
 |  | 
 | 
											
												
													
														|  |  			Map<TeachModeEnum, List<CourseSchedule>> teachModeCourseMap = surplusCourses.stream()
 |  |  			Map<TeachModeEnum, List<CourseSchedule>> teachModeCourseMap = surplusCourses.stream()
 | 
											
												
													
														|  |  					.collect(Collectors.groupingBy(CourseSchedule::getTeachMode));
 |  |  					.collect(Collectors.groupingBy(CourseSchedule::getTeachMode));
 | 
											
												
													
														|  |  			List<CourseSchedule> onlineCourses=teachModeCourseMap.get(TeachModeEnum.ONLINE);
 |  |  			List<CourseSchedule> onlineCourses=teachModeCourseMap.get(TeachModeEnum.ONLINE);
 | 
											
										
											
												
													
														|  | @@ -2959,48 +2949,56 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  				offlineCourseTotalTimes=offlineCourses.size();
 |  |  				offlineCourseTotalTimes=offlineCourses.size();
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  | -		for (int i=0;i<surplusCourses.size();i++) {
 |  | 
 | 
											
												
													
														|  | -			CourseSchedule courseSchedule=surplusCourses.get(i);
 |  | 
 | 
											
												
													
														|  | -			if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
 |  | 
 | 
											
												
													
														|  | -				offlineCourseTimes+=1;
 |  | 
 | 
											
												
													
														|  | -			}else if(courseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)){
 |  | 
 | 
											
												
													
														|  | -				onlineCourseTimes+=1;
 |  | 
 | 
											
												
													
														|  | -			}
 |  | 
 | 
											
												
													
														|  | -			if(hasGiveClass
 |  | 
 | 
											
												
													
														|  | -					&&vipGroup.getGiveTeachMode() == courseSchedule.getTeachMode()){
 |  | 
 | 
											
												
													
														|  | -				if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)
 |  | 
 | 
											
												
													
														|  | -					&&offlineCourseTimes>(offlineCourseTotalTimes-giveClassTimes)){
 |  | 
 | 
											
												
													
														|  | -					continue;
 |  | 
 | 
											
												
													
														|  | -				}
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +		//生成学生单课缴费信息
 | 
											
												
													
														|  | 
 |  | +		for (Integer studentId:studentIds) {
 | 
											
												
													
														|  | 
 |  | +			offlineCourseTimes=0;
 | 
											
												
													
														|  | 
 |  | +			onlineCourseTimes=0;
 | 
											
												
													
														|  | 
 |  | +			surplusCoursesPrice=new BigDecimal(0);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			if(studentCoursePriceMap.containsKey(studentId)){
 | 
											
												
													
														|  | 
 |  | +				VipGroupStudentCoursePrice vipGroupStudentCoursePrice = studentCoursePriceMap.get(studentId);
 | 
											
												
													
														|  | 
 |  | +				vipGroup.setOfflineClassesUnitPrice(vipGroupStudentCoursePrice.getOfflineClassesUnitPrice());
 | 
											
												
													
														|  | 
 |  | +				vipGroup.setOnlineClassesUnitPrice(vipGroupStudentCoursePrice.getOnlineClassesUnitPrice());
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			for (int i=0;i<surplusCourses.size();i++) {
 | 
											
												
													
														|  | 
 |  | +				CourseSchedule courseSchedule=surplusCourses.get(i);
 | 
											
												
													
														|  | 
 |  | +				if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
 | 
											
												
													
														|  | 
 |  | +					offlineCourseTimes+=1;
 | 
											
												
													
														|  | 
 |  | +				}else if(courseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)){
 | 
											
												
													
														|  | 
 |  | +					onlineCourseTimes+=1;
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  |  				if(hasGiveClass
 |  |  				if(hasGiveClass
 | 
											
												
													
														|  |  						&&vipGroup.getGiveTeachMode() == courseSchedule.getTeachMode()){
 |  |  						&&vipGroup.getGiveTeachMode() == courseSchedule.getTeachMode()){
 | 
											
												
													
														|  | -					if(courseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)
 |  | 
 | 
											
												
													
														|  | -							&&onlineCourseTimes>(onlineCourseTotalTimes-giveClassTimes)){
 |  | 
 | 
											
												
													
														|  | 
 |  | +					if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)
 | 
											
												
													
														|  | 
 |  | +							&&offlineCourseTimes>(offlineCourseTotalTimes-giveClassTimes)){
 | 
											
												
													
														|  |  						continue;
 |  |  						continue;
 | 
											
												
													
														|  |  					}
 |  |  					}
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +					if(hasGiveClass
 | 
											
												
													
														|  | 
 |  | +							&&vipGroup.getGiveTeachMode() == courseSchedule.getTeachMode()){
 | 
											
												
													
														|  | 
 |  | +						if(courseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)
 | 
											
												
													
														|  | 
 |  | +								&&onlineCourseTimes>(onlineCourseTotalTimes-giveClassTimes)){
 | 
											
												
													
														|  | 
 |  | +							continue;
 | 
											
												
													
														|  | 
 |  | +						}
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
 | 
											
												
													
														|  | 
 |  | +					surplusCoursesPrice=surplusCoursesPrice.add(vipGroup.getOfflineClassesUnitPrice());
 | 
											
												
													
														|  | 
 |  | +				}else if(courseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)){
 | 
											
												
													
														|  | 
 |  | +					surplusCoursesPrice=surplusCoursesPrice.add(vipGroup.getOnlineClassesUnitPrice());
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  | -			if(courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)){
 |  | 
 | 
											
												
													
														|  | -				surplusCoursesPrice=surplusCoursesPrice.add(vipGroup.getOfflineClassesUnitPrice());
 |  | 
 | 
											
												
													
														|  | -			}else if(courseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)){
 |  | 
 | 
											
												
													
														|  | -				surplusCoursesPrice=surplusCoursesPrice.add(vipGroup.getOnlineClassesUnitPrice());
 |  | 
 | 
											
												
													
														|  | -			}
 |  | 
 | 
											
												
													
														|  | -		}
 |  | 
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        BigDecimal discount=null;
 |  | 
 | 
											
												
													
														|  | -		if(Objects.nonNull(vipGroupActivity)&&vipGroupActivity.getType().equals(VipGroupActivityTypeEnum.DISCOUNT)){
 |  | 
 | 
											
												
													
														|  | -            discount=new BigDecimal(vipGroupActivity.getAttribute1()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
 |  | 
 | 
											
												
													
														|  | -            surplusCoursesPrice=surplusCoursesPrice.multiply(discount).setScale(CommonConstants.DECIMAL_FINAL_PLACE,BigDecimal.ROUND_HALF_UP);
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -		//生成学生单课缴费信息
 |  | 
 | 
											
												
													
														|  | -		for (Integer studentId:studentIds) {
 |  | 
 | 
											
												
													
														|  | -			SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentId);
 |  | 
 | 
											
												
													
														|  | -			if(sysUserCashAccount.getCourseBalance().compareTo(surplusCoursesPrice)<0){
 |  | 
 | 
											
												
													
														|  | -				throw new BizException("存在课程余额不足的学生");
 |  | 
 | 
											
												
													
														|  | 
 |  | +			BigDecimal discount=null;
 | 
											
												
													
														|  | 
 |  | +			if(Objects.nonNull(vipGroupActivity)&&vipGroupActivity.getType().equals(VipGroupActivityTypeEnum.DISCOUNT)){
 | 
											
												
													
														|  | 
 |  | +				discount=new BigDecimal(vipGroupActivity.getAttribute1()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN);
 | 
											
												
													
														|  | 
 |  | +				surplusCoursesPrice=surplusCoursesPrice.multiply(discount).setScale(CommonConstants.DECIMAL_FINAL_PLACE,BigDecimal.ROUND_HALF_UP);
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  | -//			courseScheduleStudentPaymentService.createCourseScheduleStudentPaymentForVipGroup(vipGroupId,studentId);
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +			sysUserCashAccountService.subtractFromCourseBalanceAndBalance(studentId,surplusCoursesPrice,PlatformCashAccountDetailTypeEnum.PAY_FEE, "后台添加学员扣减账户金额");
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  			List<CourseScheduleStudentPayment> courseScheduleStudentPayments=new ArrayList<>();
 |  |  			List<CourseScheduleStudentPayment> courseScheduleStudentPayments=new ArrayList<>();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -3046,8 +3044,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  |  			courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 |  |  			courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPayments);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -			sysUserCashAccountService.updateCourseBalance(studentId,sysUserCashAccount.getCourseBalance().subtract(surplusCoursesPrice),PlatformCashAccountDetailTypeEnum.PAY_FEE, surplusCoursesPrice.negate(), "后台添加学员扣除课程余额");
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  			//创建班级学生关联记录
 |  |  			//创建班级学生关联记录
 | 
											
												
													
														|  |  			ClassGroupStudentMapper classGroupStudentMapper;
 |  |  			ClassGroupStudentMapper classGroupStudentMapper;
 | 
											
												
													
														|  |  
 |  |  
 |