Bladeren bron

Merge branch 'pai_mai' into hb_dev_pai

licailing 3 jaren geleden
bovenliggende
commit
b671295d52

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

@@ -166,5 +166,5 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
 
     Collection findFirstByOnShelfAndAssetId(boolean onShelf, Long assetId);
 
-    List<Collection> findAllByOasisIdInAndSourceAndSaleLessThan(List<Long> oasisIds, CollectionSource source, int sale);
+    List<Collection> findAllByOasisIdInAndSourceInAndStockGreaterThan(List<Long> oasisIds, List<CollectionSource> sources, int sale);
 }

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

@@ -623,8 +623,11 @@ public class CollectionService {
     }
 
     public List<Collection> setOasisScancode(List<Long> oasisIds) {
+        List<CollectionSource> collectionSources = new ArrayList<>();
+        collectionSources.add(CollectionSource.COMPANY);
+        collectionSources.add(CollectionSource.OFFICIAL);
         List<Collection> collections = collectionRepo
-                .findAllByOasisIdInAndSourceAndSaleLessThan(oasisIds, CollectionSource.COMPANY, 1);
+                .findAllByOasisIdInAndSourceInAndStockGreaterThan(oasisIds, collectionSources, 0);
         List<Collection> result = new ArrayList<>();
         collections.forEach(collection -> {
             collection.setOnShelf(false);
@@ -637,8 +640,11 @@ public class CollectionService {
     }
 
     public List<Collection> setOasisOnShelf(List<Long> oasisIds) {
+        List<CollectionSource> collectionSources = new ArrayList<>();
+        collectionSources.add(CollectionSource.COMPANY);
+        collectionSources.add(CollectionSource.OFFICIAL);
         List<Collection> collections = collectionRepo
-                .findAllByOasisIdInAndSourceAndSaleLessThan(oasisIds, CollectionSource.COMPANY, 1);
+                .findAllByOasisIdInAndSourceInAndStockGreaterThan(oasisIds, collectionSources, 0);
         List<Collection> result = new ArrayList<>();
         collections.forEach(collection -> {
             collection.setOnShelf(true);

+ 4 - 1
src/main/java/com/izouma/nineth/service/CompanyCollectionService.java

@@ -111,8 +111,11 @@ public class CompanyCollectionService {
                 .findAllByOasisIdInAndStatusIn(oasisIds, assetStatuses);
         List<CompanyCollection> companyCollections = companyCollectionRepo
                 .findAllByOasisIdInAndStatusNot(oasisIds, CollectionStatus.SUCCESS);
+        List<CollectionSource> collectionSources = new ArrayList<>();
+        collectionSources.add(CollectionSource.COMPANY);
+        collectionSources.add(CollectionSource.OFFICIAL);
         List<Collection> officialCollections = collectionRepo
-                .findAllByOasisIdInAndSourceAndSaleLessThan(oasisIds, CollectionSource.COMPANY, 1);
+                .findAllByOasisIdInAndSourceInAndStockGreaterThan(oasisIds, collectionSources, 0);
 
         assets.forEach(asset -> {
             OasisDistrictCollectionDTO oasisDistrictCollectionDTO = new OasisDistrictCollectionDTO();

+ 41 - 29
src/test/java/com/izouma/nineth/service/CollectionServiceTest.java

@@ -63,47 +63,50 @@ class CollectionServiceTest extends ApplicationTests {
         Arrays.stream(new File("/Users/qiufangchao/Desktop/mugen_mu").listFiles())
                 .filter(f -> !f.getName().contains(".DS_Store"))
                 .parallel().forEach(file -> {
-                    try {
+            try {
 //                        String name = file.getName();
 //                        Pattern p = Pattern.compile("(\\d+)");
 //                        Matcher matcher = p.matcher(name);
 //                        matcher.find();
 //                        String findname = matcher.group();
 
-                        Collection collection = JSON.parseObject(jsonStr, Collection.class);
-                        collection.setId(null);
-                        collection.setName("MUGEN无限:未央宗#" + num.getAndIncrement());
-                        collection.setStock(1);
-                        collection.setTotal(1);
-                        collection.setSale(0);
-                        collection.setMinterId(5868950L);
-                        collection.setOnShelf(false);
-                        collection.setSalable(false);
+                Collection collection = JSON.parseObject(jsonStr, Collection.class);
+                collection.setId(null);
+                collection.setName("MUGEN无限:未央宗#" + num.getAndIncrement());
+                collection.setStock(1);
+                collection.setTotal(1);
+                collection.setSale(0);
+                collection.setMinterId(5868950L);
+                collection.setOnShelf(false);
+                collection.setSalable(false);
 //                        String thumbPath = "https://cdn.raex.vip/thumb_image/mahjongman/" + file.getName()
 //                                .substring(0, file.getName().lastIndexOf(".")) + ".jpg";
-                        collection.setPic(Collections.singletonList(new FileObject("", "https://cdn.raex.vip/nft/mugen_mu/" + file.getName(), null, "image/png")));
-
-                        collectionRepo.save(collection);
-                        System.out.println("保存成功" + collection.getId());
-
-                        items.add(BlindBoxItem
-                                .builder()
-                                .collectionId(collection.getId())
-                                .total(1)
-                                .stock(1)
-                                .rare(false)
-                                .build());
-                    } catch (Exception e) {
-                    }
-                });
+                collection.setPic(Collections
+                        .singletonList(new FileObject("", "https://cdn.raex.vip/nft/mugen_mu/" + file
+                                .getName(), null, "image/png")));
+
+                collectionRepo.save(collection);
+                System.out.println("保存成功" + collection.getId());
+
+                items.add(BlindBoxItem
+                        .builder()
+                        .collectionId(collection.getId())
+                        .total(1)
+                        .stock(1)
+                        .rare(false)
+                        .build());
+            } catch (Exception e) {
+            }
+        });
 
 
     }
 
     @Test
     public void createBlindBox() throws IOException {
-        List<Long> arr = Arrays.asList(6862110L, 6862511L, 6862516L, 6862533L, 6862689L, 6862792L, 6862867L, 6863009L, 6863047L,
-                6863188L, 6863438L, 6863449L, 6863588L, 6863608L, 6863671L, 6863745L, 6863760L, 6863938L, 6863954L, 6864008L, 6864081L);
+        List<Long> arr = Arrays
+                .asList(6862110L, 6862511L, 6862516L, 6862533L, 6862689L, 6862792L, 6862867L, 6863009L, 6863047L,
+                        6863188L, 6863438L, 6863449L, 6863588L, 6863608L, 6863671L, 6863745L, 6863760L, 6863938L, 6863954L, 6864008L, 6864081L);
         List<Collection> items = collectionRepo.findByNameLike("MUGEN无限:未央宗#%").stream().filter(i -> {
             int num = Integer.parseInt(i.getName().substring("MUGEN无限:未央宗#".length()));
             return num > 0 && num <= 2000 && !arr.contains(i.getId());
@@ -119,7 +122,8 @@ class CollectionServiceTest extends ApplicationTests {
         blindBox.setNoSoldOut(true);
         blindBox.setMaxCount(1);
         blindBox.setName("MUGEN无限未央宗数字艺术品盲盒");
-        blindBox.setPic(Arrays.asList(new FileObject(null, "https://cdn.raex.vip/nft/2022-04-16-19-24-54WTJLmsmR.jpg", null, "image/jpeg")));
+        blindBox.setPic(Arrays
+                .asList(new FileObject(null, "https://cdn.raex.vip/nft/2022-04-16-19-24-54WTJLmsmR.jpg", null, "image/jpeg")));
         collectionService.createBlindBox(new CreateBlindBox(blindBox, items.stream().map(i -> {
             BlindBoxItem item = new BlindBoxItem();
             item.setCollectionId(i.getId());
@@ -168,7 +172,8 @@ class CollectionServiceTest extends ApplicationTests {
                 .forEach(file -> {
                     System.out.println(file.getName());
                     try {
-                        String url = storageService.uploadFromInputStream(new FileInputStream(file), "video/mahjongman/" + file.getName());
+                        String url = storageService
+                                .uploadFromInputStream(new FileInputStream(file), "video/mahjongman/" + file.getName());
                         String thumbPath = "thumb_image/mahjongman/" + file.getName()
                                 .substring(0, file.getName().lastIndexOf(".")) + ".jpg";
 
@@ -210,4 +215,11 @@ class CollectionServiceTest extends ApplicationTests {
         System.out.println(firstHour);
     }
 
+    @Test
+    public void test3() {
+        List<Long> oasisIds = new ArrayList<>(Arrays
+                .asList(1560L, 1559L, 1558L, 1459L, 1457L, 1454L, 1453L, 1456L, 1460L, 1452L));
+        collectionService.setOasisScancode(oasisIds);
+    }
+
 }