浏览代码

乐团学员列表新增是否有剩余vip、网管课、转化率

zouxuan 4 年之前
父节点
当前提交
9923243da2

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -1775,4 +1775,12 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @return
      */
     List<CourseSchedule> getMusicGroupCourseInfo(@Param("musicGroupId") String musicGroupId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
+
+    /**
+     * 获取还有剩余课程的学员
+     * @param userIds
+     * @param groupType
+     * @return
+     */
+    List<Integer> findHasCourseStudent(@Param("userIds") List<Integer> userIds, @Param("groupType") String groupType);
 }

+ 20 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicGroupStudentsDto.java

@@ -54,6 +54,10 @@ public class MusicGroupStudentsDto{
 
     private Boolean isActive = false;
 
+    private Boolean hasVip;
+
+    private Boolean hasPractice;
+
     private Integer isLock;
 
     private String paymentPeriodList;
@@ -70,6 +74,22 @@ public class MusicGroupStudentsDto{
     @ApiModelProperty(value = "欠费金额",required = false)
     private BigDecimal noPaymentAmount;
 
+    public Boolean getHasVip() {
+        return hasVip;
+    }
+
+    public void setHasVip(Boolean hasVip) {
+        this.hasVip = hasVip;
+    }
+
+    public Boolean getHasPractice() {
+        return hasPractice;
+    }
+
+    public void setHasPractice(Boolean hasPractice) {
+        this.hasPractice = hasPractice;
+    }
+
     public BigDecimal getNoPaymentAmount() {
         return noPaymentAmount;
     }

+ 22 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/MusicGroupStudentQueryInfo.java

@@ -20,6 +20,12 @@ public class MusicGroupStudentQueryInfo extends QueryInfo {
   @ApiModelProperty(value = "是否激活")
   private Boolean isActive;
 
+  @ApiModelProperty(value = "是否有未开始的vip课")
+  private Boolean hasVip;
+
+  @ApiModelProperty(value = "是否有未开始的网管课")
+  private Boolean hasPractice;
+
   @ApiModelProperty(value = "是否锁定")
   private Integer isLock;
 
@@ -31,6 +37,22 @@ public class MusicGroupStudentQueryInfo extends QueryInfo {
 
   private boolean isExport = false;
 
+  public Boolean getHasVip() {
+    return hasVip;
+  }
+
+  public void setHasVip(Boolean hasVip) {
+    this.hasVip = hasVip;
+  }
+
+  public Boolean getHasPractice() {
+    return hasPractice;
+  }
+
+  public void setHasPractice(Boolean hasPractice) {
+    this.hasPractice = hasPractice;
+  }
+
   public boolean getIsExport() {
     return isExport;
   }

+ 54 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java

@@ -416,6 +416,32 @@ public class StudentManageServiceImpl implements StudentManageService {
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
         List<MusicGroupStudentsDto> dataList = null;
+        List<StudentRegistration> studentRegistrations = studentRegistrationDao.getMusicGroupStu(queryInfo.getMusicGroupId());
+        if(studentRegistrations.size() == 0){
+            return pageInfo;
+        }
+        List<Integer> userIds = studentRegistrations.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+        if(queryInfo.getHasVip() != null){
+            //有剩余课程的学员
+            List<Integer> hasVipStudent = courseScheduleDao.findHasCourseStudent(userIds,"VIP");
+            if(queryInfo.getHasVip()){
+                userIds = hasVipStudent;
+            }else {
+                userIds.removeAll(hasVipStudent);
+            }
+        }
+        if(queryInfo.getHasPractice() != null && userIds.size() > 0){
+            List<Integer> hasPracticeStudent = courseScheduleDao.findHasCourseStudent(userIds,"PRACTICE");
+            if(queryInfo.getHasPractice()){
+                userIds = hasPracticeStudent;
+            }else {
+                userIds.removeAll(hasPracticeStudent);
+            }
+        }
+        if(userIds.size() == 0){
+            return pageInfo;
+        }
+        params.put("userIds",userIds);
         int count = studentManageDao.countMusicGroupStudent(params);
         if (queryInfo.getIsExport() && count > 50000) {
             throw new BizException("数据集太大,不能导出.最大数据集不能超过50000");
@@ -437,7 +463,12 @@ public class StudentManageServiceImpl implements StudentManageService {
                     }
                 }
             }
+            List<Integer> collect = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+            List<Integer> hasVipStudent = courseScheduleDao.findHasCourseStudent(collect,"VIP");
+            List<Integer> hasPracticeStudent = courseScheduleDao.findHasCourseStudent(collect,"PRACTICE");
             dataList.forEach(e->{
+                e.setHasVip(hasVipStudent.contains(e.getUserId()));
+                e.setHasPractice(hasPracticeStudent.contains(e.getUserId()));
                 e.setNoPaymentAmount(totalAmountMap.get(e.getUserId()));
             });
         }
@@ -450,13 +481,35 @@ public class StudentManageServiceImpl implements StudentManageService {
 
     @Override
     public Object musicGroupStudentsSum(String musicGroupId) {
-        Map<String, Integer> resultMap = new HashMap<>(3);
+        Map<String, Object> resultMap = new HashMap<>(3);
         //乐团在读人数
         resultMap.put("studying", studentManageDao.countStudyNum(musicGroupId));
         //退团人数
         resultMap.put("quit", studentManageDao.countQuitNum(musicGroupId));
         //新增人数
         resultMap.put("add", studentManageDao.countAddNum(musicGroupId));
+        //未完成vip、网管课学员数量/该乐团在读学员人数*100%
+        List<StudentRegistration> studentRegistrations = studentRegistrationDao.getMusicGroupStu(musicGroupId);
+        if(studentRegistrations.size() == 0){
+            resultMap.put("vipRate","0.00%");
+            resultMap.put("practiceRate","0.00%");
+        }
+        List<Integer> userIds = studentRegistrations.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+        List<Integer> hasVipStudent = courseScheduleDao.findHasCourseStudent(userIds,"VIP");
+        double size = userIds.size()+0d;
+        if(hasVipStudent.size() == 0){
+            resultMap.put("vipRate","0.00%");
+        }else {
+            double d = (hasVipStudent.size() / size) * 100;
+            resultMap.put("vipRate",String.format("%.2f", d) + "%");
+        }
+        List<Integer> hasPracticeStudent = courseScheduleDao.findHasCourseStudent(userIds,"PRACTICE");
+        if(hasPracticeStudent.size() == 0){
+            resultMap.put("practiceRate","0.00%");
+        }else {
+            double d = (hasPracticeStudent.size() / size) * 100;
+            resultMap.put("practiceRate",String.format("%.2f", d) + "%");
+        }
         return resultMap;
     }
 

+ 11 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -3524,4 +3524,15 @@
             AND cs.teach_mode_ = 'OFFLINE'
         ORDER BY cs.id_ ASC
     ]]></select>
+    <select id="findHasCourseStudent" resultType="java.lang.Integer">
+        SELECT cssp.user_id_ FROM course_schedule cs
+        LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
+        WHERE cssp.user_id_ IN
+        <foreach collection="userIds" separator="," item="item" close=")" open="(">
+            #{item}
+        </foreach>
+        AND CONCAT(cs.class_date_,' ',cs.start_class_time_) > NOW()
+        AND cs.group_type_ = #{groupType}
+        GROUP BY cssp.user_id_
+    </select>
 </mapper>

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

@@ -453,6 +453,12 @@
             <if test="isActive != null and isActive == false">
                 and su.password_ is null
             </if>
+            <if test="userIds != null">
+                AND sr.user_id_ IN
+                <foreach collection="userIds" open="(" close=")" item="item" separator=",">
+                    #{item}
+                </foreach>
+            </if>
         </where>
     </sql>
     <resultMap id="MusicGroupStudentsDto" type="com.ym.mec.biz.dal.dto.MusicGroupStudentsDto">

+ 2 - 2
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -1251,9 +1251,9 @@ public class ExportController extends BaseController {
                 }
             }
             String[] header = {"学员编号", "学员姓名", "性别", "联系电话", "年级", "班级", "专业", "学员状态", "新增学员", "缴费金额",
-                        "下次缴费日期", "是否报名缴费", "是否激活", "欠费总额"};
+                        "下次缴费日期", "是否报名缴费", "是否激活", "是否有剩余VIP", "是否有剩余网管课", "欠费总额"};
             String[] body = {"userId", "realName", "gender", "phone", "currentGrade", "currentClass", "subjectName", "studentStatus", "isNewStudentStr",
-                    "courseFee", "nextPaymentDateStr", "paymentStatus.desc", "activeName","noPaymentAmount"};
+                    "courseFee", "nextPaymentDateStr", "paymentStatus.desc", "activeName", "hasVip ? '是' : '否'", "hasPractice ? '是' : '否'","noPaymentAmount"};
             HSSFWorkbook workbook = POIUtil.exportExcel(header, body, musicGroupStudentsDtoPageInfo.getRows());
             response.setContentType("application/octet-stream");
             response.setHeader("Content-Disposition", "attachment;filename=lender-" + DateUtil.getDate(new Date()) + ".xls");