Browse Source

上架,私售

wangqifan 3 năm trước cách đây
mục cha
commit
9259803c5e

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

@@ -22,6 +22,7 @@ import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.Range;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.rocketmq.client.consumer.LitePullConsumer;
 import org.apache.rocketmq.spring.core.RocketMQTemplate;
 import org.springframework.beans.BeanUtils;
 import org.springframework.cache.annotation.Cacheable;
@@ -297,7 +298,8 @@ public class CollectionService {
                 collection.setLiked(likes.stream().anyMatch(l -> l.getCollectionId().equals(collection.getId())));
             }
             if (!appointments.isEmpty()) {
-                collection.setAppointment(appointments.stream().anyMatch(a -> a.getBlindBoxId().equals(collection.getId())));
+                collection.setAppointment(appointments.stream()
+                        .anyMatch(a -> a.getBlindBoxId().equals(collection.getId())));
             }
         });
     }
@@ -619,4 +621,32 @@ public class CollectionService {
 
         return dtos;
     }
+
+    public List<Collection> setOasisScancode(List<Long> oasisIds) {
+        List<Collection> collections = collectionRepo
+                .findAllByOasisIdInAndSourceAndSaleLessThan(oasisIds, CollectionSource.COMPANY, 1);
+        List<Collection> result = new ArrayList<>();
+        collections.forEach(collection -> {
+            collection.setOnShelf(false);
+            collection.setScanCode(true);
+            collection.setSalable(true);
+            collectionRepo.save(collection);
+            result.add(collection);
+        });
+        return result;
+    }
+
+    public List<Collection> setOasisOnShelf(List<Long> oasisIds) {
+        List<Collection> collections = collectionRepo
+                .findAllByOasisIdInAndSourceAndSaleLessThan(oasisIds, CollectionSource.COMPANY, 1);
+        List<Collection> result = new ArrayList<>();
+        collections.forEach(collection -> {
+            collection.setOnShelf(true);
+            collection.setScanCode(false);
+            collection.setSalable(true);
+            collectionRepo.save(collection);
+            result.add(collection);
+        });
+        return result;
+    }
 }

+ 12 - 0
src/main/java/com/izouma/nineth/web/CollectionController.java

@@ -214,5 +214,17 @@ public class CollectionController extends BaseController {
         collection.setSalable(salable);
         collectionRepo.save(collection);
     }
+
+    @PreAuthorize("hasAnyRole('ADMIN','COMPANY')")
+    @PostMapping("/onShelfOasis")
+    public List<Collection> onShelfOasis(List<Long> oasisIds) {
+        return collectionService.setOasisOnShelf(oasisIds);
+    }
+
+    @PreAuthorize("hasAnyRole('ADMIN','COMPANY')")
+    @PostMapping("/setScancodeOasis")
+    public List<Collection> setScancodeOasis(List<Long> oasisIds) {
+        return collectionService.setOasisScancode(oasisIds);
+    }
 }