소스 검색

1、vip课详情展示所有学员,增加学员状态等字段

Joburgess 5 년 전
부모
커밋
9a5612f5d2

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupStudentMapperDao.java

@@ -232,4 +232,15 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      * @return
      */
     List<Map<Integer, String>> queryTeacherIdMap(Long vipGroupId);
+
+    /**
+     * @describe 根据班级和学生编号获取关联记录
+     * @author Joburgess
+     * @date 2019/12/8
+     * @param classGroupId: 班级编号
+     * @param userIds: 学生编号列表
+     * @return java.util.List<com.ym.mec.biz.dal.entity.ClassGroupStudentMapper>
+     */
+    List<ClassGroupStudentMapper> findByClassGroupAndStudent(@Param("classGroupId") Integer classGroupId,
+                                                             @Param("userIds") List<Integer> userIds);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentApplyRefundsDao.java

@@ -18,5 +18,16 @@ public interface StudentApplyRefundsDao extends BaseDAO<Long, StudentApplyRefund
      */
     List<Map<String,Integer>> checkIsApplyRefund(@Param("musicGroupIds") List<String> musicGroupIds,
                                                  @Param("userId") Integer userId);
+
+    /**
+     * @describe 获取指定乐团下的退课记录
+     * @author Joburgess
+     * @date 2019/12/8
+     * @param groupId: 乐团编号
+     * @param groupType: 乐团类型
+     * @return java.util.List<com.ym.mec.biz.dal.entity.StudentApplyRefunds>
+     */
+    List<StudentApplyRefunds> findByGroupAndType(@Param("groupId") String groupId,
+                                                 @Param("groupType") String groupType);
 	
 }

