Browse Source

1、试听课
2、收费网管课活动

Joburgess 5 years ago
parent
commit
83fec014de

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

@@ -1312,6 +1312,15 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
                                                                @Param("endTime") Date endTime);
 
     /**
+     * @describe 统计学生在未来的vip课数量
+     * @author Joburgess
+     * @date 2020.04.28
+     * @param studentIds:
+     * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.Integer>>
+     */
+    List<Map<Integer, Long>> countStudentVipCoursesInFuture(@Param("studentIds") List<Integer> studentIds);
+
+    /**
      * @param groupId:
      * @param groupType:
      * @param isLock:    冻结状态:1、冻结,0、正常

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

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.dto;
 
 import com.ym.mec.biz.dal.entity.ExtracurricularExercisesReply;
+import io.swagger.annotations.ApiModelProperty;
 
 import java.util.Date;
 
@@ -26,6 +27,17 @@ public class ExtraExerciseStudentsDto extends ExtracurricularExercisesReply {
     private String isRepliedStr;
     private String isViewStr;
 
+    @ApiModelProperty(value = "是否存在vip课")
+    private Integer existVipCourse;
+
+    public Integer getExistVipCourse() {
+        return existVipCourse;
+    }
+
+    public void setExistVipCourse(Integer existVipCourse) {
+        this.existVipCourse = existVipCourse;
+    }
+
     public String getStatusStr() {
         return statusStr;
     }

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ExtraExercilseReplyQueryInfo.java

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.dal.page;
 
 import com.ym.mec.common.page.QueryInfo;
+import io.swagger.annotations.ApiModelProperty;
 
 import java.util.Date;
 
@@ -39,6 +40,17 @@ public class ExtraExercilseReplyQueryInfo extends QueryInfo {
 
 	private Date expireEndDate;
 
+	@ApiModelProperty(value = "是否存在vip课")
+	private Integer existVipCourse;
+
+	public Integer getExistVipCourse() {
+		return existVipCourse;
+	}
+
+	public void setExistVipCourse(Integer existVipCourse) {
+		this.existVipCourse = existVipCourse;
+	}
+
 	public Integer getIsRepliedTimely() {
 		return isRepliedTimely;
 	}

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExtracurricularExercisesReplyServiceImpl.java

@@ -46,6 +46,8 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 	private SysMessageService sysMessageService;
 	@Autowired
 	private TeacherDao teacherDao;
+	@Autowired
+	private CourseScheduleDao courseScheduleDao;
 
 	@Override
 	public BaseDAO<Long, ExtracurricularExercisesReply> getDAO() {
@@ -185,6 +187,22 @@ public class ExtracurricularExercisesReplyServiceImpl extends BaseServiceImpl<Lo
 			Map<Integer, String> idNameMap = teachers.stream().collect(Collectors.toMap(SimpleUserDto::getUserId, SimpleUserDto::getUserName));
 			for (ExtraExerciseStudentsDto extraExerciseStudentsDto : dataList) {
 				extraExerciseStudentsDto.setTeacherName(idNameMap.get(extraExerciseStudentsDto.getTeacherId()));
+				if(Objects.nonNull(queryInfo.getExistVipCourse())){
+					extraExerciseStudentsDto.setExistVipCourse(queryInfo.getExistVipCourse());
+				}
+			}
+			if(Objects.isNull(queryInfo.getExistVipCourse())){
+				List<Integer> studentIds = dataList.stream().map(ExtraExerciseStudentsDto::getUserId).collect(Collectors.toList());
+				List<Map<Integer, Long>> studentVipCoursesMaps = courseScheduleDao.countStudentVipCoursesInFuture(studentIds);
+				Map<Integer, Long> studentVipCourseMap = MapUtil.convertIntegerMap(studentVipCoursesMaps);
+				for (ExtraExerciseStudentsDto exercisesSituationDto : dataList) {
+					Long vipCourses=studentVipCourseMap.get(exercisesSituationDto.getUserId());
+					if(Objects.isNull(vipCourses)||vipCourses<=0){
+						exercisesSituationDto.setExistVipCourse(0);
+					}else{
+						exercisesSituationDto.setExistVipCourse(1);
+					}
+				}
 			}
 		}
 		if (count == 0) {

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

@@ -3007,5 +3007,22 @@
         GROUP BY
         cssp.user_id_
     </select>
+    <select id="countStudentVipCoursesInFuture" resultType="map">
+        SELECT
+          cssp.user_id_ as 'key',
+          COUNT( cs.id_ ) as 'value'
+        FROM
+          course_schedule_student_payment cssp
+          LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
+        WHERE
+        cssp.user_id_ IN
+        <foreach collection="studentIds" item="studentId" separator="," open="(" close=")">
+            #{studentId}
+        </foreach>
+        AND cssp.group_type_ = 'VIP'
+        AND CONCAT(cs.class_date_," ",cs.start_class_time_) &gt; NOW()
+        GROUP BY
+        cssp.user_id_
+    </select>
 
 </mapper>

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

@@ -279,6 +279,12 @@
 			<if test="isRepliedTimely!=null">
 				AND eer.is_replied_timely_=#{isRepliedTimely}
 			</if>
+			<if test="existVipCourse!=null and existVipCourse==1">
+				AND EXISTS (SELECT cssp.id_ FROM course_schedule_student_payment cssp LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_ WHERE cssp.user_id_=eer.user_id_ AND cssp.group_type_='VIP' AND CONCAT(cs.class_date_," ",cs.start_class_time_) &gt; NOW())
+			</if>
+			<if test="existVipCourse!=null and existVipCourse==0">
+				AND NOT EXISTS (SELECT cssp.id_ FROM course_schedule_student_payment cssp LEFT JOIN course_schedule cs ON cs.id_=cssp.course_schedule_id_ WHERE cssp.user_id_=eer.user_id_ AND cssp.group_type_='VIP' AND CONCAT(cs.class_date_," ",cs.start_class_time_) &gt; NOW())
+			</if>
 		</where>
 	</sql>