فهرست منبع

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

# Conflicts:
#	mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleTeacherSalaryDao.java
#	mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml
zouxuan 5 سال پیش
والد
کامیت
fd2587887a

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

@@ -334,7 +334,13 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	 * @return
 	 */
 	List<Long> querySettlementScheduleId(String courseScheduleIds);
-
+	
+	/**
+	 * 获取所有线上课
+	 * @param groupType
+	 * @return
+	 */
+	List<CourseScheduleTeacherSalary> queryOnlineCourseByGroupType(GroupType groupType);
 	/**
 	 * 该用户是不是这个群组的老师
 	 * @param groupId

+ 6 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/VipGroupDao.java

@@ -335,4 +335,10 @@ public interface VipGroupDao extends BaseDAO<Long, VipGroup> {
      * @return
      */
     List<Map<Integer,String>> queryUserVipStatus(@Param("userIds") Set<Integer> userIds);
+    
+    /**
+     * 临时用
+     * @return
+     */
+    List<VipCourseStudentInfoDto> queryVipCourseStudentInfo();
 }

+ 46 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/VipCourseStudentInfoDto.java

@@ -0,0 +1,46 @@
+package com.ym.mec.biz.dal.dto;
+
+import java.math.BigDecimal;
+
+public class VipCourseStudentInfoDto {
+
+	private BigDecimal totalAmount;
+
+	private Integer studentNum;
+
+	private Long musicGroupId;
+
+	private Integer totalCourseTimes;
+
+	public BigDecimal getTotalAmount() {
+		return totalAmount;
+	}
+
+	public void setTotalAmount(BigDecimal totalAmount) {
+		this.totalAmount = totalAmount;
+	}
+
+	public Integer getStudentNum() {
+		return studentNum;
+	}
+
+	public void setStudentNum(Integer studentNum) {
+		this.studentNum = studentNum;
+	}
+
+	public Long getMusicGroupId() {
+		return musicGroupId;
+	}
+
+	public void setMusicGroupId(Long musicGroupId) {
+		this.musicGroupId = musicGroupId;
+	}
+
+	public Integer getTotalCourseTimes() {
+		return totalCourseTimes;
+	}
+
+	public void setTotalCourseTimes(Integer totalCourseTimes) {
+		this.totalCourseTimes = totalCourseTimes;
+	}
+}

+ 21 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -24,10 +24,12 @@ import com.ym.mec.im.ImFeignService;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -2728,9 +2730,26 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	}
 
 	@Override
+	@Async
 	public boolean updateHistoryTeacherSalaryOfOnline() {
-		//查询所有含有线上课的课程组,线上课节数,实付金额
+		// 查询所有含有线上课的课程组,线上课节数,实付金额
+		List<VipCourseStudentInfoDto> list = vipGroupDao.queryVipCourseStudentInfo();
+		Map<Long, VipCourseStudentInfoDto> map = list.stream().collect(Collectors.toMap(VipCourseStudentInfoDto::getMusicGroupId, e -> e));
+
+		VipCourseStudentInfoDto dto = null;
+		// 查询需要修改的课酬记录
+		List<CourseScheduleTeacherSalary> teacherSalaryList = courseScheduleTeacherSalaryDao.queryOnlineCourseByGroupType(GroupType.VIP);
+		for (CourseScheduleTeacherSalary ts : teacherSalaryList) {
+			dto = map.get(ts.getCourseScheduleId());
+			if (dto != null) {
+				ts.setExpectSalary(dto.getTotalAmount().divide(new BigDecimal((dto.getTotalCourseTimes() / dto.getStudentNum()))));
+			}
+		}
 		
-		return false;
+		if(teacherSalaryList.size() > 0){
+			courseScheduleTeacherSalaryDao.batchUpdateTeacherExpectSalarys(teacherSalaryList);
+		}
+
+		return true;
 	}
 }

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

@@ -602,6 +602,12 @@
 		WHERE cs.class_date_ BETWEEN #{firstDayOfMonth} AND #{lastDayOfMonth} AND cs.`del_flag_` != 1 AND cs.group_type_ = 'PRACTICE' AND ts.settlement_time_ IS NOT NULL
 		GROUP BY ts.id_,ta.id_
 	</select>
+	
+	<select id="queryOnlineCourseByGroupType" resultMap="CourseScheduleTeacherSalary">
+		SELECT csts.*  FROM `course_schedule_teacher_salary` csts LEFT JOIN `course_schedule` cs on csts.`course_schedule_id_` = cs.`id_` 
+		WHERE cs.`group_type_` = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} and cs.`teach_mode_` = 'ONLINE'
+	</select>
+
     <select id="isTeacher" resultType="java.lang.Boolean">
 		SELECT COUNT(DISTINCT csts.user_id_) FROM class_group_teacher_mapper csts
 		WHERE csts.class_group_id_ = #{groupId} AND csts.user_id_ = #{userId}

+ 14 - 0
mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml

@@ -71,6 +71,13 @@
         <result property="courseStatus" column="course_status_"/>
     </resultMap>
 
+    <resultMap id="vipCourseStudentInfoDto" type="com.ym.mec.biz.dal.dto.VipCourseStudentInfoDto">
+        <result property="totalAmount" column="total_amount_"/>
+        <result property="studentNum" column="student_num_"/>
+        <result property="musicGroupId" column="music_group_id_"/>
+        <result property="totalCourseTimes" column="total_times_"/>
+    </resultMap>
+
     <resultMap id="vipGroupManageDetailDto" type="com.ym.mec.biz.dal.dto.VipGroupManageDetailDto" extends="VipGroup">
         <result property="studentNum" column="student_num_"/>
         <result property="subjectIdList" column="subject_id_list_"/>
@@ -912,4 +919,11 @@
         </foreach>
         GROUP BY cgsm.user_id_
     </select>
+    
+    <select id="queryVipCourseStudentInfo" resultMap="vipCourseStudentInfoDto">
+        SELECT cssp.music_group_id_,sum(cssp.expect_price_) total_amount_,count(DISTINCT(cssp.user_id_)) student_num_,count(cssp.id_) total_times_   
+		FROM course_schedule_student_payment cssp LEFT JOIN course_schedule cs on cs.id_ = cssp.course_schedule_id_
+		WHERE cs.group_type_ = 'VIP' and cs.teach_mode_ = 'ONLINE'
+		GROUP BY cssp.music_group_id_
+    </select>
 </mapper>

+ 12 - 0
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleTeacherSalaryController.java

@@ -2,9 +2,12 @@ package com.ym.mec.web.controller;
 
 import com.ym.mec.biz.dal.page.CourseScheduleTeacherSalaryQueryInfo;
 import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
+import com.ym.mec.biz.service.VipGroupService;
 import com.ym.mec.common.controller.BaseController;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -18,6 +21,9 @@ public class CourseScheduleTeacherSalaryController extends BaseController {
 
     @Autowired
     private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
+    
+    @Autowired
+    private VipGroupService vipGroupService;
 
     @ApiOperation(value = "分页查询教师薪酬列表")
     @GetMapping("/queryPage")
@@ -25,4 +31,10 @@ public class CourseScheduleTeacherSalaryController extends BaseController {
     public Object queryPage(CourseScheduleTeacherSalaryQueryInfo queryInfo) {
         return succeed(courseScheduleTeacherSalaryService.querySalaries(queryInfo));
     }
+    
+    @GetMapping("/updateHistoryTeacherSalaryOfOnline")
+    public Object updateHistoryTeacherSalaryOfOnline() {
+    	vipGroupService.updateHistoryTeacherSalaryOfOnline();
+        return succeed();
+    }
 }