Browse Source

Merge remote-tracking branch 'origin/master'

Joburgess 5 years ago
parent
commit
ad4e609c2d

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

@@ -200,7 +200,7 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
      * @author Joburgess
      * @date 2019/10/18
      */
-    int deleteCourseSchedulesByMusicGroupID(@Param("musicGroupID") String musicGroupID);
+    int deleteCourseSchedulesByMusicGroupID(@Param("musicGroupId")String musicGroupId, @Param("groupType")GroupType groupType);
 
     /**
      * 逻辑删除乐团课程

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

@@ -3,7 +3,9 @@ package com.ym.mec.biz.dal.dao;
 import com.ym.mec.biz.dal.dto.StudentAttendanceStatisticsResponse;
 import com.ym.mec.biz.dal.entity.CourseSchedule;
 import com.ym.mec.biz.dal.entity.CourseScheduleStudentPayment;
+import com.ym.mec.biz.dal.enums.GroupType;
 import com.ym.mec.common.dal.BaseDAO;
+
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
@@ -111,4 +113,11 @@ public interface CourseScheduleStudentPaymentDao extends BaseDAO<Long, CourseSch
                                        @Param("teachMode") String teachMode);
 
     int deleteStudentCourseScheduleByUserId(@Param("courseScheduleId") Long courseScheduleId, @Param("userIdList") List<Integer> userIdList);
+    
+    /**
+     * 根据乐团编号删除记录
+     * @param musicGroupId
+     * @return
+     */
+    int deleteByMusicGroupId(@Param("musicGroupId")String musicGroupId, @Param("groupType")GroupType groupType);
 }

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

@@ -214,4 +214,12 @@ public interface CourseScheduleTeacherSalaryDao extends BaseDAO<Long, CourseSche
 	 * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.Integer>>
 	 */
 	List<Map<Long,Integer>> checkCoursesIsSettlement(@Param("courseScheduleIds") List<Long> courseScheduleIds);
+	
+	/**
+	 * 批量删除
+	 * @param musicGroupId
+	 * @param groupType
+	 * @return
+	 */
+	int deleteByMusicGroupId(@Param("musicGroupId")String musicGroupId, @Param("groupType")GroupType groupType);
 }

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

@@ -27,7 +27,6 @@ import com.ym.mec.jiari.JiaRiFeignService;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateConvertor;
 import com.ym.mec.util.date.DateUtil;
-
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -51,16 +50,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     @Autowired
     private VipGroupDao vipGroupDao;
     @Autowired
-    private VipGroupActivityDao vipGroupActivityDao;
-    @Autowired
     private TeacherAttendanceDao teacherAttendanceDao;
     @Autowired
     private MusicGroupDao musicGroupDao;
     @Autowired
     private MusicGroupBuildLogDao musicGroupBuildLogDao;
     @Autowired
-    private MusicGroupService musicGroupService;
-    @Autowired
     private ClassGroupRelationService classGroupRelationService;
     @Autowired
     private ClassGroupStudentMapperDao classGroupStudentMapperDao;
@@ -95,8 +90,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     @Autowired
     private JiaRiFeignService jiaRiFeignService;
     @Autowired
-    private SysConfigService sysConfigService;
-    @Autowired
     private CourseScheduleService courseScheduleService;
     @Autowired
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
@@ -309,6 +302,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         List<ClassGroupTeacherMapper> classGroupTeacherMapperList = new ArrayList<>();
         List<ClassGroupImGroupDto> classGroupImGroupList = new ArrayList<>();
         Integer schoolId = musicGroup.getSchoolId();
