|
@@ -7,6 +7,7 @@ import com.izouma.nineth.config.RedisKeys;
|
|
|
import com.izouma.nineth.domain.Collection;
|
|
import com.izouma.nineth.domain.Collection;
|
|
|
import com.izouma.nineth.domain.*;
|
|
import com.izouma.nineth.domain.*;
|
|
|
import com.izouma.nineth.dto.*;
|
|
import com.izouma.nineth.dto.*;
|
|
|
|
|
+import com.izouma.nineth.enums.AuthStatus;
|
|
|
import com.izouma.nineth.enums.CollectionSource;
|
|
import com.izouma.nineth.enums.CollectionSource;
|
|
|
import com.izouma.nineth.enums.CollectionType;
|
|
import com.izouma.nineth.enums.CollectionType;
|
|
|
import com.izouma.nineth.enums.OrderStatus;
|
|
import com.izouma.nineth.enums.OrderStatus;
|
|
@@ -64,6 +65,7 @@ public class CollectionService {
|
|
|
private GeneralProperties generalProperties;
|
|
private GeneralProperties generalProperties;
|
|
|
private Environment env;
|
|
private Environment env;
|
|
|
private OrderRepo orderRepo;
|
|
private OrderRepo orderRepo;
|
|
|
|
|
+ private TokenHistoryRepo tokenHistoryRepo;
|
|
|
private PointRecordRepo pointRecordRepo;
|
|
private PointRecordRepo pointRecordRepo;
|
|
|
|
|
|
|
|
private final Map<Long, ScheduledFuture<?>> tasks = new HashMap<>();
|
|
private final Map<Long, ScheduledFuture<?>> tasks = new HashMap<>();
|
|
@@ -475,14 +477,17 @@ public class CollectionService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- public void savePoint(Long collectionId) {
|
|
|
|
|
|
|
+ public List<PointDTO> savePoint(Long collectionId) {
|
|
|
Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("无藏品"));
|
|
Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("无藏品"));
|
|
|
|
|
+ //库存
|
|
|
int stock = collection.getStock();
|
|
int stock = collection.getStock();
|
|
|
|
|
+ //是否开启白名单
|
|
|
int assignment = collection.getAssignment();
|
|
int assignment = collection.getAssignment();
|
|
|
if (assignment <= 0) {
|
|
if (assignment <= 0) {
|
|
|
- return;
|
|
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
List<User> users = userRepo.findAllByCollectionId(collectionId);
|
|
List<User> users = userRepo.findAllByCollectionId(collectionId);
|
|
|
|
|
+ //邀请者
|
|
|
Map<Long, List<User>> userMap = users.stream()
|
|
Map<Long, List<User>> userMap = users.stream()
|
|
|
.filter(user -> ObjectUtils.isNotEmpty(user.getCollectionInvitor()))
|
|
.filter(user -> ObjectUtils.isNotEmpty(user.getCollectionInvitor()))
|
|
|
.collect(Collectors.groupingBy(User::getCollectionInvitor));
|
|
.collect(Collectors.groupingBy(User::getCollectionInvitor));
|
|
@@ -490,15 +495,20 @@ public class CollectionService {
|
|
|
AtomicInteger sum = new AtomicInteger();
|
|
AtomicInteger sum = new AtomicInteger();
|
|
|
List<PointDTO> dtos = new ArrayList<>();
|
|
List<PointDTO> dtos = new ArrayList<>();
|
|
|
userMap.forEach((key, value) -> {
|
|
userMap.forEach((key, value) -> {
|
|
|
|
|
+ //邀请达到数量
|
|
|
if (value.size() >= collection.getAssignment()) {
|
|
if (value.size() >= collection.getAssignment()) {
|
|
|
value.sort(Comparator.comparing(User::getCreatedAt));
|
|
value.sort(Comparator.comparing(User::getCreatedAt));
|
|
|
|
|
+ //满足条件的时间
|
|
|
User user = value.get(collection.getAssignment() - 1);
|
|
User user = value.get(collection.getAssignment() - 1);
|
|
|
- dtos.add(new PointDTO(key, user.getCreatedAt(), value.size()));
|
|
|
|
|
|
|
+ //实名数量
|
|
|
|
|
+ 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();
|
|
sum.getAndIncrement();
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
log.info("完成任务人数:{}", sum);
|
|
log.info("完成任务人数:{}", sum);
|
|
|
|
|
|
|
|
|
|
+ //只留库存数量
|
|
|
List<PointDTO> result = dtos.stream()
|
|
List<PointDTO> result = dtos.stream()
|
|
|
.sorted(Comparator.comparing(PointDTO::getCreatedAt))
|
|
.sorted(Comparator.comparing(PointDTO::getCreatedAt))
|
|
|
.limit(stock)
|
|
.limit(stock)
|
|
@@ -508,21 +518,23 @@ public class CollectionService {
|
|
|
.stream()
|
|
.stream()
|
|
|
.collect(Collectors.toMap(User::getId, user -> user));
|
|
.collect(Collectors.toMap(User::getId, user -> user));
|
|
|
|
|
|
|
|
- result.forEach(pointDTO -> {
|
|
|
|
|
- User user = resultMap.get(pointDTO.getId());
|
|
|
|
|
- if (user.getVipPoint() <= 0) {
|
|
|
|
|
- user.setVipPoint(1);
|
|
|
|
|
- userRepo.save(user);
|
|
|
|
|
-// userRepo.updateVipPoint(pointDTO.getId(), 1);
|
|
|
|
|
- pointRecordRepo.save(PointRecord.builder()
|
|
|
|
|
- .collectionId(collectionId)
|
|
|
|
|
- .userId(pointDTO.getId())
|
|
|
|
|
- .type("VIP_POINT")
|
|
|
|
|
- .point(1)
|
|
|
|
|
- .build());
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
|
|
+ //加积分,存记录
|
|
|
|
|
+// result.forEach(pointDTO -> {
|
|
|
|
|
+// User user = resultMap.get(pointDTO.getId());
|
|
|
|
|
+// if (user.getVipPoint() <= 0) {
|
|
|
|
|
+// user.setVipPoint(1);
|
|
|
|
|
+// userRepo.save(user);
|
|
|
|
|
+//// userRepo.updateVipPoint(pointDTO.getId(), 1);
|
|
|
|
|
+// pointRecordRepo.save(PointRecord.builder()
|
|
|
|
|
+// .collectionId(collectionId)
|
|
|
|
|
+// .userId(pointDTO.getId())
|
|
|
|
|
+// .type("VIP_POINT")
|
|
|
|
|
+// .point(1)
|
|
|
|
|
+// .build());
|
|
|
|
|
+// }
|
|
|
|
|
+//
|
|
|
|
|
+// });
|
|
|
|
|
+
|
|
|
|
|
+ return dtos;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|