浏览代码

Merge remote-tracking branch 'origin/master'

Joburgess 4 年之前
父节点
当前提交
cd1e34908f

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

@@ -91,6 +91,15 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      */
     int deleteStudentByClassGroupId(@Param("classGroupId") Long classGroupId, @Param("userId") Long userId);
 
+    /**
+     * @return int
+     * @Author: zouxuan
+     * @Date: 2019/10/17
+     * @params [classGroupId, userId]
+     * @describe 删除班级上的指定学生
+     */
+    int deleteByClassGroupIdAndStudents(@Param("classGroupId") Integer classGroupId, @Param("userIds") String userIds);
+
     int deleteClassGroupStudent(@Param("classGroupId") Long classGroupId, @Param("userId") Integer userId);
 
   /**

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

@@ -1654,4 +1654,12 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      */
     List<Long> queryStudentNotStartByClassIdsAndStudentIds(@Param("classGroupIds") List<Integer> classGroupIds,
                                                            @Param("studentIds") List<Integer> studentIds);
+
+    /**
+     * 获取没有学员的课程
+     * @author zouxuan
+     * @param courseIds
+     * @return
+     */
+    List<Long> findNoStudentCourseIds(@Param("courseIds") List<Long> courseIds);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MergeClassSplitClassAffirmDto.java

@@ -2,6 +2,7 @@ package com.ym.mec.biz.dal.dto;
 
 
 import java.util.List;
+import java.util.Map;
 
 public class MergeClassSplitClassAffirmDto {
     private List<ClassGroup4MixDto> classGroup4MixDtos;
@@ -12,6 +13,16 @@ public class MergeClassSplitClassAffirmDto {
 
     private List<Integer> studentIds;
 
+    private List<Map<Integer,String>> classGroupStudents;
+
+    public List<Map<Integer, String>> getClassGroupStudents() {
+        return classGroupStudents;
+    }
+
+    public void setClassGroupStudents(List<Map<Integer, String>> classGroupStudents) {
+        this.classGroupStudents = classGroupStudents;
+    }
+
     public List<Integer> getStudentIds() {
         return studentIds;
     }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/MusicGroupStudentClassAdjust.java

@@ -37,6 +37,9 @@ public class MusicGroupStudentClassAdjust {
 	@ApiModelProperty(value = "所选学员冻结的课程列表", required = false)
 	private String subLockCourseIds;
 
+	@ApiModelProperty(value = "每个班级对应的学员", required = false)
+	private String classGroupStudents;
+
 	@ApiModelProperty(value = "是否排课", required = false)
 	private boolean courseFlag;
 
@@ -46,6 +49,14 @@ public class MusicGroupStudentClassAdjust {
 
 	private Date updateTime;
 
+	public String getClassGroupStudents() {
+		return classGroupStudents;
+	}
+
+	public void setClassGroupStudents(String classGroupStudents) {
+		this.classGroupStudents = classGroupStudents;
+	}
+
 	public Integer getId() {
 		return id;
 	}

+ 19 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -27,6 +27,7 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import com.alibaba.fastjson.JSONArray;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.*;
@@ -34,7 +35,6 @@ import com.ym.mec.biz.service.*;
 import com.ym.mec.common.service.IdGeneratorService;
 import org.apache.commons.beanutils.BeanUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.json.JSONArray;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
@@ -3388,13 +3388,17 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         musicGroupStudentClassAdjust.setNewClassGroupJson(JSON.toJSONString(classGroup4MixDtos));
         musicGroupStudentClassAdjust.setClassGroupIds(JSON.toJSONString(classGroupIds));
         musicGroupStudentClassAdjust.setStudentIds(JSON.toJSONString(studentIds));
+        List<Map<Integer, String>> classGroupStudents = mergeClassSplitClassAffirmDto.getClassGroupStudents();
+        if(classGroupStudents != null && classGroupStudents.size() > 0){
+            musicGroupStudentClassAdjust.setClassGroupStudents(JSON.toJSONString(mergeClassSplitClassAffirmDto.getClassGroupStudents()));
+        }
 
         //获取需要冻结的课程
         List<Long> allLockCourseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds,null);
         musicGroupStudentClassAdjust.setAllLockCourseIds(JSON.toJSONString(allLockCourseIds));
         //获取需要删除的学员关联的课程
         List<Long> courseIds = courseScheduleDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds,studentIds);
-
+        musicGroupStudentClassAdjust.setSubLockCourseIds(JSON.toJSONString(courseIds));
         List<Long> studentPaymentIds = courseScheduleStudentPaymentDao.queryStudentNotStartByClassIdsAndStudentIds(classGroupIds,studentIds);
 
 //        musicGroupStudentClassAdjust.setSubLockCourseIds(JSON.toJSONString(courseIds));
@@ -3427,6 +3431,19 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             }
             //排课完成后删除所选课程
             courseScheduleDao.deleteMusicGroupCourseSchedulesWithStudents(courseIds,studentIds);
+            //删除班级关联的学员
+            if(classGroupStudents != null && classGroupStudents.size() > 0){
+                for (Map<Integer, String> classGroupStudent : classGroupStudents) {
+                    Set<Integer> integers = classGroupStudent.keySet();
+                    for (Integer integer : integers) {
+                        classGroupStudentMapperDao.deleteByClassGroupIdAndStudents(integer,classGroupStudent.get(integer));
+                    }
+                }
+            }
+            List<Long> delCourseIds = courseScheduleDao.findNoStudentCourseIds(courseIds);
+            if(delCourseIds != null && delCourseIds.size() > 0){
+                courseScheduleDao.deleteCourseSchedulesByClassGroupIds(delCourseIds);
+            }
         }else {
             //冻结班级
             classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds,1);

