Browse Source

学员列表修改

zouxuan 5 years ago
parent
commit
fb8b31b533

+ 23 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentManageDao.java

@@ -175,13 +175,13 @@ public interface StudentManageDao {
      * 查询有课的学员
      * @return
      */
-    List<Integer> queryHasCourse(Map<String, Object> params);
+    Set<Integer> queryHasCourse(Map<String, Object> params);
 
     /**
      * 查询没课的学员
      * @return
      */
-    List<Integer> queryNotCourse(Map<String, Object> params);
+    Set<Integer> queryNotCourse(Map<String, Object> params);
 
     /**
      * 查询有课的学员
@@ -238,4 +238,25 @@ public interface StudentManageDao {
     Integer countRepliedNum(Integer courseScheduleId);
 
     List<StudentHasCourseDto> queryCourseStudent(@Param("userIds") Set<Integer> userIds);
+
+    /**
+     * 有陪练课的学员列表
+     * @param params
+     * @return
+     */
+    Set<Integer> queryHasPracticeCourse(Map<String, Object> params);
+
+    /**
+     * 没有陪练课的学员列表
+     * @param params
+     * @return
+     */
+    Set<Integer> queryNotPracticeCourse(Map<String, Object> params);
+
+    /**
+     * 是否有课map列表
+     * @param userIds
+     * @return
+     */
+    List<Map<Integer,Integer>> getHasPracticeCourse(List<Integer> userIds);
 }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/StudentManageListDto.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.dal.dto;
 
