Explorar o código

无库存不能买

licailing %!s(int64=3) %!d(string=hai) anos
pai
achega
2ccfafda8e
Modificáronse 1 ficheiros con 3 adicións e 3 borrados
  1. 3 3
      src/main/java/com/izouma/nineth/service/UserService.java

+ 3 - 3
src/main/java/com/izouma/nineth/service/UserService.java

@@ -192,8 +192,8 @@ public class UserService {
 
 
         // 加积分
         // 加积分
         if (collectionId != null && invitor != null) {
         if (collectionId != null && invitor != null) {
-            // 额度或者额度为空
-            if (collection.getVipQuota() > 0 || ObjectUtils.isEmpty(collection.getVipQuota())) {
+            // 额度或者额度为空, 库存不为空
+            if (collection.getStock() > 0 && (collection.getVipQuota() > 0 || ObjectUtils.isEmpty(collection.getVipQuota()))) {
                 int countUser = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
                 int countUser = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
                 // 邀请人数
                 // 邀请人数
                 if (countUser >= collection.getAssignment()) {
                 if (countUser >= collection.getAssignment()) {
@@ -210,7 +210,7 @@ public class UserService {
                                     .point(1)
                                     .point(1)
                                     .build());
                                     .build());
                             // 扣除藏品额度
                             // 扣除藏品额度
-                            if(ObjectUtils.isNotEmpty(collection.getVipQuota())){
+                            if (ObjectUtils.isNotEmpty(collection.getVipQuota())) {
                                 collectionService.decreaseQuota(collectionId, 1);
                                 collectionService.decreaseQuota(collectionId, 1);
                             }
                             }
                         }
                         }