|
@@ -1,5 +1,6 @@
|
|
package com.ym.mec.biz.service.impl;
|
|
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.dao.*;
|
|
import com.ym.mec.biz.dal.dto.ReturnFeeDto;
|
|
import com.ym.mec.biz.dal.dto.ReturnFeeDto;
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
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.entity.HttpResponseResult;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.common.exception.BizException;
|
|
import com.ym.mec.util.date.DateUtil;
|
|
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.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -55,7 +58,7 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
@Autowired
|
|
@Autowired
|
|
private PracticeGroupDao practiceGroupDao;
|
|
private PracticeGroupDao practiceGroupDao;
|
|
@Autowired
|
|
@Autowired
|
|
- private SysUserCashAccountService sysUserCashAccountService;
|
|
|
|
|
|
+ private TeacherDao teacherDao;
|
|
@Autowired
|
|
@Autowired
|
|
private SysUserCashAccountLogDao sysUserCashAccountLogDao;
|
|
private SysUserCashAccountLogDao sysUserCashAccountLogDao;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -81,6 +84,8 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
@Autowired
|
|
@Autowired
|
|
private PracticeGroupService practiceGroupService;
|
|
private PracticeGroupService practiceGroupService;
|
|
|
|
|
|
|
|
+ private final static Logger LOGGER = LoggerFactory.getLogger(GroupClassServiceImpl.class);
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public boolean deleteAllGroupInfo(String groupId, GroupType groupType) {
|
|
public boolean deleteAllGroupInfo(String groupId, GroupType groupType) {
|
|
@@ -223,6 +228,130 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
return BaseController.succeed();
|
|
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
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|