+import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.common.enums.UserGenderEnum;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -50,6 +51,17 @@ public class StudentManageListDto {
 
     private Long hasCourse;
 
+    @ApiModelProperty(value = "是否有陪练课")
+    private YesOrNoEnum hasPracticeCourse;
+
+    public YesOrNoEnum getHasPracticeCourse() {
+        return hasPracticeCourse;
+    }
+
+    public void setHasPracticeCourse(YesOrNoEnum hasPracticeCourse) {
+        this.hasPracticeCourse = hasPracticeCourse;
+    }
+
     public Boolean getIsMake() {
         return isMake;
     }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/StudentManageQueryInfo.java

@@ -34,6 +34,16 @@ public class StudentManageQueryInfo extends QueryInfo {
 
     private Boolean hasCourse;
 
+    private Boolean hasPracticeCourse;
+
+    public Boolean getHasPracticeCourse() {
+        return hasPracticeCourse;
+    }
+
+    public void setHasPracticeCourse(Boolean hasPracticeCourse) {
+        this.hasPracticeCourse = hasPracticeCourse;
+    }
+
     public Boolean getIsMake() {
         return isMake;
     }

+ 15 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java

@@ -56,21 +56,31 @@ public class StudentManageServiceImpl implements StudentManageService {
     public PageInfo findStudentsByOrganId(StudentManageQueryInfo queryInfo) {
         PageInfo<StudentManageListDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
         Boolean hasCourse = queryInfo.getHasCourse();
+        Boolean hasPracticeCourse = queryInfo.getHasPracticeCourse();
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
         params.put("offset", pageInfo.getOffset());
         int count = 0;
+        Set<Integer> paramUserIds = null;
+        if(hasPracticeCourse != null){
+            //是否有陪练课
+            if(hasPracticeCourse){
+                paramUserIds = studentManageDao.queryHasPracticeCourse(params);
+            }else {
+                paramUserIds = studentManageDao.queryNotPracticeCourse(params);
+            }
+            params.put("userIds",paramUserIds);
+        }
         if(hasCourse != null){
-            List<Integer> userIds;
             if(hasCourse){
-                userIds = studentManageDao.queryHasCourse(params);
+                paramUserIds = studentManageDao.queryHasCourse(params);
                 count = studentManageDao.countHasCourse(params);
             }else {
-                userIds = studentManageDao.queryNotCourse(params);
+                paramUserIds = studentManageDao.queryNotCourse(params);
                 count = studentManageDao.countNotCourse(params);
             }
             params.remove("offset");
-            params.put("userIds",userIds);
+            params.put("userIds",paramUserIds);
         }else {
             count = studentManageDao.countStudentByOrganId(params);
         }
@@ -84,6 +94,7 @@ public class StudentManageServiceImpl implements StudentManageService {
 //            Map<Integer,Long> hasCourseMap = MapUtil.convertIntegerMap(studentManageDao.queryStudentHasCourse(userIds));
             Map<Integer, SysUserCashAccount> collect = byUserIds.stream()
                     .collect(Collectors.toMap(SysUserCashAccount::getUserId, sysUserCashAccount -> sysUserCashAccount));
+            Map<Integer,Integer> hasPracticeCourseMap = MapUtil.convertIntegerMap(studentManageDao.getHasPracticeCourse(userIds));
             dataList.forEach(e -> {
                 if(hasCourse == null){
                     e.setHasCourse(studentManageDao.getHasCourse(e.getUserId()));

+ 47 - 3
mec-biz/src/main/resources/config/mybatis/StudentManageDao.xml

@@ -572,6 +572,12 @@
         </if>
     </select>
     <sql id="queryHasCourseSql">
+        <if test="userIds != null">
+            AND su.id_ IN
+            <foreach collection="userIds" open="(" close=")" separator="," item="item">
+                #{item}
+            </foreach>
+        </if>
         <if test="organId != null">
             AND FIND_IN_SET(su.organ_id_,#{organId})
         </if>
@@ -596,7 +602,7 @@
         LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = su.id_
         LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
         LEFT JOIN practice_lesson_apply pla ON su.id_ = pla.user_id_
-        WHERE su.user_type_ LIKE '%STUDENT%' AND cs.status_ != 'OVER'
+        WHERE su.user_type_ LIKE '%STUDENT%' AND cs.status_ != 'OVER' AND su.del_flag_ = 0
         <include refid="queryHasCourseSql"/>
         GROUP BY su.id_
         ORDER BY su.create_time_ DESC
@@ -607,7 +613,7 @@
         LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = su.id_
         LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
         LEFT JOIN practice_lesson_apply pla ON su.id_ = pla.user_id_
-        WHERE su.user_type_ LIKE '%STUDENT%' AND cs.status_ != 'OVER'
+        WHERE su.user_type_ LIKE '%STUDENT%' AND cs.status_ != 'OVER' AND su.del_flag_ = 0
         <include refid="queryHasCourseSql"/>
     </select>
     <select id="queryNotCourse" resultType="java.lang.Integer">
@@ -632,7 +638,13 @@
     </select>
     <sql id="queryNotCourseSql">
         <where>
-                su.user_type_ LIKE '%STUDENT%'
+                su.user_type_ LIKE '%STUDENT%' AND su.del_flag_ = 0
+            <if test="userIds != null">
+                AND su.id_ IN
+                <foreach collection="userIds" open="(" close=")" separator="," item="item">
+                    #{item}
+                </foreach>
+            </if>
             <if test="organId != null">
                 AND FIND_IN_SET(su.organ_id_,#{organId})
             </if>
@@ -724,4 +736,36 @@
     <select id="countRepliedNum" resultType="java.lang.Integer">
         SELECT COUNT(id_) FROM student_course_homework WHERE course_schedule_id_ = #{courseScheduleId} AND is_replied_ = 1 AND status_ = 1
     </select>
+
+    <sql id="queryHasPracticeCourseSql">
+        <if test="organId != null">
+            AND FIND_IN_SET(su.organ_id_,#{organId})
+        </if>
+        <if test="search != null and search != ''">
+            AND (su.phone_ LIKE CONCAT('%',#{search},'%') OR su.username_ LIKE CONCAT('%',#{search},'%') OR su.id_ LIKE CONCAT('%',#{search},'%'))
+        </if>
+        <if test="isActive != null and isActive == true">
+            AND su.password_ IS NOT NULL
+        </if>
+        <if test="isActive != null and isActive == false">
+            AND su.password_ IS NULL
+        </if>
+    </sql>
+    <select id="queryHasPracticeCourse" resultType="java.lang.Integer">
+        SELECT DISTINCT su.id_ FROM sys_user su
+        LEFT JOIN course_schedule_student_payment cssp ON cssp.user_id_ = su.id_
+        WHERE su.user_type_ LIKE '%STUDENT%' AND su.del_flag_ = 0 AND cssp.group_type_ = 'PRACTICE'
+        <include refid="queryHasPracticeCourseSql"/>
+    </select>
+    <select id="queryNotPracticeCourse" resultType="java.lang.Integer">
+        SELECT DISTINCT su.id_ FROM sys_user su
+        WHERE su.id_ NOT IN
+        (SELECT DISTINCT cssp.user_id_ FROM course_schedule_student_payment cssp WHERE cssp.group_type_ = 'PRACTICE')
+        AND su.user_type_ LIKE '%STUDENT%' AND su.del_flag_ = 0
+        <include refid="queryHasPracticeCourseSql"/>
+    </select>
+    <select id="getHasPracticeCourse" resultType="java.util.Map">
+        
+    </select>
+
 </mapper>