Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

Joburgess 5 лет назад
Родитель
Сommit
ad4977ba84

+ 16 - 6
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleStudentPaymentDao.java

@@ -1,19 +1,22 @@
 package com.ym.mec.biz.dal.dao;
 
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.ibatis.annotations.Param;
+
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.Practice4ExercisesSituationDto;
 import com.ym.mec.biz.dal.dto.StudentAttendanceStatisticsResponse;
+import com.ym.mec.biz.dal.dto.StudentCourseTimesDto;
 import com.ym.mec.biz.dal.dto.VipGroupGiveCourseSortDto;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.dal.BaseDAO;
-import org.apache.ibatis.annotations.Param;
-
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseScheduleStudentPayment> {
 
@@ -249,4 +252,11 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
                                                                         @Param("sunday")String sunday);
 
     Integer findNoPracticeStudentTeacherId(@Param("studentId") Integer studentId);
+    
+    /**
+     * 从指定时间开始查询学的线上可数
+     * @param startDate 指定的开始时间
+     * @return
+     */
+    List<StudentCourseTimesDto> queryStudentCourseTimesOfOnline(Date startDate);
 }

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java

@@ -14,4 +14,8 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
 
     List<SysUser> findStudents(Map<String, Object> params);
     int countStudents(Map<String, Object> params);
+    
+    List<Student> queryByOperatingTag(Integer operatingTag);
+    
+    int batchUpdate(List<Student> studentList);
 }

+ 54 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentCourseTimesDto.java

@@ -0,0 +1,54 @@
+package com.ym.mec.biz.dal.dto;
+
+public class StudentCourseTimesDto {
+
+	private Integer userId;
+	
+	private Integer totalCourseTimes;
+	
+	private Integer vipCourseTimes;
+	
+	private Integer practiceCourseTimes;
+	
+	private Integer freePracticeCourseTimes;
+
+	public Integer getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Integer userId) {
+		this.userId = userId;
+	}
+
+	public Integer getTotalCourseTimes() {
+		return totalCourseTimes;
+	}
+
+	public void setTotalCourseTimes(Integer totalCourseTimes) {
+		this.totalCourseTimes = totalCourseTimes;
+	}
+
+	public Integer getVipCourseTimes() {
+		return vipCourseTimes;
+	}
+
+	public void setVipCourseTimes(Integer vipCourseTimes) {
+		this.vipCourseTimes = vipCourseTimes;
+	}
+
+	public Integer getPracticeCourseTimes() {
+		return practiceCourseTimes;
+	}
+
+	public void setPracticeCourseTimes(Integer practiceCourseTimes) {
+		this.practiceCourseTimes = practiceCourseTimes;
+	}
+
+	public Integer getFreePracticeCourseTimes() {
+		return freePracticeCourseTimes;
+	}
+
+	public void setFreePracticeCourseTimes(Integer freePracticeCourseTimes) {
+		this.freePracticeCourseTimes = freePracticeCourseTimes;
+	}
+}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentService.java

@@ -1,5 +1,7 @@
 package com.ym.mec.biz.service;
 
+import java.text.ParseException;
+
 import com.ym.mec.biz.dal.entity.Student;
 import com.ym.mec.biz.dal.page.StudentQueryInfo;
 import com.ym.mec.common.page.PageInfo;
@@ -11,4 +13,10 @@ public interface StudentService extends BaseService<Integer, Student> {
 
     Long upSet(Student student);
 
+    /**
+     * 更新学生运营指标
+     * @return
+     * @throws ParseException 
+     */
+    boolean updateOperatingTag() throws ParseException;
 }

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

@@ -30,5 +30,5 @@ public interface TeacherSalaryComplaintsService extends BaseService<Long, Teache
 	 * @param salarySettlementMonth
 	 * @return
 	 */
-	Object repealComplaints(String salarySettlementMonth);
+	void repealComplaints(String salarySettlementMonth);
 }

+ 46 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServiceImpl.java

@@ -1,6 +1,21 @@
 package com.ym.mec.biz.service.impl;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
 import com.ym.mec.biz.dal.dao.StudentDao;
+import com.ym.mec.biz.dal.dto.StudentCourseTimesDto;
 import com.ym.mec.biz.dal.entity.Student;
 import com.ym.mec.biz.dal.page.StudentQueryInfo;
 import com.ym.mec.biz.service.StudentService;
