wangqifan 4 lat temu
rodzic
commit
a2fe8d62a3

+ 2 - 0
src/main/java/com/izouma/nineth/domain/AirDrop.java

@@ -65,4 +65,6 @@ public class AirDrop extends BaseEntity {
 
 
     @ApiModelProperty("忽略库存校验")
     @ApiModelProperty("忽略库存校验")
     private boolean ignoreStockCheck = false;
     private boolean ignoreStockCheck = false;
+
+    private Long oasisId;
 }
 }

+ 2 - 0
src/main/java/com/izouma/nineth/domain/Showroom.java

@@ -75,4 +75,6 @@ public class Showroom extends BaseEntity {
     @Transient
     @Transient
     private boolean liked;
     private boolean liked;
 
 
+    private Long oasisId;
+
 }
 }

+ 8 - 6
src/main/java/com/izouma/nineth/dto/oasis/OasisLoginDTO.java

@@ -1,5 +1,6 @@
 package com.izouma.nineth.dto.oasis;
 package com.izouma.nineth.dto.oasis;
 
 
+import com.izouma.nineth.domain.Showroom;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 import lombok.NoArgsConstructor;
@@ -8,10 +9,11 @@ import lombok.NoArgsConstructor;
 @AllArgsConstructor
 @AllArgsConstructor
 @NoArgsConstructor
 @NoArgsConstructor
 public class OasisLoginDTO {
 public class OasisLoginDTO {
-    private Long   assetId;
-    private Long   oasisId;
-    private String url;
-    private String source;
-    private String token;
-    private Long   userId;
+    private Long     assetId;
+    private Long     oasisId;
+    private String   url;
+    private String   source;
+    private String   token;
+    private Long     userId;
+    private Showroom showroom;
 }
 }

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

@@ -10,6 +10,7 @@ import org.springframework.data.jpa.repository.Query;
 
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nonnull;
 import javax.transaction.Transactional;
 import javax.transaction.Transactional;
+import java.util.List;
 import java.util.Optional;
 import java.util.Optional;
 
 
 public interface ShowroomRepo extends JpaRepository<Showroom, Long>, JpaSpecificationExecutor<Showroom> {
 public interface ShowroomRepo extends JpaRepository<Showroom, Long>, JpaSpecificationExecutor<Showroom> {
@@ -36,4 +37,6 @@ public interface ShowroomRepo extends JpaRepository<Showroom, Long>, JpaSpecific
     @Cacheable(value = "showroom", key = "#id")
     @Cacheable(value = "showroom", key = "#id")
     Optional<Showroom> findById(@Nonnull Long id);
     Optional<Showroom> findById(@Nonnull Long id);
 
 
+    Optional<Showroom> findByOasisId(Long oasisId);
+
 }
 }

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

@@ -38,7 +38,8 @@ public class AirDropService {
     private CollectionPrivilegeRepo collectionPrivilegeRepo;
     private CollectionPrivilegeRepo collectionPrivilegeRepo;
 
 
     public Page<AirDrop> all(PageQuery pageQuery) {
     public Page<AirDrop> all(PageQuery pageQuery) {
-        return airDropRepo.findAll(JpaUtils.toSpecification(pageQuery, AirDrop.class), JpaUtils.toPageRequest(pageQuery));
+        return airDropRepo
+                .findAll(JpaUtils.toSpecification(pageQuery, AirDrop.class), JpaUtils.toPageRequest(pageQuery));
     }
     }
 
 
     public AirDrop create(AirDrop record) {
     public AirDrop create(AirDrop record) {
@@ -118,6 +119,7 @@ public class AirDropService {
                                                 collectionService.getNextNumber(collection.getId()) : null);
                                                 collectionService.getNextNumber(collection.getId()) : null);
                                 //创建展厅
                                 //创建展厅
                                 if (collection.getType() == CollectionType.SHOWROOM) {
                                 if (collection.getType() == CollectionType.SHOWROOM) {
+                                    asset.setOasisId(record.getOasisId());
                                     showroomService.save(asset);
                                     showroomService.save(asset);
                                 }
                                 }
                             }
                             }
