zouxuan 2 years ago
parent
commit
1cfe35e526

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/MessageTypeEnum.java

@@ -50,6 +50,7 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     TEACHER_SMS_PUSH_VIP_COURSE_APPLY_RESULT("TEACHER_SMS_PUSH_VIP_COURSE_APPLY_RESULT", "VIP课申请结果"),
     TEACHER_SMS_VIP_COURSE_ADD("TEACHER_SMS_VIP_COURSE_ADD", "VIP课新增"),
     TEACHER_PUSH_VIP_COURSE_STOP("TEACHER_PUSH_VIP_COURSE_STOP", "VIP课停止"),
+    TEACHER_PUSH_LIVE_COURSE_STOP("TEACHER_PUSH_LIVE_COURSE_STOP", "直播课停止"),
     //    TEACHER_PUSH_ACTION_COURSE_MESSAGE("TEACHER_PUSH_ACTION_COURSE_MESSAGE", "开课提醒"),
     TEACHER_PUSH_HAVE_COURSE_MESSAGE("TEACHER_PUSH_HAVE_COURSE_MESSAGE", "有课提醒"),
     TEACHER_PUSH_ATTEND_CLASS_MESSAGE("TEACHER_PUSH_ATTEND_CLASS_MESSAGE", "上课提醒"),

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/ReturnFeeEnum.java

@@ -7,6 +7,7 @@ import com.ym.mec.common.enums.BaseEnum;
  */
 public enum ReturnFeeEnum implements BaseEnum<String, ReturnFeeEnum> {
 	VIP("VIP", "VIP退学"),
+	LIVE("LIVE", "直播课退学"),
 	PRACTICE("PRACTICE", "网管课关闭"),
 	MUSIC("MUSIC", "乐团退团"),
 	GOODS("GOODS", "商品退费"),

+ 2 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/VipGroupQueryInfo.java

@@ -13,6 +13,8 @@ public class VipGroupQueryInfo extends QueryInfo {
 
     private String organId;
 
+    private String liveOrganId;
+
     private Long vipGroupId;
 
     private Integer teacherId;

+ 45 - 51
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -1508,7 +1508,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         }
         vipGroup.setStatus(VipGroupStatusEnum.DELETE);
         vipGroupDao.update(vipGroup);
-        groupClassService.hideGroupInfo(vipGroupId.toString(), GroupType.VIP);
+        groupClassService.hideGroupInfo(vipGroupId.toString(), "VIP".equals(vipGroup.getGroupType())?GroupType.VIP:GroupType.LIVE);
     }
 
     @Override
@@ -2745,7 +2745,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         Long vipGroupId = returnFeeDto.getVipGroupId();
         Integer studentId = returnFeeDto.getStudentId();
         if (Objects.isNull(vipGroupId) || Objects.isNull(studentId)) {
-            throw new BizException("请指定课与学生");
+            throw new BizException("请指定课与学生");
         }
         VipGroup vipGroup = vipGroupDao.get(vipGroupId);
         if (Objects.isNull(vipGroup)) {
@@ -2760,7 +2760,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
         VipGroupCategory vipGroupCategory = vipGroupCategoryService.get(vipGroup.getVipGroupCategoryId());
 
-        List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsDao.findByGroupAndUser(vipGroupId.toString(), GroupType.VIP.getCode(), studentId);
+        List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsDao.findByGroupAndUser(vipGroupId.toString(), vipGroup.getGroupType(), studentId);
         if (!CollectionUtils.isEmpty(studentApplyRefunds)) {
             throw new BizException("此学生存在退课申请,请到系统日志中查看");
         }
@@ -2788,36 +2788,38 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                 throw new BizException("学员最大可退费金额为{}元", suplusCourseFee.toString());
             }
         }
-        //退还活动购买
-//        groupClassService.quitActivityGive(activityUserMapperService.findByStudentId(vipGroup.getId(), studentId));
+        GroupType groupType = GroupType.VIP;
+        ReturnFeeEnum returnFeeEnum = ReturnFeeEnum.VIP;
+        if("LIVE".equals(vipGroup.getGroupType())){
+            groupType = GroupType.LIVE;
+            returnFeeEnum = ReturnFeeEnum.LIVE;
+        }
 
         if (classStudentMapperByUserIdAndClassGroupId.getStatus().equals(ClassGroupStudentStatusEnum.QUIT_SCHOOL)) {
             classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT);
             classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
-            studentPauseInfoDao.deleteUserPauseInfoWithGroup(GroupType.VIP, vipGroupId.toString(), studentId);
+            studentPauseInfoDao.deleteUserPauseInfoWithGroup(groupType, vipGroupId.toString(), studentId);
 
             classGroup.setStudentNum(classGroup.getStudentNum() - 1);
             classGroupDao.update(classGroup);
             return BaseController.succeed();
         }
 
