|
@@ -1106,17 +1106,22 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
throw new BizException("您已预约过此课程");
|
|
|
}
|
|
|
throw new BizException("您已购买过此课程");
|
|
|
- }else if(CollectionUtils.isEmpty(oldOrders)||Objects.isNull(statusCountMap.get(DealStatusEnum.ING))){
|
|
|
+ }else if(CollectionUtils.isEmpty(oldOrders)){
|
|
|
if(classGroup.getStudentNum()>=classGroup.getExpectStudentNum()){
|
|
|
throw new BizException("该课程人数已达上限");
|
|
|
}
|
|
|
//更新班级人数,如果订单支付失败则减少
|
|
|
this.updateVipGroupStudentNumAndStatus(vipGroup.getId(),classGroup,1,false);
|
|
|
|
|
|
- ClassGroupStudentMapper classGroupStudentMapper=new ClassGroupStudentMapper(classGroup.getId(),user.getId().intValue());
|
|
|
- classGroupStudentMapper.setGroupType(GroupType.VIP);
|
|
|
- classGroupStudentMapper.setMusicGroupId(vipGroup.getId().toString());
|
|
|
- classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
+ ClassGroupStudentMapper classGroupStudentMapper=classGroupStudentMapperDao.query(classGroup.getId(),user.getId());
|
|
|
+ if(Objects.isNull(classGroupStudentMapper)){
|
|
|
+ classGroupStudentMapper=new ClassGroupStudentMapper(classGroup.getId(),user.getId().intValue());
|
|
|
+ classGroupStudentMapper.setGroupType(GroupType.VIP);
|
|
|
+ classGroupStudentMapper.setMusicGroupId(vipGroup.getId().toString());
|
|
|
+ classGroupStudentMapperDao.insert(classGroupStudentMapper);
|
|
|
+ }else{
|
|
|
+ classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Date date=new Date();
|
|
@@ -1237,8 +1242,9 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
Integer userId = order.getUserId();
|
|
|
boolean isOk=order.getStatus().equals(DealStatusEnum.SUCCESS);
|
|
|
|
|
|
- int successOrderNum = studentPaymentOrderDao.countUserBuyVipGroupSuccessOrder(userId, vipGroupId.intValue());
|
|
|
- if(successOrderNum>0){
|
|
|
+ List<StudentPaymentOrder> userOrders = studentPaymentOrderDao.findUserBuyVipGroupOrder(userId, vipGroupId.intValue());
|
|
|
+ Map<DealStatusEnum, List<StudentPaymentOrder>> statusOrdersMap = userOrders.stream().collect(Collectors.groupingBy(StudentPaymentOrder::getStatus));
|
|
|
+ if(!CollectionUtils.isEmpty(statusOrdersMap.get(DealStatusEnum.SUCCESS))){
|
|
|
studentPaymentOrderDao.update(order);
|
|
|
return;
|
|
|
}
|
|
@@ -1254,8 +1260,10 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
|
|
|
|
|
|
//将学生加入到班级,更新班级报名状态及人数信息
|
|
|
if(!isOk){
|
|
|
- updateVipGroupStudentNumAndStatus(vipGroupId,classGroup,-1,false);
|
|
|
- classGroupStudentMapperDao.deleteStudentByMusicGroupId(vipGroupId.toString(),userId);
|
|
|
+ if(CollectionUtils.isEmpty(statusOrdersMap.get(DealStatusEnum.ING))){
|
|
|
+ updateVipGroupStudentNumAndStatus(vipGroupId,classGroup,-1,false);
|
|
|
+ classGroupStudentMapperDao.deleteStudentByMusicGroupId(vipGroupId.toString(),userId);
|
|
|
+ }
|
|
|
if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().doubleValue() > 0) {
|
|
|
sysUserCashAccountService.updateBalance(userId, studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS,
|
|
|
"VIP课购买失败");
|