licailing 3 лет назад
Родитель
Сommit
65a4795d40

+ 5 - 1
src/main/java/com/izouma/nineth/service/AirDropService.java

@@ -27,6 +27,7 @@ public class AirDropService {
     private UserRepo          userRepo;
     private AssetService      assetService;
     private CollectionService collectionService;
+    private ShowroomService   showroomService;
 
     public Page<AirDrop> all(PageQuery pageQuery) {
         return airDropRepo.findAll(JpaUtils.toSpecification(pageQuery, AirDrop.class), JpaUtils.toPageRequest(pageQuery));
@@ -60,7 +61,10 @@ public class AirDropService {
                         assetService.createAsset(winItem, user, null, null, "空投",
                                 collectionService.getNextNumber(winItem.getCollectionId()), collection.getHoldDays());
                     } else {
-                        assetService.createAsset(collection, user, null, null, "空投", collectionService.getNextNumber(collection.getId()));
+                        Asset asset = assetService.createAsset(collection, user, null, null, "空投", collectionService.getNextNumber(collection.getId()));
+                        if (collection.getType() == CollectionType.SHOWROOM) {
+                            showroomService.save(asset);
+                        }
                     }
                     collectionService.decreaseStock(collection.getId(), 1);
                     collectionService.increaseSale(collection.getId(), 1);

+ 5 - 1
src/main/java/com/izouma/nineth/service/OrderService.java

@@ -92,6 +92,7 @@ public class OrderService {
     private SmsService                    smsService;
     private ErrorOrderRepo                errorOrderRepo;
     private ShowCollectionRepo            showCollectionRepo;
+    private ShowroomService               showroomService;
 
     public Page<Order> all(PageQuery pageQuery) {
         return orderRepo.findAll(JpaUtils.toSpecification(pageQuery, Order.class), JpaUtils.toPageRequest(pageQuery));
@@ -608,8 +609,11 @@ public class OrderService {
 
                     } else {
                         orderRepo.save(order);
-                        assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售",
+                        Asset asset = assetService.createAsset(collection, user, order.getId(), order.getPrice(), "出售",
                                 collection.getTotal() > 1 ? collectionService.getNextNumber(order.getCollectionId()) : null);
+                        if (collection.getType() == CollectionType.SHOWROOM) {
+                            showroomService.save(asset);
+                        }
                     }
                 }
                 commission(order);

+ 23 - 0
src/main/java/com/izouma/nineth/service/ShowroomService.java

@@ -99,6 +99,29 @@ public class ShowroomService {
         return show;
     }
 
+    public Showroom save(Asset asset) {
+        if (!AssetStatus.NORMAL.equals(asset.getStatus())) {
+            throw new BusinessException("该状态不可创建展厅");
+        }
+        if (asset.isConsignment()) {
+            throw new BusinessException("寄售中不可以创建");
+        }
+
+        if (showroomRepo.findByAssetId(asset.getId()).isPresent()) {
+            throw new BusinessException("已创建过展厅");
+        }
+        Showroom showroom = Showroom.builder()
+                .showroomBg(asset.getShowroomBg())
+                .maxCollection(asset.getMaxCollection())
+                .publish(false)
+                .userId(asset.getUserId())
+                .assetId(asset.getId())
+                .build();
+
+
+        return showroomRepo.save(showroom);
+    }
+
     public Showroom update(Long userId, Showroom showroom) {
         Showroom recordRoom = showroomRepo.findById(showroom.getId()).orElseThrow(new BusinessException("无展厅"));
         showroom.setMaxCollection(recordRoom.getMaxCollection());