|
|
@@ -63,6 +63,8 @@ public class AssetService {
|
|
|
private DestroyRecordRepo destroyRecordRepo;
|
|
|
private AirDropService airDropService;
|
|
|
private HCChainService hcChainService;
|
|
|
+ private RockRecordService rockRecordService;
|
|
|
+ private RockRecordRepo rockRecordRepo;
|
|
|
|
|
|
public Page<Asset> all(PageQuery pageQuery) {
|
|
|
Page<Asset> all = assetRepo
|
|
|
@@ -89,7 +91,9 @@ public class AssetService {
|
|
|
return assetDTOs;
|
|
|
}
|
|
|
// 取出资产中未开启盲盒数据
|
|
|
- List<Asset> blindBoxClosedAssets = assets.stream().filter(asset -> !asset.isOpened() && CollectionType.BLIND_BOX.equals(asset.getType())).collect(Collectors.toList());
|
|
|
+ List<Asset> blindBoxClosedAssets = assets.stream()
|
|
|
+ .filter(asset -> !asset.isOpened() && CollectionType.BLIND_BOX.equals(asset.getType()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
if (CollectionUtils.isNotEmpty(blindBoxClosedAssets)) {
|
|
|
blindBoxClosedAssets.forEach(asset -> {
|
|
|
assetDTOs.add(AssetDTO.create(Lists.newArrayList(asset)));
|
|
|
@@ -98,7 +102,9 @@ public class AssetService {
|
|
|
assets.removeAll(blindBoxClosedAssets);
|
|
|
}
|
|
|
// 取出资产中所有未设置prefixName的值
|
|
|
- List<Asset> prefixNameIsNullAssets = assets.stream().filter(asset -> StringUtils.isBlank(asset.getPrefixName())).collect(Collectors.toList());
|
|
|
+ List<Asset> prefixNameIsNullAssets = assets.stream()
|
|
|
+ .filter(asset -> StringUtils.isBlank(asset.getPrefixName()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
if (CollectionUtils.isNotEmpty(prefixNameIsNullAssets)) {
|
|
|
prefixNameIsNullAssets.forEach(asset -> {
|
|
|
assetDTOs.add(AssetDTO.create(Lists.newArrayList(asset)));
|
|
|
@@ -107,10 +113,15 @@ public class AssetService {
|
|
|
}
|
|
|
if (CollectionUtils.isNotEmpty(assets)) {
|
|
|
// 取出资产中所有prefixName
|
|
|
- List<String> prefixNames = assets.stream().map(Asset::getPrefixName).distinct().collect(Collectors.toList());
|
|
|
+ List<String> prefixNames = assets.stream()
|
|
|
+ .map(Asset::getPrefixName)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
// 将资产中相同prefixName归类(除未开启盲盒和未设置prefixName)
|
|
|
prefixNames.forEach(str -> {
|
|
|
- List<Asset> collect = assets.stream().filter(asset -> str.equals(asset.getPrefixName())).collect(Collectors.toList());
|
|
|
+ List<Asset> collect = assets.stream()
|
|
|
+ .filter(asset -> str.equals(asset.getPrefixName()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
assetDTOs.add(AssetDTO.create(collect));
|
|
|
});
|
|
|
}
|
|
|
@@ -507,6 +518,11 @@ public class AssetService {
|
|
|
.build();
|
|
|
tokenHistoryRepo.save(tokenHistory);
|
|
|
|
|
|
+ //购买者加绿洲石
|
|
|
+ if (TransferReason.TRANSFER.equals(reason) || TransferReason.AUCTION.equals(reason)) {
|
|
|
+ rockRecordService.addRock(newOwner.getId(), price, "购买");
|
|
|
+ }
|
|
|
+
|
|
|
asset.setPublicShow(false);
|
|
|
asset.setConsignment(false);
|
|
|
asset.setPublicCollectionId(null);
|
|
|
@@ -658,18 +674,18 @@ public class AssetService {
|
|
|
|
|
|
@Cacheable(value = "userStat", key = "#userId")
|
|
|
public Map<String, BigDecimal> breakdown(Long userId) {
|
|
|
- List<TokenHistory> page = tokenHistoryRepo.userHistory(userId);
|
|
|
- BigDecimal sale = page.stream()
|
|
|
- .filter(th -> th.getFromUserId().equals(userId) && ObjectUtils.isNotEmpty(th.getPrice()))
|
|
|
- .map(TokenHistory::getPrice)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal buy = page.stream()
|
|
|
- .filter(th -> th.getToUserId().equals(userId) && ObjectUtils.isNotEmpty(th.getPrice()))
|
|
|
- .map(TokenHistory::getPrice)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+// List<TokenHistory> page = tokenHistoryRepo.userHistory(userId);
|
|
|
+// BigDecimal sale = page.stream()
|
|
|
+// .filter(th -> th.getFromUserId().equals(userId) && ObjectUtils.isNotEmpty(th.getPrice()))
|
|
|
+// .map(TokenHistory::getPrice)
|
|
|
+// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+// BigDecimal buy = page.stream()
|
|
|
+// .filter(th -> th.getToUserId().equals(userId) && ObjectUtils.isNotEmpty(th.getPrice()))
|
|
|
+// .map(TokenHistory::getPrice)
|
|
|
+// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
Map<String, BigDecimal> map = new HashMap<>();
|
|
|
- map.put("sale", sale);
|
|
|
- map.put("buy", buy);
|
|
|
+ map.put("sale", BigDecimal.ZERO);
|
|
|
+ map.put("buy", rockRecordRepo.findRecordByUserIdOrderByIdDesc(userId));
|
|
|
return map;
|
|
|
}
|
|
|
|