|
@@ -2639,7 +2639,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
if (Objects.isNull(classGroup)) {
|
|
|
throw new BizException("班级信息错误");
|
|
|
}
|
|
|
- Boolean exist = classGroupStudentMapperDao.existByClassGroupIds(classGroup.getId().toString(), userId);
|
|
|
+ Integer classGroupId = classGroup.getId();
|
|
|
+ Boolean exist = classGroupStudentMapperDao.existByClassGroupIds(classGroupId.toString(), userId);
|
|
|
if (exist) {
|
|
|
throw new BizException("您已加入此课程");
|
|
|
}
|
|
@@ -2671,40 +2672,38 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
return result;
|
|
|
}
|
|
|
if(groupType == GroupType.VIP){
|
|
|
- classGroupDao.modifyStudentNum(classGroup.getId(),-1);
|
|
|
+ classGroupDao.modifyStudentNum(classGroupId,-1);
|
|
|
}
|
|
|
}
|
|
|
Date date = new Date();
|
|
|
-
|
|
|
- VipGroupActivity vipGroupActivity = null;
|
|
|
- if (Objects.nonNull(vipGroup.getVipGroupActivityId())) {
|
|
|
- vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId());
|
|
|
- }
|
|
|
- if (Objects.nonNull(vipGroupActivity) && Objects.nonNull(vipGroupActivity.getStudentMaxUsedTimes()) && vipGroupActivity.getStudentMaxUsedTimes() != -1) {
|
|
|
- int useNum = activityUserMapperService.countActivityBuyNum(vipGroupActivity.getId(), userId);
|
|
|
- if (useNum >= vipGroupActivity.getStudentMaxUsedTimes()) {
|
|
|
- throw new BizException("您已超过该活动购买限制{}次", vipGroupActivity.getStudentMaxUsedTimes());
|
|
|
- }
|
|
|
- }
|
|
|
if (vipGroup.getPaymentExpireDate().before(date)) {
|
|
|
throw new BizException("该课程已结束报名!");
|
|
|
}
|
|
|
- if (groupType == VIP && 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("您无法购买此课程");
|
|
|
+ Integer vipGroupActivityId = vipGroup.getVipGroupActivityId();
|
|
|
+ if (Objects.nonNull(vipGroupActivityId)) {
|
|
|
+ VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId());
|
|
|
+ if (Objects.nonNull(vipGroupActivity) && Objects.nonNull(vipGroupActivity.getStudentMaxUsedTimes()) && vipGroupActivity.getStudentMaxUsedTimes() != -1) {
|
|
|
+ int useNum = activityUserMapperService.countActivityBuyNum(vipGroupActivity.getId(), userId);
|
|
|
+ if (useNum >= vipGroupActivity.getStudentMaxUsedTimes()) {
|
|
|
+ throw new BizException("您已超过该活动购买限制{}次", vipGroupActivity.getStudentMaxUsedTimes());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if(groupType == GroupType.VIP){
|
|
|
- if (classGroupDao.checkStudentNum(classGroup.getId())) {
|
|
|
+ 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 (classGroupDao.checkStudentNum(classGroupId)) {
|
|
|
throw new BizException("该课程组人数已满,请联系教务老师!");
|
|
|
}
|
|
|
//增加学员数
|
|
|
- classGroupDao.modifyStudentNum(classGroup.getId(),1);
|
|
|
+ classGroupDao.modifyStudentNum(classGroupId,1);
|
|
|
}
|
|
|
ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
|
|
|
- classGroupStudentMapper.setClassGroupId(classGroup.getId());
|
|
|
+ classGroupStudentMapper.setClassGroupId(classGroupId);
|
|
|
classGroupStudentMapper.setGroupType(classGroup.getGroupType());
|
|
|
classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
|
|
|
classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
@@ -2725,11 +2724,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
studentPaymentOrder.setType(orderTypeEnum);
|
|
|
studentPaymentOrder.setMusicGroupId(vipGroup.getId().toString());
|
|
|
studentPaymentOrder.setMusicGroupId(vipGroup.getId().toString());
|
|
|
- studentPaymentOrder.setClassGroupId(classGroup.getId());
|
|
|
+ studentPaymentOrder.setClassGroupId(classGroupId);
|
|
|
studentPaymentOrder.setOrganId(user.getOrganId());
|
|
|
studentPaymentOrder.setVersion(0);
|
|
|
studentPaymentOrder.setActivityBuyNum(vipGroup.getOnlineClassesNum() + vipGroup.getOfflineClassesNum());
|
|
|
- Integer vipGroupActivityId = vipGroup.getVipGroupActivityId();
|
|
|
studentPaymentOrder.setActivityId(vipGroupActivityId == null ? "" : vipGroupActivityId.toString());
|
|
|
studentPaymentOrderDao.insert(studentPaymentOrder);
|
|
|
|