zouxuan hace 1 año
padre
commit
5d47a2e399

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

@@ -325,7 +325,7 @@ public interface VipGroupDao extends BaseDAO<Long, VipGroup> {
      * @author Joburgess
      * @date 2019/12/3
      */
-    List<VipGroup> queryNormalStatusList(@Param("groupType") String groupType);
+    List<VipGroup> queryNormalStatusList();
 
     int countUserRepeatVipGroupInCourseStartEndTime(@Param("userId") Integer userId,
                                                     @Param("courseStartDate") Date courseStartDate,

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

@@ -51,6 +51,11 @@ public enum MessageTypeEnum implements BaseEnum<String, MessageTypeEnum> {
     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", "直播课停止"),
+    JIGUANG_TEACHER_LIVE_PROGRESS("JIGUANG_TEACHER_LIVE_PROGRESS", "直播课成课"),
+    JIGUANG_EDUCATION_LIVE_PROGRESS("JIGUANG_EDUCATION_LIVE_PROGRESS", "直播课成课"),
+    JIGUANG_TEACHER_LIVE_CANCEL("JIGUANG_TEACHER_LIVE_CANCEL", "直播课取消"),
+    JIGUANG_EDUCATION_LIVE_CANCEL("JIGUANG_EDUCATION_LIVE_CANCEL", "直播课取消"),
+    JIGUANG_STUDENT_QUIT_VIP("JIGUANG_STUDENT_QUIT_VIP", "退学成功"),
     //    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", "上课提醒"),

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

@@ -249,15 +249,6 @@ public interface VipGroupService extends BaseService<Long, VipGroup> {
     void orderCallback(StudentPaymentOrder order);
 
     /**
-     * @Author: Joburgess
-     * @Date: 2019/10/3
-     * @params [vipGroupId, studentId]
-     * @return void
-     * @describe 申请退课
-     */
-    void applyRefund(Long vipGroupId);
-
-    /**
      * @describe 给指定学生退课
      * @author Joburgess
      * @date 2019/11/15

+ 31 - 96
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -2040,9 +2040,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             pageInfo.setTotal(count);
             params.put("offset", pageInfo.getOffset());
             dataList = vipGroupDao.findVipGroupStudents(params);
-            List<StudentApplyRefunds> applyRefunds = studentApplyRefundsDao.findByGroupAndType(queryInfo.getVipGroupId().toString(), queryInfo.getGroupType());
-            Map<Integer, List<StudentApplyRefunds>> studentApplyRefundsMap = applyRefunds.stream()
-                    .collect(Collectors.groupingBy(StudentApplyRefunds::getUserId));
             //获取学员基本信息
             List<Integer> userIds = dataList.stream().map(e -> e.getId()).collect(Collectors.toList());
             List<Integer> subjectIds = dataList.stream().map(e -> e.getSubjectId()).collect(Collectors.toList());
@@ -2056,15 +2053,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             Map<Integer, String> organMap = getMap("organization", "id_", "name_", organIds,queryInfo.getTenantId(), Integer.class, String.class);
             Map<Integer, String> subjectMap = getMap("subject", "id_", "name_", subjectIds,queryInfo.getTenantId(), Integer.class, String.class);
             dataList.forEach(data -> {
-                List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsMap.get(data.getId());
-                if (!CollectionUtils.isEmpty(studentApplyRefunds)) {
-                    StudentApplyRefunds studentApplyRefund = studentApplyRefunds.get(0);
-                    if (data.getStudentStatus() == 0 && studentApplyRefund.getStatus().equals(StudentApplyRefundsStatus.ING)) {
-                        data.setStudentStatus(2);
-                    }
-                } else if (data.getStudentStatus() == 0) {
-                    data.setRefundDate(null);
-                }
+                data.setRefundDate(null);
                 SimpleUserDto userDto = studentInfoMap.get(data.getId());
                 if(Objects.nonNull(userDto)){
                     data.setUserName(userDto.getNickName());
@@ -2978,70 +2967,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         classGroupDao.update(classGroup);
     }
 
-    @Transactional(rollbackFor = Exception.class)
-    @Override
-    public void applyRefund(Long vipGroupId) {
-        if (true) {
-            throw new BizException("暂不支持退课");
-        }
-        SysUser sysUser = sysUserService.getUser();
-        Integer userId = sysUser.getId();
-        VipGroup vipGroup = vipGroupDao.get(vipGroupId);
-        StudentApplyRefunds studentApplyRefunds = new StudentApplyRefunds();
-        StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, userId, DealStatusEnum.SUCCESS.getCode(),"VIP".equals(vipGroup.getGroupType())?"SMALL_CLASS_TO_BUY":"LIVE_GROUP_BUY");
-        if (null == studentPaymentOrder) {
-            throw new BizException("未找到相关订单信息!");
-        }
-        //剩余课时数
-        int surplusCourses = studentPaymentOrderDao.countSurplusCourseByMusicGroupAndUser(vipGroup.getId().toString(), userId);
-        if (surplusCourses <= 0) {
-            throw new BizException("此vip课程没有剩余排课");
-        }
-        Date now = new Date();
-        BigDecimal surplusCourseFee;
-        List<StudentCourseInfoDto> userCourseInfos = courseScheduleDao.findUserCourseInfos(GroupType.VIP, vipGroupId.toString(), userId, null);
-        if (CollectionUtils.isEmpty(userCourseInfos) && vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)) {
-            if (Objects.isNull(studentPaymentOrder)) {
-                surplusCourseFee = new BigDecimal(0);
-            } else {
-                surplusCourseFee = studentPaymentOrder.getActualAmount();
-            }
-        } else if (!CollectionUtils.isEmpty(userCourseInfos)) {
-            BigDecimal historyPrice = new BigDecimal(0);
-            BigDecimal allPrice = new BigDecimal(0);
-            for (StudentCourseInfoDto userCourseInfo : userCourseInfos) {
-                allPrice = allPrice.add(userCourseInfo.getExpectPrice());
-                if (now.after(userCourseInfo.getStartClassTime())) {
-                    historyPrice = historyPrice.add(userCourseInfo.getTeachMode().equals(TeachModeEnum.ONLINE) ? vipGroup.getOnlineClassesUnitPrice() : vipGroup.getOfflineClassesUnitPrice());
-                }
-            }
-            surplusCourseFee = allPrice.subtract(historyPrice);
-            if (surplusCourseFee.longValue() < 0) {
-                surplusCourseFee = new BigDecimal(0);
-            }
-        } else {
-            surplusCourseFee = new BigDecimal(0);
-        }
-        if (Objects.isNull(surplusCourseFee)) {
-            surplusCourseFee = new BigDecimal(0);
-        }
-        VipGroupCategory vipGroupCategory = vipGroupCategoryService.get(vipGroup.getVipGroupCategoryId().intValue());
-        surplusCourseFee = sysUserCashAccountLogService.vipReturnFeeCharges(surplusCourseFee, vipGroupCategory == null ? 0 : vipGroupCategory.getStudentNum());
-
-        studentApplyRefunds.setExpectAmount(surplusCourseFee);
-        studentApplyRefunds.setStatus(StudentApplyRefundsStatus.ING);
-        String orderNo = StringUtils.join(new String[]{userId.toString(), String.valueOf(System.currentTimeMillis())});
-        studentApplyRefunds.setOrderNo(orderNo);
-        studentApplyRefunds.setOrigPaymentOrderId(studentPaymentOrder.getId());
-        studentApplyRefunds.setUserId(userId);
-        studentApplyRefundsDao.insert(studentApplyRefunds);
-        Map<String, Object> memo = new HashMap<>(2);
-        memo.put("Id", studentApplyRefunds.getId());
-        memo.put("type", "VIPGROUP");
-        sendSeoMessageSource.sendSeoMessage(sysUser.getOrganId(), new SysUserRoleEnum[]{ORGAN_MANAGER},
-                JSONObject.toJSONString(memo), vipGroup.getEducationalTeacherId(), MessageTypeEnum.BACKSTAGE_STUDENT_APPLY_QUIT_COURSE, sysUser.getUsername());
-    }
-
     @Override
     @Transactional(rollbackFor = Exception.class)
     public HttpResponseResult applyRefundForStudent(ReturnFeeDto returnFeeDto) {
@@ -3063,11 +2988,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 
         VipGroupCategory vipGroupCategory = vipGroupCategoryService.get(vipGroup.getVipGroupCategoryId());
 
-        List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsDao.findByGroupAndUser(vipGroupId.toString(), vipGroup.getGroupType(), studentId);
-        if (!CollectionUtils.isEmpty(studentApplyRefunds)) {
-            throw new BizException("此学生存在退课申请,请到系统日志中查看");
-        }
-
         ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, vipGroup.getGroupType());
 
         ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
@@ -3119,13 +3039,16 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         if (!vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING) || (Objects.nonNull(vipGroupCategory) && vipGroupCategory.getMusicTheory())) {
             courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(vipGroupId.intValue(), vipGroup.getUserId());
         }
-
         classGroup.setStudentNum(classGroup.getStudentNum() - 1);
-
         classGroupDao.update(classGroup);
 
         //学员退出班级群
         imGroupMemberService.quit(classGroup.getId().toString(), studentId);
+        //退学通知
+        Map<Integer, String> studentMap = new HashMap<>(1);
+        studentMap.put(studentId,studentId.toString());
+        sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG,
+                MessageTypeEnum.JIGUANG_STUDENT_QUIT_VIP, studentMap, null, 0, null, "STUDENT",vipGroup.getName());
         return BaseController.succeed();
     }
 
@@ -3155,11 +3078,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             throw new BizException("课程 {} {} 不支持退学", vipGroupId, vipGroup.getName());
         }
 
-        List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsDao.findByGroupAndUser(vipGroupId.toString(),vipGroup.getGroupType(), studentId);
-        if (!CollectionUtils.isEmpty(studentApplyRefunds)) {
-            throw new BizException("学生 {} {} 存在退课申请", studentId, user.getUsername());
-        }
-
         ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, vipGroup.getGroupType());
 
         ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
@@ -3173,7 +3091,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             throw new BizException("学生 {} {} 已经是退学状态", studentId, user.getUsername());
         }
         //不再校验退费金额
-        /*BigDecimal amount = returnFeeDto.getAmount();
+        BigDecimal amount = returnFeeDto.getAmount();
         if (!classStudentMapperByUserIdAndClassGroupId.getStatus().equals(ClassGroupStudentStatusEnum.QUIT_SCHOOL)) {
             if (Objects.isNull(amount)) {
                 throw new BizException("请确定退费金额");
@@ -3183,7 +3101,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
             if (amount.compareTo(suplusCourseFee) > 0) {
                 throw new BizException("学员 {} {} 最大可退费金额为{}元", studentId, user.getUsername(), suplusCourseFee.toString());
             }
-        }*/
+        }
     }
 
     @Override
@@ -3636,14 +3554,20 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         if (vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)) {
             throw new BizException("不能对已停止的课程进行退课操作");
         }
+        GroupType groupType = GroupType.VIP;
+        String orderType = "SMALL_CLASS_TO_BUY";
+        if("LIVE".equals(vipGroup.getGroupType())){
+            groupType = GroupType.LIVE;
+            orderType = "LIVE_GROUP_BUY";
+        }
         VipGroupCategory vipGroupCategory = vipGroupCategoryService.get(vipGroup.getVipGroupCategoryId().intValue());
         Map<String, BigDecimal> result = new HashMap<>();
         Date now = new Date();
         BigDecimal bigDecimal = ZERO;
-        List<StudentCourseInfoDto> userCourseInfos  = courseScheduleDao.findUserCourseInfos(GroupType.VIP, vipGroupId.toString(), studentId, null);
+        List<StudentCourseInfoDto> userCourseInfos  = courseScheduleDao.findUserCourseInfos(groupType, vipGroupId.toString(), studentId, null);
 
         if (CollectionUtils.isEmpty(userCourseInfos) && vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)) {
-            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode(),"VIP".equals(vipGroup.getGroupType())?"SMALL_CLASS_TO_BUY":"LIVE_GROUP_BUY");
+            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode(),orderType);
             if (Objects.nonNull(studentPaymentOrder)) {
                 bigDecimal = studentPaymentOrder.getActualAmount().add(studentPaymentOrder.getBalancePaymentAmount());
             }
