|
@@ -173,7 +173,8 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
|
if (!practiceGroup.getGroupStatus().equals(GroupStatusEnum.NORMAL) || practiceGroup.getCoursesExpireDate().before(now)) {
|
|
|
throw new BizException("当前课程组不可关闭");
|
|
|
}
|
|
|
- HttpResponseResult result = quitActivityGive(practiceGroup.getActivityUserMapperId(), returnFeeDto.getConfirmReturnActivityGive(), practiceGroup.getStudentId());
|
|
|
+ ActivityUserMapper activityUserMapper = activityUserMapperDao.get(practiceGroup.getActivityUserMapperId());
|
|
|
+ HttpResponseResult result = quitActivityGive(activityUserMapper, returnFeeDto.getConfirmReturnActivityGive(), practiceGroup.getId(),GroupType.PRACTICE);
|
|
|
if(result.getCode() != 200){
|
|
|
return result;
|
|
|
}
|
|
@@ -215,125 +216,174 @@ public class GroupClassServiceImpl implements GroupClassService {
|
|
|
|
|
|
@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()){
|
|
|
- return BaseController.succeed();
|
|
|
+ public HttpResponseResult quitActivityGive(ActivityUserMapper activityUserMapper, boolean confirmReturnActivityGive,Long groupId,GroupType groupType){
|
|
|
+ if(activityUserMapper != null){
|
|
|
+ if(activityUserMapper.getReturnFee()){
|
|
|
+ return BaseController.succeed();
|
|
|
+ }
|
|
|
+ VipGroupActivity activity = vipGroupActivityDao.get(activityUserMapper.getActivityId());
|
|
|
+ Boolean masterGroup;
|
|
|
+ if(groupType == GroupType.VIP){
|
|
|
+ //付费vip课
|
|
|
+ if(groupId.equals(activityUserMapper.getVipGroupId())){
|
|
|
+ masterGroup = true;
|
|
|
+ }else {
|
|
|
+ masterGroup = false;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //付费网管课
|
|
|
+ if(groupId.equals(activityUserMapper.getPracticeGroupId())){
|
|
|
+ masterGroup = true;
|
|
|
+ }else {
|
|
|
+ masterGroup = false;
|
|
|
}
|
|
|
- VipGroupActivity activity = vipGroupActivityDao.get(activityUserMapper.getActivityId());
|
|
|
- if(!confirmReturnActivityGive){
|
|
|
+ }
|
|
|
+ if(!confirmReturnActivityGive){
|
|
|
+ if(masterGroup){
|
|
|
if(activityUserMapper.getGiveMemberFlag() != 0){
|
|
|
- String format = String.format("该课程组通过%s创建,含赠送会员,确认退学后将扣减学员%s%s会员使用期限", activity.getName(), activity.getGiveMemberTime(), activity.getGivePeriodEnum().getMsg());
|
|
|
+ String format = String.format("该课程组通过 %s 创建,含赠送会员,确认退学(关闭)后将扣减学员%s%s会员使用期限", activity.getName(), activity.getGiveMemberTime(), activity.getGivePeriodEnum().getMsg());
|
|
|
return BaseController.failed(HttpStatus.PARTIAL_CONTENT,format);
|
|
|
}
|
|
|
if(activityUserMapper.getGiveVipFlag() == 1 || activityUserMapper.getGivePracticeFlag() == 1){
|
|
|
- String format = String.format("该课程组通过%s创建,学员赠课尚未排课,赠课排课资格将清除", activity.getName());
|
|
|
+ String format = String.format("该课程组通过 %s 创建,学员赠课尚未排课,赠课排课资格将清除", activity.getName());
|
|
|
return BaseController.failed(HttpStatus.PARTIAL_CONTENT,format);
|
|
|
}
|
|
|
if(activityUserMapper.getGiveVipFlag() == 2){
|
|
|
VipGroup vipGroup = vipGroupDao.get(activityUserMapper.getGiveVipGroupId());
|
|
|
- String format = String.format("该课程组通过%s创建,含赠课课程组%s %s,确认退学(关闭)后赠课课程组也将退学", activity.getName(),vipGroup.getId(),vipGroup.getName());
|
|
|
+ String format = String.format("该课程组通过 %s 创建,含赠课课程组%s %s,确认退学(关闭)后赠课课程组也将退学", activity.getName(),vipGroup.getId(),vipGroup.getName());
|
|
|
return BaseController.failed(HttpStatus.PARTIAL_CONTENT,format);
|
|
|
}
|
|
|
if(activityUserMapper.getGivePracticeFlag() == 2){
|
|
|
PracticeGroup practiceGroup = practiceGroupDao.get(activityUserMapper.getGivePracticeGroupId());
|
|
|
- String format = String.format("该课程组通过%s创建,含赠课课程组%s %s,确认退学(关闭)后赠课课程组也将退学", activity.getName(),practiceGroup.getId(),practiceGroup.getName());
|
|
|
+ String format = String.format("该课程组通过 %s 创建,含赠课课程组%s %s,确认退学(关闭)后赠课课程组也将退学", activity.getName(),practiceGroup.getId(),practiceGroup.getName());
|
|
|
return BaseController.failed(HttpStatus.PARTIAL_CONTENT,format);
|
|
|
}
|
|
|
- }
|
|
|
- activityUserMapper.setReturnFee(true);
|
|
|
- Date now = new Date();
|
|
|
- if(activityUserMapper.getGiveMemberFlag() == 2){
|
|
|
- //只退还赠送的时间
|
|
|
- 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("错误的会员周期类型");
|
|
|
+ }else {
|
|
|
+ if(activityUserMapper.getMemberFlag() != 0){
|
|
|
+ String format = String.format("该课程组通过 %s 赠送创建,含付费会员,确认退学(关闭)后将扣减学员%s%s会员使用期限", activity.getName(), activity.getGiveMemberTime(), activity.getGivePeriodEnum().getMsg());
|
|
|
+ return BaseController.failed(HttpStatus.PARTIAL_CONTENT,format);
|
|
|
}
|
|
|
- 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);
|
|
|
+ if(activityUserMapper.getVipFlag() == 1 || activityUserMapper.getPracticeFlag() == 1){
|
|
|
+ String format = String.format("该课程组通过 %s 赠送创建,学员付费课尚未排课,付费课排课资格将清除", activity.getName());
|
|
|
+ return BaseController.failed(HttpStatus.PARTIAL_CONTENT,format);
|
|
|
+ }
|
|
|
+ if(activityUserMapper.getVipFlag() == 2){
|
|
|
+ VipGroup vipGroup = vipGroupDao.get(activityUserMapper.getVipGroupId());
|
|
|
+ String format = String.format("该课程组通过 %s 赠送创建,含付费课课程组%s %s,确认退学(关闭)后付费课课程组也将退学", activity.getName(),vipGroup.getId(),vipGroup.getName());
|
|
|
+ return BaseController.failed(HttpStatus.PARTIAL_CONTENT,format);
|
|
|
+ }
|
|
|
+ if(activityUserMapper.getPracticeFlag() == 2){
|
|
|
+ PracticeGroup practiceGroup = practiceGroupDao.get(activityUserMapper.getGivePracticeGroupId());
|
|
|
+ String format = String.format("该课程组通过 %s 赠送创建,含付费课课程组%s %s,确认退学(关闭)后付费课课程组也将退学", activity.getName(),practiceGroup.getId(),practiceGroup.getName());
|
|
|
+ return BaseController.failed(HttpStatus.PARTIAL_CONTENT,format);
|
|
|
}
|
|
|
- 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);
|
|
|
- ClassGroup giveClassGroup = classGroupDao.findByVipGroup(giveVipGroupId, null);
|
|
|
- ClassGroupStudentMapper giveClassGroupStudentMapper = classGroupStudentMapperDao.findClassGroupStudent(giveClassGroup.getId(),studentId);
|
|
|
- giveClassGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
- classGroupStudentMapperDao.update(giveClassGroupStudentMapper);
|
|
|
+ }
|
|
|
+ Integer studentId = activityUserMapper.getUserId();
|
|
|
+ activityUserMapper.setReturnFee(true);
|
|
|
+ Date now = new Date();
|
|
|
+ if(activityUserMapper.getGiveMemberFlag() == 2 || activityUserMapper.getMemberFlag() == 2 ){
|
|
|
+ //只退还赠送的时间
|
|
|
+ Integer giveMemberTime = activity.getGiveMemberTime();
|
|
|
+ PeriodEnum givePeriodEnum = activity.getGivePeriodEnum();
|
|
|
+ Long giveMemberOrderId = activityUserMapper.getGiveMemberOrderId();
|
|
|
+ if(activityUserMapper.getMemberFlag() == 2){
|
|
|
+ giveMemberTime = activity.getMemberTime();
|
|
|
+ givePeriodEnum = activity.getPeriodEnum();
|
|
|
+ giveMemberOrderId = activityUserMapper.getMemberOrderId();
|
|
|
+ }
|
|
|
+ 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(giveMemberOrderId);
|
|
|
+ cloudTeacherOrder.setStatus(3);
|
|
|
+ cloudTeacherOrder.setRemark("退还活动关联会员时长");
|
|
|
+ cloudTeacherOrderDao.update(cloudTeacherOrder);
|
|
|
+ }
|
|
|
+ if(activityUserMapper.getGiveVipFlag() == 2 || activityUserMapper.getVipFlag() == 2){
|
|
|
+ Long giveVipGroupId = activityUserMapper.getGiveVipGroupId();
|
|
|
+ if(activityUserMapper.getVipFlag() == 2){
|
|
|
+ giveVipGroupId = activityUserMapper.getVipGroupId();
|
|
|
+ }
|
|
|
+ VipGroup giveVipGroup = vipGroupDao.get(giveVipGroupId);
|
|
|
+ ClassGroup giveClassGroup = classGroupDao.findByVipGroup(giveVipGroupId, null);
|
|
|
+ ClassGroupStudentMapper giveClassGroupStudentMapper = classGroupStudentMapperDao.findClassGroupStudent(giveClassGroup.getId(),studentId);
|
|
|
+ giveClassGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
+ classGroupStudentMapperDao.update(giveClassGroupStudentMapper);
|
|
|
|
|
|
- courseScheduleService.batchDeleteMusicGroupCourseWithStudent(giveVipGroupId.toString(),studentId,GroupType.VIP);
|
|
|
+ courseScheduleService.batchDeleteMusicGroupCourseWithStudent(giveVipGroupId.toString(),studentId,GroupType.VIP);
|
|
|
|
|
|
- List<Integer> studentPaymentIds = courseScheduleStudentPaymentDao.findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent(giveClassGroup.getId(), studentId);
|
|
|
- if(!CollectionUtils.isEmpty(studentPaymentIds)){
|
|
|
- courseScheduleStudentPaymentDao.batchDeleteWithID(studentPaymentIds);
|
|
|
- }
|
|
|
- VipGroupCategory giveVipGroupCategory = vipGroupCategoryDao.get(giveVipGroup.getVipGroupCategoryId());
|
|
|
+ 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())){
|
|
|
- BigDecimal offlineTeacherSalary=BigDecimal.ZERO;
|
|
|
+ if(!giveVipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING) || (Objects.nonNull(giveVipGroupCategory) && giveVipGroupCategory.getMusicTheory())){
|
|
|
+ BigDecimal offlineTeacherSalary=BigDecimal.ZERO;
|
|
|
|
|
|
- List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = courseScheduleTeacherSalaryDao.findByGroupWithNotStart(giveVipGroupId.toString(), GroupType.VIP.getCode());
|
|
|
- if(!CollectionUtils.isEmpty(courseScheduleTeacherSalaries)){
|
|
|
- for(int i=0;i<courseScheduleTeacherSalaries.size();i++){
|
|
|
- if(!courseScheduleTeacherSalaries.get(i).getEnableChangeSalary()){
|
|
|
- continue;
|
|
|
- }
|
|
|
- Map<String, BigDecimal> salary = vipGroupService.countVipGroupPredictFee1(giveVipGroup, giveVipGroup.getUserId(), courseScheduleTeacherSalaries.get(i).getCourseScheduleId());
|
|
|
- if(Objects.nonNull(salary)){
|
|
|
- offlineTeacherSalary = salary.get("giveOfflineTeacherSalary");
|
|
|
- }
|
|
|
- courseScheduleTeacherSalaries.get(i).setExpectSalary(offlineTeacherSalary);
|
|
|
+ List<CourseScheduleTeacherSalary> courseScheduleTeacherSalaries = courseScheduleTeacherSalaryDao.findByGroupWithNotStart(giveVipGroupId.toString(), GroupType.VIP.getCode());
|
|
|
+ if(!CollectionUtils.isEmpty(courseScheduleTeacherSalaries)){
|
|
|
+ for(int i=0;i<courseScheduleTeacherSalaries.size();i++){
|
|
|
+ if(!courseScheduleTeacherSalaries.get(i).getEnableChangeSalary()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, BigDecimal> salary = vipGroupService.countVipGroupPredictFee1(giveVipGroup, giveVipGroup.getUserId(), courseScheduleTeacherSalaries.get(i).getCourseScheduleId());
|
|
|
+ if(masterGroup){
|
|
|
+ offlineTeacherSalary = salary.get("offlineTeacherSalary");
|
|
|
+ }else {
|
|
|
+ offlineTeacherSalary = salary.get("giveOfflineTeacherSalary");
|
|
|
}
|
|
|
- courseScheduleTeacherSalaryDao.batchUpdateTeacherExpectSalarys(courseScheduleTeacherSalaries);
|
|
|
+ courseScheduleTeacherSalaries.get(i).setExpectSalary(offlineTeacherSalary);
|
|
|
}
|
|
|
+ courseScheduleTeacherSalaryDao.batchUpdateTeacherExpectSalarys(courseScheduleTeacherSalaries);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- giveClassGroup.setStudentNum(giveClassGroup.getStudentNum() - 1);
|
|
|
- classGroupDao.update(giveClassGroup);
|
|
|
+ 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);
|
|
|
+ //学员退出班级群
|
|
|
+ imGroupMemberService.quit(giveClassGroup.getId().longValue(), studentId);
|
|
|
+ }
|
|
|
+ if(activityUserMapper.getGivePracticeFlag() == 2 || activityUserMapper.getPracticeFlag() == 2){
|
|
|
+ Long givePracticeGroupId = activityUserMapper.getGivePracticeGroupId();
|
|
|
+ if(activityUserMapper.getPracticeFlag() == 2){
|
|
|
+ givePracticeGroupId = activityUserMapper.getPracticeGroupId();
|
|
|
}
|
|
|
+ PracticeGroup practiceGroup = practiceGroupService.get(givePracticeGroupId);
|
|
|
+ cleanGroupInfo(givePracticeGroupId.toString(), GroupType.PRACTICE);
|
|
|
+ practiceGroup.setMemo("关闭活动关联网管课");
|
|
|
+ practiceGroup.setGroupStatus(GroupStatusEnum.CANCEL);
|
|
|
+ practiceGroup.setUpdateTime(now);
|
|
|
+ practiceGroupService.update(practiceGroup);
|
|
|
}
|
|
|
activityUserMapperDao.update(activityUserMapper);
|
|
|
}
|