|
|
@@ -2550,29 +2550,49 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
// }
|
|
|
|
|
|
@Override
|
|
|
- public void enableBuyVipGroup(Integer vipGroupId, Integer userId) {
|
|
|
+ public void enableBuyVipGroup(Long vipGroupId, Integer userId,String groupType) {
|
|
|
if (Objects.isNull(vipGroupId)){
|
|
|
- throw new BizException("请指定VIP课");
|
|
|
+ throw new BizException("请指定课程组");
|
|
|
}
|
|
|
- VipGroup vipGroup = get(vipGroupId.longValue());
|
|
|
- if(Objects.nonNull(vipGroup.getStudentIdList())){
|
|
|
- Set<Integer> userIds = Arrays.asList(vipGroup.getStudentIdList().split(",")).stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toSet());
|
|
|
- if(!userIds.contains(userId)){
|
|
|
- throw new BizException("您无法购买此课程");
|
|
|
+ if("PRACTICE".equals(groupType)){
|
|
|
+ PracticeGroup practiceGroup = practiceGroupService.get(vipGroupId);
|
|
|
+ if(Objects.nonNull(practiceGroup.getStudentId())){
|
|
|
+ if(!practiceGroup.getStudentId().equals(userId)){
|
|
|
+ throw new BizException("您无法购买此课程");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ ClassGroup classGroup = classGroupDao.findByGroupAndType(vipGroupId.toString(), "PRACTICE");
|
|
|
|
|
|
- ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId.longValue(), null);
|
|
|
+ if(classGroup.getStudentNum()>0 && (VipGroupStatusEnum.APPLYING.equals(practiceGroup.getGroupStatus()))){
|
|
|
+ int i = studentPaymentOrderDao.countGroupOrderWithoutFailed(vipGroupId.toString(), GroupType.PRACTICE);
|
|
|
+ if(i<=0){
|
|
|
+ throw new BizException("该课程已经无法通过购买加入,请联系教务老师!");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if(classGroup.getStudentNum()>0&&(VipGroupStatusEnum.APPLYING.equals(vipGroup.getStatus()))){
|
|
|
- int i = studentPaymentOrderDao.countGroupOrderWithoutFailed(vipGroupId.toString(), GroupType.VIP);
|
|
|
- if(i<=0){
|
|
|
- throw new BizException("该课程已经无法通过购买加入,请联系教务老师!");
|
|
|
+ List<CourseSchedule> courseSchedules = JSON.parseArray(practiceGroup.getCourseScheduleJson(),CourseSchedule.class);
|
|
|
+ courseScheduleService.checkNewCourseSchedules(courseSchedules,false,false);
|
|
|
+ }else {
|
|
|
+ VipGroup vipGroup = get(vipGroupId.longValue());
|
|
|
+ if(Objects.nonNull(vipGroup.getStudentIdList())){
|
|
|
+ Set<Integer> userIds = Arrays.asList(vipGroup.getStudentIdList().split(",")).stream().mapToInt(Integer::parseInt).boxed().collect(Collectors.toSet());
|
|
|
+ if(!userIds.contains(userId)){
|
|
|
+ throw new BizException("您无法购买此课程");
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(),CourseSchedule.class);
|
|
|
- courseScheduleService.checkNewCourseSchedules(courseSchedules,false,false);
|
|
|
+ ClassGroup classGroup = classGroupDao.findByVipGroup(vipGroupId.longValue(), null);
|
|
|
+
|
|
|
+ if(classGroup.getStudentNum()>0&&(VipGroupStatusEnum.APPLYING.equals(vipGroup.getStatus()))){
|
|
|
+ int i = studentPaymentOrderDao.countGroupOrderWithoutFailed(vipGroupId.toString(), GroupType.VIP);
|
|
|
+ if(i<=0){
|
|
|
+ throw new BizException("该课程已经无法通过购买加入,请联系教务老师!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<CourseSchedule> courseSchedules = JSON.parseArray(vipGroup.getCourseSchedulesJson(),CourseSchedule.class);
|
|
|
+ courseScheduleService.checkNewCourseSchedules(courseSchedules,false,false);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|