Browse Source

Merge remote-tracking branch 'origin/teacher_income' into teacher_income

zouxuan 4 years ago
parent
commit
e764e65efb

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleTeacherSalaryDao.java

@@ -552,7 +552,7 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	 * @param year:
 	 * @return java.util.List<java.util.Map<java.lang.String,java.math.BigDecimal>>
 	 */
-	List<Map<String, BigDecimal>> teacherIncomeStat(@Param("teacherId") Integer teacherId,
+	List<LocalDateBigDecimalMapDto> teacherIncomeStat(@Param("teacherId") Integer teacherId,
 													@Param("year") Integer year,
 													@Param("month") Integer month);
 

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/IndexBaseMonthDataDao.java

@@ -74,7 +74,8 @@ public interface IndexBaseMonthDataDao extends BaseDAO<Long, IndexBaseMonthData>
      * @date 2021/1/7 0007
      * @return java.util.List<com.ym.mec.biz.dal.dto.IndexBaseMonthDto>
      */
-    List<IndexBaseMonthData> getStudentSignUpData(@Param("dayStr") String dayStr);
+    List<IndexBaseMonthData> getStudentSignUpData(@Param("dayStr") String dayStr,
+                                                  @Param("courseStartDay") String courseStartDay);
 
     /**
      * @describe 统计作业布置数据

+ 51 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/LocalDateBigDecimalMapDto.java

@@ -0,0 +1,51 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.Date;
+
+/**
+ * @Author Joburgess
+ * @Date 2021/4/21 0021
+ */
+public class LocalDateBigDecimalMapDto {
+
+    private Date date;
+
+    private String dateStr;
+
+    private BigDecimal amount;
+
+    public LocalDateBigDecimalMapDto(Date date, String dateStr, BigDecimal amount) {
+        this.date = date;
+        this.dateStr = dateStr;
+        this.amount = amount;
+    }
+
+    public LocalDateBigDecimalMapDto() {
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    public String getDateStr() {
+        return dateStr;
+    }
+
+    public void setDateStr(String dateStr) {
+        this.dateStr = dateStr;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+}

+ 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>
      */
-    Map<String, BigDecimal> teacherIncomeStat(Integer teacherId, Integer year, Integer month);
+    Map<String, Object> teacherIncomeStat(Integer teacherId, Integer year, Integer month);
 
     /**
      * @describe 推送查看今日收入提醒

+ 47 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -1642,9 +1642,9 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         }else{
             List<TeacherSalaryDeductReasonDto> deductReasons = new ArrayList<>();
 
-            BigDecimal subsidy = school.getSubsidy();
-            if (Objects.isNull(subsidy)) {
-                subsidy = new BigDecimal(0);
+            BigDecimal subsidy = new BigDecimal(0);
+            if (Objects.nonNull(school)&&Objects.nonNull(school.getSubsidy())) {
+                subsidy = school.getSubsidy();
             }
             teacherSalary = teacherSalary.add(subsidy);
 
@@ -2147,22 +2147,54 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     }
 
     @Override
-    public Map<String, BigDecimal> teacherIncomeStat(Integer teacherId, Integer year, Integer month) {
-        List<Map<String, BigDecimal>> monthIncomeMapList = courseScheduleTeacherSalaryDao.teacherIncomeStat(teacherId, year, month);
-        Map<String, BigDecimal> monthIncomeMap = MapUtil.convertIntegerMap(monthIncomeMapList);
-        LocalDate now = LocalDate.now();
-        DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
+    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(Objects.isNull(month)){
+            Set<String> months = monthIncomeMapList.stream().map(e -> DateUtil.dateToString(e.getDate(), "yyyy-MM")).collect(Collectors.toSet());
+
+            LocalDate now = LocalDate.now();
+            DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM");
 
-        LocalDate startDate = LocalDate.of(year, 1, 1);
-        while (startDate.compareTo(now)<=0&&year.equals(startDate.get(ChronoField.YEAR))){
-            String monthStr = dateFormatter.format(startDate);
-            if(!monthIncomeMap.containsKey(monthStr)){
-                monthIncomeMap.put(monthStr, BigDecimal.ZERO);
+            LocalDate startDate = LocalDate.of(year, Objects.isNull(month)?1:month, 1);
+            while (startDate.compareTo(now)<=0&&year.equals(startDate.get(ChronoField.YEAR))){
+                String dateStr = dateFormatter.format(startDate);
+                if(!months.contains(dateStr)){
+                    monthIncomeMapList.add(new LocalDateBigDecimalMapDto(Date.from(startDate.atStartOfDay(DateUtil.zoneId).toInstant()), dateStr, BigDecimal.ZERO));
+                }
+                startDate = startDate.plusMonths(1);
+            }
+        }else{
+            Set<String> dates = monthIncomeMapList.stream().map(e -> DateUtil.dateToString(e.getDate(), "yyyy-MM-dd")).collect(Collectors.toSet());
+
+            LocalDate startDate = LocalDate.of(year, Objects.isNull(month)?1:month, 1);
+            Integer oldMonth = Objects.isNull(month)?new Integer(1):month;
+            while (oldMonth.equals(startDate.get(ChronoField.MONTH_OF_YEAR))){
+                String dateStr = DateUtil.dateFormatter.format(startDate);
+                if(!dates.contains(dateStr)){
+                    monthIncomeMapList.add(new LocalDateBigDecimalMapDto(Date.from(startDate.atStartOfDay(DateUtil.zoneId).toInstant()), dateStr, BigDecimal.ZERO));
+                }
+                startDate = startDate.plusDays(1);
             }
-            startDate = startDate.plusMonths(1);
         }
 
-        return monthIncomeMap;
+        monthIncomeMapList.sort(Comparator.comparing(LocalDateBigDecimalMapDto::getDate));
+
+        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

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/IndexBaseMonthDataServiceImpl.java

@@ -234,7 +234,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 		//学员数据
 		saveData(indexBaseMonthDataDao.getStudentRegistrationData(dayStr), dayStr, IndexDataType.STUDENT_REGISTRATION_NUM);
 		saveData(indexBaseMonthDataDao.getChargeStudentChangeData(dayStr), dayStr, IndexDataType.CHARGE_STUDENT_CHANGE_RATE);
-		saveData(indexBaseMonthDataDao.getStudentSignUpData(dayStr), dayStr, IndexDataType.ACTIVATION_RATE);
+		saveData(indexBaseMonthDataDao.getStudentSignUpData(dayStr, nowDate.plusMonths(-6).toString()), dayStr, IndexDataType.ACTIVATION_RATE);
 
 		//运营数据
 		saveData(indexBaseMonthDataDao.getSchoolData(dayStr), dayStr, IndexDataType.SCHOOL);
@@ -467,6 +467,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			params.put("sunday",sunDayDate.toString());
 			params.put("jobNature", JobNatureEnum.FULL_TIME);
 			params.put("unDone",1);
+			params.put("reminded",0);
 			int serveErrTeacherNum = studentExtracurricularExercisesSituationDao.countTeacherServeInfo(params);
 			fourChild.add(new IndexErrInfoDto(IndexErrorType.TEACHER_SERVE_ERROR, IndexErrorType.TEACHER_SERVE_ERROR.getMsg(), serveErrTeacherNum, null));
 
@@ -609,6 +610,7 @@ public class IndexBaseMonthDataServiceImpl extends BaseServiceImpl<Long, IndexBa
 			params.put("sunday",sunDayDate.toString());
 			params.put("jobNature", JobNatureEnum.FULL_TIME);
 			params.put("unDone",1);
+			params.put("reminded",0);
 			List<Map<Integer, Integer>> teacherServeErrorMapList = indexBaseMonthDataDao.countOrganTeacherServeInfo(params);
 			teacherServeErrorMap = MapUtil.mapListToMap(teacherServeErrorMapList, Integer.class, Integer.class);
 		}

+ 17 - 5
mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml

@@ -1096,16 +1096,22 @@
 			AND (cs.is_lock_=0 OR cs.is_lock_ IS NULL)
 			AND (cs.new_course_id_ IS NULL OR cs.new_course_id_=cs.id_)
 			AND csts.user_id_ = #{teacherId}
-			AND cs.class_date_ BETWEEN #{startDay} AND #{endDay}
 			<if test="courseStatus!=null">
 				AND cs.status_ = #{courseStatus, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
 	</select>
 
-	<select id="teacherIncomeStat" resultType="map">
+	<select id="teacherIncomeStat" resultType="com.ym.mec.biz.dal.dto.LocalDateBigDecimalMapDto">
 		SELECT
-			DATE_FORMAT( cs.class_date_, '%Y-%m' ) AS 'key',
-			SUM( csts.actual_salary_ ) AS 'value'
+			<if test="month==null">
+				CONCAT(DATE_FORMAT( cs.class_date_, '%Y-%m' ), '-01') date,
+				CONCAT(DATE_FORMAT( cs.class_date_, '%Y-%m' )) dateStr,
+			</if>
+			<if test="month!=null">
+				DATE_FORMAT( cs.class_date_, '%Y-%m-%d' ) date,
+				DATE_FORMAT( cs.class_date_, '%Y-%m-%d' ) dateStr,
+			</if>
+			SUM( csts.actual_salary_ ) amount
 		FROM
 			course_schedule_teacher_salary csts
 				LEFT JOIN course_schedule cs ON csts.course_schedule_id_ = cs.id_
@@ -1121,7 +1127,13 @@
 				AND MONTH(cs.class_date_) = #{month}
 			</if>
 		  AND csts.settlement_time_ IS NOT NULL
-		GROUP BY MONTH(cs.class_date_)
+		GROUP BY
+			<if test="month==null">
+				MONTH(cs.class_date_)
+			</if>
+			<if test="month!=null">
+				DATE_FORMAT( cs.class_date_, '%Y-%m-%d' )
+			</if>
 	</select>
 
     <select id="getTodayHasCourseTeacherIds" resultType="int">

+ 2 - 4
mec-biz/src/main/resources/config/mybatis/IndexBaseMonthDataMapper.xml

@@ -171,7 +171,7 @@
 					 mg.status_ IN ( 'PREPARE', 'PROGRESS' )
 				   AND sr.music_group_status_ = 'NORMAL'
 				   AND DATE_FORMAT(sr.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
-			 ) UNION
+			 ) UNION ALL
 			(
 			 SELECT DISTINCT
 				 cssp.user_id_
@@ -185,6 +185,7 @@
 			   AND cssp.group_type_ IN ('VIP', 'PRACTICE')
 			   AND cs.organ_id_ IS NOT NULL
 			   AND DATE_FORMAT(cssp.create_time_, '%Y-%m-%d')&lt;=#{dayStr}
+				AND cs.class_date_ &gt;= #{courseStartDay}
 			)) u
 			LEFT JOIN sys_user su ON u.user_id_ = su.id_
 		WHERE
@@ -1258,9 +1259,6 @@
 			<if test="teacherId!=null">
 				AND sees.teacher_id_ = #{teacherId}
 			</if>
-			<if test="unDone!=null and unDone==1">
-				AND tm.teacher_id_ IS NULL
-			</if>
 			<if test="reminded!=null and reminded==0">
 				AND NOT EXISTS (SELECT id_ FROM teacher_remind WHERE teacher_id_=sees.teacher_id_ AND monday_ = sees.monday_ AND type_='SERVICE')
 			</if>

+ 3 - 3
mec-biz/src/main/resources/config/mybatis/StudentExtracurricularExercisesSituationMapper.xml

@@ -509,9 +509,9 @@
 			<if test="monday!=null and monday!='' and sunday!=null and sunday!=''">
 				AND sees.monday_ BETWEEN #{monday} AND #{sunday}
 			</if>
-			<if test="unDone!=null and unDone==1">
-				AND tm.teacher_id_ IS NULL
-			</if>
+<!--			<if test="unDone!=null and unDone==1">-->
+<!--				AND tm.teacher_id_ IS NULL-->
+<!--			</if>-->
 			<if test="teacherId!=null">
 				AND sees.teacher_id_ = #{teacherId}
 			</if>