|
@@ -109,6 +109,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
private ContractService contractService;
|
|
|
@Autowired
|
|
|
private TeacherService teacherService;
|
|
|
+ @Autowired
|
|
|
+ private StudentPauseInfoDao studentPauseInfoDao;
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory
|
|
|
.getLogger(VipGroup.class);
|
|
@@ -834,6 +836,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if(Objects.isNull(vipGroupActivity.getType())){
|
|
|
+ throw new BizException("此活动未设置活动类型");
|
|
|
+ }
|
|
|
+
|
|
|
if(computeTotalPrice){
|
|
|
//课程购买费用计算
|
|
|
BigDecimal totalPrice;
|
|
@@ -1044,7 +1050,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("用户账户找不到");
|
|
|
}
|
|
|
studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
- if(userCashAccount.getBalance().subtract(vipGroup.getTotalPrice()).doubleValue() > 0){
|
|
|
+ if(userCashAccount.getBalance().subtract(vipGroup.getTotalPrice()).doubleValue() >= 0){
|
|
|
// 更新订单信息
|
|
|
studentPaymentOrder.setActualAmount(new BigDecimal(0));
|
|
|
studentPaymentOrder.setBalancePaymentAmount(amount);
|
|
@@ -1074,7 +1080,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
try {
|
|
|
contractService.register(user.getId(),user.getRealName(),user.getIdCardNo(),user.getPhone());
|
|
|
} catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
+ LOGGER.error("[{}]小课购买协议生成错误:{}", vipGroup.getId(), e.getCause());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1142,7 +1148,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
try {
|
|
|
updateVipGroupStudentNumAndStatus(vipGroupId, classGroup,0,true);
|
|
|
} catch (Exception e) {
|
|
|
- LOGGER.error("小课[{}]开课失败",vipGroupId);
|
|
|
+ LOGGER.error("小课[{}]开课失败:{}",vipGroupId,e.getCause());
|
|
|
}
|
|
|
|
|
|
SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId);
|
|
@@ -1195,7 +1201,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
try {
|
|
|
contractService.transferVipGroupCoursesContract(userId,vipGroupId);
|
|
|
} catch (Exception e) {
|
|
|
- LOGGER.error("小课[{}]开课失败:",vipGroupId,e.getMessage());
|
|
|
+ LOGGER.error("小课[{}]购买协议错误:{}",vipGroupId,e.getMessage(),e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1272,6 +1278,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("当前学生已经是退学状态");
|
|
|
}
|
|
|
|
|
|
+ if(classStudentMapperByUserIdAndClassGroupId.getStatus().equals(ClassGroupStudentStatusEnum.QUIT_SCHOOL)){
|
|
|
+ throw new BizException("当前学生已是休学状态");
|
|
|
+ }
|
|
|
+
|
|
|
sysUserCashAccountService.updateBalance(studentId, amount);
|
|
|
SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentId);
|
|
|
SysUserCashAccountDetail sysUserCashAccountDetail = new SysUserCashAccountDetail();
|
|
@@ -1293,16 +1303,18 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
courseScheduleStudentPaymentDao.batchDeleteWithID(studentPaymentIds);
|
|
|
}
|
|
|
|
|
|
- courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(vipGroupId.intValue(),-1);
|
|
|
+ if(!vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
|
|
|
+ courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(vipGroupId.intValue(),-1, vipGroup.getStatus());
|
|
|
+ }
|
|
|
|
|
|
//学员退出班级群
|
|
|
ImGroupMember[] imGroupMembers = new ImGroupMember[]{new ImGroupMember(studentId.toString())};
|
|
|
- imFeignService.groupJoin(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, null));
|
|
|
+ imFeignService.groupQuit(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, null));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void quitForStudent(Long vipGroupId, Integer studentId) {
|
|
|
+ public void pauseForStudent(Long vipGroupId, Integer studentId) {
|
|
|
if(Objects.isNull(vipGroupId)||Objects.isNull(studentId)){
|
|
|
throw new BizException("请指定小课与学生");
|
|
|
}
|
|
@@ -1338,26 +1350,112 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("当前学生已是休学状态");
|
|
|
}
|
|
|
|
|
|
-// sysUserCashAccountService.updateBalance(studentId, amount);
|
|
|
+ BigDecimal surplusCourseFee = courseScheduleStudentPaymentDao.countSurplusCourseFee(classGroup.getId(), studentId);
|
|
|
|
|
|
+ Map<String, Object> pauseInfos = new HashMap<>();
|
|
|
+ //学生剩余课时
|
|
|
+ List<StudentCourseInfoDto> userSurplusCourseInfoByGroup = courseScheduleDao.findUserSurplusCourseInfoByGroup(GroupType.VIP, vipGroupId.toString(), studentId);
|
|
|
+ int[] teachModeSequence=new int[userSurplusCourseInfoByGroup.size()];
|
|
|
+ List<BigDecimal> coursePrices = new ArrayList<>();
|
|
|
+ for (int i=0;i<userSurplusCourseInfoByGroup.size();i++) {
|
|
|
+ teachModeSequence[i] = userSurplusCourseInfoByGroup.get(i).getTeachMode().equals(TeachModeEnum.ONLINE)?1:0;
|
|
|
+ coursePrices.add(userSurplusCourseInfoByGroup.get(i).getExpectPrice());
|
|
|
+ }
|
|
|
+ pauseInfos.put("teaChModeSequence", Arrays.toString(teachModeSequence));
|
|
|
+ pauseInfos.put("coursePriceInfo",coursePrices);
|
|
|
+
|
|
|
+ StudentPauseInfo studentPauseInfo=new StudentPauseInfo();
|
|
|
+ studentPauseInfo.setUserId(studentId);
|
|
|
+ studentPauseInfo.setGroupType(GroupType.VIP);
|
|
|
+ studentPauseInfo.setMusicGroupId(vipGroup.getId().intValue());
|
|
|
+ studentPauseInfo.setClassGroupId(classGroup.getId());
|
|
|
+ studentPauseInfo.setCoursesJson(JSON.toJSONString(pauseInfos));
|
|
|
+
|
|
|
+ studentPauseInfoDao.insert(studentPauseInfo);
|
|
|
+
|
|
|
+ sysUserCashAccountService.updateCourseBalance(studentId, surplusCourseFee);
|
|
|
classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT_SCHOOL);
|
|
|
classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
|
|
|
|
|
|
- courseScheduleService.batchDeleteMusicGroupCourseWithStudent(vipGroupId.toString(),studentId,GroupType.VIP);
|
|
|
-
|
|
|
List<Integer> studentPaymentIds = courseScheduleStudentPaymentDao.findNotStartCourseStudentPaymentIdsWithClassGroupAndStudent(classGroup.getId(), studentId);
|
|
|
if(!CollectionUtils.isEmpty(studentPaymentIds)){
|
|
|
courseScheduleStudentPaymentDao.batchDeleteWithID(studentPaymentIds);
|
|
|
}
|
|
|
|
|
|
- courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(vipGroupId.intValue(),-1);
|
|
|
+ }
|
|
|
|
|
|
- //学员退出班级群
|
|
|
- ImGroupMember[] imGroupMembers = new ImGroupMember[]{new ImGroupMember(studentId.toString())};
|
|
|
- imFeignService.groupJoin(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, null));
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void recoverForStudent(Long vipGroupId, Integer studentId) {
|
|
|
+ if(Objects.isNull(vipGroupId)||Objects.isNull(studentId)){
|
|
|
+ throw new BizException("请指定小课与学生");
|
|
|
+ }
|
|
|
+ VipGroup vipGroup=vipGroupDao.get(vipGroupId);
|
|
|
+ if(Objects.isNull(vipGroup)){
|
|
|
+ throw new BizException("指定的课程不存在");
|
|
|
+ }
|
|
|
+ if(vipGroup.getStatus().equals(VipGroupStatusEnum.CANCEL)){
|
|
|
+ throw new BizException("不能对已停止的课程进行此操作");
|
|
|
+ }
|
|
|
+ if(vipGroup.getStatus().equals(VipGroupStatusEnum.FINISHED)){
|
|
|
+ throw new BizException("此课程已结束");
|
|
|
+ }
|
|
|
+ List<StudentApplyRefunds> studentApplyRefunds = studentApplyRefundsDao.findByGroupAndUser(vipGroupId.toString(), GroupType.VIP.getCode(), studentId);
|
|
|
+ if(!CollectionUtils.isEmpty(studentApplyRefunds)){
|
|
|
+ throw new BizException("此学生存在退课申请,请到系统日志中查看");
|
|
|
+ }
|
|
|
+
|
|
|
+ ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
|
|
|
+
|
|
|
+ ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
|
|
|
+ studentId);
|
|
|
+
|
|
|
+ if(Objects.isNull(classStudentMapperByUserIdAndClassGroupId)){
|
|
|
+ throw new BizException("指定学生不在此课程中");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!classStudentMapperByUserIdAndClassGroupId.getStatus().equals(ClassGroupStudentStatusEnum.QUIT_SCHOOL)){
|
|
|
+ throw new BizException("当前学生不是休学状态");
|
|
|
+ }
|
|
|
+
|
|
|
+ StudentPauseInfo studentPauseInfo = studentPauseInfoDao.findByGroupAndUser(GroupType.VIP, vipGroupId.toString(), studentId);
|
|
|
+ Map<String, Object> courseInfo = JSON.parseObject(studentPauseInfo.getCoursesJson(), Map.class);
|
|
|
+ List<BigDecimal> coursePrices = (List<BigDecimal>) courseInfo.get("coursePriceInfo");
|
|
|
+ coursePrices.sort(Comparator.naturalOrder());
|
|
|
+
|
|
|
+ BigDecimal surplusCourseFee = new BigDecimal(0);
|
|
|
+
|
|
|
+ Date now=new Date();
|
|
|
+
|
|
|
+ List<CourseSchedule> surplusCourseWithGroup = courseScheduleDao.findSurplusCourseWithGroup(GroupType.VIP, vipGroupId.toString());
|
|
|
+ surplusCourseWithGroup.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
+
|
|
|
+ List<CourseScheduleStudentPayment> courseScheduleStudentPaymentList = new ArrayList<>();
|
|
|
+ for (int i=0;i<surplusCourseWithGroup.size();i++) {
|
|
|
+ CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();
|
|
|
+ courseScheduleStudentPayment.setGroupType(GroupType.VIP);
|
|
|
+ courseScheduleStudentPayment.setMusicGroupId(vipGroupId.toString());
|
|
|
+ courseScheduleStudentPayment.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
+ courseScheduleStudentPayment.setCourseScheduleId(surplusCourseWithGroup.get(i).getId());
|
|
|
+ courseScheduleStudentPayment.setUserId(studentId);
|
|
|
+ courseScheduleStudentPayment.setExpectPrice(coursePrices.get(i));
|
|
|
+ courseScheduleStudentPayment.setCreateTime(now);
|
|
|
+ courseScheduleStudentPayment.setUpdateTime(now);
|
|
|
+ courseScheduleStudentPayment.setClassGroupId(classGroup.getId());
|
|
|
+ courseScheduleStudentPaymentList.add(courseScheduleStudentPayment);
|
|
|
+ surplusCourseFee.add(coursePrices.get(i));
|
|
|
+ }
|
|
|
+ if(!CollectionUtils.isEmpty(courseScheduleStudentPaymentList)){
|
|
|
+ courseScheduleStudentPaymentDao.batchInsert(courseScheduleStudentPaymentList);
|
|
|
+ }
|
|
|
+ sysUserCashAccountService.updateCourseBalance(studentId, surplusCourseFee);
|
|
|
+ classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
|
|
|
+ studentPauseInfo.setDelFlag(1);
|
|
|
+ studentPauseInfoDao.update(studentPauseInfo);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Map<String, BigDecimal> getStudentSurplusCourseFee(Long vipGroupId, Integer studentId) {
|
|
|
if(Objects.isNull(vipGroupId)||Objects.isNull(studentId)){
|
|
@@ -1390,7 +1488,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("未找到对应班级");
|
|
|
}
|
|
|
BigDecimal bigDecimal = courseScheduleStudentPaymentDao.countSurplusCourseFee(classGroup.getId(), studentId);
|
|
|
- result.put("suplusCourseFee",Objects.isNull(bigDecimal)?new BigDecimal(0):bigDecimal);
|
|
|
+ if(Objects.isNull(bigDecimal)){
|
|
|
+ bigDecimal = new BigDecimal(0);
|
|
|
+ }
|
|
|
+ bigDecimal = bigDecimal.multiply(new BigDecimal(0.8)).setScale(CommonConstants.DECIMAL_FINAL_PLACE, BigDecimal.ROUND_HALF_UP);
|
|
|
+ result.put("suplusCourseFee", bigDecimal);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -1457,7 +1559,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
courseScheduleService.batchDeleteMusicGroupCourseWithStudent(studentPaymentOrder.getMusicGroupId(),studentApplyRefunds.getUserId(),GroupType.VIP);
|
|
|
|
|
|
|
|
|
- courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(Integer.parseInt(studentPaymentOrder.getMusicGroupId()),-1);
|
|
|
+ courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(Integer.parseInt(studentPaymentOrder.getMusicGroupId()),-1, null);
|
|
|
|
|
|
//学员退出班级群
|
|
|
ImGroupMember[] imGroupMembers = new ImGroupMember[]{new ImGroupMember(studentApplyRefunds.getUserId().toString())};
|
|
@@ -1887,6 +1989,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
classGroupService.updateClassGroupInfo(classGroup.getId());
|
|
|
|
|
|
+
|
|
|
ImGroupMember[] imGroupMembers = imGroupMemberList.toArray(new ImGroupMember[imGroupMemberList.size()]);
|
|
|
imFeignService.groupJoin(new ImGroupModel(classGroup.getId().toString(),
|
|
|
imGroupMembers, classGroup.getName()));
|
|
@@ -2115,6 +2218,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentMappers);
|
|
|
}
|
|
|
|
|
|
+ VipGroupStatusEnum vipGroupStatus = vipGroup.getStatus();
|
|
|
+
|
|
|
Integer currentStudentNum = classGroupStudentMapperDao.countClassGroupStudentNum(classGroup.getId());
|
|
|
if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)
|
|
|
&¤tStudentNum.compareTo(classGroup.getExpectStudentNum())>=0){
|
|
@@ -2125,7 +2230,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
classGroupDao.update(classGroup);
|
|
|
classGroupService.updateClassGroupInfo(classGroup.getId());
|
|
|
|
|
|
- courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(vipGroupId.intValue(),studentIds.size());
|
|
|
+ courseScheduleTeacherSalaryService.updateVipGroupCourseTeacherSalary(vipGroupId.intValue(),studentIds.size(), vipGroupStatus);
|
|
|
|
|
|
try {
|
|
|
ImGroupMember[] imGroupMembers = imGroupMemberList.toArray(new ImGroupMember[imGroupMemberList.size()]);
|