+ 4 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleStudentPaymentServiceImpl.java

@@ -348,6 +348,9 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				}
 				//处理缴费的排课信息
 				List<MusicGroupPaymentStudentCourseDetail> musicGroupPaymentStudentCourseDetails = musicGroupPaymentStudentCourseDetailDao.getUnUseWithStudentAndCourseTypeAndCourseMinutes(batchNo, studentId,courseSchedule.getType());
+				if(musicGroupPaymentStudentCourseDetails == null || musicGroupPaymentStudentCourseDetails.size() == 0){
+					throw new BizException("学员缴费详情获取失败");
+				}
 				//获取合班时的缴费项目
 				Set<Long> calenderIds = musicGroupPaymentCalenderDao.findByBatchNoAndStudentId(batchNo,studentId);
 				List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.getWithPaymentCalendersAndCourseType(calenderIds, null);
@@ -373,6 +376,7 @@ public class CourseScheduleStudentPaymentServiceImpl extends BaseServiceImpl<Lon
 				cssp.setExpectPrice(courseCurrentPrice);
 				cssp.setActualPrice(BigDecimal.ZERO);
 				courseScheduleStudentPayments.add(cssp);
+				//获取课程类型默认排课时长
 				int typeCourseDuration = Integer.parseInt(jsonObject.get(courseSchedule.getType().getCode()).toString());
 				for (MusicGroupPaymentStudentCourseDetail musicGroupPaymentStudentCourseDetail : musicGroupPaymentStudentCourseDetails) {
 					if(typeCourseDuration > musicGroupPaymentStudentCourseDetail.getTotalCourseMinutes()){

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

@@ -120,6 +120,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 	@Autowired
 	private CourseScheduleStudentPaymentServiceImpl courseScheduleStudentPaymentService;
 	@Autowired
+	private ClassGroupStudentMapperDao classGroupStudentMapperDao;
+	@Autowired
 	private MusicGroupStudentClassAdjustDao musicGroupStudentClassAdjustDao;
 	@Autowired
 	private MusicGroupPaymentCalenderDetailService musicGroupPaymentCalenderDetailService;
@@ -928,7 +930,23 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		List<Integer> classGroupIds = JSON.parseArray(musicGroupStudentClassAdjust.getClassGroupIds(), Integer.class);
 		classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds,0);
 		musicGroupStudentClassAdjust.setCourseFlag(true);
+		//删除班级学员
 		musicGroupStudentClassAdjustDao.update(musicGroupStudentClassAdjust);
+		String classGroupStudents = musicGroupStudentClassAdjust.getClassGroupStudents();
+		if(StringUtils.isNotEmpty(classGroupStudents)){
+			List<Map> maps = JSON.parseArray(classGroupStudents, Map.class);
+			for (Map<Integer, String> classGroupStudent : maps) {
+				Set<Integer> integers = classGroupStudent.keySet();
+				for (Integer integer : integers) {
+					classGroupStudentMapperDao.deleteByClassGroupIdAndStudents(integer,classGroupStudent.get(integer));
+				}
+			}
+		}
+		//获取没有学员的课程列表
+		List<Long> delCourseIds = courseScheduleDao.findNoStudentCourseIds(courseIds);
+		if(delCourseIds != null && delCourseIds.size() > 0){
+			courseScheduleDao.deleteCourseSchedulesByClassGroupIds(delCourseIds);
+		}
 	}
 
 	@Override

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

