Browse Source

Merge remote-tracking branch 'origin/master'

Joburgess 5 years ago
parent
commit
df20d37cd0

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

@@ -99,7 +99,7 @@ public interface ClassGroupStudentMapperDao extends BaseDAO<Long, ClassGroupStud
      * @param classGroupId
      * @return
      */
-    ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(@Param("userId") Integer userId, @Param("classGroupId") Integer classGroupId);
+    ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(@Param("userId") Integer userId, @Param("classGroupId") Integer classGroupId,@Param("status") String status);
 
     /**
      * @param classGroupIds: 班级编号列表

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/ClassGroupTeacherMapperDao.java

@@ -4,6 +4,7 @@ import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.biz.dal.enums.TeachTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
+
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
@@ -71,7 +72,7 @@ public interface ClassGroupTeacherMapperDao extends BaseDAO<Long, ClassGroupTeac
      * @param classGroupIds
      * @return
      */
-    int delClassGroupTeacherMapper(@Param("classGroupIds") List<Integer> classGroupIds);
+    int delClassGroupTeacherMapper(@Param("courseScheduleIds") List<Long> courseScheduleIds);
 
     /**
      * 获取助教名称列表

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -9,6 +9,7 @@ import com.ym.mec.biz.dal.entity.StudentCourseScheduleRecordDto;
 import com.ym.mec.biz.dal.enums.CourseStatusEnum;
 import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.dal.BaseDAO;
+
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
@@ -650,7 +651,7 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @param classGroupIds 班级编号列表
      * @return
      */