@@ -8,17 +23,15 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.*;
 
 @Service
 public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implements StudentService {
 
 	@Autowired
 	private StudentDao studentDao;
+	
+	@Autowired
+	private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
 
 	@Override
 	public BaseDAO<Integer, Student> getDAO() {
@@ -56,4 +69,32 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
 			return student.getUserId().longValue();
 		}
 	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public boolean updateOperatingTag() throws ParseException {
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+		Date date = sdf.parse("2020-02-08");
+		List<StudentCourseTimesDto> studentCourseTimesDtoList = courseScheduleStudentPaymentDao.queryStudentCourseTimesOfOnline(date);
+		Map<Integer,StudentCourseTimesDto> map = studentCourseTimesDtoList.stream().collect(Collectors.toMap(StudentCourseTimesDto::getUserId, s -> s));
+		//查询服务指标为0的用户
+		List<Student> studentList = studentDao.queryByOperatingTag(0);
+		
+		List<Student> updateStudentList = new ArrayList<Student>();
+		StudentCourseTimesDto dto = null;
+		for(Student s : studentList){
+			dto = map.get(s.getUpdateTime());
+			if(dto != null){
+				if(dto.getTotalCourseTimes() != dto.getFreePracticeCourseTimes()){
+					updateStudentList.add(s);
+				}
+			}
+		}
+		
+		if(updateStudentList.size() > 0){
+			studentDao.batchUpdate(updateStudentList);
+		}
+		
+		return true;
+	}
 }

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

@@ -91,11 +91,11 @@ public class TeacherSalaryComplaintsServiceImpl extends BaseServiceImpl<Long, Te
 	}
 
 	@Override
-	public Object repealComplaints(String salarySettlementMonth) {
+	public void repealComplaints(String salarySettlementMonth) {
 		SysUser sysUser = sysUserFeignService.queryUserInfo();
 		if (sysUser == null) {
 			throw new BizException("用户信息获取失败");
 		}
-		return teacherSalaryComplaintsDao.repealComplaints(salarySettlementMonth,sysUser.getId());
+		teacherSalaryComplaintsDao.repealComplaints(salarySettlementMonth,sysUser.getId());
 	}
 }

+ 18 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -20,6 +20,14 @@
 		<result column="class_group_id_" property="classGroupId" />
 	</resultMap>
 	
+	<resultMap type="com.ym.mec.biz.dal.dto.StudentCourseTimesDto" id="studentCourseTimesDto">
+		<result column="user_id_" property="userId" />
+        <result column="totalTimes" property="totalCourseTimes"/>
+		<result column="vipTimes" property="vipCourseTimes" />
+		<result column="practiceTmes" property="practiceCourseTimes" />
+		<result column="freePracticeTimes" property="freePracticeCourseTimes" />
+	</resultMap>
+	
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="CourseScheduleStudentPayment" >
 		SELECT * FROM course_schedule_student_payment WHERE id_ = #{id} 
@@ -373,4 +381,14 @@
 	<delete id="deleteByGroup">
 		DELETE FROM course_schedule_student_payment WHERE music_group_id_=#{groupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 	</delete>
+	
+	<select id="queryStudentCourseTimesOfOnline" resultMap="studentCourseTimesDto">
+		SELECT cssp.`user_id_`,count(*) totalTimes, 
+		sum(case when (pg.buy_months_ > 0) then 1 ELSE 0 END) practiceTmes,
+		sum(case when (pg.buy_months_ IS NULL AND cssp.`group_type_` = 'PRACTICE' ) then 1 ELSE 0 END) freePracticeTimes
+		FROM course_schedule_student_payment cssp LEFT JOIN course_schedule cs on cssp.course_schedule_id_ = cs.id_
+		LEFT JOIN practice_group pg ON pg.id_ = cs.music_group_id_ AND cs.group_type_ = 'PRACTICE'
+		WHERE cs.`teach_mode_` = 'ONLINE' AND cs.`class_date_` &gt;= #{startDate}
+		GROUP BY cssp.`user_id_`
+	</select>
 </mapper>

+ 28 - 0
mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