-//		sysUserCashAccountService.updateBalance(studentId, amount);
-//		SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentId);
         //记录日志
         SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
         sysUserCashAccountLog.setUserId(studentId);
-        sysUserCashAccountLog.setGroupType(VIP);
+        sysUserCashAccountLog.setGroupType(groupType);
         sysUserCashAccountLog.setOrganId(vipGroup.getOrganId());
         sysUserCashAccountLog.setGroupId(vipGroupId.toString());
         sysUserCashAccountLog.setAmount(amount);
-        sysUserCashAccountLog.setReturnFeeType(ReturnFeeEnum.VIP);
-        sysUserCashAccountLog.setComment("VIP退课");
+        sysUserCashAccountLog.setReturnFeeType(returnFeeEnum);
+        sysUserCashAccountLog.setComment(groupType.getDesc() + "退学");
         sysUserCashAccountLogDao.insert(sysUserCashAccountLog);
 
         classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT);
         classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
 
-        courseScheduleService.batchDeleteMusicGroupCourseWithStudent(vipGroupId.toString(), studentId, GroupType.VIP);
+        courseScheduleService.batchDeleteMusicGroupCourseWithStudent(vipGroupId.toString(), studentId, groupType);
 
         List<Integer> studentPaymentIds = courseScheduleStudentPaymentDao.findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent(classGroup.getId(), studentId);
         if (!CollectionUtils.isEmpty(studentPaymentIds)) {
@@ -2993,7 +2995,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     @Transactional(rollbackFor = Exception.class)
     public void pauseForStudent(Long vipGroupId, Integer studentId) {
         if (Objects.isNull(vipGroupId) || Objects.isNull(studentId)) {
-            throw new BizException("请指定课与学生");
+            throw new BizException("请指定课与学生");
         }
         VipGroup vipGroup = vipGroupDao.get(vipGroupId);
         if (Objects.isNull(vipGroup)) {
@@ -3002,7 +3004,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         if (!VipGroupStatusEnum.PROGRESS.equals(vipGroup.getStatus())) {
             throw new BizException("当前课程组状态非进行中,无法进行该操作");
         }
-        List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsDao.findByGroupAndUser(vipGroupId.toString(), GroupType.VIP.getCode(), studentId);
+        List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsDao.findByGroupAndUser(vipGroupId.toString(), vipGroup.getGroupType(), studentId);
         if (!CollectionUtils.isEmpty(studentApplyRefunds)) {
             throw new BizException("此学生存在退课申请,请到系统日志中查看");
         }
@@ -3024,11 +3026,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             throw new BizException("当前学生已是休学状态");
         }
 
-        BigDecimal surplusCourseFee = courseScheduleStudentPaymentDao.countSurplusCourseFee(classGroup.getId(), studentId);
-
-        if (Objects.isNull(surplusCourseFee)) {
-            surplusCourseFee = new BigDecimal(0);
-        }
 
         Map<String, Object> pauseInfos = new HashMap<>();
         //学生剩余课时
@@ -3224,7 +3221,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             throw new BizException("剩余课时不足,无法与现有课时对齐");
         }
 
-
         CourseSchedule lastCourseSchedule = surplusCourseWithGroup.stream().max(Comparator.comparing(CourseSchedule::getClassDate)).get();
         if (vipGroup.getCoursesExpireDate().compareTo(lastCourseSchedule.getEndClassTime()) <= 0 && !DateUtil.isSameDay(vipGroup.getCoursesExpireDate(), lastCourseSchedule.getEndClassTime())) {
             throw new BizException("排课时间不可超过{}", DateUtil.dateToString(vipGroup.getCoursesExpireDate(), "yyyy年MM月dd日"));
@@ -3405,7 +3401,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
     @Transactional(rollbackFor = Exception.class)
     @Override
     public HttpResponseResult applyRefundAudit(Long id, StudentApplyRefundsStatus status, String remark, BigDecimal amount, boolean confirmReturnActivityGive) {
-
         StudentApplyRefunds studentApplyRefunds = studentApplyRefundsDao.get(id);
         if (studentApplyRefunds == null) {
             throw new BizException("退课申请记录不存在");
@@ -3422,33 +3417,30 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         VipGroup vipGroup = vipGroupDao.get(id);
         studentApplyRefunds.setStatus(status);
         if (studentApplyRefunds.getStatus() == StudentApplyRefundsStatus.DONE) {
-            //退还活动购买
-
-//            ActivityUserMapper activityUserMapper = activityUserMapperService.findByStudentId(vipGroup.getId(), studentPaymentOrder.getUserId());
-//            HttpResponseResult result = groupClassService.quitActivityGive(activityUserMapper, confirmReturnActivityGive, id, VIP);
-//            if (result.getCode() != 200) {
-//                return result;
-//            }
             studentApplyRefunds.setActualAmount(amount);
         } else {
             studentApplyRefunds.setActualAmount(new BigDecimal(0));
         }
+        GroupType groupType = GroupType.VIP;
+        ReturnFeeEnum returnFeeEnum = ReturnFeeEnum.VIP;
+        if("LIVE".equals(vipGroup.getGroupType())){
+            groupType = GroupType.LIVE;
+            returnFeeEnum = ReturnFeeEnum.LIVE;
+        }
         studentApplyRefunds.setRemark(remark);
         studentApplyRefunds.setUpdateTime(new Date());
         studentApplyRefundsDao.update(studentApplyRefunds);
         switch (studentApplyRefunds.getStatus()) {
             case DONE:
-//				sysUserCashAccountService.updateBalance(studentApplyRefunds.getUserId(), studentApplyRefunds.getActualAmount());
-//				SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentApplyRefunds.getUserId().intValue());
                 //记录日志
                 SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
                 sysUserCashAccountLog.setGroupId(vipGroup.getId().toString());
                 sysUserCashAccountLog.setUserId(studentApplyRefunds.getUserId());
-                sysUserCashAccountLog.setGroupType(VIP);
+                sysUserCashAccountLog.setGroupType(groupType);
                 sysUserCashAccountLog.setOrganId(vipGroup.getOrganId());
                 sysUserCashAccountLog.setAmount(amount);
-                sysUserCashAccountLog.setReturnFeeType(ReturnFeeEnum.VIP);
-                sysUserCashAccountLog.setComment("VIP退课审核");
+                sysUserCashAccountLog.setReturnFeeType(returnFeeEnum);
+                sysUserCashAccountLog.setComment(groupType.getDesc() + "退费审核");
                 sysUserCashAccountLogDao.insert(sysUserCashAccountLog);
 
                 ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(studentPaymentOrder.getClassGroupId(),
@@ -3461,17 +3453,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                 classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT);
                 classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
 
-//				ClassGroup classGroup=new ClassGroup();
-//				classGroup.setId(classStudentMapperByUserIdAndClassGroupId.getClassGroupId());
-//				classGroup.setStudentNum(classGroupStudentMapperDao.countClassGroupStudentNum(classGroup.getId()));
-//				classGroupDao.update(classGroup);
-
                 List<Integer> studentPaymentIds = courseScheduleStudentPaymentDao.findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent(classStudentMapperByUserIdAndClassGroupId.getClassGroupId(), studentApplyRefunds.getUserId());
                 if (!CollectionUtils.isEmpty(studentPaymentIds)) {
                     courseScheduleStudentPaymentDao.batchDeleteWithID(studentPaymentIds);
                 }
 
-                courseScheduleService.batchDeleteMusicGroupCourseWithStudent(studentPaymentOrder.getMusicGroupId(), studentApplyRefunds.getUserId(), GroupType.VIP);
+                courseScheduleService.batchDeleteMusicGroupCourseWithStudent(studentPaymentOrder.getMusicGroupId(), studentApplyRefunds.getUserId(), groupType);
 
 
                 courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(Integer.parseInt(studentPaymentOrder.getMusicGroupId()), null);
@@ -3638,9 +3625,19 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 //			stopVipPush(vipGroup.getId(),vipGroup.getName());
             return;
         }
+
+        String orderType = "SMALL_CLASS_TO_BUY";
+        GroupType groupType = VIP;
+        ReturnFeeEnum returnFeeEnum = ReturnFeeEnum.VIP;
+        if("LIVE".equals(vipGroup.getGroupType())){
+            orderType = "LIVE_GROUP_BUY";
+            groupType = GroupType.LIVE;
+            returnFeeEnum = ReturnFeeEnum.LIVE;
+        }
         Map<Integer, BigDecimal> studentSurplusClassFees = MapUtil.convertIntegerMap(maps);
         for (Integer userId : studentSurplusClassFees.keySet()) {
-            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, userId, DealStatusEnum.SUCCESS.getCode(),"VIP".equals(vipGroup.getGroupType())?"SMALL_CLASS_TO_BUY":"LIVE_GROUP_BUY");
+            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, userId,
+                    DealStatusEnum.SUCCESS.getCode(),orderType);
             if (null == studentPaymentOrder) {
                 throw new BizException("无法停止课程,需要全部学员退学后,才能停止,请先操作学员退学。");
             }
@@ -3649,11 +3646,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
             sysUserCashAccountLog.setGroupId(vipGroupId.toString());
             sysUserCashAccountLog.setUserId(userId);
-            sysUserCashAccountLog.setGroupType(VIP);
+            sysUserCashAccountLog.setGroupType(groupType);
             sysUserCashAccountLog.setOrganId(vipGroup.getOrganId());
             sysUserCashAccountLog.setAmount(studentSurplusClassFees.get(userId));
-            sysUserCashAccountLog.setReturnFeeType(ReturnFeeEnum.VIP);
-            sysUserCashAccountLog.setComment("VIP课关闭");
+            sysUserCashAccountLog.setReturnFeeType(returnFeeEnum);
+            sysUserCashAccountLog.setComment(groupType.getDesc() + "关闭");
             sysUserCashAccountLogDao.insert(sysUserCashAccountLog);
         }
 
@@ -3666,20 +3663,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
         courseScheduleStudentPaymentDao.deleteByCourseSchedule(courseScheduleIds);
         teacherAttendanceDao.batchDeleteByCourseSchedules(courseScheduleIds);
-        //vip课停止通知
-//		Teacher teacher = teacherDao.get(vipGroup.getUserId());
-//		Map<Integer,String> map = new HashMap<>(1);
-//		map.put(vipGroup.getUserId(),vipGroup.getUserId().toString());
-//		sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG,MessageTypeEnum.TEACHER_PUSH_VIP_COURSE_STOP,
-//				map,null,0,"1",vipGroup.getName());
         teacherPush(vipGroup);
-//		stopVipPush(vipGroup.getId(),vipGroup.getName());
     }
 
     private void teacherPush(VipGroup vipGroup) {
+        MessageTypeEnum messageTypeEnum = MessageTypeEnum.TEACHER_PUSH_VIP_COURSE_STOP;
+        if("LIVE".equals(vipGroup.getGroupType())){
+            messageTypeEnum = MessageTypeEnum.TEACHER_PUSH_LIVE_COURSE_STOP;
+        }
         Map<Integer, String> map = new HashMap<>(1);
         map.put(vipGroup.getUserId(), vipGroup.getUserId().toString());
-        sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TEACHER_PUSH_VIP_COURSE_STOP,
+        sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, messageTypeEnum,
                 map, null, 0, "1", "TEACHER", vipGroup.getName());
     }
 

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

