|
@@ -395,9 +395,11 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
pageInfo.setTotal(count);
|
|
|
params.put("offset", pageInfo.getOffset());
|
|
|
dataList = vipGroupDao.findAllByOrgan(params);
|
|
|
- List<Long> vipGroupIds = dataList.stream().map(vipGroup -> vipGroup.getId()).collect(Collectors.toList());
|
|
|
+ List<Long> vipGroupIds = dataList.stream().map(vipGroup -> vipGroup.getId()).distinct().collect(Collectors.toList());
|
|
|
List<Map<Long, Integer>> vipGroupOverCourses = vipGroupDao.countVipGroupOverCourse(vipGroupIds);
|
|
|
Map<Long,Integer> vipGroupOverCourseMaps = MapUtil.convertIntegerMap(vipGroupOverCourses);
|
|
|
+ List<ClassGroup> classGroupsByVipGroups = vipGroupClassGroupMapperDao.findClassGroupsByVipGroups(vipGroupIds);
|
|
|
+ Map<String, ClassGroup> vipGroupClassGroupMap = classGroupsByVipGroups.stream().collect(Collectors.toMap(ClassGroup::getMusicGroupId, classGroup -> classGroup));
|
|
|
dataList.forEach(vipGroup -> {
|
|
|
Integer overCourses = vipGroupOverCourseMaps.get(vipGroup.getId());
|
|
|
if(Objects.isNull(overCourses)){
|
|
@@ -416,7 +418,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
vipGroup.setMonthConsumeRate(monthConsumeRate);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ }
|
|
|
+ ClassGroup classGroup = vipGroupClassGroupMap.get(vipGroup.getId().toString());
|
|
|
+ if(Objects.nonNull(classGroup)){
|
|
|
+ vipGroup.setStudentNum(classGroup.getStudentNum());
|
|
|
+ vipGroup.setTotalClassTimes(classGroup.getTotalClassTimes());
|
|
|
+ vipGroup.setCurrentClassTimes(classGroup.getCurrentClassTimes());
|
|
|
}
|
|
|
|
|
|
});
|
|
@@ -749,12 +756,13 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
Integer studentPaymentNum=studentPaymentOrderDao.countStudentPaymentNum(vipGroupId.toString());
|
|
|
-
|
|
|
if(studentPaymentNum.equals(classGroup.getExpectStudentNum())&&updateVipStatus){
|
|
|
+ classGroup.setDelFlag(YesOrNoEnum.NO);
|
|
|
vipGroup.setStatus(VipGroupStatusEnum.FINISH);
|
|
|
vipGroupDao.update(vipGroup);
|
|
|
createVipGroupCourseScheInfo(vipGroupId);
|
|
|
}
|
|
|
+ System.out.println(studentPaymentNum+"------"+JSON.toJSONString(classGroup));
|
|
|
classGroupDao.update(classGroup);
|
|
|
}
|
|
|
|
|
@@ -768,8 +776,6 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
SysUser sysUser = sysUserFeignService.queryUserById(vipGroupApplyBaseInfoDto.getUserId());
|
|
|
|
|
|
ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId,null);
|
|
|
- classGroup.setDelFlag(YesOrNoEnum.NO);
|
|
|
- classGroupDao.update(classGroup);
|
|
|
|
|
|
ClassGroupTeacherSalary classGroupTeacherSalary = classGroupTeacherSalaryDao.findByVipGoupAndTeacher(vipGroupId.intValue(), vipGroupApplyBaseInfoDto.getUserId());
|
|
|
|
|
@@ -871,6 +877,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
studentPaymentOrder.setMusicGroupId(vipGroup.getId().toString());
|
|
|
studentPaymentOrder.setClassGroupId(vipGroupClassGroupMapper.getClassGroupId());
|
|
|
|
|
|
+ contractService.register(user.getId(),user.getRealName(),user.getIdCardNo(),user.getPhone());
|
|
|
+
|
|
|
//生成回调地址
|
|
|
Map<String,Object> payMap = payService.getPayMap(
|
|
|
vipGroup.getTotalPrice(),
|
|
@@ -983,6 +991,65 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
studentApplyRefundsDao.insert(studentApplyRefunds);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void applyRefundForStudent(Long vipGroupId, Integer studentId, BigDecimal amount) {
|
|
|
+ if(Objects.isNull(vipGroupId)||Objects.isNull(studentId)){
|
|
|
+ throw new BizException("请指定小课与学生");
|
|
|
+ }
|
|
|
+ if(Objects.isNull(amount)){
|
|
|
+ throw new BizException("请确定退费金额");
|
|
|
+ }
|
|
|
+ VipGroup vipGroup=vipGroupDao.get(vipGroupId);
|
|
|
+ if(Objects.isNull(vipGroup)){
|
|
|
+ throw new BizException("指定的课程不存在");
|
|
|
+ }
|
|
|
+ ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
|
|
|
+ sysUserCashAccountService.updateBalance(studentId, amount);
|
|
|
+ SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(studentId);
|
|
|
+ SysUserCashAccountDetail sysUserCashAccountDetail = new SysUserCashAccountDetail();
|
|
|
+ sysUserCashAccountDetail.setUserId(studentId);
|
|
|
+ sysUserCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.REFUNDS);
|
|
|
+ sysUserCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
+ sysUserCashAccountDetail.setAmount(amount);
|
|
|
+ sysUserCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
|
|
|
+ sysUserCashAccountDetail.setAttribute(studentId.toString());
|
|
|
+ sysUserCashAccountDetailDao.insert(sysUserCashAccountDetail);
|
|
|
+
|
|
|
+ ClassGroupStudentMapper classStudentMapperByUserIdAndClassGroupId = classGroupStudentMapperDao.query(classGroup.getId(),
|
|
|
+ studentId);
|
|
|
+
|
|
|
+ classStudentMapperByUserIdAndClassGroupId.setStatus(ClassGroupStudentStatusEnum.QUIT);
|
|
|
+ classGroupStudentMapperDao.update(classStudentMapperByUserIdAndClassGroupId);
|
|
|
+
|
|
|
+ //学员退出班级群
|
|
|
+ ImGroupMember[] imGroupMembers = new ImGroupMember[]{new ImGroupMember(studentId.toString())};
|
|
|
+ imFeignService.groupJoin(new ImGroupModel(classGroup.getId().toString(), imGroupMembers, null));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, BigDecimal> getStudentSurplusCourseFee(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("未找到指定vip课");
|
|
|
+ }
|
|
|
+ Map<String,BigDecimal> result=new HashMap<>();
|
|
|
+ if(vipGroup.getStatus().equals(VipGroupStatusEnum.APPLYING)){
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId, studentId, DealStatusEnum.SUCCESS.getCode());
|
|
|
+ result.put("suplusCourseFee",studentPaymentOrder.getActualAmount());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId, null);
|
|
|
+ if(Objects.isNull(classGroup)){
|
|
|
+ throw new BizException("为找到对应班级");
|
|
|
+ }
|
|
|
+ BigDecimal bigDecimal = courseScheduleStudentPaymentDao.countSurplusCourseFee(classGroup.getId(), studentId);
|
|
|
+ result.put("suplusCourseFee",Objects.isNull(bigDecimal)?new BigDecimal(0):bigDecimal);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void applyRefundAudit(Long id, StudentApplyRefundsStatus status, String remark,BigDecimal amount) {
|
|
@@ -1147,7 +1214,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if(Objects.isNull(vipGroup)){
|
|
|
throw new BizException("该课程不存在");
|
|
|
}
|
|
|
- if(vipGroup.getStatus()==VipGroupStatusEnum.FINISH||vipGroup.getStatus()==VipGroupStatusEnum.CANCEL){
|
|
|
+ if(vipGroup.getStatus()==VipGroupStatusEnum.CANCEL){
|
|
|
throw new BizException("该课程已结束或者已被停止,无法进行此操作");
|
|
|
}
|
|
|
List<CourseSchedule> vipGroupCourseSchedules = courseScheduleDao.findVipGroupCourseSchedules(vipGroupId);
|
|
@@ -1163,13 +1230,15 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if(CollectionUtils.isEmpty(maps)||(maps.size()==1&&Objects.isNull(maps.get(0)))){
|
|
|
vipGroup.setStatus(VipGroupStatusEnum.CANCEL);
|
|
|
vipGroupDao.update(vipGroup);
|
|
|
- courseScheduleDao.batchDeleteCourseSchedules(courseScheduleIds);
|
|
|
- courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
|
|
|
+ if(vipGroup.getStatus().equals(VipGroupStatusEnum.FINISH)){
|
|
|
+ courseScheduleDao.batchDeleteCourseSchedules(courseScheduleIds);
|
|
|
+ courseScheduleTeacherSalaryDao.batchDeleteByCourseScheduleIds(courseScheduleIds);
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
Map<Integer, BigDecimal> studentSurplusClassFees = MapUtil.convertIntegerMap(maps);
|
|
|
for(Integer userId:studentSurplusClassFees.keySet()){
|
|
|
- StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId,userId,DealStatusEnum.SUCCESS.getMsg());
|
|
|
+ StudentPaymentOrder studentPaymentOrder = studentPaymentOrderDao.findByStudentVipGroup(vipGroupId,userId,DealStatusEnum.SUCCESS.getCode());
|
|
|
if(null==studentPaymentOrder){
|
|
|
throw new BizException("未找到相关订单信息!");
|
|
|
}
|