licailing 3 лет назад
Родитель
Сommit
5442ae8d64

+ 15 - 5
src/main/java/com/izouma/nineth/service/CollectionService.java

@@ -40,6 +40,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import javax.annotation.PostConstruct;
 import javax.persistence.criteria.Predicate;
 import javax.transaction.Transactional;
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.util.*;
@@ -477,7 +478,7 @@ public class CollectionService {
     }
 
 
-    public List<PointDTO> savePoint(Long collectionId) {
+    public List<PointDTO> savePoint(Long collectionId, LocalDateTime time) {
         Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("无藏品"));
         //库存
         int stock = collection.getStock();
@@ -493,20 +494,29 @@ public class CollectionService {
                 .collect(Collectors.groupingBy(User::getCollectionInvitor));
 
         AtomicInteger sum = new AtomicInteger();
+        AtomicInteger sum1 = new AtomicInteger();
         List<PointDTO> dtos = new ArrayList<>();
         userMap.forEach((key, value) -> {
             //邀请达到数量
             if (value.size() >= collection.getAssignment()) {
                 value.sort(Comparator.comparing(User::getCreatedAt));
+                BigDecimal buy = tokenHistoryRepo.userBuy(key);
                 //满足条件的时间
                 User user = value.get(collection.getAssignment() - 1);
-                //实名数量
-                long identitySum = value.stream().filter(u -> AuthStatus.SUCCESS.equals(u.getAuthStatus())).count();
-                dtos.add(new PointDTO(key, user.getCreatedAt(), value.size(), (int) identitySum, tokenHistoryRepo.userBuy(key)));
-                sum.getAndIncrement();
+                if ((ObjectUtils.isEmpty(buy) || buy.compareTo(BigDecimal.valueOf(500)) < 0) && user.getCreatedAt()
+                        .isBefore(time)) {
+                    sum1.getAndIncrement();
+                    System.out.println(key + "," + user.getCreatedAt() + "," + buy);
+                } else {
+                    //实名数量
+                    long identitySum = value.stream().filter(u -> AuthStatus.SUCCESS.equals(u.getAuthStatus())).count();
+                    dtos.add(new PointDTO(key, user.getCreatedAt(), value.size(), (int) identitySum, buy));
+                    sum.getAndIncrement();
+                }
             }
         });
         log.info("完成任务人数:{}", sum);
+        log.info("作弊任务人数:{}", sum1);
 
         //只留库存数量
         List<PointDTO> result = dtos.stream()

+ 1 - 1
src/test/java/com/izouma/nineth/service/CollectionServiceTest.java

@@ -140,7 +140,7 @@ class CollectionServiceTest extends ApplicationTests {
 
     @Test
     public void savePoint() {
-        collectionService.savePoint(196332L).forEach(System.out::println);
+        collectionService.savePoint(3749128L, LocalDateTime.now()).forEach(System.out::println);
     }
 
 }