|
|
@@ -418,70 +418,7 @@ public class AssetService {
|
|
|
}
|
|
|
|
|
|
public Page<UserHistory> userHistory(Long userId, PageQuery pageQuery) {
|
|
|
- String chushou = "出售";
|
|
|
- String zhuanrang = "转让";
|
|
|
- String kongtou = "空投";
|
|
|
- String zengsong = "转赠";
|
|
|
Map<String, Object> query = pageQuery.getQuery();
|
|
|
- List<TokenHistory> allUserIds = new ArrayList<>();
|
|
|
- if (ObjectUtils.isNotEmpty(query.get("operation"))) {
|
|
|
- String operation = (String) query.get("operation");
|
|
|
- switch (operation) {
|
|
|
- case "买入":
|
|
|
- allUserIds = tokenHistoryRepo.findAllToUserId(userId,chushou,zhuanrang,kongtou);
|
|
|
- break;
|
|
|
- case "卖出":
|
|
|
- allUserIds = tokenHistoryRepo.findAllFromUserId(userId,zhuanrang);
|
|
|
- break;
|
|
|
- case "赠送":
|
|
|
- allUserIds = tokenHistoryRepo.findAllFromUserId(userId,zengsong);
|
|
|
- break;
|
|
|
- }
|
|
|
- }else {
|
|
|
- allUserIds = tokenHistoryRepo.findAllUserId(userId);
|
|
|
- }
|
|
|
- List<UserHistory> userHistories = new ArrayList<>();
|
|
|
- for (TokenHistory allUserId : allUserIds) {
|
|
|
-
|
|
|
- UserHistory userHistory = new UserHistory();
|
|
|
- BeanUtils.copyProperties(allUserId, userHistory);
|
|
|
- switch (allUserId.getOperation()) {
|
|
|
- case "出售":
|
|
|
- case "转让":
|
|
|
- userHistory.setDescription(allUserId.getToUserId().equals(userId) ? "买入" : "卖出");
|
|
|
- break;
|
|
|
- case "空投":
|
|
|
- userHistory.setDescription("买入");
|
|
|
- break;
|
|
|
- case "转赠":
|
|
|
- //userHistory.setDescription(tokenHistory.getToUserId().equals(userId) ? "他人赠送" : "作品赠送");
|
|
|
- userHistory.setDescription("赠送");
|
|
|
- break;
|
|
|
- }
|
|
|
- userHistories.add(userHistory);
|
|
|
- }
|
|
|
- List<String> tokenIds = allUserIds.stream().map(TokenHistory::getTokenId).collect(Collectors.toList());
|
|
|
- List<Asset> assets = assetRepo.findByTokenIdIn(tokenIds);
|
|
|
- userHistories.stream()
|
|
|
- .map(rel -> assets.stream()
|
|
|
- .filter(ord -> rel.getTokenId() == ord.getTokenId())
|
|
|
- .findFirst()
|
|
|
- .map(ord -> { rel.setPic(ord.getPic()==null ? new ArrayList<>() : ord.getPic());
|
|
|
- return rel;
|
|
|
- }).orElse(null)
|
|
|
- ).collect(Collectors.toList());
|
|
|
- userHistories.stream()
|
|
|
- .map(rel -> assets.stream()
|
|
|
- .filter(ord -> rel.getTokenId() == ord.getTokenId())
|
|
|
- .findFirst()
|
|
|
- .map(ord -> { rel.setAssetName(ord.getName()==null ? null : ord.getName());
|
|
|
- return rel;
|
|
|
- }).orElse(null)
|
|
|
- ).collect(Collectors.toList());
|
|
|
- Pageable pageable = PageRequest.of(pageQuery.getPage(), pageQuery.getSize());
|
|
|
- Page<UserHistory> map = PageUtil.createPageFromList(userHistories, pageable);
|
|
|
- return map;
|
|
|
- /*Map<String, Object> query = pageQuery.getQuery();
|
|
|
Page<TokenHistory> page = tokenHistoryRepo.findAll(((root, criteriaQuery, criteriaBuilder) -> {
|
|
|
List<Predicate> and = JpaUtils.toPredicates(pageQuery, TokenHistory.class, root, criteriaQuery, criteriaBuilder);
|
|
|
if (ObjectUtils.isEmpty(query.get("toUserId")) && ObjectUtils.isEmpty(query.get("fromUserId"))) {
|
|
|
@@ -536,19 +473,18 @@ public class AssetService {
|
|
|
}
|
|
|
|
|
|
return userHistory;
|
|
|
- });*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ });
|
|
|
/*Object operation1 = query.get("operation");
|
|
|
boolean b = null != operation1;
|
|
|
+ log.error("是否进入"+b);
|
|
|
if (null!=operation1){
|
|
|
String operation = operation1.toString();
|
|
|
List<UserHistory> content = map.getContent();
|
|
|
+ log.error("总长度为"+content.size());
|
|
|
for (int i = 0; i < content.size(); i++) {
|
|
|
+ log.error("传过来的值为:"+operation);
|
|
|
+ log.error("原来的的值为:"+content.get(i).getDescription());
|
|
|
+ log.error("=================");
|
|
|
if (!content.get(i).getDescription().equals(operation)){
|
|
|
content.remove(i);
|
|
|
i--;
|
|
|
@@ -557,8 +493,7 @@ public class AssetService {
|
|
|
Pageable pageable = PageRequest.of(pageQuery.getPage(), pageQuery.getSize());
|
|
|
map = PageUtil.createPageFromList(content, pageable);
|
|
|
}*/
|
|
|
- //return map;
|
|
|
-
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
public String mint(LocalDateTime time) {
|