Просмотр исходного кода

Merge branch 'dev' of xiongzhu/raex_back into master

wangqifan 3 лет назад
Родитель
Сommit
0cfeef6e92

+ 3 - 0
src/main/java/com/izouma/nineth/repo/AssetRepo.java

@@ -122,6 +122,9 @@ public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationE
     @Query("select a from Asset a where a.status in ?2 and a.userId = ?1 and a.name like ?3 and a.type in (com.izouma.nineth.enums.CollectionType.DEFAULT,com.izouma.nineth.enums.CollectionType.BLIND_BOX)")
     List<Asset> findAllByUserIdAndStatusInAndNameLike(Long userId, List<AssetStatus> status, String name);
 
+    @Query("select a from Asset a where a.status = 'NORMAL' and a.consignment = true and a.name like ?1")
+    List<Asset> findOnShelfByNameLike(String search);
+
     List<Asset> findAllByIdNotInAndUserIdAndStatusInAndOpened(List<Long> ids, Long userId, List<AssetStatus> status, boolean opened);
 
     List<Asset> findAllByUserIdAndStatusInAndOpened(Long userId, List<AssetStatus> status, boolean opened);

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

@@ -60,6 +60,6 @@ public interface TokenHistoryRepo extends JpaRepository<TokenHistory, Long>, Jpa
     List<TokenHistory> findByOperationAndCreatedAtBefore(String operation, LocalDateTime time);
 
     @Query(nativeQuery = true, value = "select to_user nickname, to_avatar avatar, to_user_id id from token_history " +
-            "where created_at > ?1 group by to_user_id order by sum(price) desc limit 20")
+            "where created_at > ?1 group by to_user_id order by sum(price) desc limit 30")
     List<Map<String, String>> top(LocalDateTime time);
 }

+ 11 - 3
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -661,6 +661,11 @@ public class AssetService {
         return assetRepo.saveAndFlush(asset);
     }
 
+    public void batchCancelConsignment(String search) {
+        List<Asset> onShelf = assetRepo.findOnShelfByNameLike("%" + search + "%");
+        onShelf.forEach(this::cancelConsignmentBySystem);
+    }
+
     public void cancelConsignment(Long id) {
         Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
         if (!asset.getUserId().equals(SecurityUtils.getAuthenticatedUser().getId())) {
@@ -1012,10 +1017,13 @@ public class AssetService {
         assetIds.forEach(this::cancelConsignmentBySystem);
     }
 
-
     public void cancelConsignmentBySystem(Long id) {
+        Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
+        cancelConsignmentBySystem(asset);
+    }
+
+    public void cancelConsignmentBySystem(Asset asset) {
         try {
-            Asset asset = assetRepo.findById(id).orElseThrow(new BusinessException("无记录"));
             if (asset.getPublicCollectionId() != null) {
                 List<Order> orders = orderRepo.findByCollectionId(asset.getPublicCollectionId());
                 if (orders.stream().anyMatch(o -> o.getStatus() != OrderStatus.CANCELLED)) {
@@ -1032,7 +1040,7 @@ public class AssetService {
             asset.setPublicShow(false);
             assetRepo.saveAndFlush(asset);
         } catch (Exception e) {
-            log.info("自动下架报错,assetId:" + id);
+            log.info("自动下架报错,assetId:" + asset.getId());
         }
     }
 

+ 7 - 0
src/main/java/com/izouma/nineth/web/AssetController.java

@@ -264,6 +264,13 @@ public class AssetController extends BaseController {
     public List<FuAssetDTO> queryFu() {
         return assetService.queryFu();
     }
+
+    @PostMapping("/batchCancelConsignment")
+    @PreAuthorize("hasRole('ADMIN')")
+    @ApiOperation("批量下架")
+    public void cancelConsignment(@RequestParam String search) {
+        assetService.batchCancelConsignment(search);
+    }
 }
 
 

+ 1 - 1
src/main/java/com/izouma/nineth/web/UserHoldCountController.java

@@ -41,7 +41,7 @@ public class UserHoldCountController {
 
     @GetMapping("/app/top")
     public List<UserHoldDTO> appTop() {
-        List<UserHoldDTO> top = top(20);
+        List<UserHoldDTO> top = top(30);
         if (CollectionUtils.isEmpty(top)) {
             return null;
         }