|
|
@@ -265,27 +265,20 @@ public class OrderService {
|
|
|
throw new BusinessException("该藏品当前不可购买");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- AtomicInteger userMax = new AtomicInteger();
|
|
|
- userPropertyRepo.findById(userId).ifPresent(userProperty -> userMax.set(userProperty.getMaxCount()));
|
|
|
-
|
|
|
if (collection.getMaxCount() > 0) {
|
|
|
+ int userMax = userPropertyRepo.findById(userId)
|
|
|
+ .map(UserProperty::getMaxCount)
|
|
|
+ .orElse(collection.getMaxCount());
|
|
|
int count;
|
|
|
if (StringUtils.isNotBlank(collection.getCountId())) {
|
|
|
- count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(), Arrays
|
|
|
- .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
+ count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(),
|
|
|
+ Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
} else {
|
|
|
- count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId, Arrays
|
|
|
- .asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
+ count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId,
|
|
|
+ Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
}
|
|
|
- if (userMax.get() > 0) {
|
|
|
- if (count >= userMax.get()) {
|
|
|
- throw new BusinessException("限购" + userMax.get() + "件");
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (count >= collection.getMaxCount()) {
|
|
|
- throw new BusinessException("限购" + collection.getMaxCount() + "件");
|
|
|
- }
|
|
|
+ if (count >= userMax) {
|
|
|
+ throw new BusinessException("限购" + userMax + "件");
|
|
|
}
|
|
|
|
|
|
}
|