Ver Fonte

1、课酬确认相关
2、VIP课导出添加学生姓名和编号

Joburgess há 5 anos atrás
pai
commit
c9c885bed9

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

@@ -384,6 +384,38 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	int countIsSettlementCourseSalarys(Map<String, Object> params);
 
 	/**
+	 * @describe 获取老师指定月份的已结算课酬编号
+	 * @author Joburgess
+	 * @date 2020/4/15
+	 * @param teacherId:
+	 * @param month:
+	 * @return java.util.List<java.lang.Long>
+	 */
+	List<Long> findTeacherSalaryIdsWithMonth(@Param("teacherId") Integer teacherId,
+											 @Param("month") String month);
+
+	/**
+	 * @describe 统计教师指定月份不同团体类型的课酬
+	 * @author Joburgess
+	 * @date 2020/4/15
+	 * @param month:
+	 * @param teacherId:
+	 * @return java.util.List<com.ym.mec.biz.dal.dto.CourseTeacherSalaryStatisticsDto>
+	 */
+	List<CourseTeacherSalaryStatisticsDto> getTeacherGroupTypeSalary(@Param("month") String month,
+																 @Param("teacherId") Integer teacherId);
+
+	/**
+	 * @describe 统计教师每月的工资
+	 * @author Joburgess
+	 * @date 2020/4/15
+	 * @param teacherId:
+	 * @return java.util.List<com.ym.mec.biz.dal.dto.CourseTeacherSalaryStatisticsDto>
+	 */
+	List<CourseTeacherSalaryStatisticsDto> getTeacherMonthSalarys(@Param("teacherId") Integer teacherId,
+																  @Param("year") String year);
+
+	/**
 	 * 调整已结算的课酬
 	 * @param modifyLog
 	 */

+ 52 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseTeacherSalaryStatisticsDto.java

@@ -0,0 +1,52 @@
+package com.ym.mec.biz.dal.dto;
+
+import com.ym.mec.biz.dal.enums.GroupType;
+
+import java.math.BigDecimal;
+
+/**
+ * @Author Joburgess
+ * @Date 2020/4/15
+ */
+public class CourseTeacherSalaryStatisticsDto {
+
+    private GroupType groupType;
+
+    private String month;
+
+    private BigDecimal totalActualSalary;
+
+    private BigDecimal totalReduceSalary;
+
+    public String getMonth() {
+        return month;
+    }
+
+    public void setMonth(String month) {
+        this.month = month;
+    }
+
+    public GroupType getGroupType() {
+        return groupType;
+    }
+
+    public void setGroupType(GroupType groupType) {
+        this.groupType = groupType;
+    }
+
+    public BigDecimal getTotalActualSalary() {
+        return totalActualSalary;
+    }
+
+    public void setTotalActualSalary(BigDecimal totalActualSalary) {
+        this.totalActualSalary = totalActualSalary;
+    }
+
+    public BigDecimal getTotalReduceSalary() {
+        return totalReduceSalary;
+    }
+
+    public void setTotalReduceSalary(BigDecimal totalReduceSalary) {
+        this.totalReduceSalary = totalReduceSalary;
+    }
+}

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

@@ -100,6 +100,16 @@ public interface CourseScheduleTeacherSalaryService extends BaseService<Long, Co
     List<Long> querySettlementScheduleId(String courseScheduleIds);
 
     /**
+     * @describe 确定教师指定月份的课酬
+     * @author Joburgess
+     * @date 2020/4/15
+     * @param teacherId:
+     * @param month:
+     * @return void
+     */
+    void confirmTeacherMonthSalary(Integer teacherId, String month);
+
+    /**
      * @describe 获取课酬记录
      * @author Joburgess
      * @date 2020/4/15
@@ -116,4 +126,14 @@ public interface CourseScheduleTeacherSalaryService extends BaseService<Long, Co
      * @return java.util.Map<java.lang.String,java.lang.Object>
      */
     Map<String, Object> findTeacherSettlementCourseSalarys(CourseSalaryQueryInfo4Web queryInfo4Web);
+
+    /**
+     * @describe 获取教师指定年份每月的课酬
+     * @author Joburgess
+     * @date 2020/4/15
+     * @param teacherId:
+     * @param year:
+     * @return java.util.Map<java.lang.String,java.lang.Object>
+     */
+    Map<String, Object> findTeacherYearSalarys(Integer teacherId, String year);
 }

+ 35 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleTeacherSalaryServiceImpl.java

@@ -828,6 +828,14 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
     }
 
     @Override