+
+
         for (HighClassGroupDto highClassGroup : highClassGroupList) {
             if (highClassGroup.getDayOfWeek() < 1 || highClassGroup.getDayOfWeek() > 7) {
                 throw new BizException("上课星期错误,请核查");
@@ -338,15 +333,31 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
             //3、插入班级排课信息
             int times = 0;
-            //LocalDateTime now = LocalDateTime.ofInstant(highClassGroup.getStartDate().toInstant(), ZoneId.systemDefault());
             LocalDateTime now = LocalDate.parse(highClassGroup.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
 
-
             List<Subject> subjectList = subjectService.findBySubjectByIdList(highClassGroup.getSubjectIdList());
 
             String courseScheduleName = subjectList.stream().map(subject -> subject.getName()).collect(Collectors.joining("/"));
 
+
+            Map<String, Integer> holidayDays = new HashMap<>();
+            Map<Integer, Map<String, Integer>> holiday = new HashMap<>();
+            if (highClassGroup.getHoliday()) {
+                holiday = jiaRiFeignService.query(now.getYear());
+                holidayDays = holiday.get(now.getYear());
+            }
+
+            WhileNode:
             while (highClassGroup.getCourseTimes() > times) {
+                if(highClassGroup.getHoliday() && !holiday.containsKey(now.getYear())){
+                    holiday = jiaRiFeignService.query(now.getYear());
+                    holidayDays = holiday.get(now.getYear());
+                }
+                if (highClassGroup.getHoliday() && holidayDays.containsKey(now.format(DateTimeFormatter.ofPattern("MMdd")))) {
+                    now = now.plusDays(1);
+                    continue;
+                }
+
                 int dayOfWeek = now.getDayOfWeek().getValue();
                 if (highClassGroup.getDayOfWeek() == dayOfWeek) {
                     CourseSchedule courseSchedule = new CourseSchedule();
@@ -384,6 +395,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             classGroupImGroupDto.setUserIds(userIdList);
             classGroupImGroupList.add(classGroupImGroupDto);
         }
+
+
         //加入Im群组
         batchAddImGroup(classGroupImGroupList);
         classGroupTeacherMapperService.classGroupTeachersInsert(classGroupTeacherMapperList);
@@ -1091,14 +1104,19 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         int times = 0;
 
         Map<String, Integer> holidayDays = new HashMap<>();
+        Map<Integer, Map<String, Integer>> holiday = new HashMap<>();
         if (classGroup4MixDto.getHoliday()) {
-            Map<Integer, Map<String, Integer>> holiday = jiaRiFeignService.query(now.getYear());
+            holiday = jiaRiFeignService.query(now.getYear());
             holidayDays = holiday.get(now.getYear());
         }
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
         WhileNode:
         while (true) {
+            if(classGroup4MixDto.getHoliday() && !holiday.containsKey(now.getYear())){
+                holiday = jiaRiFeignService.query(now.getYear());
+                holidayDays = holiday.get(now.getYear());
+            }
             if (classGroup4MixDto.getHoliday() && holidayDays.containsKey(now.format(DateTimeFormatter.ofPattern("MM-dd")))) {
                 now = now.plusDays(1);
                 continue;
@@ -1298,14 +1316,19 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
         int times = 0;
         Map<String, Integer> holidayDays = new HashMap<>();
+        Map<Integer, Map<String, Integer>> holiday = new HashMap<>();
         if (classGroup4MixDto.getHoliday()) {
-            Map<Integer, Map<String, Integer>> holiday = jiaRiFeignService.query(now.getYear());
+            holiday = jiaRiFeignService.query(now.getYear());
             holidayDays = holiday.get(now.getYear());
         }
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
         WhileNode:
         while (true) {
+            if(classGroup4MixDto.getHoliday() && !holiday.containsKey(now.getYear())){
+                holiday = jiaRiFeignService.query(now.getYear());
+                holidayDays = holiday.get(now.getYear());
+            }
             if (classGroup4MixDto.getHoliday() && holidayDays.containsKey(now.format(DateTimeFormatter.ofPattern("MM-dd")))) {
                 now = now.plusDays(1);
                 continue;
@@ -1525,14 +1548,19 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         BigDecimal expectPrice = new BigDecimal("0");
         int times = 0;
         Map<String, Integer> holidayDays = new HashMap<>();
+        Map<Integer, Map<String, Integer>> holiday = new HashMap<>();
         if (classGroup4MixDto.getHoliday()) {
-            Map<Integer, Map<String, Integer>> holiday = jiaRiFeignService.query(now.getYear());
+            holiday = jiaRiFeignService.query(now.getYear());
             holidayDays = holiday.get(now.getYear());
         }
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
         WhileNode:
         while (true) {
+            if(classGroup4MixDto.getHoliday() && !holiday.containsKey(now.getYear())){
+                holiday = jiaRiFeignService.query(now.getYear());
+                holidayDays = holiday.get(now.getYear());
+            }
             if (classGroup4MixDto.getHoliday() && holidayDays.containsKey(now.format(DateTimeFormatter.ofPattern("MM-dd")))) {
                 now = now.plusDays(1);
                 continue;

+ 0 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ContractServiceImpl.java

@@ -85,9 +85,6 @@ public class ContractServiceImpl implements ContractService, InitializingBean {
 	private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
 
 	@Autowired
-	private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
-
-	@Autowired
 	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
 
 	@Autowired

+ 0 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseHomeworkServiceImpl.java

@@ -1,15 +1,12 @@
 package com.ym.mec.biz.service.impl;
 
-import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.biz.dal.dao.CourseHomeworkDao;
-import com.ym.mec.biz.dal.dao.TeacherAttendanceDao;
 import com.ym.mec.biz.dal.dto.Mapper;
 import com.ym.mec.biz.dal.dto.TeacherHomeworkListDto;
 import com.ym.mec.biz.dal.entity.CourseHomework;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
 import com.ym.mec.biz.dal.page.CourseHomeworkQueryInfo;
 import com.ym.mec.biz.service.CourseHomeworkService;
-import com.ym.mec.biz.service.CourseScheduleService;
 import com.ym.mec.biz.service.SysMessageService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
@@ -30,13 +27,7 @@ public class CourseHomeworkServiceImpl extends BaseServiceImpl<Long, CourseHomew
 	@Autowired
 	private CourseHomeworkDao courseHomeworkDao;
 	@Autowired
-	private CourseScheduleService courseScheduleService;
-	@Autowired
-	private SysUserFeignService sysUserFeignService;
-	@Autowired
 	private SysMessageService sysMessageService;
-	@Autowired
-	private TeacherAttendanceDao teacherAttendanceDao;
 
 	@Override
 	public BaseDAO<Long, CourseHomework> getDAO() {

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

@@ -21,6 +21,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+
 import org.apache.commons.collections.ListUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -201,7 +202,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 			throw new BizException("请指定乐团!");
 		}
 		checkNewCourseSchedules(courseSchedules,false);
-        courseScheduleDao.deleteCourseSchedulesByMusicGroupID(musicGroupID);
+        courseScheduleDao.deleteCourseSchedulesByMusicGroupID(musicGroupID, GroupType.MUSIC);
         courseScheduleDao.batchAddCourseSchedules(courseSchedules);
 	}
 

+ 6 - 5
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -167,9 +167,6 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Autowired
     private CourseScheduleDao courseScheduleDao;
-    
-    @Autowired
-    private CourseScheduleService courseScheduleService;
 
     @Autowired
     private ClassGroupDao classGroupDao;
@@ -885,9 +882,13 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         
         //删除续费记录
         musicGroupStudentFeeDao.deleteByMusicGroupId(musicGroupId);
+
+		// 删除课表
+		courseScheduleDao.deleteCourseSchedulesByMusicGroupID(musicGroupId, GroupType.MUSIC);
+		// 删除每节课的课酬
+		courseScheduleStudentPaymentDao.deleteByMusicGroupId(musicGroupId, GroupType.MUSIC);
+		courseScheduleTeacherSalaryDao.deleteByMusicGroupId(musicGroupId, GroupType.MUSIC);
         
-        //删除课表
-        //删除每节课的课酬
         //删除考勤
 
         // 查询已缴费信息

+ 0 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentAttendanceServiceImpl.java

@@ -54,8 +54,6 @@ public class StudentAttendanceServiceImpl extends BaseServiceImpl<Long, StudentA
 	@Autowired
 	private SysConfigDao sysConfigDao;
 	@Autowired
-	private TeacherAttendanceService teacherAttendanceService;
-	@Autowired
 	private SchoolDao schoolDao;
 	@Autowired
 	private SysConfigService sysConfigService;

+ 0 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRechargeServiceImpl.java

@@ -34,9 +34,6 @@ public class StudentRechargeServiceImpl extends BaseServiceImpl<String, StudentR
 	@Resource
 	private StudentRechargeDao studentRechargeDao;
 	@Autowired
-	private StudentRegistrationDao studentRegistrationDao;
-
-	@Autowired
 	private SysUserCashAccountService sysUserCashAccountService;
 
 	@Resource

+ 1 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -51,8 +51,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Autowired
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
     @Autowired
-    private ClassGroupRelationService classGroupRelationService;
-    @Autowired
     private CourseScheduleService courseScheduleService;
     @Autowired
     private TeacherDao teacherDao;
@@ -89,8 +87,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     @Autowired
     private SysUserCashAccountService sysUserCashAccountService;
     @Autowired
-    private ClassGroupStudentMapperService classGroupStudentMapperService;
-    @Autowired
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private RedisCache<String, Object> redisCache;
@@ -637,7 +633,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         }
         Integer highClassId = studentAddDto.getHighClassId();
         if(highClassId != null){
-            addStudent(mixClassId,userId,nowDate,courseScheduleList);
+            addStudent(highClassId,userId,nowDate,courseScheduleList);
         }
         String snapClassIds = studentAddDto.getSnapClassIds();
         if(StringUtils.isNotEmpty(snapClassIds)){
@@ -712,19 +708,6 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
                 studentPaymentOrderService.update(waitPayOrder);
                 //添加学生
                 //classGroupStudentMapperService.addStudents(waitPayOrder.getClassGroupId(), studentRegistration.getUserId().toString(), GroupType.MUSIC);
-            } else {
-                //加入缴费周期
-                MusicGroupStudentFee musicGroupStudentFee = new MusicGroupStudentFee();
-                musicGroupStudentFee.setMusicGroupId(studentRegistration.getMusicGroupId());
-                musicGroupStudentFee.setUserId(studentRegistration.getUserId());
-                musicGroupStudentFee.setCourseFee(musicOneSubjectClassPlan.getFee());
-                musicGroupStudentFee.setCreateTime(nowDate);
-                musicGroupStudentFee.setUpdateTime(nowDate);
-                musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(studentRegistration.getMusicGroupId()));
-                musicGroupStudentFee.setLatestPaidTime(nowDate);
-                musicGroupStudentFee.setSubjectId(studentRegistration.getActualSubjectId());
-                musicGroupStudentFee.setPaymentStatus(MusicGroupStudentFee.PaymentStatus.PAID_COMPLETED);
-                musicGroupStudentFeeDao.insert(musicGroupStudentFee);
             }
 
             //插入交易明细

+ 5 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysUserBankCardServiceImpl.java

@@ -1,12 +1,5 @@
 package com.ym.mec.biz.service.impl;
 
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.SysUserBankCardDao;
@@ -15,6 +8,11 @@ import com.ym.mec.biz.service.SysUserBankCardService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
 
 @Service
 public class SysUserBankCardServiceImpl extends BaseServiceImpl<Long, SysUserBankCard> implements SysUserBankCardService {
@@ -24,10 +22,6 @@ public class SysUserBankCardServiceImpl extends BaseServiceImpl<Long, SysUserBan
 	
 	@Autowired
 	private SysUserFeignService sysUserFeignService;
-	
-	@Autowired
-	private RedisTemplate<String,String> redisTemplate;
-	private final String loginVerifyCodeKey = "loginVerifyCode:";
 
 	@Override
 	public BaseDAO<Long, SysUserBankCard> getDAO() {

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

@@ -190,8 +190,8 @@
         DELETE FROM course_schedule WHERE id_ = #{id}
     </delete>
 
-    <delete id="deleteCourseSchedulesByMusicGroupID">
-        DELETE FROM course_schedule WHERE music_group_id_=#{musicGroupID} AND group_type_='MUSIC' and status_ = 'NOT_START'
+    <delete id="deleteCourseSchedulesByMusicGroupID" parameterType="map">
+        DELETE FROM course_schedule WHERE music_group_id_=#{musicGroupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler} and status_ = 'NOT_START'
     </delete>
     
     <update id="logicDeleteCourseSchedulesByMusicGroupID">

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleStudentPaymentMapper.xml

@@ -204,4 +204,8 @@
 			#{userId}
 		</foreach>
 	</delete>
+	
+	<delete id="deleteByMusicGroupId" parameterType="map">
+		DELETE FROM course_schedule_student_payment WHERE music_group_id_=#{musicGroupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+	</delete>
 </mapper>

+ 4 - 0
mec-biz/src/main/resources/config/mybatis/CourseScheduleTeacherSalaryMapper.xml

@@ -380,4 +380,8 @@
 			</foreach>
 		GROUP BY course_schedule_id_
 	</select>
+	
+	<delete id="deleteByMusicGroupId" parameterType="map" >
+		DELETE FROM course_schedule_teacher_salary WHERE music_group_id_=#{musicGroupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+	</delete>
 </mapper>

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

@@ -168,8 +168,9 @@
     </select>
 
     <select id="initMusicGroupStudentFee" resultMap="MusicGroupStudentFee">
-        SELECT sr.music_group_id_,sr.user_id_,sr.actual_subject_id_ subject_id_ FROM student_registration sr
+        SELECT sr.music_group_id_,sr.user_id_,sr.actual_subject_id_ subject_id_,mgsp.fee_ course_fee_ FROM student_registration sr
         LEFT JOIN music_group_student_fee_ mgsf ON sr.user_id_ = mgsf.user_id_ AND sr.music_group_id_ = mgsf.music_group_id_
+        LEFT JOIN music_group_subject_plan mgsp ON mgsp.music_group_id_ = sr.music_group_id_ AND mgsp.subject_id_ = sr.actual_subject_id_
         WHERE sr.music_group_status_ != 'QUIT' AND sr.payment_status_ = 2 AND mgsf.id_ IS NULL AND sr.music_group_id_ = #{musicGroupId}
     </select>