|
@@ -2,16 +2,13 @@ package com.izouma.nineth.service;
|
|
|
|
|
|
|
|
import com.izouma.nineth.ApplicationTests;
|
|
import com.izouma.nineth.ApplicationTests;
|
|
|
import com.izouma.nineth.domain.*;
|
|
import com.izouma.nineth.domain.*;
|
|
|
-import com.izouma.nineth.enums.AssetStatus;
|
|
|
|
|
import com.izouma.nineth.repo.*;
|
|
import com.izouma.nineth.repo.*;
|
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
class AssetServiceTest extends ApplicationTests {
|
|
class AssetServiceTest extends ApplicationTests {
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -85,38 +82,12 @@ class AssetServiceTest extends ApplicationTests {
|
|
|
|
|
|
|
|
@Test
|
|
@Test
|
|
|
public void stat() {
|
|
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);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ List<User> match = assetService.holdQuery(Arrays.asList("国潮-兰陵武王-高长恭", "国潮-燕南三士-赵云", "国潮-武安君-李牧", "国潮-战神无双-吕布"),
|
|
|
|
|
+ LocalDateTime.of(2021, 12, 23, 23, 0, 0),
|
|
|
|
|
+ LocalDateTime.of(2021, 12, 23, 23, 59, 59));
|
|
|
|
|
+ for (User user : match) {
|
|
|
|
|
+ System.out.printf("%d,%s,%s%n", user.getId(), user.getNickname(), user.getPhone());
|
|
|
|
|
+ }
|
|
|
System.out.println(match);
|
|
System.out.println(match);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|