Forráskód Böngészése

跨团合班逻辑调整

zouxuan 4 éve
szülő
commit
4ee7b1cfbc

+ 2 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupPaymentCalenderStudentDetail.java

@@ -177,20 +177,19 @@ public class MusicGroupPaymentCalenderStudentDetail {
 	public String toString() {
 		return "MusicGroupPaymentCalenderStudentDetail{" +
 				"userId=" + userId +
-				", courseOriginalPrice=" + courseOriginalPrice +
 				", courseCurrentPrice=" + courseCurrentPrice +
 				", courseType='" + courseType + '\'' +
 				", classGroupId=" + classGroupId +
 				'}';
 	}
 
+
 	@Override
 	public boolean equals(Object o) {
 		if (this == o) return true;
 		if (o == null || getClass() != o.getClass()) return false;
 		MusicGroupPaymentCalenderStudentDetail that = (MusicGroupPaymentCalenderStudentDetail) o;
 		return userId.equals(that.userId) &&
-				courseOriginalPrice.doubleValue()==(that.courseOriginalPrice.doubleValue()) &&
 				courseCurrentPrice.doubleValue()==(that.courseCurrentPrice.doubleValue()) &&
 				courseType.equals(that.courseType) &&
 				classGroupId.equals(that.classGroupId);
@@ -198,6 +197,6 @@ public class MusicGroupPaymentCalenderStudentDetail {
 
 	@Override
 	public int hashCode() {
-		return Objects.hash(userId, courseOriginalPrice.doubleValue(), courseCurrentPrice.doubleValue(), courseType, classGroupId);
+		return Objects.hash(userId, courseCurrentPrice.doubleValue(), courseType, classGroupId);
 	}
 }

+ 42 - 16
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

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