+ 31 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/VipGroupStudentDto.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.dal.dto;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.math.BigDecimal;
+import java.util.Date;
 
 /**
  * @Author Joburgess
@@ -27,6 +28,36 @@ public class VipGroupStudentDto {
 
     private BigDecimal courseSalary;
 
+    private Date applyDate;
+
+    private Date refundDate;
+
+    private Integer studentStatus;
+
+    public Date getApplyDate() {
+        return applyDate;
+    }
+
+    public void setApplyDate(Date applyDate) {
+        this.applyDate = applyDate;
+    }
+
+    public Date getRefundDate() {
+        return refundDate;
+    }
+
+    public void setRefundDate(Date refundDate) {
+        this.refundDate = refundDate;
+    }
+
+    public Integer getStudentStatus() {
+        return studentStatus;
+    }
+
+    public void setStudentStatus(Integer studentStatus) {
+        this.studentStatus = studentStatus;
+    }
+
     public BigDecimal getCourseSalary() {
         return courseSalary;
     }

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

@@ -593,6 +593,11 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		Map<Integer, IntegerAndIntegerListDto> courseScheduleTeacherMap = courseScheduleTeachingTeacherIdList.stream()
 				.collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
 
+		//班级教师关联ID集合
+		List<IntegerAndIntegerListDto> classGroupAndUserIdsMap = courseScheduleDao.findClassGroupAndUserIdsMap(newCourseScheduleClassGroupIds, null);
+		Map<Integer, IntegerAndIntegerListDto> classGroupTeachingTeacherMap = classGroupAndUserIdsMap.stream()
+				.collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
+
 		//将课程计划按照开课时间排序
 		allCourseSchedules.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 		if(allCourseSchedules.size()>1){
@@ -620,7 +625,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 					//教师冲突检测
 					if(Objects.isNull(preCourseSchedule.getId())){
-						IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeacherMap.get(preCourseSchedule.getId());
+						IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(preCourseSchedule.getClassGroupId());
 						if(Objects.nonNull(integerAndIntegerListDto)){
 							preCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
 						}
@@ -631,7 +636,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 						}
 					}
 					if(Objects.isNull(backCourseSchedule.getId())){
-						IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeacherMap.get(backCourseSchedule.getId());
+						IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(backCourseSchedule.getClassGroupId());
 						if(Objects.nonNull(integerAndIntegerListDto)){
 							backCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
 						}
@@ -1235,6 +1240,11 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			throw new BizException("字符长度超限");
 		}
 
+		int settlementTimes = courseScheduleTeacherSalaryDao.checkCourseIsSettlement(courseScheduleComplaints.getCourseScheduleId().intValue());
+		if(settlementTimes>0){
+			throw new BizException("该课程已结算");
+		}
+
 		courseScheduleComplaints.setUserId(user.getId());
 
 		CourseScheduleComplaints byUserAndCourse = courseScheduleComplaintsDao.findByUserAndCourse(courseScheduleComplaints.getUserId().longValue(), courseScheduleComplaints.getCourseScheduleId());

+ 50 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -545,12 +545,28 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		Map<String, Object> params = new HashMap<String, Object>();
 		MapUtil.populateMap(params, queryInfo);
 
-		List dataList = null;
+		List<VipGroupStudentDto> dataList = null;
 		int count = vipGroupDao.countVipGroupStudents(params);
 		if (count > 0) {
 			pageInfo.setTotal(count);
 			params.put("offset", pageInfo.getOffset());
 			dataList = vipGroupDao.findVipGroupStudents(params);
+			List<StudentApplyRefunds> applyRefunds = studentApplyRefundsDao.findByGroupAndType(queryInfo.getVipGroupId().toString(), GroupType.VIP.getCode());
+			Map<Integer, List<StudentApplyRefunds>> studentApplyRefundsMap = applyRefunds.stream()
+					.collect(Collectors.groupingBy(StudentApplyRefunds::getUserId));
+			dataList.forEach(data->{
+				List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsMap.get(data.getId());
+				if(!CollectionUtils.isEmpty(studentApplyRefunds)){
+					StudentApplyRefunds studentApplyRefund = studentApplyRefunds.get(0);
+					if(data.getStudentStatus()==0&&studentApplyRefund.getStatus().equals(StudentApplyRefundsStatus.ING)){
+						data.setStudentStatus(2);
+						data.setRefundDate(studentApplyRefund.getUpdateTime());
+					}
+					if(data.getStudentStatus()==0){
+						data.setRefundDate(studentApplyRefund.getUpdateTime());
+					}
+				}
+			});
 		}
 		if (count == 0) {
 			dataList = new ArrayList<>();
@@ -1169,6 +1185,18 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			throw new BizException("不能已进行的课程进行此操作");
 		}
 		ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
+
+		ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
+				studentId);
+
+		if(Objects.isNull(classStudentMapperByUserIdAndClassGroupId)){
+			throw new BizException("指定学生不在此课程中");
+		}
+
+		if(classStudentMapperByUserIdAndClassGroupId.getStatus().equals(ClassGroupStudentStatusEnum.QUIT)){
+			throw new BizException("当前学生已经是退学状态");
+		}
+
 		sysUserCashAccountService.updateBalance(studentId, amount);
 		SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentId);
 		SysUserCashAccountDetail sysUserCashAccountDetail = new SysUserCashAccountDetail();
@@ -1180,13 +1208,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		sysUserCashAccountDetail.setAttribute(studentId.toString());
 		sysUserCashAccountDetailDao.insert(sysUserCashAccountDetail);
 
-		ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
-				studentId);
-
-		if(Objects.isNull(classStudentMapperByUserIdAndClassGroupId)){
-			throw new BizException("指定学生不在此课程中");
-		}
-
 		classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT);
 		classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
 
@@ -1695,6 +1716,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
 		List<ImGroupMember> imGroupMemberList = new ArrayList<>();
 		List<ClassGroupStudentMapper> classGroupStudentMappers=new ArrayList<>();
+
+		List<ClassGroupStudentMapper> classGroupStudentsList = classGroupStudentMapperDao.findByClassGroupAndStudent(classGroup.getId(), studentIds);
+		Map<Integer, List<ClassGroupStudentMapper>> classGroupStudentsMap = classGroupStudentsList.stream()
+				.collect(Collectors.groupingBy(ClassGroupStudentMapper::getUserId));
+
 		//生成学生单课缴费信息
 		for (Integer studentId:studentIds) {
 			SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentId);
@@ -1721,13 +1747,22 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 			sysUserCashAccountService.updateCourseBalance(studentId,sysUserCashAccount.getCourseBalance().subtract(surplusCoursesPrice));
 
 			//创建班级学生关联记录
-			ClassGroupStudentMapper classGroupStudentMapper=new ClassGroupStudentMapper();
-			classGroupStudentMapper.setGroupType(classGroup.getGroupType());
-			classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
-			classGroupStudentMapper.setClassGroupId(classGroup.getId());
-			classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
-			classGroupStudentMapper.setUserId(studentId);
-			classGroupStudentMappers.add(classGroupStudentMapper);
+			ClassGroupStudentMapper classGroupStudentMapper;
+
+			List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentsMap.get(studentId);
+			if(!CollectionUtils.isEmpty(classGroupStudents)){
+				classGroupStudentMapper = classGroupStudents.get(0);
+				classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+				classGroupStudentMapperDao.update(classGroupStudentMapper);
+			}else{
+				classGroupStudentMapper=new ClassGroupStudentMapper();
+				classGroupStudentMapper.setGroupType(classGroup.getGroupType());
+				classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
+				classGroupStudentMapper.setClassGroupId(classGroup.getId());
+				classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+				classGroupStudentMapper.setUserId(studentId);
+				classGroupStudentMappers.add(classGroupStudentMapper);
+			}
 
 			imGroupMemberList.add(new ImGroupMember(studentId.toString()));
 		}

+ 13 - 0
mec-biz/src/main/resources/config/mybatis/ClassGroupStudentMapperMapper.xml

@@ -274,4 +274,17 @@
         SELECT cgtm.user_id_ 'key',cgtm.user_id_ 'value' FROM class_group_teacher_mapper cgtm
         WHERE cgtm.music_group_id_ = #{vipGroupId} AND cgtm.group_type_ = 'VIP'
     </select>
+    <select id="findByClassGroupAndStudent" resultMap="ClassGroupStudentMapper">
+        SELECT
+            *
+        FROM
+            class_group_student_mapper
+        WHERE
+            class_group_id_ = #{classGroupId}
+            AND user_id_ IN
+            <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
+                #{userId}
+            </foreach>
+        ORDER BY create_time_ DESC
+    </select>
 </mapper>

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

@@ -137,4 +137,22 @@
                 #{musicGroupId}
             </foreach>
     </select>
+    <select id="findByGroupAndType" resultMap="StudentApplyRefunds">
+        SELECT
+            sar.user_id_,
+            sar.status_,
+            sar.update_time_
+        FROM
+            student_payment_order spo
+            LEFT JOIN student_apply_refunds sar ON spo.user_id_
+            AND spo.id_ = sar.orig_payment_order_id_
+        WHERE
+            spo.music_group_id_ = #{groupId}
+            AND spo.group_type_ = #{groupType}
+            AND spo.status_ = 'SUCCESS'
+            AND sar.user_id_ IS NOT NULL
+        ORDER BY
+            spo.update_time_ DESC
+
+    </select>
 </mapper>

+ 6 - 3
mec-biz/src/main/resources/config/mybatis/VipGroupMapper.xml

@@ -473,6 +473,8 @@
         <result column="total_class_times_" property="totalClassTimes"/>
         <result column="current_class_times_" property="currentClassTimes"/>
         <result column="course_balance_" property="courseSalary"/>
+        <result column="create_time_" property="applyDate"/>
+        <result column="student_status_" property="studentStatus"/>
     </resultMap>
 
     <select id="findVipGroupStudents" resultMap="vipGroupStudentDto">
@@ -482,7 +484,9 @@
             su.phone_,
             cg.total_class_times_,
             cg.current_class_times_,
-            suaa.course_balance_
+            suaa.course_balance_,
+            cgsm.create_time_,
+            CASE cgsm.status_ WHEN 'QUIT' THEN 1 ELSE 0 END student_status_
         FROM
             class_group cg
             LEFT JOIN class_group_student_mapper cgsm ON cg.id_=cgsm.class_group_id_
@@ -490,7 +494,6 @@
             LEFT JOIN sys_user_cash_account suaa ON cgsm.user_id_=suaa.user_id_
         WHERE cg.music_group_id_=#{vipGroupId}
             AND cg.group_type_='VIP'
-            AND cgsm.status_!='QUIT'
             AND cgsm.user_id_ IS NOT NULL
         ORDER BY su.id_
         <include refid="global.limit"/>
@@ -531,7 +534,7 @@
         FROM
         class_group cg
         LEFT JOIN class_group_student_mapper cgsm ON cg.id_=cgsm.class_group_id_
-        WHERE cg.music_group_id_=#{vipGroupId} AND cg.group_type_='VIP' AND cgsm.status_!='QUIT'
+        WHERE cg.music_group_id_=#{vipGroupId} AND cg.group_type_='VIP'
     </select>
 
     <resultMap id="teachingRecord" type="com.ym.mec.biz.dal.dto.VipGroupCourseSchduleRecordDto">