@@ -97,7 +97,8 @@
     </delete>
 
     <update id="deleteByGroupWithLogic">
-        UPDATE class_group SET del_flag_=1,update_time_=NOW() WHERE music_group_id_=#{groupId} AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+        UPDATE class_group SET del_flag_=1,update_time_=NOW() WHERE music_group_id_=#{groupId}
+        AND group_type_=#{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
     </update>
 
     <!-- 根据主键查询一条记录 -->

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

@@ -197,9 +197,12 @@
             <if test="activityId!=null">
                 AND vg.vip_group_activity_id_=#{activityId}
             </if>
-            <if test="organId != null">
+            <if test="organId != null and organId != ''">
                 AND FIND_IN_SET(vg.organ_id_,#{organId})
             </if>
+            <if test="liveOrganId != null and liveOrganId != ''">
+                AND INTE_ARRAY(vg.organ_id_list_,#{liveOrganId})
+            </if>
             <if test="educationalTeacherId!=null">
                 AND vg.educational_teacher_id_=#{educationalTeacherId}
             </if>
@@ -399,11 +402,14 @@
             AND vg.courses_expire_date_ &gt;= DATE_FORMAT(NOW(),'%Y%m%d')
             AND vg.registration_start_time_ &lt;= NOW()
             AND vg.courses_start_date &gt; NOW()
-            AND (select count(1) as num from student_payment_order where vg.id_ = music_group_id_ AND user_id_=#{userId} AND type_ = 'LIVE_GROUP_BUY'
+            AND (select count(1) as num from student_payment_order where vg.id_ = music_group_id_ AND user_id_ = #{userId} AND type_ = 'LIVE_GROUP_BUY'
             AND status_='SUCCESS') = 0
             <if test="expireFlag != null and expireFlag == true">
                 AND vg.payment_expire_date_ >= NOW()
             </if>
+            <if test="organId != null">
+                AND FIND_IN_SET(#{organId},vg.organ_id_list_)
+            </if>
             <if test="subjectId!=null">
                 AND FIND_IN_SET(#{subjectId},cg.subject_id_list_)
             </if>

+ 5 - 1
mec-web/src/main/java/com/ym/mec/web/controller/VipGroupManageController.java

@@ -184,7 +184,11 @@ public class VipGroupManageController extends BaseController {
     @PostMapping("/queryAll")
     @PreAuthorize("@pcs.hasPermissions('vipGroupManage/queryAll')")
     public Object queryAll(@RequestBody VipGroupQueryInfo queryInfo) {
-        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
+        if("VIP".equals(queryInfo.getGroupType())){
+            queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
+        }else {
+            queryInfo.setLiveOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
+        }
         return succeed(vipGroupService.findVipGroups(queryInfo));
     }