Explorar o código

Merge branch 'zx_saas_2022_05_06' of http://git.dayaedu.com/yonge/mec into master_saas

 Conflicts:
	mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java
	mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java
zouxuan %!s(int64=3) %!d(string=hai) anos
pai
achega
f66a3ac457

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/ClassGroupService.java

@@ -12,6 +12,7 @@ import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.BaseService;
+import org.apache.ibatis.annotations.Param;
 
 import java.lang.reflect.InvocationTargetException;
 import java.math.BigDecimal;
@@ -591,4 +592,14 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
 
     //修改班级基本信息
     int updateClassGroup(ClassGroup classGroup);
+
+    /**
+     * 根据班级编号冻结所选班级
+     *
+     * @param classGroupIds
+     * @param lockFlag
+     * @return
+     * @author zouxuan
+     */
+    int batchUpdateLockByClassGroupIds(List<Integer> classGroupIds,int lockFlag);
 }

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

@@ -3432,6 +3432,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int batchUpdateLockByClassGroupIds(List<Integer> classGroupIds, int lockFlag) {
+        return classGroupDao.batchUpdateLockByClassGroupIds(classGroupIds,lockFlag);
+    }
+
+    @Override
     public PageInfo<MusicGroupCourseScheduleDto> queryMusicGroupCourseScheduleDetail(queryMusicGroupCourseScheduleQueryInfo queryInfo) {
         PageInfo<MusicGroupCourseScheduleDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
         Map<String, Object> params = new HashMap<>();
@@ -4660,13 +4666,6 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         } else {
             paymentCalenderDto.setStatus(NO);
         }
-
-        //将学员加入新乐团、扣除原乐团剩余课程余额、补充到现有乐团
-        Map<Integer, List<MusicGroupPaymentCalenderStudentDetail>> collect = calenderStudentDetails.stream().collect(Collectors.groupingBy(e -> e.getUserId()));
-        for (Map<Integer, String> classGroupStudent : classGroupStudents) {
-            Integer classGroupId = classGroupStudent.keySet().iterator().next();
-            studentRegistrationService.insertStudent(classGroupStudent.get(classGroupId), musicGroupDao.findByClassGroupId(classGroupId).getId(), musicGroup.getId(), collect);
-        }
         paymentCalenderDto.setPayUserType(MusicGroupPaymentCalender.PayUserType.STUDENT);
         paymentCalenderDto.setPaymentType(SPAN_GROUP_CLASS_ADJUST);
         //生成缴费项目
