瀏覽代碼

Merge branch 'master' of http://git.dayaedu.com/yonge/mec

yonge 3 年之前
父節點
當前提交
71a231cebe

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

@@ -82,4 +82,13 @@ public interface FinancialExpenditureDao extends BaseDAO<Long, FinancialExpendit
     * @date 2021/11/29 16:48
     */
     Integer findByBatchNoAndProcessNo(Integer workOrderId);
+
+    /**
+    * @description: 获取社保分部
+     * @param deptId
+    * @return java.lang.Integer
+    * @author zx
+    * @date 2021/11/30 14:40
+    */
+    Integer getDeptId(Integer deptId);
 }

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/PWorkOrderInfo.java

@@ -17,6 +17,16 @@ public class PWorkOrderInfo {
 
     private String title;
 
+    private Integer deptId;
+
+    public Integer getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(Integer deptId) {
+        this.deptId = deptId;
+    }
+
     public String getTitle() {
         return title;
     }

+ 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

+ 40 - 22
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 {
                     //退团
@@ -373,12 +379,13 @@ public class FinancialExpenditureServiceImpl extends BaseServiceImpl<Long, Finan
                 financialExpenditure.setBatchNo(workOrderId.toString());
                 financialExpenditure.setFinancialProcessNo(workOrderId.toString());
                 Employee employee = employeeDao.get(pWorkOrderInfo.getCreator());
+                Integer organId = financialExpenditureDao.getDeptId(pWorkOrderInfo.getDeptId());
+                Organization organization = organizationDao.get(organId);
+                if(organization != null){
+                    financialExpenditure.setOrganId(organization.getId());
+                    financialExpenditure.setOrganName(organization.getName());
+                }
                 if(employee != null){
-                    Organization organization = organizationDao.get(employee.getDeptId());
-                    if(organization != null){
-                        financialExpenditure.setOrganId(organization.getId());
-                        financialExpenditure.setOrganName(organization.getName());
-                    }
                     List<Integer> userIds = new ArrayList<>();
                     userIds.add(employee.getUserId());
                     List<SimpleUserDto> byIds = employeeDao.findByIds(userIds);
@@ -453,6 +460,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 +496,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)

+ 5 - 0
mec-biz/src/main/resources/config/mybatis/FinancialExpenditureMapper.xml

@@ -196,6 +196,7 @@
         LEFT JOIN organization o ON o.id_ = fe.organ_id_
         LEFT JOIN cooperation_organ co ON co.id_ = fe.cooperation_organ_id_
         <include refid="queryPageSql"/>
+        ORDER BY fe.id_ DESC
         <include refid="global.limit"/>
     </select>
 
@@ -224,6 +225,7 @@
         <result property="creator" column="mec_user_id"/>
         <result property="process" column="process"/>
         <result property="title" column="title"/>
+        <result property="deptId" column="dept_id"/>
     </resultMap>
     <select id="getWorkOrderInfo" resultMap="PWorkOrderInfo">
         SELECT woi.*,su.mec_user_id FROM mec_dev_api.p_work_order_info woi
@@ -245,4 +247,7 @@
     <select id="findByBatchNoAndProcessNo" resultType="integer">
         SELECT id_ FROM financial_expenditure WHERE batch_no_ = #{workOrderId} AND financial_process_no_ = #{workOrderId} LIMIT 1
     </select>
+    <select id="getDeptId" resultType="java.lang.Integer">
+        SELECT organ_id FROM mec_dev_api.sys_dept WHERE dept_id = #{deptId}
+    </select>
 </mapper>

+ 10 - 10
mec-web/src/main/java/com/ym/mec/web/controller/FinancialExpenditureController.java

@@ -48,17 +48,17 @@ public class FinancialExpenditureController extends BaseController {
         if (sysUser == null) {
             return failed("用户信息获取失败");
         }
-            Employee employee = employeeDao.get(sysUser.getId());
-            if (StringUtils.isEmpty(queryInfo.getOrganId())) {
-                queryInfo.setOrganId(employee.getOrganIdList());
-            }else if(StringUtils.isEmpty(employee.getOrganIdList())){
-                return failed("用户所在分部异常");
-            }else {
-                List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
-                if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
-                    return failed("非法请求");
-                }
+        Employee employee = employeeDao.get(sysUser.getId());
+        if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+            queryInfo.setOrganId(employee.getOrganIdList());
+        }else if(StringUtils.isEmpty(employee.getOrganIdList())){
+            return failed("用户所在分部异常");
+        }else {
+            List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+            if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+                return failed("非法请求");
             }
+        }
         return succeed(financialExpenditureService.queryFinancialExpenditurePage(queryInfo));
     }