浏览代码

feat:激活率统计优化

Joburgess 4 年之前
父节点
当前提交
288f811686

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleTeacherSalaryService.java

@@ -282,7 +282,7 @@ public interface CourseScheduleTeacherSalaryService extends BaseService<Long, Co
      * @param year:
      * @return java.util.Map<java.lang.String,java.math.BigDecimal>
      */
-    List<LocalDateBigDecimalMapDto> teacherIncomeStat(Integer teacherId, Integer year, Integer month);
+    Map<String, Object> teacherIncomeStat(Integer teacherId, Integer year, Integer month);
 
     /**
      * @describe 推送查看今日收入提醒

+ 18 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -2147,10 +2147,19 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     }
 
     @Override
-    public List<LocalDateBigDecimalMapDto> teacherIncomeStat(Integer teacherId, Integer year, Integer month) {
+    public Map<String, Object> teacherIncomeStat(Integer teacherId, Integer year, Integer month) {
+        if(Objects.isNull(year)){
+            year = LocalDate.now().get(ChronoField.YEAR);
+        }
+
+        Map<String, Object> result = new HashMap<>();
+        result.put("total", BigDecimal.ZERO);
+        result.put("salary", BigDecimal.ZERO);
+
         List<LocalDateBigDecimalMapDto> monthIncomeMapList = courseScheduleTeacherSalaryDao.teacherIncomeStat(teacherId, year, month);
         if(CollectionUtils.isEmpty(monthIncomeMapList)){
-            return monthIncomeMapList;
+            result.put("data", monthIncomeMapList);
+            return result;
         }
 
         if(Objects.isNull(month)){
@@ -2184,7 +2193,13 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
 
         monthIncomeMapList.sort(Comparator.comparing(LocalDateBigDecimalMapDto::getDate));
 
-        return monthIncomeMapList;
+        BigDecimal reduce = monthIncomeMapList.stream().map(LocalDateBigDecimalMapDto::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+        result.put("total", reduce);
+        result.put("salary", reduce);
+        result.put("data", monthIncomeMapList);
+
+        return result;
     }
 
     @Override