Prechádzať zdrojové kódy

Merge branch 'dev' of xiongzhu/raex_back into master

sunkean 3 rokov pred
rodič
commit
91e1333e6f

+ 3 - 0
src/main/java/com/izouma/nineth/domain/Collection.java

@@ -242,6 +242,9 @@ public class Collection extends CollectionBaseEntity {
     @ApiModelProperty("最低消费")
     private BigDecimal minimumCharge;
 
+    @ApiModelProperty("是否支付中")
+    private boolean inPaying;
+
     @ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.MERGE})
     @JoinTable(
             name = "collection_tag",

+ 6 - 0
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -98,6 +98,12 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
     @CacheEvict(value = "collection", key = "#id")
     void setOnShelf(Long id, boolean onShelf);
 
+    @Transactional
+    @Modifying
+    @Query("update Collection c set c.inPaying = ?2 where c.id = ?1")
+    @CacheEvict(value = "collection", key = "#id")
+    void setInPaying(Long id, boolean inPaying);
+
     @Transactional
     @Modifying
     @Query("update Collection c set c.scheduleSale = false, c.startTime = null, c.onShelf = ?2, c.salable = true where c.id = ?1")

+ 7 - 4
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -45,7 +45,6 @@ import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.rocketmq.client.producer.SendResult;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
-import org.junit.Test;
 import org.springframework.cache.annotation.Cacheable;
 import org.springframework.context.event.EventListener;
 import org.springframework.core.env.Environment;
@@ -237,6 +236,9 @@ public class OrderService {
                 throw new BusinessException("很遗憾,藏品已售罄", ErrorCode.SOLD_OUT);
             }
             Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("藏品不存在"));
+            if (collection.isInPaying()) {
+                throw new BusinessException("当然藏品正在支付中");
+            }
             if (collection.getAssetId() != null && collection.getAssetId().equals(778359L)) {
                 throw new BusinessException("很遗憾,藏品已售罄", ErrorCode.SOLD_OUT);
             }
@@ -390,8 +392,8 @@ public class OrderService {
                 Asset asset = assetRepo.findById(collection.getAssetId()).orElseThrow(new BusinessException("资产不存在"));
                 asset.setStatus(AssetStatus.TRADING);
                 assetRepo.save(asset);
-                collectionRepo.setOnShelf(collectionId, false);
-
+//                collectionRepo.setOnShelf(collectionId, false);
+                collectionRepo.setInPaying(collectionId, true);
                 //拥有指定藏品降税
                 order.setRoyalties(assetService.getRoyalties(minter.getId(), collection.getRoyalties(), userId));
             }
@@ -864,7 +866,8 @@ public class OrderService {
                     asset.setStatus(AssetStatus.NORMAL);
                     assetRepo.save(asset);
                 }
-                collectionRepo.setOnShelf(order.getCollectionId(), true);
+//                collectionRepo.setOnShelf(order.getCollectionId(), true);
+                collectionRepo.setInPaying(order.getCollectionId(), false);
             }
             collectionService.increaseStock(order.getCollectionId(), order.getQty());