Ver Fonte

提前续费判断是不是续费的同一个产品

Bob há 3 meses atrás
pai
commit
661aa79af8

+ 10 - 0
pdf-office-pdf-website/src/main/java/cn/kdan/cloud/pdf/office/website/service/impl/ProductInfoServiceImpl.java

@@ -90,7 +90,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
         }
         // 筛选订单购买的产品中有没有vip订阅类型
         boolean hasVip = false;
+        UserSubscriptionInfoVO vipSubscriptionInfoVO = null;
         boolean hasSVip = false;
+        UserSubscriptionInfoVO sVipSubscriptionInfoVO = null;
         // 买断版  平台数
         int permanentPlatform = 0;
         for (UserSubscriptionInfoVO userSubscriptionInfoVO : userSubscriptionInfoVOList) {
@@ -109,8 +111,10 @@ public class ProductInfoServiceImpl implements ProductInfoService {
             } else {
                 if (StringUtils.isNotEmpty(userSubscriptionInfoVO.getLevels())&&userSubscriptionInfoVO.getLevels().contains("2")) {
                     hasVip = true;
+                    vipSubscriptionInfoVO = userSubscriptionInfoVO;
                 } else if (StringUtils.isNotEmpty(userSubscriptionInfoVO.getLevels())&&userSubscriptionInfoVO.getLevels().contains("3")) {
                     hasSVip = true;
+                    sVipSubscriptionInfoVO = userSubscriptionInfoVO;
                 }
             }
         }
@@ -127,6 +131,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
                         .anyMatch(userSubscriptionInfoVO -> userSubscriptionInfoVO.getPlatform().equals(2) && userSubscriptionInfoVO.getPayType() == 1)) {
                     throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_USER_ALREADY_SUBSCRIBED);
                 }
+                if (!sVipSubscriptionInfoVO.getProductId().equals(productId)) {
+                    throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_USER_ALREADY_SUBSCRIBED);
+                }
                 // svip原价提前续费
                 return listingProductVO;
             }
@@ -154,6 +161,9 @@ public class ProductInfoServiceImpl implements ProductInfoService {
                         .anyMatch(userSubscriptionInfoVO -> userSubscriptionInfoVO.getPlatform().equals(2) && userSubscriptionInfoVO.getPayType() == 1)) {
                     throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_USER_ALREADY_SUBSCRIBED);
                 }
+                if (!vipSubscriptionInfoVO.getProductId().equals(productId)) {
+                    throw new BackendRuntimeException(ExceptionEnum.EXCEPTION_USER_ALREADY_SUBSCRIBED);
+                }
                 return listingProductVO;
             }
             // svip无法购买vip