소스 검색

增加学生运营指标查询

周箭河 5 년 전
부모
커밋
52e299a445
2개의 변경된 파일122개의 추가작업 그리고 0개의 파일을 삭제
  1. 15 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentDao.java
  2. 107 0
      mec-biz/src/main/resources/config/mybatis/StudentMapper.xml

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

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dto.Student4operating;
 import com.ym.mec.biz.dal.entity.Student;
 import org.apache.ibatis.annotations.Param;
 
@@ -18,4 +19,18 @@ public interface StudentDao extends com.ym.mec.common.dal.BaseDAO<Integer, Stude
     List<Student> queryByOperatingTag(Integer operatingTag);
     
     int batchUpdate(@Param("studentList") List<Student> studentList);
+
+    /**
+     * 查询运营学生列表
+     * @param params
+     * @return
+     */
+    List<Student4operating> getOperatingStudents(Map<String, Object> params);
+
+    /**
+     * 查询运营学生总数
+     * @param params
+     * @return
+     */
+    Integer countOperatingStudents(Map<String, Object> params);
 }

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

@@ -133,4 +133,111 @@
 			WHERE user_id_ = #{item.userId}
         </foreach>
 	</update>
+
+	<resultMap id="student4operating" type="com.ym.mec.biz.dal.dto.Student4operating">
+		<result column="organ_name_" property="organName"/>
+		<result column="organ_id_" property="organId"/>
+		<result column="student_name_" property="studentName"/>
+		<result column="student_id_" property="studentId"/>
+		<result column="teacher_id_" property="teacherId"/>
+		<result column="teacher_name_" property="teacherName"/>
+		<result column="operating_tag_" property="operatingTag"/>
+		<result column="vip_times_" property="vipTimes"/>
+		<result column="free_practice_times_" property="freePracticeTimes"/>
+		<result column="buy_practice_times_" property="buyPracticeTimes"/>
+	</resultMap>
+
+	<select id="getOperatingStudents" resultMap="student4operating">
+		SELECT su.organ_id_,
+		o.name_ organ_name_,
+		su.username_   student_name_,
+		s.user_id_     student_id_,
+		tsu.id_        teacher_id_,
+		tsu.real_name_ teacher_name_,
+		s.operating_tag_,
+		a.vip_times_,
+		a.buy_practice_times_,
+		p.free_practice_times_
+		FROM student s
+		LEFT JOIN sys_user su ON s.user_id_ = su.id_
+		LEFT JOIN sys_user tsu ON tsu.id_ = s.teacher_id_
+		LEFT JOIN organization o ON o.id_ = su.organ_id_
+		LEFT JOIN (
+		SELECT s.user_id_,
+		SUM(case when (cs.group_type_ = 'VIP') then 1 ELSE 0 END) vip_times_,
+		SUM(case when (pg.buy_months_ > 0) then 1 ELSE 0 END)     buy_practice_times_
+		FROM student s
+		LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = s.user_id_
+		LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+		LEFT JOIN practice_group pg ON pg.`id_` = cs.`music_group_id_` AND cs.`group_type_` = 'PRACTICE'
+		WHERE cs.status_ = 'NOT_START'
+		GROUP BY s.user_id_
+		) a on a.user_id_ = s.user_id_
+		LEFT JOIN (
+		SELECT student_id_, count(id_) free_practice_times_
+		FROM practice_group
+		WHERE buy_months_ IS NULL
+		GROUP BY student_id_
+		) p ON p.student_id_ = s.user_id_
+		<include refid="student4OperatingQueryCondition"/>
+		ORDER BY s.user_id_
+		<include refid="global.limit"/>
+	</select>
+
+	<select id="countOperatingStudents" resultType="int">
+		SELECT COUNT(s.user_id_) FROM student s
+		LEFT JOIN sys_user su ON s.user_id_ = su.id_
+		LEFT JOIN sys_user tsu ON tsu.id_ = s.teacher_id_
+		LEFT JOIN (
+		SELECT s.user_id_,
+		SUM(case when (cs.group_type_ = 'VIP') then 1 ELSE 0 END) vip_times_,
+		SUM(case when (pg.buy_months_ > 0) then 1 ELSE 0 END)     buy_practice_times_
+		FROM student s
+		LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = s.user_id_
+		LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+		LEFT JOIN practice_group pg ON pg.`id_` = cs.`music_group_id_` AND cs.`group_type_` = 'PRACTICE'
+		WHERE cs.status_ = 'NOT_START'
+		GROUP BY s.user_id_
+		) a on a.user_id_ = s.user_id_
+		LEFT JOIN (
+		SELECT student_id_, count(id_) free_practice_times_
+		FROM practice_group
+		WHERE buy_months_ IS NULL
+		GROUP BY student_id_
+		) p ON p.student_id_ = s.user_id_
+
+		<include refid="student4OperatingQueryCondition"/>
+	</select>
+
+	<sql id="student4OperatingQueryCondition">
+		<where>
+			<if test="organId != null and organId != ''">
+				AND FIND_IN_SET(su.organ_id_,#{organId})
+			</if>
+			<if test="teacherId!=null">
+				AND s.teacher_id_ = #{teacherId}
+			</if>
+			<if test="operatingTag !=null">
+				AND s.operating_tag_ = #{operatingTag}
+			</if>
+			<if test='hasVip != null and hasVip.toString()=="1".toString()'>
+				AND a.vip_times_ >=1
+			</if>
+			<if test='hasVip != null and hasVip.toString()=="0".toString()'>
+				AND (a.vip_times_ =0 OR a.vip_times_ IS NULL)
+			</if>
+			<if test='HasFreePractice != null and HasFreePractice.toString()=="1".toString()'>
+				AND p.free_practice_times_ >=1
+			</if>
+			<if test='HasFreePractice != null and HasFreePractice.toString()=="0".toString()'>
+				AND (p.free_practice_times_ =0 OR p.free_practice_times_ IS NULL)
+			</if>
+			<if test='HasBuyPractice != null and HasBuyPractice.toString()=="1".toString()'>
+				AND a.buy_practice_times_ >=1
+			</if>
+			<if test='HasBuyPractice != null and HasBuyPractice.toString()=="0".toString()'>
+				AND (a.buy_practice_times_ =0 OR a.buy_practice_times_ IS NULL)
+			</if>
+		</where>
+	</sql>
 </mapper>