+    public void confirmTeacherMonthSalary(Integer teacherId, String month) {
+        if(Objects.isNull(month)){
+            month=DateUtil.dateToString(DateUtil.addMonths(new Date(), -1), "yyyy-MM");
+        }
+        courseScheduleTeacherSalaryDao.findTeacherSalaryIdsWithMonth(teacherId,month);
+    }
+
+    @Override
     public PageInfo<TeacherCourseSalaryDetail4WebDto> findIsSettlementCourseSalarys(CourseSalaryQueryInfo4Web queryInfo) {
         PageInfo<TeacherCourseSalaryDetail4WebDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
         Map<String, Object> params = new HashMap<>();
@@ -855,6 +863,33 @@ public class CourseScheduleTeacherSalaryServiceImpl extends BaseServiceImpl<Long
         PageInfo<TeacherCourseSalaryDetail4WebDto> pageInfo = findIsSettlementCourseSalarys(queryInfo4Web);
         Map<String, Object> result=new HashMap<>();
         result.put("pageInfo",pageInfo);
+        Map<String, BigDecimal> groupTypeSalaryMap = new HashMap<>();
+        if(queryInfo4Web.getPage()<=1){
+            List<CourseTeacherSalaryStatisticsDto> teacherGroupTypeSalary = courseScheduleTeacherSalaryDao.getTeacherGroupTypeSalary(queryInfo4Web.getMonth(), queryInfo4Web.getTeacherId());
+            groupTypeSalaryMap = teacherGroupTypeSalary.stream()
+                    .collect(Collectors.toMap(c->c.getGroupType().getCode(),
+                            c -> Objects.isNull(c.getTotalReduceSalary()) ? c.getTotalActualSalary() : c.getTotalActualSalary().subtract(c.getTotalReduceSalary())));
+        }
+        result.put("stat", groupTypeSalaryMap);
+        return result;
+    }
+
+    @Override
+    public Map<String, Object> findTeacherYearSalarys(Integer teacherId, String year) {
+        if(Objects.isNull(year)){
+            year=DateUtil.getYear(new Date());
+        }
+        List<CourseTeacherSalaryStatisticsDto> teacherMonthSalarys = courseScheduleTeacherSalaryDao.getTeacherMonthSalarys(teacherId, year);
+        BigDecimal totalSalary = BigDecimal.ZERO;
+        for (CourseTeacherSalaryStatisticsDto teacherMonthSalary : teacherMonthSalarys) {
+            if(Objects.nonNull(teacherMonthSalary.getTotalReduceSalary())){
+                teacherMonthSalary.setTotalActualSalary(teacherMonthSalary.getTotalReduceSalary().subtract(teacherMonthSalary.getTotalReduceSalary()));
+            }
+            totalSalary = totalSalary.add(teacherMonthSalary.getTotalActualSalary());
+        }
+        Map<String, Object> result=new HashMap<>();
+        result.put("monthSalarys", teacherMonthSalarys);
+        result.put("totalSalary", totalSalary);
         return result;
     }
 }

+ 8 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentCourseHomeworkServiceImpl.java

@@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.util.*;
 import java.util.stream.Collectors;
@@ -233,11 +234,13 @@ public class StudentCourseHomeworkServiceImpl extends BaseServiceImpl<Long, Stud
             pageInfo.setTotal(count);
             params.put("offset", pageInfo.getOffset());
             dataList = studentCourseHomeworkDao.findStudentHomeworkRecord(params);
