|
|
@@ -2,10 +2,17 @@ package com.izouma.nineth.service;
|
|
|
|
|
|
import com.izouma.nineth.ApplicationTests;
|
|
|
import com.izouma.nineth.domain.*;
|
|
|
+import com.izouma.nineth.enums.AssetStatus;
|
|
|
import com.izouma.nineth.repo.*;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
class AssetServiceTest extends ApplicationTests {
|
|
|
@Autowired
|
|
|
private OrderRepo orderRepo;
|
|
|
@@ -75,4 +82,41 @@ class AssetServiceTest extends ApplicationTests {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void stat() {
|
|
|
+ List<User> match = new ArrayList<>();
|
|
|
+ userRepo.findAll().stream().parallel().forEach(user -> {
|
|
|
+ List<String> names = Arrays.asList("游戏《青丘奇缘》-人族玲珑 婉儿", "游戏《青丘奇缘》-人族逍遥 饮剑",
|
|
|
+ "游戏《青丘奇缘》-人族无极 魔修", "游戏《青丘奇缘》-人族玲珑 夜旋");
|
|
|
+ List<Asset> assets = assetRepo.findByUserId(user.getId());
|
|
|
+ assets = assets.stream().filter(a -> names.stream().anyMatch(n -> n.equals(a.getName())))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (assets.size() < 4) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ assets = assets.stream().filter(a -> a.getCreatedAt().isBefore(LocalDateTime.of(2021, 12, 19, 18, 0, 0)))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (assets.size() < 4) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ assets = assets.stream().filter(a -> {
|
|
|
+ if (a.getStatus() != AssetStatus.GIFTED && a.getStatus() != AssetStatus.TRANSFERRED) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ Asset a1 = assetRepo.findFirstByTokenIdAndCreatedAtAfterOrderByCreatedAt(a.getTokenId(), a.getCreatedAt());
|
|
|
+ return a1 != null && a.getCreatedAt().isAfter(LocalDateTime.of(2021, 12, 19, 20, 0, 0));
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ boolean flag = true;
|
|
|
+ for (String name : names) {
|
|
|
+ flag = flag && assets.stream().anyMatch(a -> name.equals(a.getName()));
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ match.add(user);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ System.out.println(match);
|
|
|
+ }
|
|
|
}
|