@@ -105,4 +105,32 @@
 			AND FIND_IN_SET("STUDENT", user_type_)
 		</where>
 	</sql>
+	
+	<select id="queryByOperatingTag" resultMap="Student">
+		SELECT * FROM student WHERE operating_tag_ = #{operatingTag}
+	</select>
+	
+	<update id="batchUpdate" parameterType="java.util.List">
+    	<foreach collection="studentList" item="item" index="index" open="" close="" separator=";">
+			UPDATE student
+			<set>
+				<if test="item.subjectIdList != null">
+					subject_id_list_ = #{item.subjectIdList},
+				</if>
+				<if test="item.serviceTag != null">
+					service_tag_ = #{item.serviceTag},
+				</if>
+				<if test="item.operatingTag != null">
+					operating_tag_ = #{item.operatingTag},
+				</if>
+				<if test="item.updateTime != null">
+					update_time_ = #{item.updateTime},
+				</if>
+				<if test="item.updateTime == null">
+					update_time_ = NOW()
+				</if>
+			</set>
+			WHERE user_id_ = #{item.userId}
+        </foreach>
+	</update>
 </mapper>

+ 4 - 0
mec-client-api/src/main/java/com/ym/mec/task/TaskRemoteService.java

@@ -105,4 +105,8 @@ public interface TaskRemoteService {
 
 	@GetMapping("task/exercisesSituationStatistics")
 	void exercisesSituationStatistics();
+
+	//更新学生运营指标
+	@GetMapping("task/updateStudentOperatingTag")
+	void updateStudentOperatingTag();
 }

+ 5 - 0
mec-client-api/src/main/java/com/ym/mec/task/fallback/TaskRemoteServiceFallback.java

@@ -135,4 +135,9 @@ public class TaskRemoteServiceFallback implements TaskRemoteService {
 	public void exercisesSituationStatistics() {
 		logger.info("学员服务信息统计失败");
 	}
+
+	@Override
+	public void updateStudentOperatingTag() {
+		logger.info("更新学生运营指标失败");
+	}
 }

+ 20 - 0
mec-task/src/main/java/com/ym/mec/task/jobs/UpdateStudentOperatingTagTask.java

@@ -0,0 +1,20 @@
+package com.ym.mec.task.jobs;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.ym.mec.task.TaskRemoteService;
+import com.ym.mec.task.core.BaseTask;
+import com.ym.mec.task.core.TaskException;
+
+@Service
+public class UpdateStudentOperatingTagTask extends BaseTask {
+
+	@Autowired
+	private TaskRemoteService taskRemoteService;
+
+	@Override
+	public void execute() throws TaskException {
+		taskRemoteService.updateStudentOperatingTag();
+	}
+}

+ 2 - 1
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherSalaryComplaintsController.java

@@ -40,6 +40,7 @@ public class TeacherSalaryComplaintsController extends BaseController {
     @ApiOperation(value = "撤销当月未处理申述")
     @RequestMapping("/repealComplaints")
     public Object repealComplaints(String salarySettlementMonth){
-        return succeed(teacherSalaryComplaintsService.repealComplaints(salarySettlementMonth));
+        teacherSalaryComplaintsService.repealComplaints(salarySettlementMonth);
+        return succeed();
     }
 }

+ 11 - 0
mec-web/src/main/java/com/ym/mec/web/controller/TaskController.java

@@ -2,11 +2,13 @@ package com.ym.mec.web.controller;
 
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.text.ParseException;
 import java.util.Date;
 
 @RequestMapping("task")
@@ -57,6 +59,9 @@ public class TaskController extends BaseController {
 
 	@Autowired
 	private ExtracurricularExercisesReplyService extracurricularExercisesReplyService;
+	
+	@Autowired
+	private StudentService studentService;
 
 	@GetMapping("/refreshPaymentFeeStatus")
 	// 刷新付费状态
@@ -213,4 +218,10 @@ public class TaskController extends BaseController {
 	public void exercisesSituationStatistics(){
 		extracurricularExercisesReplyService.exercisesSituationStatistics();
 	}
+
+	//更新学生运营指标
+	@GetMapping("/updateStudentOperatingTag")
+	public void updateStudentOperatingTag() throws ParseException{
+		studentService.updateOperatingTag();
+	}
 }