@@ -251,6 +251,11 @@
         WHERE class_group_id_=#{classGroupId} AND user_id_=#{userId}
     </update>
 
+    <update id="deleteByClassGroupIdAndStudents">
+        update class_group_student_mapper set status_ = 'QUIT',update_time_ = NOW()
+        WHERE class_group_id_=#{classGroupId} AND FIND_IN_SET(user_id_,#{userIds})
+    </update>
+
     <update id="updateVipGroupStudentStatus">
         update class_group_student_mapper set status_ = #{status},update_time_ = NOW()
         where music_group_id_=#{groupId} and group_type_=#{groupType}

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

@@ -3398,6 +3398,15 @@
         AND CONCAT(cs.class_date_," ",cs.start_class_time_) > NOW()
         GROUP BY cssp.course_schedule_id_
     </select>
+    <select id="findNoStudentCourseIds" resultType="Long">
+        SELECT cs.id_ FROM course_schedule cs
+        LEFT JOIN course_schedule_student_payment cssp ON cssp.course_schedule_id_ = cs.id_
+        WHERE cs.id_ IN
+        <foreach collection="courseIds" open="(" close=")" separator="," item="item">
+            #{item}
+        </foreach>
+        GROUP BY cssp.course_schedule_id_,cs.id_  HAVING COUNT(cssp.id_) = 0
+    </select>
     <select id="getLock" resultMap="CourseSchedule">
         SELECT * FROM course_schedule WHERE id_ = #{courseId} FOR UPDATE
     </select>

+ 6 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupStudentClassAdjustMapper.xml

@@ -17,6 +17,7 @@
 		<result column="all_lock_course_ids_" property="allLockCourseIds" />
 		<result column="sub_lock_course_ids_" property="subLockCourseIds" />
 		<result column="student_payment_ids_" property="studentPaymentIds" />
+		<result column="class_group_students_" property="classGroupStudents" />
 		<result column="course_flag_" property="courseFlag" />
 		<result column="operator_id_" property="operatorId" />
 		<result column="create_time_" property="createTime" />
@@ -37,14 +38,17 @@
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO music_group_student_class_adjust (music_group_id_,batch_no_,new_class_group_json_,
 		class_group_ids_,student_ids_,class_course_minute_,all_lock_course_ids_,sub_lock_course_ids_,
-		course_flag_,operator_id_,student_payment_ids_,create_time_,update_time_)
+		course_flag_,operator_id_,student_payment_ids_,class_group_students_,create_time_,update_time_)
 		VALUES(#{musicGroupId},#{batchNo},#{newClassGroupJson},#{classGroupIds},#{studentIds},
-		#{classCourseMinute},#{allLockCourseIds},#{subLockCourseIds},#{courseFlag},#{operatorId},#{studentPaymentIds},NOW(),NOW())
+		#{classCourseMinute},#{allLockCourseIds},#{subLockCourseIds},#{courseFlag},#{operatorId},#{studentPaymentIds},#{classGroupStudents},NOW(),NOW())
 	</insert>
 	
 	<!-- 根据主键查询一条记录 -->
 	<update id="update" parameterType="com.ym.mec.biz.dal.entity.MusicGroupStudentClassAdjust">
 		UPDATE music_group_student_class_adjust <set>
+		<if test="classGroupStudents != null">
+			class_group_students_ = #{classGroupStudents},
+		</if>
 		<if test="studentPaymentIds != null">
 			student_payment_ids_ = #{studentPaymentIds},
 		</if>