Pārlūkot izejas kodu

feat:教师端课酬

Joburgess 4 gadi atpakaļ
vecāks
revīzija
21d6f7eec6

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

@@ -2434,18 +2434,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);
             }
 
@@ -2460,6 +2453,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);