|
|
@@ -1,16 +1,16 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.ReturnFeeDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
-import com.ym.mec.biz.dal.enums.DealStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.GroupStatusEnum;
|
|
|
-import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
-import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
|
|
|
-import com.ym.mec.biz.service.GroupClassService;
|
|
|
-import com.ym.mec.biz.service.SysTenantAccountService;
|
|
|
-import com.ym.mec.biz.service.SysUserCashAccountService;
|
|
|
+import com.ym.mec.biz.dal.enums.*;
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
+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.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -42,6 +42,8 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
|
@Autowired
|
|
|
private CourseScheduleDao courseScheduleDao;
|
|
|
@Autowired
|
|
|
+ private CourseScheduleService courseScheduleService;
|
|
|
+ @Autowired
|
|
|
private CourseScheduleTeacherSalaryDao courseScheduleTeacherSalaryDao;
|
|
|
@Autowired
|
|
|
private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
|
@@ -59,45 +61,63 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
|
private CoursesGroupDao coursesGroupDao;
|
|
|
@Autowired
|
|
|
private SysTenantAccountService sysTenantAccountService;
|
|
|
+ @Autowired
|
|
|
+ private ActivityUserMapperDao activityUserMapperDao;
|
|
|
+ @Autowired
|
|
|
+ private CloudTeacherOrderDao cloudTeacherOrderDao;
|
|
|
+ @Autowired
|
|
|
+ private VipGroupActivityDao vipGroupActivityDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
+ @Autowired
|
|
|
+ private VipGroupDao vipGroupDao;
|
|
|
+ @Autowired
|
|
|
+ private VipGroupCategoryDao vipGroupCategoryDao;
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
|
|
|
+ @Autowired
|
|
|
+ private ImGroupMemberService imGroupMemberService;
|
|
|
+ @Autowired
|
|
|
+ private PracticeGroupService practiceGroupService;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean deleteAllGroupInfo(String groupId, GroupType groupType) {
|
|
|
- groupDao.deleteGroup(groupId,groupType.getCode());
|
|
|
- classGroupDao.deleteByGroup(groupId,groupType);
|
|
|
- classGroupTeacherMapperDao.deleteByGroup(groupId,groupType);
|
|
|
- classGroupTeacherSalaryDao.deleteByGroup(groupId,groupType);
|
|
|
- classGroupStudentMapperDao.deleteByGroup(groupId,groupType);
|
|
|
- courseScheduleDao.deleteByGroup(groupId,groupType);
|
|
|
- courseScheduleTeacherSalaryDao.deleteByGroup(groupId,groupType);
|
|
|
- courseScheduleStudentPaymentDao.deleteByGroup(groupId,groupType);
|
|
|
- teacherAttendanceDao.deleteByGroup(groupId,groupType);
|
|
|
- studentAttendanceDao.deleteByGroup(groupId,groupType);
|
|
|
+ groupDao.deleteGroup(groupId, groupType.getCode());
|
|
|
+ classGroupDao.deleteByGroup(groupId, groupType);
|
|
|
+ classGroupTeacherMapperDao.deleteByGroup(groupId, groupType);
|
|
|
+ classGroupTeacherSalaryDao.deleteByGroup(groupId, groupType);
|
|
|
+ classGroupStudentMapperDao.deleteByGroup(groupId, groupType);
|
|
|
+ courseScheduleDao.deleteByGroup(groupId, groupType);
|
|
|
+ courseScheduleTeacherSalaryDao.deleteByGroup(groupId, groupType);
|
|
|
+ courseScheduleStudentPaymentDao.deleteByGroup(groupId, groupType);
|
|
|
+ teacherAttendanceDao.deleteByGroup(groupId, groupType);
|
|
|
+ studentAttendanceDao.deleteByGroup(groupId, groupType);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean deleteGroupOtherInfo(String groupId, GroupType groupType) {
|
|
|
- classGroupDao.deleteByGroup(groupId,groupType);
|
|
|
- classGroupTeacherMapperDao.deleteByGroup(groupId,groupType);
|
|
|
- classGroupTeacherSalaryDao.deleteByGroup(groupId,groupType);
|
|
|
- classGroupStudentMapperDao.deleteByGroup(groupId,groupType);
|
|
|
- courseScheduleDao.deleteByGroup(groupId,groupType);
|
|
|
- courseScheduleTeacherSalaryDao.deleteByGroup(groupId,groupType);
|
|
|
- courseScheduleStudentPaymentDao.deleteByGroup(groupId,groupType);
|
|
|
- teacherAttendanceDao.deleteByGroup(groupId,groupType);
|
|
|
- studentAttendanceDao.deleteByGroup(groupId,groupType);
|
|
|
+ classGroupDao.deleteByGroup(groupId, groupType);
|
|
|
+ classGroupTeacherMapperDao.deleteByGroup(groupId, groupType);
|
|
|
+ classGroupTeacherSalaryDao.deleteByGroup(groupId, groupType);
|
|
|
+ classGroupStudentMapperDao.deleteByGroup(groupId, groupType);
|
|
|
+ courseScheduleDao.deleteByGroup(groupId, groupType);
|
|
|
+ courseScheduleTeacherSalaryDao.deleteByGroup(groupId, groupType);
|
|
|
+ courseScheduleStudentPaymentDao.deleteByGroup(groupId, groupType);
|
|
|
+ teacherAttendanceDao.deleteByGroup(groupId, groupType);
|
|
|
+ studentAttendanceDao.deleteByGroup(groupId, groupType);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean cleanGroupInfo(String groupId, GroupType groupType) {
|
|
|
- classGroupDao.deleteByGroupWithLogic(groupId,groupType);
|
|
|
- classGroupStudentMapperDao.deleteByGroupWithLogic(groupId,groupType);
|
|
|
+ classGroupDao.deleteByGroupWithLogic(groupId, groupType);
|
|
|
+ classGroupStudentMapperDao.deleteByGroupWithLogic(groupId, groupType);
|
|
|
List<CourseSchedule> groupNotStartCourses = courseScheduleDao.findGroupNotStartCourses(groupId, groupType);
|
|
|
- if(CollectionUtils.isEmpty(groupNotStartCourses)){
|
|
|
+ if (CollectionUtils.isEmpty(groupNotStartCourses)) {
|
|
|
return true;
|
|
|
}
|
|
|
List<Long> courseIds = groupNotStartCourses.stream().map(CourseSchedule::getId).collect(Collectors.toList());
|
|
|
@@ -112,10 +132,10 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean hideGroupInfo(String groupId, GroupType groupType) {
|
|
|
- classGroupDao.deleteByGroupWithLogic(groupId,groupType);
|
|
|
- classGroupStudentMapperDao.deleteByGroupWithLogic(groupId,groupType);
|
|
|
+ classGroupDao.deleteByGroupWithLogic(groupId, groupType);
|
|
|
+ classGroupStudentMapperDao.deleteByGroupWithLogic(groupId, groupType);
|
|
|
List<CourseSchedule> groupNotStartCourses = courseScheduleDao.findGroupNotStartCourses(groupId, groupType);
|
|
|
- if(CollectionUtils.isEmpty(groupNotStartCourses)){
|
|
|
+ if (CollectionUtils.isEmpty(groupNotStartCourses)) {
|
|
|
return true;
|
|
|
}
|
|
|
List<Long> courseIds = groupNotStartCourses.stream().map(CourseSchedule::getId).collect(Collectors.toList());
|
|
|
@@ -129,28 +149,35 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public void cancelGroup(Long groupId, GroupType groupType, BigDecimal refundAmount) {
|
|
|
- if(Objects.isNull(groupId)){
|
|
|
+ public HttpResponseResult cancelGroup(ReturnFeeDto returnFeeDto) {
|
|
|
+ Long groupId = returnFeeDto.getGroupId();
|
|
|
+ if (Objects.isNull(groupId)) {
|
|
|
throw new BizException("请指定课程组");
|
|
|
}
|
|
|
- if(Objects.isNull(groupType)){
|
|
|
+ GroupType groupType = returnFeeDto.getGroupType();
|
|
|
+ if (Objects.isNull(groupType)) {
|
|
|
throw new BizException("请指定课程组类型");
|
|
|
}
|
|
|
- Date now=new Date();
|
|
|
- if(groupType.equals(GroupType.PRACTICE)){
|
|
|
+ Date now = new Date();
|
|
|
+ if (groupType.equals(GroupType.PRACTICE)) {
|
|
|
+ BigDecimal refundAmount = returnFeeDto.getAmount();
|
|
|
PracticeGroup practiceGroup = practiceGroupDao.get(groupId);
|
|
|
- if(Objects.isNull(practiceGroup)){
|
|
|
+ if (Objects.isNull(practiceGroup)) {
|
|
|
throw new BizException("指定的课程组不存在");
|
|
|
}
|
|
|
List<StudentPaymentOrder> orders = studentPaymentOrderDao.findOrderByGroup(practiceGroup.getId().toString(), GroupType.PRACTICE, DealStatusEnum.SUCCESS);
|
|
|
- if(CollectionUtils.isEmpty(orders)&&Objects.nonNull(refundAmount)){
|
|
|
+ if (CollectionUtils.isEmpty(orders) && Objects.nonNull(refundAmount)) {
|
|
|
throw new BizException("未获取到订单");
|
|
|
}
|
|
|
- if(!practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL)||practiceGroup.getCoursesExpireDate().before(now)){
|
|
|
+ if (!practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL) || practiceGroup.getCoursesExpireDate().before(now)) {
|
|
|
throw new BizException("当前课程组不可关闭");
|
|
|
}
|
|
|
- if(Objects.nonNull(refundAmount)&&refundAmount.compareTo(BigDecimal.ZERO)>0){
|
|
|
- if(refundAmount.compareTo(orders.get(0).getExpectAmount())>0){
|
|
|
+ HttpResponseResult result = quitActivityGive(practiceGroup.getActivityUserMapperId(), returnFeeDto.getConfirmReturnActivityGive(), practiceGroup.getStudentId());
|
|
|
+ if(result.getCode() != 200){
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(refundAmount) && refundAmount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (refundAmount.compareTo(orders.get(0).getExpectAmount()) > 0) {
|
|
|
throw new BizException("退款不可大于购买金额");
|
|
|
}
|
|
|
sysUserCashAccountService.updateBalance(practiceGroup.getStudentId(), refundAmount, PlatformCashAccountDetailTypeEnum.REFUNDS, "后台关闭网管课");
|
|
|
@@ -160,20 +187,20 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
|
practiceGroup.setGroupStatus(GroupStatusEnum.CANCEL);
|
|
|
practiceGroup.setUpdateTime(now);
|
|
|
practiceGroupDao.update(practiceGroup);
|
|
|
- }else if(groupType.equals(GroupType.COMM)){
|
|
|
+ } else if (groupType.equals(GroupType.COMM)) {
|
|
|
CoursesGroup coursesGroup = coursesGroupDao.get(groupId);
|
|
|
- if(Objects.isNull(coursesGroup)){
|
|
|
+ if (Objects.isNull(coursesGroup)) {
|
|
|
throw new BizException("指定的课程组不存在");
|
|
|
}
|
|
|
- if(coursesGroup.getStatus().equals(GroupStatusEnum.CANCEL)){
|
|
|
+ if (coursesGroup.getStatus().equals(GroupStatusEnum.CANCEL)) {
|
|
|
throw new BizException("此课程组已关闭");
|
|
|
}
|
|
|
List<CourseSchedule> groupNotStartCourses = courseScheduleDao.findGroupNotStartCourses(groupId.toString(), groupType);
|
|
|
- if(!CollectionUtils.isEmpty(groupNotStartCourses)){
|
|
|
+ if (!CollectionUtils.isEmpty(groupNotStartCourses)) {
|
|
|
//剩余课程时长
|
|
|
- Integer totalCourseTime=groupNotStartCourses.size()*coursesGroup.getSingleClassMinutes();
|
|
|
- sysTenantAccountService.update(coursesGroup.getTeacherId(), totalCourseTime, "", SysTenantAccountDetail.TransType.RETURN, "",BigDecimal.ZERO,"关闭课程组");
|
|
|
- }else{
|
|
|
+ Integer totalCourseTime = groupNotStartCourses.size() * coursesGroup.getSingleClassMinutes();
|
|
|
+ sysTenantAccountService.update(coursesGroup.getTeacherId(), totalCourseTime, "", SysTenantAccountDetail.TransType.RETURN, "", BigDecimal.ZERO, "关闭课程组");
|
|
|
+ } else {
|
|
|
throw new BizException("此课程组已结束");
|
|
|
}
|
|
|
cleanGroupInfo(groupId.toString(), GroupType.COMM);
|
|
|
@@ -181,5 +208,100 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
|
coursesGroup.setStatus(GroupStatusEnum.CANCEL);
|
|
|
coursesGroupDao.update(coursesGroup);
|
|
|
}
|
|
|
+ return BaseController.succeed();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public HttpResponseResult quitActivityGive(Integer activityUserMapperId,Boolean confirmReturnActivityGive,Integer studentId){
|
|
|
+ if(activityUserMapperId != null){
|
|
|
+ ActivityUserMapper activityUserMapper = activityUserMapperDao.get(activityUserMapperId);
|
|
|
+ if(activityUserMapper != null){
|
|
|
+ if(activityUserMapper.getReturnFee()){
|
|
|
+ throw new BizException("当前课程组无法退费,请联系管理员");
|
|
|
+ }
|
|
|
+ if(!confirmReturnActivityGive && activityUserMapper.getGiveMemberFlag() != 0 && activityUserMapper.getGiveVipFlag() != 0 && activityUserMapper.getGivePracticeFlag() != 0){
|
|
|
+ return BaseController.failed(HttpStatus.PARTIAL_CONTENT,"当前课程组为活动购买,退费会退还活动相关所有赠送,是否继续退费?");
|
|
|
+ }
|
|
|
+ Date now = new Date();
|
|
|
+ if(activityUserMapper.getGiveMemberFlag() == 2){
|
|
|
+ VipGroupActivity activity = vipGroupActivityDao.get(activityUserMapper.getActivityId());
|
|
|
+ //只退还赠送的时间
|
|
|
+ Integer giveMemberTime = activity.getGiveMemberTime();
|
|
|
+ PeriodEnum givePeriodEnum = activity.getGivePeriodEnum();
|
|
|
+ switch (givePeriodEnum){
|
|
|
+ case DAY:
|
|
|
+ break;
|
|
|
+ case MONTH:
|
|
|
+ giveMemberTime = giveMemberTime * 30;
|
|
|
+ break;
|
|
|
+ case QUARTERLY:
|
|
|
+ giveMemberTime = giveMemberTime * 30 * 3;
|
|
|
+ break;
|
|
|
+ case YEAR_HALF:
|
|
|
+ giveMemberTime = giveMemberTime * 30 * 6;
|
|
|
+ break;
|
|
|
+ case YEAR:
|
|
|
+ giveMemberTime = giveMemberTime * 30 * 12;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new BizException("错误的会员周期类型");
|
|
|
+ }
|
|
|
+ Student student = studentDao.get(studentId);
|
|
|
+ Date membershipEndTime = student.getMembershipEndTime();
|
|
|
+ if(membershipEndTime.compareTo(now) > 0){
|
|
|
+ membershipEndTime = DateUtil.addDays(membershipEndTime, -giveMemberTime);
|
|
|
+ student.setMembershipEndTime(membershipEndTime);
|
|
|
+ if(membershipEndTime.compareTo(now) < 0){
|
|
|
+ student.setMemberRankSettingId(null);
|
|
|
+ student.setExperienceMemberRankSettingId(null);
|
|
|
+ }
|
|
|
+ student.setUpdateTime(now);
|
|
|
+ studentDao.updateStudentMember(student);
|
|
|
+ }
|
|
|
+ CloudTeacherOrder cloudTeacherOrder = cloudTeacherOrderDao.get(activityUserMapper.getGiveMemberOrderId());
|
|
|
+ cloudTeacherOrder.setStatus(3);
|
|
|
+ cloudTeacherOrder.setRemark("退还活动赠送");
|
|
|
+ cloudTeacherOrderDao.update(cloudTeacherOrder);
|
|
|
+ }
|
|
|
+ if(activityUserMapper.getGiveVipFlag() == 2){
|
|
|
+ Long giveVipGroupId = activityUserMapper.getGiveVipGroupId();
|
|
|
+ VipGroup giveVipGroup = vipGroupDao.get(giveVipGroupId);
|
|
|
+ ClassGroupStudentMapper giveClassGroupStudentMapper = classGroupStudentMapperDao.query(giveVipGroupId.intValue(),studentId);
|
|
|
+ giveClassGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
+ classGroupStudentMapperDao.update(giveClassGroupStudentMapper);
|
|
|
+
|
|
|
+ courseScheduleService.batchDeleteMusicGroupCourseWithStudent(giveVipGroupId.toString(),studentId,GroupType.VIP);
|
|
|
+
|
|
|
+ ClassGroup giveClassGroup = classGroupDao.findByVipGroup(giveVipGroupId, null);
|
|
|
+ List<Integer> studentPaymentIds = courseScheduleStudentPaymentDao.findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent(giveClassGroup.getId(), studentId);
|
|
|
+ if(!CollectionUtils.isEmpty(studentPaymentIds)){
|
|
|
+ courseScheduleStudentPaymentDao.batchDeleteWithID(studentPaymentIds);
|
|
|
+ }
|
|
|
+ VipGroupCategory giveVipGroupCategory = vipGroupCategoryDao.get(giveVipGroup.getVipGroupCategoryId());
|
|
|
+
|
|
|
+ if(!giveVipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING) || (Objects.nonNull(giveVipGroupCategory) && giveVipGroupCategory.getMusicTheory())){
|
|
|
+ courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(giveVipGroupId.intValue(), giveVipGroup.getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
+ giveClassGroup.setStudentNum(giveClassGroup.getStudentNum() - 1);
|
|
|
+ classGroupDao.update(giveClassGroup);
|
|
|
+
|
|
|
+ //学员退出班级群
|
|
|
+ imGroupMemberService.quit(giveClassGroup.getId().longValue(), studentId);
|
|
|
+ }
|
|
|
+ if(activityUserMapper.getGivePracticeFlag() == 2){
|
|
|
+ Long givePracticeGroupId = activityUserMapper.getGivePracticeGroupId();
|
|
|
+ PracticeGroup practiceGroup = practiceGroupService.get(givePracticeGroupId);
|
|
|
+ cleanGroupInfo(givePracticeGroupId.toString(), GroupType.PRACTICE);
|
|
|
+ practiceGroup.setMemo("关闭活动赠送网管课");
|
|
|
+ practiceGroup.setGroupStatus(GroupStatusEnum.CANCEL);
|
|
|
+ practiceGroup.setUpdateTime(now);
|
|
|
+ practiceGroupService.update(practiceGroup);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return BaseController.succeed();
|
|
|
}
|
|
|
}
|