@@ -4712,6 +4711,12 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
         httpResponseResult.setStatus(true);
         //没有需要审核的缴费项目
         if (paymentCalenderDto.getStatus() != AUDITING) {
+            //将学员加入新乐团、扣除原乐团剩余课程余额、补充到现有乐团
+            Map<Integer, List<MusicGroupPaymentCalenderStudentDetail>> collect = calenderStudentDetails.stream().collect(Collectors.groupingBy(e -> e.getUserId()));
+            for (Map<Integer, String> classGroupStudent : classGroupStudents) {
+                Integer classGroupId = classGroupStudent.keySet().iterator().next();
+                studentRegistrationService.insertStudent(classGroupStudent.get(classGroupId), musicGroupDao.findByClassGroupId(classGroupId).getId(), musicGroup.getId(), collect);
+            }
             List<Map> classGroupStudents1 = JSON.parseArray(musicGroupStudentClassAdjust.getClassGroupStudents(), Map.class);
             spanGroupClassAdjustPass(masterClassGroupId, studentIds, courseIds, classGroupStudents1, allLockCourseIds, paymentCalenderDto.getBatchNo(), masterTotalPrice);
             httpResponseResult.setMsg("操作成功:学员班级调整完成");

+ 30 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -116,6 +116,8 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
     private StudentDao studentDao;
     @Autowired
     private ActivityUserMapperService activityUserMapperService;
+    @Autowired
+    private StudentRegistrationService studentRegistrationService;
 
     @Override
     public BaseDAO<Long, MusicGroupPaymentCalender> getDAO() {
@@ -1003,14 +1005,21 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 //                    autoClassGroupAdjust(musicGroupStudentClassAdjust);
 //                }
             } else if (calender.getPaymentType() == SPAN_GROUP_CLASS_ADJUST) {
-                //删除和解冻班级,课程信息
+                List<MusicGroupPaymentCalenderStudentDetail> calenderStudentDetails = musicGroupPaymentCalenderStudentDetailDao.findByBatchNo(batchNo);
+                //将学员加入新乐团、扣除原乐团剩余课程余额、补充到现有乐团
+                Map<Integer, List<MusicGroupPaymentCalenderStudentDetail>> collect = calenderStudentDetails.stream().collect(Collectors.groupingBy(e -> e.getUserId()));
                 MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(batchNo);
                 List<Map> classGroupStudents = JSON.parseArray(adjust.getClassGroupStudents(), Map.class);
+                for (Map<Integer, String> classGroupStudent : classGroupStudents) {
+                    Integer classGroupId = classGroupStudent.keySet().iterator().next();
+                    studentRegistrationService.insertStudent(classGroupStudent.get(classGroupId), musicGroupDao.findByClassGroupId(classGroupId).getId(), musicGroup.getId(), collect);
+                }
+                //删除和解冻班级,课程信息
                 List<Integer> studentIds = JSON.parseArray(adjust.getStudentIds(), Integer.class);
                 List<Long> courseIds = JSON.parseArray(adjust.getSubLockCourseIds(), Long.class);
                 List<Long> allLockCourseIds = JSON.parseArray(adjust.getAllLockCourseIds(), Long.class);
                 //如果是跨团班级合并,添加学员
-                musicGroupPaymentCalenderDetailService.batchAdd(calender, musicGroupPaymentCalenderStudentDetailDao.findByBatchNo(batchNo));
+                musicGroupPaymentCalenderDetailService.batchAdd(calender, calenderStudentDetails);
                 classGroupService.spanGroupClassAdjustPass(adjust.getMasterClassGroupId()
                         , studentIds, courseIds, classGroupStudents, allLockCourseIds, batchNo, adjust.getMasterTotalPrice());
             }
@@ -1091,7 +1100,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Date date = new Date();
         calenders.forEach(e -> {
-            if (e.getPaymentType() == ADD_STUDENT || e.getPaymentType() == SPAN_GROUP_CLASS_ADJUST) {
+            if (e.getPaymentType() == ADD_STUDENT) {
                 throw new BizException("{} 的缴费项目不允许撤回", e.getStatus().getDesc());
             }
             if (e.getStatus() != AUDITING) {
@@ -1287,9 +1296,24 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
         if (musicGroupPaymentCalenderDetailList != null && musicGroupPaymentCalenderDetailList.size() > 0) {
             throw new BizException("操作失败:缴费项目中已存在学员");
         }
-        MusicGroupStudentClassAdjust byBatchNo = musicGroupStudentClassAdjustDao.findByBatchNo(calender.getBatchNo());
-        if (byBatchNo != null) {
-            throw new BizException("操作失败:班级调整的缴费项目不支持");
+        MusicGroupStudentClassAdjust adjust = musicGroupStudentClassAdjustDao.findByBatchNo(calender.getBatchNo());
+        if (!Objects.isNull(adjust)) {
+//            throw new BizException("操作失败:班级调整的缴费项目不支持");
+            List<Map> classGroupStudents = JSON.parseArray(adjust.getClassGroupStudents(), Map.class);
+            //删除班级关联的学员
+            List<Integer> classGroupIds = new ArrayList<>();
+            if (classGroupStudents != null && classGroupStudents.size() > 0) {
+                for (Map<Integer, String> classGroupStudent : classGroupStudents) {
+                    classGroupIds.addAll(classGroupStudent.keySet());
+                }
+            }
+            List<Long> allLockCourseIds = JSON.parseArray(adjust.getAllLockCourseIds(), Long.class);
+            //解冻课程
+            courseScheduleDao.batchUpdateLockByCourseIds(allLockCourseIds, 0,null);
+            //解冻班级
+            classGroupIds.add(adjust.getMasterClassGroupId());
+            classGroupService.batchUpdateLockByClassGroupIds(classGroupIds, 0);
+            musicGroupStudentClassAdjustDao.delete(adjust.getId());
         }
 
         if (calender.getPaymentType() == PaymentType.MUSIC_APPLY) {