@@ -3675,7 +3599,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         result.put("suplusCourseFee", bigDecimal);
 
         if (VipGroupStatusEnum.APPLYING.equals(vipGroup.getStatus())) {
-            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode(),"VIP".equals(vipGroup.getGroupType())?"SMALL_CLASS_TO_BUY":"LIVE_GROUP_BUY");
+            StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode(),orderType);
             if (Objects.nonNull(studentPaymentOrder)) {
                 BigDecimal suplusCourseOriginalFee = studentPaymentOrder.getActualAmount().add(studentPaymentOrder.getBalancePaymentAmount());
                 result.put("suplusCourseOriginalFee", suplusCourseOriginalFee);
@@ -4554,14 +4478,25 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
                 try {
                     ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroup.getId(),vipGroup.getGroupType());
                     List<ClassGroupStudentMapper> classGroupStudents = classGroupStudentMapperDao.findByClassGroup(classGroup.getId());
+                    Map<Integer, String> teacherMap = new HashMap<>(1);
+                    teacherMap.put(vipGroup.getUserId(),vipGroup.getUserId().toString());
+                    Map<Integer, String> eduMap = new HashMap<>(1);
+                    eduMap.put(vipGroup.getEducationalTeacherId(),vipGroup.getEducationalTeacherId().toString());
                     if(CollectionUtils.isEmpty(classGroupStudents)){
                         vipGroup.setStatus(VipGroupStatusEnum.CANCEL);
+                        //推送
+                        sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.JIGUANG_TEACHER_LIVE_CANCEL,
+                                teacherMap, null, 0, null, "TEACHER", vipGroup.getName());
+                        sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.JIGUANG_EDUCATION_LIVE_CANCEL,
+                                eduMap, null, 0, null, "SYSTEM", vipGroup.getName());
                     }else {
                         //生成课程群聊相关信息
                         this.liveProgress(vipGroup,classGroup,classGroupStudents);
                         //推送
-//                        sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.TEACHER_PUSH_VIP_STOP,
-//                                map2, null, 0, 2, "TEACHER", vipGroupName);
+                        sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.JIGUANG_TEACHER_LIVE_PROGRESS,
+                                teacherMap, null, 0, "2", "TEACHER", vipGroup.getName());
+                        sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.JIGUANG_EDUCATION_LIVE_PROGRESS,
+                                eduMap, null, 0, "2", "SYSTEM", vipGroup.getName());
                     }
                     vipGroupDao.update(vipGroup);
                 }catch (Exception e){
@@ -4706,7 +4641,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
         }
         
         //更新到报名中
