Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/main/java/com/back/domain/cart/entity/Cart.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,14 @@ public boolean isValid() {
if (this.funding == null) {
return false;
}
Integer fundingStockFromEntity = this.funding.getStock();
int availableStock = (this.fundingStock != null)
// 재고 null = 무제한, 0 이하는 품절
Integer availableStock = (this.fundingStock != null)
? this.fundingStock
: (fundingStockFromEntity != null ? fundingStockFromEntity : 0);
: this.funding.getStock();

if (availableStock == null) {
return true; // 무제한 재고로 간주
}
if (availableStock <= 0) {
return false;
}
Expand All @@ -157,10 +160,11 @@ public boolean isValid() {
return false;
}
Integer productStock = this.product.getStock();
if (productStock == null || productStock <= 0) {
// 재고 null = 무제한, 0 이하는 품절
if (productStock != null && productStock <= 0) {
return false;
}
return this.quantity <= productStock;
return productStock == null || this.quantity <= productStock;
}

// 총 가격 계산 (null-safe)
Expand Down