Browse Source

无库存不能买

licailing 3 years ago
parent
commit
2ccfafda8e
1 changed files with 3 additions and 3 deletions
  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 (collection.getVipQuota() > 0 || ObjectUtils.isEmpty(collection.getVipQuota())) {
+            // 额度或者额度为空, 库存不为空
+            if (collection.getStock() > 0 && (collection.getVipQuota() > 0 || ObjectUtils.isEmpty(collection.getVipQuota()))) {
                 int countUser = userRepo.countAllByCollectionIdAndCollectionInvitor(collectionId, invitor);
                 // 邀请人数
                 if (countUser >= collection.getAssignment()) {
@@ -210,7 +210,7 @@ public class UserService {
                                     .point(1)
                                     .build());
                             // 扣除藏品额度
-                            if(ObjectUtils.isNotEmpty(collection.getVipQuota())){
+                            if (ObjectUtils.isNotEmpty(collection.getVipQuota())) {
                                 collectionService.decreaseQuota(collectionId, 1);
                             }
                         }