|
|
@@ -218,6 +218,7 @@ public class OrderService {
|
|
|
throw new BusinessException("该藏品当前不可购买");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
AtomicInteger userMax = new AtomicInteger();
|
|
|
userPropertyRepo.findById(userId).ifPresent(userProperty -> userMax.set(userProperty.getMaxCount()));
|
|
|
|
|
|
@@ -230,9 +231,16 @@ public class OrderService {
|
|
|
count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId, Arrays
|
|
|
.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
}
|
|
|
- if (count >= userMax.addAndGet(collection.getMaxCount()) ) {
|
|
|
- throw new BusinessException("限购" + userMax.get() + "件");
|
|
|
+ if (userMax.get() > 0) {
|
|
|
+ if (count >= userMax.get()) {
|
|
|
+ throw new BusinessException("限购" + userMax.get() + "件");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (count >= collection.getMaxCount()) {
|
|
|
+ throw new BusinessException("限购" + collection.getMaxCount() + "件");
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
User user = null;
|
|
|
if (ObjectUtils.isNotEmpty(collection.getMinimumCharge()) && collection.getMinimumCharge()
|
|
|
@@ -370,7 +378,6 @@ public class OrderService {
|
|
|
|
|
|
AtomicInteger userMax = new AtomicInteger();
|
|
|
userPropertyRepo.findById(userId).ifPresent(userProperty -> userMax.set(userProperty.getMaxCount()));
|
|
|
- int limit = userMax.addAndGet(collection.getMaxCount());
|
|
|
|
|
|
if (collection.getMaxCount() > 0) {
|
|
|
if (StringUtils.isNotBlank(collection.getCountId())) {
|
|
|
@@ -382,7 +389,7 @@ public class OrderService {
|
|
|
}
|
|
|
}
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("limit", limit);
|
|
|
+ map.put("limit", userMax.get() > 0 ? userMax.get() : collection.getMaxCount());
|
|
|
map.put("count", count);
|
|
|
return map;
|
|
|
}
|