-    int deleteCourseSchedulesByClassGroupIds(@Param("classGroupIds") List<Integer> classGroupIds);
+    int deleteCourseSchedulesByClassGroupIds(@Param("courseScheduleIds") List<Long> courseScheduleIds);
 
     /**
      * 查询所有未签到的学生信息

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

@@ -274,21 +274,21 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         if (classGroups.size() > 0) {
             List<Integer> classGroupIds = classGroups.stream().map(classGroup -> classGroup.getId()).collect(Collectors.toList());
 
+            //删除基础提高班
+            classGroupDao.batchSoftDelete(classGroupIds);
+
             List<CourseSchedule> classGroupNoStartCourseSchedules = courseScheduleService.findClassGroupNoStartCourseSchedules(classGroupIds, GroupType.MUSIC);
 
             if (classGroupNoStartCourseSchedules.size() > 0) {
                 List<Long> courseScheduleIds = classGroupNoStartCourseSchedules.stream().map(courseSchedule -> courseSchedule.getId()).collect(Collectors.toList());
                 courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
                 teacherAttendanceDao.batchDeleteByCourseSchedules(courseScheduleIds);
+                //删除基础提高班课程
+                courseScheduleDao.deleteCourseSchedulesByClassGroupIds(courseScheduleIds);
+                //删除基础提高老师
+                classGroupTeacherMapperDao.delClassGroupTeacherMapper(courseScheduleIds);
             }
 
-            //删除基础提高班
-            classGroupDao.batchSoftDelete(classGroupIds);
-            //删除基础提高班课程
-            courseScheduleDao.deleteCourseSchedulesByClassGroupIds(classGroupIds);
-            //删除基础提高老师
-            classGroupTeacherMapperDao.delClassGroupTeacherMapper(classGroupIds);
-
             for (ClassGroup classGroup : classGroups) {
                 imFeignService.groupDismiss(new ImGroupModel(classGroup.getId().toString(), null, classGroup.getName()));
             }

+ 20 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupStudentMapperServiceImpl.java

@@ -48,7 +48,7 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 
     @Override
     public ClassGroupStudentMapper findClassStudentMapperByUserIdAndClassGroupId(Integer userId, Integer classGroupId) {
-        return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId);
+        return classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId,"NORMAL");
     }
 
     @Override
@@ -152,23 +152,28 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
 
         Iterator<String> iterator = userIdStrSet.iterator();
         while (iterator.hasNext()) {
-        	String userIdStr = iterator.next();
-            List<ClassGroupStudentMapper> highClassGroupHasUser = classGroupStudentMapperDao.findHighClassGroupHasUser(classGroup.getMusicGroupId(), Integer.parseInt(userIdStr), classGroup.getType());
+        	Integer userId = Integer.parseInt(iterator.next());
+            List<ClassGroupStudentMapper> highClassGroupHasUser = classGroupStudentMapperDao.findHighClassGroupHasUser(classGroup.getMusicGroupId(), userId, classGroup.getType());
             if (highClassGroupHasUser != null && highClassGroupHasUser.size() > 0) {
             	iterator.remove();
                 continue;
             }
-
-            ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
-            classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
-            classGroupStudentMapper.setClassGroupId(classGroupId);
-            classGroupStudentMapper.setUserId(Integer.parseInt(userIdStr));
-            classGroupStudentMapper.setCreateTime(nowDate);
-            classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
-            classGroupStudentMapper.setGroupType(GroupType.MUSIC);
-            classGroupStudentMappers.add(classGroupStudentMapper);
+            //校验是否存在历史记录
+            ClassGroupStudentMapper classGroupStudentMapper = classGroupStudentMapperDao.findClassStudentMapperByUserIdAndClassGroupId(userId, classGroupId, null);
+            if(classGroupStudentMapper != null){
+                classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+            }else {
+                classGroupStudentMapper = new ClassGroupStudentMapper();
+                classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
+                classGroupStudentMapper.setClassGroupId(classGroupId);
+                classGroupStudentMapper.setUserId(userId);
+                classGroupStudentMapper.setCreateTime(nowDate);
+                classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+                classGroupStudentMapper.setGroupType(GroupType.MUSIC);
+                classGroupStudentMappers.add(classGroupStudentMapper);
+            }
             if (classGroup.getType().equals(ClassGroupTypeEnum.NORMAL)) {
-                StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(Integer.parseInt(userIdStr), classGroup.getMusicGroupId());
+                StudentRegistration studentRegistration = studentRegistrationService.queryByUserIdAndMusicGroupId(userId, classGroup.getMusicGroupId());
                 studentRegistration.setClassGroupId(classGroupId);
                 studentRegistrationService.update(studentRegistration);
             }
@@ -177,13 +182,13 @@ public class ClassGroupStudentMapperServiceImpl extends BaseServiceImpl<Long, Cl
                 classGroupStudentMapper = new ClassGroupStudentMapper();
                 classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
                 classGroupStudentMapper.setClassGroupId(classGroupRelation.getClassGroupId());
-                classGroupStudentMapper.setUserId(Integer.parseInt(userIdStr));
+                classGroupStudentMapper.setUserId(userId);
                 classGroupStudentMapper.setCreateTime(nowDate);
                 classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
                 classGroupStudentMapper.setGroupType(GroupType.MUSIC);
                 classGroupStudentMappers.add(classGroupStudentMapper);
             }
-            imGroupMemberList.add(new ImGroupMember(userIdStr));
+            imGroupMemberList.add(new ImGroupMember(userId.toString()));
         }
 		if (classGroupStudentMappers.size() > 0) {
 			classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMappers);

+ 12 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -530,18 +530,24 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderService.insert(studentPaymentOrder);
                 //生成订单明细
                 List<StudentPaymentOrderDetail> studentPaymentOrderDetails = studentAddDto.getStudentPaymentOrderDetails();
-                if (studentPaymentOrderDetails != null && studentPaymentOrderDetails.size() > 0) {
-                    studentPaymentOrderDetails.forEach(e -> {
-                        e.setPaymentOrderId(studentPaymentOrder.getId());
-                    });
-                    studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetails);
+                if (studentPaymentOrderDetails == null) {
+                    studentPaymentOrderDetails = new ArrayList<>();
                 }
+                studentPaymentOrderDetails.forEach(e -> {
+                    e.setPaymentOrderId(studentPaymentOrder.getId());
+                });
+                StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+                studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+                studentPaymentOrderDetail.setPrice(studentAddDto.getTemporaryCourseFee());
+                studentPaymentOrderDetail.setType(OrderDetailTypeEnum.COURSE);
+                studentPaymentOrderDetails.add(studentPaymentOrderDetail);
+                studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetails);
             }
             studentRegistrationDao.updateCurrentClass(studentRegistration);
             Map<Integer,String> receivers = new HashMap<>(1);
             receivers.put(studentRegistration.getUserId(),studentRegistration.getParentsPhone());
             sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.YIMEI,MessageTypeEnum.SMS_MUSIC_GROUP_ADD_STUDENT,
-                    receivers,null,0,null,studentRegistration.getParentsName(),musicGroup.getName());
+                    receivers,null,0,null,studentRegistration.getParentsName(),studentRegistration.getName(),musicGroup.getName());
             return userId;
         }
     }

+ 2 - 1
mec-biz/src/main/resources/config/mybatis/ClassGroupMapper.xml

@@ -353,7 +353,8 @@
     </select>
     <select id="findNoClassSubjects" resultMap="ClassGroup">
         SELECT cg.* FROM class_group cg LEFT JOIN class_group_relation cgr ON cgr.sub_class_group_id_=cg.id_
-        WHERE cg.music_group_id_=#{musicGroupId} AND cg.type_ = 'NORMAL' AND cg.group_type_='MUSIC' AND cg.del_flag_ = '0' AND cgr.id_ IS NULL
+        WHERE cg.music_group_id_=#{musicGroupId} AND cg.type_ = 'NORMAL'
+        AND cg.group_type_='MUSIC' AND cg.del_flag_ = '0'
     </select>
 
     <select id="countTeacherNum" resultType="java.lang.Integer">

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

@@ -150,7 +150,11 @@
 
     <select id="findClassStudentMapperByUserIdAndClassGroupId" resultMap="ClassGroupStudentMapper">
         SELECT * FROM class_group_student_mapper
-        WHERE user_id_=#{userId} AND class_group_id_=#{classGroupId} AND status_ = 'NORMAL'
+        WHERE user_id_=#{userId} AND class_group_id_=#{classGroupId}
+        <if test="status != null">
+            AND status_ = #{status}
+        </if>
+        LIMIT 1
     </select>
     <select id="findByClassGroups" resultMap="ClassGroupStudentMapper">
         SELECT * FROM class_group_student_mapper WHERE class_group_id_ IN

+ 3 - 4
mec-biz/src/main/resources/config/mybatis/ClassGroupTeacherMapperMapper.xml

@@ -157,10 +157,9 @@
 
     <!-- 删除对应班级老师关联关系 -->
     <delete id="delClassGroupTeacherMapper">
-        DELETE FROM class_group_teacher_mapper WHERE class_group_id_ IN
-        <foreach collection="classGroupIds" item="classGroupId" index="index" open="(" close=")" separator=",">
-            #{classGroupId}
+        DELETE FROM class_group_teacher_mapper WHERE course_schedule_id_ IN
+        <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
+            #{courseScheduleId}
         </foreach>
-        AND group_type_='MUSIC'
     </delete>
 </mapper>

+ 4 - 5
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -1201,7 +1201,7 @@
     </select>
     
     <select id="queryTeacherCoursesTimesOfTomorrow" resultMap="Mapper">
-    	select cssp.user_id_ key_,count(1) value_ from course_schedule cs right join course_schedule_teacher_salary cssp on cs.id_ = cssp.course_schedule_id_ where class_date_ = date(DATE_ADD(now(),INTERVAL 1 DAY)) group by cssp.user_id_
+    	select cssp.user_id_ key_,u.real_name_ value_ from course_schedule cs right join course_schedule_teacher_salary cssp on cs.id_ = cssp.course_schedule_id_ left join sys_user u on u.id_ = cssp.user_id_ where class_date_ = date(DATE_ADD(now(),INTERVAL 1 DAY)) group by cssp.user_id_
     </select>
     
     <select id="queryTeacherNotStartCourseScheduleIn30Mins" resultMap="Mapper">
@@ -1434,11 +1434,10 @@
     </delete>
 
     <delete id="deleteCourseSchedulesByClassGroupIds">
-        DELETE FROM course_schedule WHERE class_group_id_ IN
-        <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
-            #{classGroupId}
+        DELETE FROM course_schedule WHERE course_schedule_id_ IN
+        <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
+            #{courseScheduleId}
         </foreach>
-        AND group_type_ = 'MUSIC'
     </delete>
     
     <select id="queryUnsignedStudentList" resultMap="StudentAttendance">