@@ -137,10 +139,10 @@ public class AirDropService {
 
 
     @Async
     @Async
     public void asyncDrop(Long collectionId, Long userId, int num, LocalDateTime time) {
     public void asyncDrop(Long collectionId, Long userId, int num, LocalDateTime time) {
-        drop(collectionId, userId, num, time);
+        drop(collectionId, userId, num, time, null);
     }
     }
 
 
-    public void drop(Long collectionId, Long userId, int num, LocalDateTime time) {
+    public void drop(Long collectionId, Long userId, int num, LocalDateTime time, Long oasisId) {
         Collection collection = collectionRepo.findById(collectionId)
         Collection collection = collectionRepo.findById(collectionId)
                 .orElseThrow(new BusinessException("藏品不存在"));
                 .orElseThrow(new BusinessException("藏品不存在"));
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
         User user = userRepo.findById(userId).orElseThrow(new BusinessException("用户不存在"));
@@ -160,9 +162,13 @@ public class AirDropService {
                 tokenHistoryRepo.flush();
                 tokenHistoryRepo.flush();
 
 
                 asset.setCreatedAt(time.plusSeconds((long) (Math.random() * 120)));
                 asset.setCreatedAt(time.plusSeconds((long) (Math.random() * 120)));
+                if (oasisId != null) {
+                    asset.setOasisId(oasisId);
+                }
                 assetRepo.save(asset);
                 assetRepo.save(asset);
 
 
-                for (TokenHistory tokenHistory : tokenHistoryRepo.findByTokenIdOrderByCreatedAtDesc(asset.getTokenId())) {
+                for (TokenHistory tokenHistory : tokenHistoryRepo
+                        .findByTokenIdOrderByCreatedAtDesc(asset.getTokenId())) {
                     tokenHistory.setCreatedAt(asset.getCreatedAt());
                     tokenHistory.setCreatedAt(asset.getCreatedAt());
                     tokenHistoryRepo.save(tokenHistory);
                     tokenHistoryRepo.save(tokenHistory);
                 }
                 }
@@ -194,7 +200,8 @@ public class AirDropService {
                 asset.setCreatedAt(time.plusSeconds((long) (Math.random() * 120)));
                 asset.setCreatedAt(time.plusSeconds((long) (Math.random() * 120)));
                 assetRepo.save(asset);
                 assetRepo.save(asset);
 
 
-                for (TokenHistory tokenHistory : tokenHistoryRepo.findByTokenIdOrderByCreatedAtDesc(asset.getTokenId())) {
+                for (TokenHistory tokenHistory : tokenHistoryRepo
+                        .findByTokenIdOrderByCreatedAtDesc(asset.getTokenId())) {
                     tokenHistory.setCreatedAt(asset.getCreatedAt());
                     tokenHistory.setCreatedAt(asset.getCreatedAt());
                     tokenHistoryRepo.save(tokenHistory);
                     tokenHistoryRepo.save(tokenHistory);
                 }
                 }

+ 25 - 2
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -65,6 +65,7 @@ public class AssetService {
     private CollectionPrivilegeRepo collectionPrivilegeRepo;
     private CollectionPrivilegeRepo collectionPrivilegeRepo;
     private PasswordEncoder         passwordEncoder;
     private PasswordEncoder         passwordEncoder;
     private MintActivityRepo        mintActivityRepo;
     private MintActivityRepo        mintActivityRepo;
+    private AirDropService          airDropService;
 
 
     public Page<Asset> all(PageQuery pageQuery) {
     public Page<Asset> all(PageQuery pageQuery) {
         Page<Asset> all = assetRepo
         Page<Asset> all = assetRepo
@@ -104,6 +105,28 @@ public class AssetService {
                 .price(price)
                 .price(price)
                 .build());
                 .build());
         rocketMQTemplate.syncSend(generalProperties.getMintTopic(), asset.getId());
         rocketMQTemplate.syncSend(generalProperties.getMintTopic(), asset.getId());
+        if (asset.getOasisId() != null & asset.getSource().equals(AssetSource.OFFICIAL)) {
+            AirDrop airDrop = new AirDrop();
+            airDrop.setName("建筑空投展厅");
+            airDrop.setCollectionId(207012L);
+            List<Long> userIds = new ArrayList<>();
+            userIds.add(user.getId());
+            List<Long> nums = new ArrayList<>();
+            nums.add(1L);
+            airDrop.setType(AirDropType.asset);
+            List<DropTarget> dropTargets = new ArrayList<>();
+            DropTarget dropTarget = new DropTarget();
+            dropTarget.setNickname(user.getNickname());
+            dropTarget.setNum(1);
+            dropTarget.setPhone(user.getPhone());
+            dropTarget.setUserId(user.getId());
+            dropTargets.add(dropTarget);
+            airDrop.setTargets(dropTargets);
+            airDrop.setUserIds(userIds);
+            airDrop.setNum(nums);
+            airDropService.create(airDrop);
+
+        }
         return asset;
         return asset;
     }
     }
 
 
@@ -626,8 +649,8 @@ public class AssetService {
             if (tags.isEmpty()) return new PageImpl<>(Collections.emptyList());
             if (tags.isEmpty()) return new PageImpl<>(Collections.emptyList());
             return assetRepo.findAll((Specification<Asset>) (root, query, criteriaBuilder) ->
             return assetRepo.findAll((Specification<Asset>) (root, query, criteriaBuilder) ->
                     query.distinct(true).where(criteriaBuilder.equal(root.get("userId"), userId),
                     query.distinct(true).where(criteriaBuilder.equal(root.get("userId"), userId),
-                                    criteriaBuilder.equal(root.get("status"), AssetStatus.NORMAL),
-                                    root.join("tags").get("id").in(tags.stream().map(Tag::getId).toArray()))
+                            criteriaBuilder.equal(root.get("status"), AssetStatus.NORMAL),
+                            root.join("tags").get("id").in(tags.stream().map(Tag::getId).toArray()))
                             .getRestriction(), pageable);
                             .getRestriction(), pageable);
         } else {
         } else {
             return assetRepo.findByUserIdAndStatusAndNameLike(userId, AssetStatus.NORMAL,
             return assetRepo.findByUserIdAndStatusAndNameLike(userId, AssetStatus.NORMAL,

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

@@ -130,6 +130,7 @@ public class ShowroomService {
                 .nickname(asset.getOwner())
                 .nickname(asset.getOwner())
                 .type(type)
                 .type(type)
                 .status(AuthStatus.SUCCESS)
                 .status(AuthStatus.SUCCESS)
+                .oasisId(asset.getOasisId())
                 .build();
                 .build();
         showroom = showroomRepo.save(showroom);
         showroom = showroomRepo.save(showroom);
 
 

+ 29 - 3
src/main/java/com/izouma/nineth/service/UserService.java

@@ -105,6 +105,10 @@ public class UserService {
     private OrderRepo                     orderRepo;
     private OrderRepo                     orderRepo;
     private AuctionPassRecordRepo         auctionPassRecordRepo;
     private AuctionPassRecordRepo         auctionPassRecordRepo;
     private AssetRepo                     assetRepo;
     private AssetRepo                     assetRepo;
+    private ShowroomRepo                  showroomRepo;
+    private ShowCollectionRepo            showCollectionRepo;
+    private ShowroomService               showroomService;
+    private NewsLikeRepo                  newsLikeRepo;
 
 
     public User update(User user) {
     public User update(User user) {
         if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
         if (!SecurityUtils.hasRole(AuthorityName.ROLE_ADMIN)) {
@@ -579,7 +583,7 @@ public class UserService {
             throw new BusinessException("用户不存在或未认证");
             throw new BusinessException("用户不存在或未认证");
         }
         }
         String realName = identityAuthRepo.findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(
         String realName = identityAuthRepo.findFirstByUserIdAndStatusAndDelFalseOrderByCreatedAtDesc(
-                        user.getId(), AuthStatus.SUCCESS)
+                user.getId(), AuthStatus.SUCCESS)
                 .map(IdentityAuth::getRealName).orElse("").replaceAll(".*(?=.)", "**");
                 .map(IdentityAuth::getRealName).orElse("").replaceAll(".*(?=.)", "**");
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         map.put("id", user.getId());
         map.put("id", user.getId());
@@ -592,8 +596,8 @@ public class UserService {
 
 
     public Map<String, Object> searchByPhoneAdmin(String phoneStr) {
     public Map<String, Object> searchByPhoneAdmin(String phoneStr) {
         List<String> phone = Arrays.stream(phoneStr.replaceAll("\n", " ")
         List<String> phone = Arrays.stream(phoneStr.replaceAll("\n", " ")
-                        .replaceAll("\r\n", " ")
-                        .split(" "))
+                .replaceAll("\r\n", " ")
+                .split(" "))
                 .map(String::trim)
                 .map(String::trim)
                 .filter(s -> !StringUtils.isEmpty(s))
                 .filter(s -> !StringUtils.isEmpty(s))
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
@@ -927,6 +931,28 @@ public class UserService {
             } else {
             } else {
                 oasisLoginDTO.setUrl("未公开展示");
                 oasisLoginDTO.setUrl("未公开展示");
             }
             }
+
+            Showroom showroom = showroomRepo.findByOasisId(oasisLoginDTO.getOasisId())
+                    .orElseThrow(new BusinessException("无记录 "));
+            List<ShowCollection> origin = showCollectionRepo.findAllByShowroomIdOrderBySort(showroom.getId());
+            List<ShowCollection> neo = new ArrayList<>();
+            if (origin != null) {
+                origin.forEach(orig -> collectionRepo.findById(orig.getCollectionId())
+                        .ifPresent(collection1 -> {
+                            orig.setStatus(showroomService.getStatus(collection1));
+                            orig.setPrice(collection1.getPrice());
+                            neo.add(orig);
+                        }));
+            }
+            showroom.setCollections(neo);
+            User showRoomUser = SecurityUtils.getAuthenticatedUser();
+
+            if (showRoomUser != null && !showRoomUser.isAdmin()) {
+                List<NewsLike> likes = newsLikeRepo.findByUserIdAndShowroomId(showRoomUser
+                        .getId(), showroom.getId());
+                showroom.setLiked(CollUtil.isNotEmpty(likes));
+            }
+            oasisLoginDTO.setShowroom(showroom);
             oasisLoginDTOS.add(oasisLoginDTO);
             oasisLoginDTOS.add(oasisLoginDTO);
         });
         });
         map.put("oasisInfo", oasisLoginDTOS);
         map.put("oasisInfo", oasisLoginDTOS);