Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,11 @@ public interface CartRepository extends JpaRepository<Cart, Long> {
@Modifying
@Query("DELETE FROM Cart c WHERE c.user = :user AND c.product.productUuid IN :productUuids")
void deleteByUserAndProductUuidIn(@Param("user") User user, @Param("productUuids") List<java.util.UUID> productUuids);

/**
* 주문 완료 후 펀딩 장바구니에서 제거 (Funding ID 기반)
*/
@Modifying
@Query("DELETE FROM Cart c WHERE c.user = :user AND c.funding.id IN :fundingIds")
void deleteByUserAndFundingIdIn(@Param("user") User user, @Param("fundingIds") List<Long> fundingIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public List<CartResponseDto> getAllCartItems(User user, boolean validateForOrder
public void validateCartItemsForOrder(User user, boolean isFullOrder) {
List<Cart> cartItems = isFullOrder ?
cartRepository.findByUserWithProduct(user) :
cartRepository.findByUserAndIsSelectedTrue(user);
cartRepository.findByUserAndIsSelectedTrueWithProduct(user);

if (cartItems.isEmpty()) {
throw new ServiceException("CART_EMPTY", "주문할 장바구니 아이템이 없습니다.");
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/back/domain/funding/entity/Funding.java
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,19 @@ public void decreaseStock(int quantity) {
this.soldCount += quantity;
}

public void increaseStock(int quantity) {
if (quantity <= 0) {
throw new IllegalArgumentException("복원 수량은 0보다 커야 합니다.");
}
if (stock != null) {
this.stock += quantity;
}
this.soldCount -= quantity;
if (this.soldCount < 0) {
this.soldCount = 0;
}
}

public boolean hasStock(int quantity) {
return stock == null || stock >= quantity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,23 @@ public record OrderRequestDto(
) {

/**
* 주문 상품 요청 DTO
* 주문 상품 요청 DTO (NORMAL/FUNDING 통합)
*/
public record OrderItemRequestDto(
@NotNull(message = "상품 UUID는 필수입니다.")
// NORMAL 상품용 (FUNDING일 때는 null 가능)
UUID productUuid,


// FUNDING 상품용 (NORMAL일 때는 null 가능)
Long fundingId,
Integer fundingPrice,
Integer fundingStock,

@NotNull(message = "수량은 필수입니다.")
Integer quantity,

String optionInfo

String optionInfo,

// 장바구니 타입: NORMAL 또는 FUNDING
String cartType
) {}
}
Loading