-        List<VipGroup> normalVipGroupList = vipGroupDao.queryNormalStatusList("VIP");
+        List<VipGroup> normalVipGroupList = vipGroupDao.queryNormalStatusList();
         if (!CollectionUtils.isEmpty(normalVipGroupList)) {
             List<VipGroup> needUpdateVipGroups = new ArrayList<>();
             for (VipGroup vipGroup : normalVipGroupList) {

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

@@ -1566,7 +1566,7 @@
                     AND INTE_ARRAY(mg.organ_id_list_,#{organIds})
                 </if>
                 <if test="groupType != 'LIVE'">
-                    FIND_IN_SET(mg.organ_id_,#{organIds})
+                   AND FIND_IN_SET(mg.organ_id_,#{organIds})
                 </if>
             </if>
             <if test="educationUserId != null">

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

@@ -501,9 +501,7 @@
           and spo.type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
     </select>
     <select id="findByStudentVipGroup" resultMap="StudentPaymentOrder">
-        SELECT
-        spo.*
-        FROM
+        SELECT spo.* FROM
         student_payment_order spo
         WHERE spo.user_id_ = #{userId}
         AND spo.music_group_id_ = #{vipGroupId}
@@ -516,6 +514,7 @@
         <if test="orderType == null or orderType == ''">
             AND spo.type_ = 'SMALL_CLASS_TO_BUY'
         </if>
+        order by id_ DESC LIMIT 1
     </select>
     <select id="sumSurplusCourseFee" resultType="java.math.BigDecimal">
         SELECT SUM(cssp.expect_price_)

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

@@ -1082,7 +1082,7 @@
     <select id="queryNormalStatusList" resultMap="VipGroup">
         SELECT *
         FROM vip_group
-        WHERE group_status_ = 0 AND group_type_ = #{groupType}
+        WHERE group_status_ = 0
     </select>
 
     <select id="findVipGroupInfo" resultMap="VipGroup">

+ 0 - 8
mec-student/src/main/java/com/ym/mec/student/controller/StudentVipGroupController.java

@@ -93,14 +93,6 @@ public class StudentVipGroupController extends BaseController {
         return vipGroupService.buyVipGroup(vipGroupBuyParams);
     }
 
-    @ApiOperation(value = "vip课退课")
-    @PostMapping("/applyRefund")
-    @AuditLogAnnotation(operateName = "vip课退课")
-	public HttpResponseResult applyRefund(Long vipGroupId) {
-		vipGroupService.applyRefund(vipGroupId);
-		return succeed();
-	}
-
     @ApiOperation(value = "获取vip购买信息")
     @PostMapping("/getVipGroupPayInfo")
 	public HttpResponseResult<VipGroupPayInfoDto> getVipGroupPayInfo(Integer vipGroupId){