Browse Source

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

zouxuan 5 years ago
parent
commit
54b5571d1c

+ 6 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -754,6 +754,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         Map<Integer, IntegerAndIntegerListDto> classGroupTeachingTeacherMap = classGroupAndUserIdsMap.stream()
                 .collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
 
+        Set<Long> existCourseScheduleIdsSet=new HashSet<>(existCourseScheduleIds);
+
         Map<Date, List<CourseSchedule>> existClassDateCoursesMap = allCourseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getClassDate));
         Map<Date, List<CourseSchedule>> newClassDateCoursesMap = courseSchedules.stream().collect(Collectors.groupingBy(CourseSchedule::getClassDate));
         if (allCourseSchedules.size() > 1) {
@@ -791,7 +793,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                             if (Objects.nonNull(integerAndIntegerListDto)) {
                                 preCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
                             }
-                        } else if (existCourseScheduleIds.contains(preCourseSchedule.getId())) {
+                        } else if (existCourseScheduleIdsSet.contains(preCourseSchedule.getId())) {
                             IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeachingTeacherMap.get(preCourseSchedule.getId());
                             if (Objects.nonNull(integerAndIntegerListDto)) {
                                 preCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
@@ -802,7 +804,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                             if (Objects.nonNull(integerAndIntegerListDto)) {
                                 backCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
                             }
-                        } else if (existCourseScheduleIds.contains(backCourseSchedule.getId())) {
+                        } else if (existCourseScheduleIdsSet.contains(backCourseSchedule.getId())) {
                             IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeachingTeacherMap.get(backCourseSchedule.getId());
                             if (Objects.nonNull(integerAndIntegerListDto)) {
                                 backCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
@@ -834,9 +836,9 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                                 .map(ClassGroupStudentMapper::getUserId)
                                 .collect(Collectors.toList());
                         //后面一节课程所在班级的学生编号列表
-                        List<Integer> backClassGroupStudentIds = backClassGroupStudents.stream()
+                        Set<Integer> backClassGroupStudentIds = backClassGroupStudents.stream()
                                 .map(ClassGroupStudentMapper::getUserId)
-                                .collect(Collectors.toList());
+                                .collect(Collectors.toSet());
                         List<Integer> repeatStudentIds = preClassGroupStudentIds.stream()
                                 .filter(backClassGroupStudentIds::contains)
                                 .collect(Collectors.toList());

+ 73 - 74
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -876,76 +876,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		BigDecimal totalClassNum=offlineClassNum.add(onlineClassNum);
 		BigDecimal teacherOnlineSalary=null,teacherOfflineSalary=null;
 
-		//教师线下单课酬计算
-		if(Objects.nonNull(vipGroupSalarySettlementDto.getOfflineSalarySettlement())){
-            if(vipGroup instanceof VipGroupApplyBaseInfoDto&&!useDefaultTeacherSalary
-                    &&vipGroupActivity.getSalaryReadonlyFlag().equals("1")){
-                teacherOfflineSalary=((VipGroupApplyBaseInfoDto) vipGroup).getOfflineTeacherSalary();
-                results.put("offlineTeacherSalary",teacherOfflineSalary);
-            }
-            if(Objects.isNull(teacherOfflineSalary)){
-                switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
-                    case TEACHER_DEFAULT:
-                        if(Objects.isNull(teacherDefaultVipGroupSalary)||Objects.isNull(teacherDefaultVipGroupSalary.getOfflineClassesSalary())){
-                            teacherOfflineSalary=new BigDecimal(0);
-                        }else{
-                            teacherOfflineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
-                        }
-//                        teacherOfflineSalary=teacherOfflineSalary.multiply(classTimeDuty);
-                        results.put("offlineTeacherSalary",teacherOfflineSalary.setScale(0, BigDecimal.ROUND_HALF_UP));
-                        break;
-                    case RATIO_DISCOUNT:
-                        results.put("offlineTeacherSalary",offlineClassesUnitPrice.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("未指定课酬结算标准!");
-                }
-            }
-		}else{
-			results.put("offlineTeacherSalary", new BigDecimal(0));
-		}
-
-		if(Objects.isNull(vipGroupActivity.getType())){
-            throw new BizException("此活动未设置活动类型");
-        }
-
-		//课程购买费用计算
-		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).setScale(CommonConstants.DECIMAL_FINAL_PLACE,BigDecimal.ROUND_HALF_UP);
-				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("活动类型错误!");
-		}
-		results.put("totalPrice",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
-
 		//教师课酬线上单课酬计算
 		if(Objects.nonNull(vipGroupSalarySettlementDto.getOnlineSalarySettlement())){
 			if(vipGroup instanceof VipGroupApplyBaseInfoDto&&!useDefaultTeacherSalary
@@ -961,13 +891,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 						}else{
 							teacherOnlineSalary=teacherDefaultVipGroupSalary.getOnlineClassesSalary();
 						}
+//                        teacherOnlineSalary=teacherOnlineSalary.multiply(classTimeDuty);
 						results.put("onlineTeacherSalary",teacherOnlineSalary.setScale(0, BigDecimal.ROUND_HALF_UP));
 						break;
 					case RATIO_DISCOUNT:
-						BigDecimal tos=results.get("totalPrice").divide(onlineClassNum.add(offlineClassNum), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN)
-								.multiply(vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue());
-//						results.put("onlineTeacherSalary",onlineClassesUnitPrice.multiply((vipGroupSalarySettlementDto.getOnlineSalarySettlement().getSettlementValue())).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, BigDecimal.ROUND_DOWN).setScale(0,BigDecimal.ROUND_HALF_UP));
-						results.put("onlineTeacherSalary", tos);
+						results.put("onlineTeacherSalary",onlineClassesUnitPrice.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));
@@ -981,6 +909,77 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			results.put("onlineTeacherSalary", new BigDecimal(0));
 		}
 
+		//教师线下单课酬计算
+		if(Objects.nonNull(vipGroupSalarySettlementDto.getOfflineSalarySettlement())){
+			if(vipGroup instanceof VipGroupApplyBaseInfoDto&&!useDefaultTeacherSalary
+					&&vipGroupActivity.getSalaryReadonlyFlag().equals("1")){
+				teacherOfflineSalary=((VipGroupApplyBaseInfoDto) vipGroup).getOfflineTeacherSalary();
+				results.put("offlineTeacherSalary",teacherOfflineSalary);
+			}
+			if(Objects.isNull(teacherOfflineSalary)){
+				switch (vipGroupSalarySettlementDto.getOfflineSalarySettlement().getSalarySettlementType()){
+					case TEACHER_DEFAULT:
+						if(Objects.isNull(teacherDefaultVipGroupSalary)||Objects.isNull(teacherDefaultVipGroupSalary.getOfflineClassesSalary())){
+							teacherOfflineSalary=new BigDecimal(0);
+						}else{
+							teacherOfflineSalary=teacherDefaultVipGroupSalary.getOfflineClassesSalary();
+						}
+//                        teacherOfflineSalary=teacherOfflineSalary.multiply(classTimeDuty);
+						results.put("offlineTeacherSalary",teacherOfflineSalary.setScale(0, BigDecimal.ROUND_HALF_UP));
+						break;
+					case RATIO_DISCOUNT:
+						results.put("offlineTeacherSalary",offlineClassesUnitPrice.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("未指定课酬结算标准!");
+				}
+			}
+		}else{
+			results.put("offlineTeacherSalary", new BigDecimal(0));
+		}
+
+		if(Objects.isNull(vipGroupActivity.getType())){
+			throw new BizException("此活动未设置活动类型");
+		}
+
+		if(computeTotalPrice){
+			//课程购买费用计算
+			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).setScale(CommonConstants.DECIMAL_FINAL_PLACE,BigDecimal.ROUND_HALF_UP);
+					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("活动类型错误!");
+			}
+			results.put("totalPrice",totalPrice.setScale(0,BigDecimal.ROUND_CEILING));
+		}
         return results;
     }