|
|
@@ -221,7 +221,7 @@ public class OrderService {
|
|
|
AtomicInteger userMax = new AtomicInteger();
|
|
|
userPropertyRepo.findById(userId).ifPresent(userProperty -> userMax.set(userProperty.getMaxCount()));
|
|
|
|
|
|
- if (userMax.addAndGet(collection.getMaxCount()) > 0) {
|
|
|
+ if (collection.getMaxCount() > 0) {
|
|
|
int count;
|
|
|
if (StringUtils.isNotBlank(collection.getCountId())) {
|
|
|
count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(), Arrays
|
|
|
@@ -230,8 +230,8 @@ public class OrderService {
|
|
|
count = orderRepo.countByUserIdAndCollectionIdAndStatusIn(userId, collectionId, Arrays
|
|
|
.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|
|
|
}
|
|
|
- if (count >= collection.getMaxCount()) {
|
|
|
- throw new BusinessException("限购" + collection.getMaxCount() + "件");
|
|
|
+ if (count >= userMax.addAndGet(collection.getMaxCount()) ) {
|
|
|
+ throw new BusinessException("限购" + userMax.get() + "件");
|
|
|
}
|
|
|
}
|
|
|
User user = null;
|
|
|
@@ -365,13 +365,14 @@ public class OrderService {
|
|
|
|
|
|
public Object checkLimit(Long collectionId, Long userId) {
|
|
|
Collection collection = collectionRepo.findById(collectionId).orElseThrow(new BusinessException("藏品不存在"));
|
|
|
- int limit = collection.getMaxCount();
|
|
|
+
|
|
|
int count = 0;
|
|
|
|
|
|
AtomicInteger userMax = new AtomicInteger();
|
|
|
userPropertyRepo.findById(userId).ifPresent(userProperty -> userMax.set(userProperty.getMaxCount()));
|
|
|
+ int limit = userMax.addAndGet(collection.getMaxCount());
|
|
|
|
|
|
- if (userMax.addAndGet(collection.getMaxCount()) > 0) {
|
|
|
+ if (collection.getMaxCount() > 0) {
|
|
|
if (StringUtils.isNotBlank(collection.getCountId())) {
|
|
|
count = orderRepo.countByUserIdAndCountIdAndStatusIn(userId, collection.getCountId(),
|
|
|
Arrays.asList(OrderStatus.FINISH, OrderStatus.NOT_PAID, OrderStatus.PROCESSING));
|