xiongzhu %!s(int64=3) %!d(string=hai) anos
pai
achega
a194ccf155

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

@@ -13,7 +13,6 @@ import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.stereotype.Service;
 
-import javax.transaction.Transactional;
 import java.util.List;
 
 @Service
@@ -33,7 +32,6 @@ public class AirDropService {
         return airDropRepo.findAll(JpaUtils.toSpecification(pageQuery, AirDrop.class), JpaUtils.toPageRequest(pageQuery));
     }
 
-    @Transactional
     public AirDrop create(AirDrop record) {
         if (AirDropType.coupon == record.getType()) {
             Coupon coupon = couponRepo.findById(record.getCouponId()).orElseThrow(new BusinessException("兑换券不存在"));
@@ -48,6 +46,9 @@ public class AirDropService {
         } else {
             Collection collection = collectionRepo.findById(record.getCollectionId())
                     .orElseThrow(new BusinessException("藏品不存在"));
+            if (collection.isSalable()) {
+                throw new BusinessException("请先设置藏品为不可购买");
+            }
             if (collection.getStock() < record.getUserIds().size()) {
                 throw new BusinessException("藏品库存不足");
             }