zouxuan 5 years ago
parent
commit
5b3e34a25c

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

@@ -6,6 +6,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import com.ym.mec.biz.dal.entity.TeacherSalaryModifyLog;
 import org.apache.ibatis.annotations.Param;
 
 import com.ym.mec.biz.dal.dto.CourseScheduleTeachersDto;
@@ -376,4 +377,10 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	 * @return
 	 */
 	Integer countTeacherGiveLesson(Integer userId);
+
+	/**
+	 * 调整已结算的课酬
+	 * @param modifyLog
+	 */
+    void updateSalary(@Param("modifyLog") TeacherSalaryModifyLog modifyLog);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/CourseScheduleTeacherSalary.java

@@ -49,6 +49,9 @@ public class CourseScheduleTeacherSalary {
 	
 	/** 实际薪水 */
 	private java.math.BigDecimal actualSalary;
+
+	/** 扣除金额 */
+	private java.math.BigDecimal reduceSalary;
 	
 	/** 结算时间 */
 	private java.util.Date settlementTime;
@@ -81,6 +84,14 @@ public class CourseScheduleTeacherSalary {
 		this.classGroupId = classGroupId;
 	}
 
+	public BigDecimal getReduceSalary() {
+		return reduceSalary;
+	}
+
+	public void setReduceSalary(BigDecimal reduceSalary) {
+		this.reduceSalary = reduceSalary;
+	}
+
 	public String getUserName() {
 		return userName;
 	}

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/TeacherSalaryModifyLogService.java

@@ -4,4 +4,10 @@ import com.ym.mec.biz.dal.entity.TeacherSalaryModifyLog;
 import com.ym.mec.common.service.BaseService;
 
 public interface TeacherSalaryModifyLogService extends BaseService<Long, TeacherSalaryModifyLog> {
+    /**
+     * 新增修改记录
+     * @param modifyLog
+     * @return
+     */
+    Object add(TeacherSalaryModifyLog modifyLog);
 }

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TeacherSalaryModifyLogServiceImpl.java

@@ -1,21 +1,39 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.biz.dal.dao.CourseScheduleTeacherSalaryDao;
 import com.ym.mec.biz.dal.dao.TeacherSalaryModifyLogDao;
+import com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary;
 import com.ym.mec.biz.dal.entity.TeacherSalaryModifyLog;
+import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
 import com.ym.mec.biz.service.TeacherSalaryModifyLogService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 @Service
 public class TeacherSalaryModifyLogServiceImpl extends BaseServiceImpl<Long, TeacherSalaryModifyLog>  implements TeacherSalaryModifyLogService {
 	
 	@Autowired
 	private TeacherSalaryModifyLogDao teacherSalaryModifyLogDao;
+	@Autowired
+	private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
 
 	@Override
 	public BaseDAO<Long, TeacherSalaryModifyLog> getDAO() {
 		return teacherSalaryModifyLogDao;
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public Object add(TeacherSalaryModifyLog modifyLog) {
+		//获取之前的课酬信息
+		CourseScheduleTeacherSalary salary = courseScheduleTeacherSalaryDao.queryByCourseScheduleIdAndUserId(modifyLog.getCourseScheduleId(), modifyLog.getTeacherId());
+		courseScheduleTeacherSalaryDao.updateSalary(modifyLog);
+		//修改教师课酬
+		modifyLog.setPreExpectSalary(salary.getActualSalary());
+		modifyLog.setPreReduceSalary(salary.getReduceSalary());
+		return teacherSalaryModifyLogDao.insert(modifyLog);
+	}
 }

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

@@ -26,6 +26,7 @@
 		<result column="class_date_" property="courseSchedule.classDate" />
 		<result column="start_class_time_" property="courseSchedule.startClassTime" />
 		<result column="end_class_time_" property="courseSchedule.endClassTime" />
+		<result column="reduce_salary" property="reduceSalary" />
 	</resultMap>
 	
 	<resultMap type="com.ym.mec.biz.dal.dto.TeacherVipSalaryDto" id="teacherVipSalaryDto" extends="CourseScheduleTeacherSalary">
@@ -64,6 +65,9 @@
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.CourseScheduleTeacherSalary">
 		UPDATE course_schedule_teacher_salary 
 		<set>
+			<if test="reduceSalary != null">
+				reduce_salary = #{reduceSalary},
+			</if>
 			<if test="userId != null">
 				user_id_ = #{userId},
 			</if>
@@ -425,6 +429,10 @@
 		</foreach>
 		AND csts.teacher_role_ = 'BISHOP'
 	</update>
+    <update id="updateSalary">
+		UPDATE course_schedule_teacher_salary SET actual_salary_ = #{modifyLog.currentExpectSalary},reduce_salary = #{modifyLog.currentReduceSalary},update_time_ = NOW()
+		WHERE course_schedule_id_ = #{modifyLog.courseScheduleId} AND user_id_ = #{modifyLog.teacherId}
+	</update>
 
     <select id="findCourseScheduleTeacherSalaryByMusicGroupId" resultMap="CourseScheduleTeacherSalary">
 		SELECT * FROM course_schedule_teacher_salary WHERE music_group_id_=#{musicGroupId} AND group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/TeacherSalaryModifyLogController.java

@@ -40,6 +40,6 @@ public class TeacherSalaryModifyLogController extends BaseController {
     @RequestMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('teacherSalaryModifyLog/add')")
     public Object add(TeacherSalaryModifyLog modifyLog){
-        return succeed(teacherSalaryModifyLogService.insert(modifyLog));
+        return succeed(teacherSalaryModifyLogService.add(modifyLog));
     }
 }