|
@@ -894,11 +894,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void enableBuyVipGroup(Integer vipGroupId) {
|
|
|
+ public void enableBuyVipGroup(Integer vipGroupId, Integer userId) {
|
|
|
if (Objects.isNull(vipGroupId)){
|
|
|
throw new BizException("请指定VIP课");
|
|
|
}
|
|
|
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);
|
|
|
}
|
|
@@ -982,7 +988,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public Map buyVipGroup(VipGroupBuyParamsDto vipGroupBuyParams) throws Exception {
|
|
|
+ public Map buyVipGroup(VipGroupBuyParamsDto vipGroupBuyParams) {
|
|
|
SysUser user = sysUserFeignService.queryUserInfo();
|
|
|
if(user == null){
|
|
|
throw new BizException("用户信息获取失败");
|
|
@@ -1009,19 +1015,17 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- StudentPaymentOrder oldOrder = studentPaymentOrderDao.findNotFailedOrderByStudentVipGroup(vipGroupBuyParams.getVipGroupId(),
|
|
|
+ List<StudentPaymentOrder> oldOrders = studentPaymentOrderDao.findNotFailedOrderByStudentVipGroup(vipGroupBuyParams.getVipGroupId(),
|
|
|
user.getId());
|
|
|
+ Map<DealStatusEnum, Long> statusCountMap = oldOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getStatus, Collectors.counting()));
|
|
|
|
|
|
- if(Objects.nonNull(oldOrder)&&oldOrder.getStatus().equals(DealStatusEnum.SUCCESS)){
|
|
|
+ if(Objects.nonNull(statusCountMap.get(DealStatusEnum.SUCCESS))&&statusCountMap.get(DealStatusEnum.SUCCESS)>0){
|
|
|
if("36".equals(user.getOrganId())){
|
|
|
throw new BizException("您已预约过此课程");
|
|
|
}
|
|
|
throw new BizException("您已购买过此课程");
|
|
|
- }else if(Objects.nonNull(oldOrder)&&oldOrder.getStatus().equals(DealStatusEnum.ING)){
|
|
|
- if("36".equals(user.getOrganId())){
|
|
|
- throw new BizException("您已预约过此课程,请等待处理结果");
|
|
|
- }
|
|
|
- throw new BizException("您有处理中的订单,请等待处理结果");
|
|
|
+ }else if(Objects.nonNull(statusCountMap.get(DealStatusEnum.ING))&&statusCountMap.get(DealStatusEnum.ING)>0){
|
|
|
+
|
|
|
}else{
|
|
|
if(classGroup.getStudentNum()>=classGroup.getExpectStudentNum()){
|
|
|
throw new BizException("该课程人数已达上限");
|
|
@@ -1170,7 +1174,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- updateVipGroupStudentNumAndStatus(vipGroupId, classGroup,0,true);
|
|
|
+ if(classGroup.getDelFlag()==1){
|
|
|
+ updateVipGroupStudentNumAndStatus(vipGroupId, classGroup,0,true);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
LOGGER.error("小课[{}]开课失败:{}",vipGroupId,e.getCause());
|
|
|
}
|