|
|
@@ -438,14 +438,16 @@ public class CollectionService {
|
|
|
log.info("blindBoxDraw, userId={}, collectionId={}", userId, collectionId);
|
|
|
List<BlindBoxItem> items = blindBoxItemRepo.findByBlindBoxId(collectionId);
|
|
|
BoundHashOperations<String, Object, Object> operations = redisTemplate.boundHashOps(RedisKeys.DRAW_BLIND_BOX + collectionId);
|
|
|
+ Map<Object, Object> entries = operations.entries();
|
|
|
|
|
|
Map<BlindBoxItem, Range<Integer>> randomRange = new HashMap<>();
|
|
|
int c = 0, sum = 0;
|
|
|
for (BlindBoxItem item : items) {
|
|
|
if (item.getStock() > 0) {
|
|
|
+ int stock = Optional.ofNullable(entries.get(item.getCollectionId() + "")).map(i -> (int) i).orElse(item.getStock());
|
|
|
randomRange.put(item, Range.between(c, c + item.getStock()));
|
|
|
- c += item.getStock();
|
|
|
- sum += item.getStock();
|
|
|
+ c += stock;
|
|
|
+ sum += stock;
|
|
|
}
|
|
|
}
|
|
|
|