Jelajahi Sumber

Merge branch 'teacher_client_salary'

Joburgess 4 tahun lalu
induk
melakukan
c1aec9291a

+ 9 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -2442,18 +2442,11 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
 
         monthIncomeMapList.sort(Comparator.comparing(LocalDateBigDecimalMapDto::getDate));
 
-        BigDecimal reduce = monthIncomeMapList.stream().map(LocalDateBigDecimalMapDto::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
-
-        BigDecimal subsidy = monthIncomeMapList.stream().map(LocalDateBigDecimalMapDto::getSubsidy).reduce(BigDecimal.ZERO, BigDecimal::add);
-
-        result.put("total", reduce.add(subsidy));
-        salaryResult.put("amount", reduce);
-        salaryResult.put("data", monthIncomeMapList);
-
         List<LocalDateBigDecimalMapDto> subsidyList = new ArrayList<>();
         List<LocalDateBigDecimalMapDto> saleRewardList = new ArrayList<>();
         for (LocalDateBigDecimalMapDto localDateBigDecimalMapDto : monthIncomeMapList) {
             if(localDateBigDecimalMapDto.getAmount().compareTo(BigDecimal.ZERO)<0){
+                localDateBigDecimalMapDto.setSubsidy(localDateBigDecimalMapDto.getSubsidy().subtract(localDateBigDecimalMapDto.getAmount().abs()));
                 localDateBigDecimalMapDto.setAmount(BigDecimal.ZERO);
             }
 
@@ -2468,6 +2461,14 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
             saleRewardList.add(saleRewardData);
         }
 
+        BigDecimal reduce = monthIncomeMapList.stream().map(LocalDateBigDecimalMapDto::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+        BigDecimal subsidy = monthIncomeMapList.stream().map(LocalDateBigDecimalMapDto::getSubsidy).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+        result.put("total", reduce.add(subsidy));
+        salaryResult.put("amount", reduce);
+        salaryResult.put("data", monthIncomeMapList);
+
         subsidyResult.put("amount", subsidy);
         subsidyResult.put("data", subsidyList);