|
|
@@ -426,24 +426,19 @@ public class AssetService {
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Map<String, BigDecimal> userHistory(Long userId) {
|
|
|
+ public Map<String, BigDecimal> breakdown(Long userId) {
|
|
|
List<TokenHistory> page = tokenHistoryRepo.userHistory(userId);
|
|
|
- Set<String> tokenIds = page.stream().map(TokenHistory::getTokenId).collect(Collectors.toSet());
|
|
|
- BigDecimal sales = BigDecimal.ZERO;
|
|
|
- BigDecimal buy = BigDecimal.ZERO;
|
|
|
- page.stream().map(tokenHistory -> {
|
|
|
-
|
|
|
-
|
|
|
-// switch (tokenHistory.getOperation()) {
|
|
|
-// case "出售":
|
|
|
-// case "转让":
|
|
|
-// if (tokenHistory.getToUserId().equals(userId)) {
|
|
|
-// buy.add(asset.stream().map().getPrice())
|
|
|
-// }
|
|
|
-// break;
|
|
|
-// }
|
|
|
- return null;
|
|
|
- });
|
|
|
- return null;
|
|
|
+ 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);
|
|
|
+ return map;
|
|
|
}
|
|
|
}
|