licailing 4 år sedan
förälder
incheckning
5ab0b0f8bf

+ 15 - 15
src/main/java/com/izouma/nineth/service/CollectionService.java

@@ -60,21 +60,21 @@ public class CollectionService {
 
     private final Map<Long, ScheduledFuture<?>> tasks = new HashMap<>();
 
-    @PostConstruct
-    public void init() {
-        List<Collection> collections = collectionRepo.findByScheduleSaleTrueAndOnShelfFalseAndStartTimeBeforeAndDelFalse(LocalDateTime.now());
-        for (Collection collection : collections) {
-            onShelfTask(collection);
-        }
-        for (CollectionStockAndSale collection : collectionRepo.getStockAndSale()) {
-            if (redisTemplate.opsForValue().get("collectionStock::" + collection.getId()) == null) {
-                redisTemplate.opsForValue().set("collectionStock::" + collection.getId(), collection.getStock());
-            }
-            if (redisTemplate.opsForValue().get("collectionSale::" + collection.getId()) == null) {
-                redisTemplate.opsForValue().set("collectionSale::" + collection.getId(), collection.getSale());
-            }
-        }
-    }
+//    @PostConstruct
+//    public void init() {
+//        List<Collection> collections = collectionRepo.findByScheduleSaleTrueAndOnShelfFalseAndStartTimeBeforeAndDelFalse(LocalDateTime.now());
+//        for (Collection collection : collections) {
+//            onShelfTask(collection);
+//        }
+//        for (CollectionStockAndSale collection : collectionRepo.getStockAndSale()) {
+//            if (redisTemplate.opsForValue().get("collectionStock::" + collection.getId()) == null) {
+//                redisTemplate.opsForValue().set("collectionStock::" + collection.getId(), collection.getStock());
+//            }
+//            if (redisTemplate.opsForValue().get("collectionSale::" + collection.getId()) == null) {
+//                redisTemplate.opsForValue().set("collectionSale::" + collection.getId(), collection.getSale());
+//            }
+//        }
+//    }
 
     public Page<Collection> all(PageQuery pageQuery) {
         pageQuery.getQuery().put("del", false);

+ 21 - 16
src/main/java/com/izouma/nineth/service/MintOrderService.java

@@ -129,20 +129,23 @@ public class MintOrderService {
             throw new BusinessException("铸造活动已无库存");
         }
 
-
-        if (assetId.size() != mintActivity.getNum()) {
-            throw new BusinessException("数量不正确,请重新选择");
+        if (mintActivity.getNum() > 0) {
+            if (assetId.size() != mintActivity.getNum()) {
+                throw new BusinessException("数量不正确,请重新选择");
+            }
         }
 
+
         List<Asset> assets = assetRepo.findAllByIdInAndUserId(assetId, user.getId());
         // 资产产品是否符合铸造活动的名称
         assets = assets.stream()
                 .filter(asset -> asset.getName()
                         .contains(mintActivity.getCollectionName()) && AssetStatus.NORMAL.equals(asset.getStatus()))
                 .collect(Collectors.toList());
-        if (assets.size() != mintActivity.getNum()) {
+        if (mintActivity.getNum() > 0 && (assets.size() != mintActivity.getNum())) {
             throw new BusinessException("有藏品不符合,请重新选择");
         }
+
         Map<Long, Long> privilegeIds = new HashMap<>();
         // 铸造特权
         if (!mintActivity.isConsume()) {
@@ -375,16 +378,19 @@ public class MintOrderService {
         }
         List<MintMaterial> materials = order.getMaterial();
 
-        Map<Long, Long> privilegeIds = materials.stream()
-                .collect(Collectors.toMap(MintMaterial::getAssetId, MintMaterial::getPrivilegeId));
-
-        List<Asset> assets = assetRepo.findAllById(privilegeIds.keySet());
+        List<Asset> assets = assetRepo.findAllById(materials.stream()
+                .map(MintMaterial::getAssetId)
+                .collect(Collectors.toList()));
 
-        assets.forEach(asset -> {
-            if (order.isConsume()) {
+        if (order.isConsume()) {
+            assets.forEach(asset -> {
                 asset.setStatus(AssetStatus.NORMAL);
-
-            } else {
+                assetRepo.save(asset);
+            });
+        } else {
+            Map<Long, Long> privilegeIds = materials.stream()
+                    .collect(Collectors.toMap(MintMaterial::getAssetId, MintMaterial::getPrivilegeId));
+            assets.forEach(asset -> {
                 asset.getPrivileges()
                         .stream()
                         .filter(p -> p.getId().equals(privilegeIds.get(asset.getId())))
@@ -393,10 +399,9 @@ public class MintOrderService {
                             p.setOpenTime(null);
                             p.setOpenedBy(null);
                         });
-            }
-            assetRepo.save(asset);
-
-        });
+                assetRepo.save(asset);
+            });
+        }
 
         log.info("set normal mintOrder {}", order.getId());