Quellcode durchsuchen

课程退费支持网管课

zouxuan vor 3 Jahren
Ursprung
Commit
54756c7d04

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/FinancialExpenditure.java

@@ -72,12 +72,22 @@ public class FinancialExpenditure {
 
 	private Long vipGroupId;
 
+	private String groupType;
+
 	private String musicGroupId;
 
 	private String returnFeeType;
 
 	private Integer studentId;
 
+	public String getGroupType() {
+		return groupType;
+	}
+
+	public void setGroupType(String groupType) {
+		this.groupType = groupType;
+	}
+
 	public String getMusicGroupId() {
 		return musicGroupId;
 	}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/GroupType.java

@@ -25,6 +25,16 @@ public enum GroupType implements BaseEnum<String, GroupType> {
 		this.desc = desc;
 	}
 
+	public static GroupType valueOfDesc(String desc) {
+		GroupType[] values = GroupType.values();
+		for (GroupType value : values) {
+			if(value.getDesc().equals(desc)){
+				return value;
+			}
+		}
+		return null;
+	}
+
 	@Override
 	public String getCode() {
 		return name();

+ 18 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/GroupClassService.java

@@ -65,6 +65,24 @@ public interface GroupClassService {
     HttpResponseResult cancelGroup(ReturnFeeDto returnFeeDto);
 
     /**
+    * @description: OA审批关闭课程组
+     * @param returnFeeDto
+    * @return void
+    * @author zx
+    * @date 2021/11/30 11:16
+    */
+    void cancelGroupOa(ReturnFeeDto returnFeeDto);
+
+    /**
+    * @description: 校验OA审批关闭课程组参数
+     * @param returnFeeDto
+    * @return void
+    * @author zx
+    * @date 2021/11/30 11:16
+    */
+    void checkCancelGroupOa(ReturnFeeDto returnFeeDto);
+
+    /**
     * @description: 退还活动相关赠送
      * @param activityUserMapper
      * @param confirmReturnActivityGive

+ 34 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/FinancialExpenditureServiceImpl.java

@@ -14,9 +14,7 @@ import com.ym.mec.biz.dal.entity.FinancialExpenditure;
 import com.ym.mec.biz.dal.entity.Organization;
 import com.ym.mec.biz.dal.enums.*;
 import com.ym.mec.biz.dal.page.FinancialExpenditureQueryInfo;
-import com.ym.mec.biz.service.FinancialExpenditureService;
-import com.ym.mec.biz.service.MusicGroupService;
-import com.ym.mec.biz.service.VipGroupService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
@@ -55,6 +53,8 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
     @Autowired
     private VipGroupService vipGroupService;
     @Autowired
+    private GroupClassService groupClassService;
+    @Autowired
     private MusicGroupService musicGroupService;
 
     @Override
@@ -267,29 +267,31 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                                                 financialExpenditure.setVipGroupId(Long.parseLong(o.toString()));
                                                 continue;
                                             }
-                                        }
-                                        if(name.contains("乐团编号")){
+                                        }else if(name.contains("课程类型")){
+                                            Object o = hashMap.get(inputDto.getModel());
+                                            if(o != null){
+                                                financialExpenditure.setGroupType(o.toString());
+                                                continue;
+                                            }
+                                        }else if(name.contains("乐团编号")){
                                             Object o = hashMap.get(inputDto.getModel());
                                             if(o != null){
                                                 financialExpenditure.setMusicGroupId(o.toString());
                                                 continue;
                                             }
-                                        }
-                                        if(name.contains("退费项目")){
+                                        }else if(name.contains("退费项目")){
                                             Object o = hashMap.get(inputDto.getModel());
                                             if(o != null){
                                                 financialExpenditure.setReturnFeeType(o.toString());
                                                 continue;
                                             }
-                                        }
-                                        if(name.contains("学员编号")){
+                                        }else if(name.contains("学员编号")){
                                             Object o = hashMap.get(inputDto.getModel());
                                             if(o != null){
                                                 financialExpenditure.setStudentId(Integer.parseInt(o.toString()));
                                                 continue;
                                             }
-                                        }
-                                        if(name.contains("分部")){
+                                        }else if(name.contains("分部")){
                                             Object o = hashMap.get(inputDto.getModel());
                                             if(o != null){
                                                 int organId = Integer.parseInt(o.toString());
@@ -300,8 +302,7 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                                                 }
                                                 continue;
                                             }
-                                        }
-                                        if(name.contains("金额")){
+                                        }else if(name.contains("金额")){
                                             Object o = hashMap.get(inputDto.getModel());
                                             if(o != null){
                                                 financialExpenditure.setAmount(new BigDecimal(Double.parseDouble(o.toString())));
@@ -337,12 +338,17 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                 if(pWorkOrderInfo.getProcess().equals(22)){
                     for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
                         ReturnFeeDto returnFeeDto = new ReturnFeeDto();
-                        returnFeeDto.setGroupType(GroupType.VIP);
+                        returnFeeDto.setGroupType(GroupType.valueOfDesc(financialExpenditure.getGroupType()));
                         returnFeeDto.setAmount(financialExpenditure.getAmount());
                         returnFeeDto.setStudentId(financialExpenditure.getStudentId());
                         returnFeeDto.setConfirmReturnActivityGive(true);
+                        returnFeeDto.setGroupId(financialExpenditure.getVipGroupId());
                         returnFeeDto.setVipGroupId(financialExpenditure.getVipGroupId());
-                        vipGroupService.applyRefundForStudentOa(returnFeeDto);
+                        if(returnFeeDto.getGroupType() == GroupType.VIP){
+                            vipGroupService.applyRefundForStudentOa(returnFeeDto);
+                        }else if(returnFeeDto.getGroupType() == GroupType.COMM || returnFeeDto.getGroupType() == GroupType.PRACTICE){
+                            groupClassService.cancelGroupOa(returnFeeDto);
+                        }
                     }
                 }else {
                     //退团
@@ -453,6 +459,12 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                                             financialExpenditure.setVipGroupId(Long.parseLong(o.toString()));
                                             continue;
                                         }
+                                    }else if(name.contains("课程类型")){
+                                        Object o = hashMap.get(inputDto.getModel());
+                                        if(o != null){
+                                            financialExpenditure.setGroupType(o.toString());
+                                            continue;
+                                        }
                                     }else if(name.contains("乐团编号")){
                                         Object o = hashMap.get(inputDto.getModel());
                                         if(o != null){
@@ -483,12 +495,17 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
             if(tplInfoId.equals("11")){
                 for (FinancialExpenditure financialExpenditure : financialExpenditureList) {
                     ReturnFeeDto returnFeeDto = new ReturnFeeDto();
-                    returnFeeDto.setGroupType(GroupType.VIP);
+                    returnFeeDto.setGroupType(GroupType.valueOfDesc(financialExpenditure.getGroupType()));
                     returnFeeDto.setAmount(financialExpenditure.getAmount());
                     returnFeeDto.setStudentId(financialExpenditure.getStudentId());
                     returnFeeDto.setConfirmReturnActivityGive(true);
+                    returnFeeDto.setGroupId(financialExpenditure.getVipGroupId());
                     returnFeeDto.setVipGroupId(financialExpenditure.getVipGroupId());
-                    vipGroupService.checkApplyRefundForStudentOa(returnFeeDto);
+                    if(returnFeeDto.getGroupType() == GroupType.VIP){
+                        vipGroupService.checkApplyRefundForStudentOa(returnFeeDto);
+                    }else if(returnFeeDto.getGroupType() == GroupType.COMM || returnFeeDto.getGroupType() == GroupType.PRACTICE){
+                        groupClassService.checkCancelGroupOa(returnFeeDto);
+                    }
                 }
             }else {
                 for (FinancialExpenditure financialExpenditure : financialExpenditureList) {

+ 130 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/GroupClassServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.dto.ReturnFeeDto;
 import com.ym.mec.biz.dal.entity.*;
@@ -9,6 +10,8 @@ import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.util.date.DateUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
@@ -55,7 +58,7 @@ public class GroupClassServiceImpl implements GroupClassService {
     @Autowired
     private PracticeGroupDao practiceGroupDao;
     @Autowired
-    private SysUserCashAccountService sysUserCashAccountService;
+    private TeacherDao teacherDao;
     @Autowired
     private SysUserCashAccountLogDao sysUserCashAccountLogDao;
     @Autowired
@@ -81,6 +84,8 @@ public class GroupClassServiceImpl implements GroupClassService {
     @Autowired
     private PracticeGroupService practiceGroupService;
 
+    private final static Logger LOGGER = LoggerFactory.getLogger(GroupClassServiceImpl.class);
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean deleteAllGroupInfo(String groupId, GroupType groupType) {
@@ -223,6 +228,130 @@ public class GroupClassServiceImpl implements GroupClassService {
         return BaseController.succeed();
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void cancelGroupOa(ReturnFeeDto returnFeeDto) {
+        Long groupId = returnFeeDto.getGroupId();
+        if (Objects.isNull(groupId)) {
+            LOGGER.error("请指定课程组");
+            return;
+        }
+        GroupType groupType = returnFeeDto.getGroupType();
+        if (Objects.isNull(groupType)) {
+            LOGGER.error("请指定课程组类型");
+            return;
+        }
+        Date now = new Date();
+        if (groupType.equals(GroupType.PRACTICE)) {
+            PracticeGroup practiceGroup = practiceGroupDao.get(groupId);
+            if (Objects.isNull(practiceGroup)) {
+                LOGGER.error("课程组 {} 不存在",groupId);
+                return;
+            }
+            if (!practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL) || practiceGroup.getCoursesExpireDate().before(now)) {
+                LOGGER.error("课程组 {} {} 不可关闭",groupId,practiceGroup.getName());
+                return;
+            }
+            if (Objects.nonNull(returnFeeDto.getAmount()) && returnFeeDto.getAmount().compareTo(BigDecimal.ZERO) > 0) {
+                SysUserCashAccountLog sysUserCashAccountLog = new SysUserCashAccountLog();
+                sysUserCashAccountLog.setGroupType(GroupType.PRACTICE);
+                sysUserCashAccountLog.setUserId(practiceGroup.getStudentId());
+                sysUserCashAccountLog.setOrganId(practiceGroup.getOrganId());
+                sysUserCashAccountLog.setGroupId(practiceGroup.getId().toString());
+                sysUserCashAccountLog.setAmount(returnFeeDto.getAmount());
+                sysUserCashAccountLog.setReturnFeeType(ReturnFeeEnum.PRACTICE);
+                sysUserCashAccountLog.setComment("OA审批关闭网管课");
+                sysUserCashAccountLogDao.insert(sysUserCashAccountLog);
+            }
+            ActivityUserMapper activityUserMapper = activityUserMapperDao.findVipUserMapper(practiceGroup.getId(),"PRACTICE",null);
+            quitActivityGive(activityUserMapper, returnFeeDto.getConfirmReturnActivityGive(), practiceGroup.getId(),GroupType.PRACTICE);
+            cleanGroupInfo(groupId.toString(), GroupType.PRACTICE);
+            practiceGroup.setMemo("OA审批关闭网管课");
+            practiceGroup.setGroupStatus(GroupStatusEnum.CANCEL);
+            practiceGroup.setUpdateTime(now);
+            practiceGroupDao.update(practiceGroup);
+        } else if (groupType.equals(GroupType.COMM)) {
+            CoursesGroup coursesGroup = coursesGroupDao.get(groupId);
+            if (Objects.isNull(coursesGroup)) {
+                LOGGER.error("课程组 {} 不存在",groupId);
+                return;
+            }
+            if (coursesGroup.getStatus().equals(GroupStatusEnum.CANCEL)) {
+                LOGGER.error("课程组 {} {} 已关闭",groupId,coursesGroup.getName());
+                return;
+            }
+            List<CourseSchedule> groupNotStartCourses = courseScheduleDao.findGroupNotStartCourses(groupId.toString(), groupType);
+            if (!CollectionUtils.isEmpty(groupNotStartCourses)) {
+                //剩余课程时长
+                Integer totalCourseTime = groupNotStartCourses.size() * coursesGroup.getSingleClassMinutes();
+                sysTenantAccountService.update(coursesGroup.getTeacherId(), totalCourseTime, "", SysTenantAccountDetail.TransType.RETURN, "", BigDecimal.ZERO, "关闭课程组");
+            } else {
+                LOGGER.error("课程组 {} {} 已结束",groupId,coursesGroup.getName());
+                return;
+            }
+            cleanGroupInfo(groupId.toString(), GroupType.COMM);
+            coursesGroup.setMemo("OA审批关闭课程组");
+            coursesGroup.setStatus(GroupStatusEnum.CANCEL);
+            coursesGroupDao.update(coursesGroup);
+        }
+    }
+
+    @Override
+    public void checkCancelGroupOa(ReturnFeeDto returnFeeDto) {
+        Long groupId = returnFeeDto.getGroupId();
+        Integer studentId = returnFeeDto.getStudentId();
+        if (Objects.isNull(groupId)) {
+            throw new BizException("请指定课程组");
+        }
+        if (Objects.isNull(studentId)) {
+            throw new BizException("请指定学员");
+        }
+        GroupType groupType = returnFeeDto.getGroupType();
+        if (Objects.isNull(groupType)) {
+            throw new BizException("请指定课程组类型");
+        }
+        SysUser user = teacherDao.getUser(studentId);
+        if(user == null){
+            throw new BizException("用户 {} 信息不存在",studentId);
+        }
+        Student student = studentDao.get(studentId);
+        if(student == null){
+            throw new BizException("学员 {} 信息不存在",studentId);
+        }
+        Date now = new Date();
+        if (groupType.equals(GroupType.PRACTICE)) {
+            PracticeGroup practiceGroup = practiceGroupDao.get(groupId);
+            if (Objects.isNull(practiceGroup)) {
+                throw new BizException("课程组 {} 不存在",groupId);
+            }
+            if (!returnFeeDto.getStudentId().equals(practiceGroup.getStudentId())) {
+                throw new BizException("学员 {} 不在 {} 课程组内",user.getUsername(),practiceGroup.getName());
+            }
+            if (!practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL) || practiceGroup.getCoursesExpireDate().before(now)) {
+                throw new BizException("课程组 {} {} 不可关闭",groupId,practiceGroup.getName());
+            }
+            if (Objects.nonNull(returnFeeDto.getAmount()) && returnFeeDto.getAmount().compareTo(BigDecimal.ZERO) > 0) {
+                Map<String, BigDecimal> studentSurplusCourseFee = practiceGroupService.getStudentSurplusCourseFee(groupId);
+                BigDecimal suplusCourseFee = studentSurplusCourseFee.get("suplusCourseOriginalFee");
+                if(returnFeeDto.getAmount().compareTo(suplusCourseFee) > 0){
+                    throw new BizException("学员 {} {} 最大可退费金额为{}元",studentId,user.getUsername(),suplusCourseFee.toString());
+                }
+            }
+        } else if (groupType.equals(GroupType.COMM)) {
+            CoursesGroup coursesGroup = coursesGroupDao.get(groupId);
+            if (Objects.isNull(coursesGroup)) {
+                throw new BizException("课程组 {} 不存在",groupId);
+            }
+            if (coursesGroup.getStatus().equals(GroupStatusEnum.CANCEL)) {
+                throw new BizException("课程组 {} {} 已关闭",groupId,coursesGroup.getName());
+            }
+            List<CourseSchedule> groupNotStartCourses = courseScheduleDao.findGroupNotStartCourses(groupId.toString(), groupType);
+            if (CollectionUtils.isEmpty(groupNotStartCourses)) {
+                throw new BizException("课程组 {} {} 已结束",groupId,coursesGroup.getName());
+            }
+        }
+    }
+
 
     @Override
     @Transactional(rollbackFor = Exception.class)