-            List<Integer> teacherIds = dataList.stream().map(StudentHomeworkRecordDto::getTeacherId).collect(Collectors.toList());
-            List<SimpleUserDto> teachers = teacherDao.findSimpleTeachers(teacherIds);
-            Map<Integer, String> idNameMap = teachers.stream().collect(Collectors.toMap(SimpleUserDto::getUserId, u -> u.getUserName()));
-            for (StudentHomeworkRecordDto studentHomeworkRecordDto : dataList) {
-                studentHomeworkRecordDto.setTeacherName(idNameMap.get(studentHomeworkRecordDto.getTeacherId()));
+            if(!CollectionUtils.isEmpty(dataList)){
+                List<Integer> teacherIds = dataList.stream().map(StudentHomeworkRecordDto::getTeacherId).collect(Collectors.toList());
+                List<SimpleUserDto> teachers = teacherDao.findSimpleTeachers(teacherIds);
+                Map<Integer, String> idNameMap = teachers.stream().collect(Collectors.toMap(SimpleUserDto::getUserId, u -> u.getUserName()));
+                for (StudentHomeworkRecordDto studentHomeworkRecordDto : dataList) {
+                    studentHomeworkRecordDto.setTeacherName(idNameMap.get(studentHomeworkRecordDto.getTeacherId()));
+                }
             }
         }
         if (count == 0) {

+ 51 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml

@@ -817,4 +817,55 @@
 		ORDER BY csts.id_ DESC
 		<include refid="global.limit"/>
 	</select>
+
+	<resultMap id="CourseTeacherSalaryStatisticsDto" type="com.ym.mec.biz.dal.dto.CourseTeacherSalaryStatisticsDto">
+		<result property="groupType" column="group_type_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
+		<result property="month" column="month_"/>
+		<result property="totalActualSalary" column="total_actual_salary_"/>
+		<result property="totalReduceSalary" column="total_reduce_salary_"/>
+	</resultMap>
+
+    <select id="getTeacherGroupTypeSalary" resultMap="CourseTeacherSalaryStatisticsDto">
+		SELECT
+			csts.group_type_,
+			SUM(actual_salary_) total_actual_salary_,
+			SUM(reduce_salary) total_reduce_salary_
+		FROM
+			course_schedule_teacher_salary csts
+			LEFT JOIN course_schedule cs ON csts.course_schedule_id_ = cs.id_
+		WHERE
+			( cs.del_flag_ IS NULL OR cs.del_flag_ = 0 )
+			AND csts.settlement_time_ IS NOT NULL
+			AND csts.user_id_ = #{teacherId}
+			AND DATE_FORMAT( cs.class_date_, '%Y-%m' ) = #{month}
+			GROUP BY csts.group_type_
+	</select>
+	<select id="getTeacherMonthSalarys" resultMap="CourseTeacherSalaryStatisticsDto">
+		SELECT
+			DATE_FORMAT( cs.class_date_, '%Y-%m' ) month_,
+			SUM(actual_salary_) total_actual_salary_,
+			SUM(reduce_salary) total_reduce_salary_
+		FROM
+			course_schedule_teacher_salary csts
+			LEFT JOIN course_schedule cs ON csts.course_schedule_id_ = cs.id_
+		WHERE
+			( cs.del_flag_ IS NULL OR cs.del_flag_ = 0 )
+			AND csts.settlement_time_ IS NOT NULL
+			AND csts.user_id_ = #{teacherId}
+			AND DATE_FORMAT( cs.class_date_, '%Y' ) = #{year}
+		GROUP BY DATE_FORMAT( cs.class_date_, '%Y-%m' )
+	</select>
+	<select id="findTeacherSalaryIdsWithMonth" resultType="java.lang.Long">
+		SELECT
+			csts.id_
+		FROM
+			course_schedule_teacher_salary csts
+			LEFT JOIN course_schedule cs ON csts.course_schedule_id_ = cs.id_
+		WHERE
+			( cs.del_flag_ IS NULL OR cs.del_flag_ = 0 )
+			AND csts.settlement_time_ IS NOT NULL
+			AND csts.user_id_ = #{teacherId}
+			AND DATE_FORMAT( cs.class_date_, '%Y-%m' ) = #{month}
+	</select>
+
 </mapper>

+ 21 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/CourseScheduleTeacherSalaryController.java

@@ -28,6 +28,17 @@ public class CourseScheduleTeacherSalaryController extends BaseController {
     @Autowired
     private SysUserFeignService sysUserFeignService;
 
+    @ApiOperation(value = "确定教师指定月份的课酬")
+    @GetMapping("confirmTeacherMonthSalary")
+    public HttpResponseResult confirmTeacherMonthSalary(String month){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        courseScheduleTeacherSalaryService.confirmTeacherMonthSalary(sysUser.getId(), month);
+        return succeed();
+    }
+
     @ApiOperation(value = "获取老师指定月份课酬信息")
     @GetMapping("findTeacherSettlementCourseSalarys")
     public HttpResponseResult findTeacherSettlementCourseSalarys(CourseSalaryQueryInfo4Web queryInfo) {
@@ -39,4 +50,14 @@ public class CourseScheduleTeacherSalaryController extends BaseController {
         return succeed(courseScheduleTeacherSalaryService.findTeacherSettlementCourseSalarys(queryInfo));
     }
 
+    @ApiOperation(value = "获取教师指定年份每月的课酬")
+    @GetMapping("findTeacherYearSalarys")
+    public HttpResponseResult findTeacherYearSalarys(String year){
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed("用户信息获取失败");
+        }
+        return succeed(courseScheduleTeacherSalaryService.findTeacherYearSalarys(sysUser.getId(), year));
+    }
+
 }