-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [FEAT] 동시성을 고려하지 않은 임시 order id generator 생성 * [FEAT] DeliveryInfo 생성 로직 구현 * [FEAT] DeliveryOption (배송비, 배송방법) 관련 로직 구현 * [FEAT] 필드 변경에 따른 메서드명 변경 * [RENAME] 폴더 이동 * [REFACT] Order 에서 사용을 위한 접근제한자 변경 * [REFACT] OrderSheet 유효성 검증 로직 분리 * [FEAT] Order 생성 로직 구현 * [FEAT] Order 생성 로직에 필요한 ErrorCode 추가 * [FIX] PaymentInfo 미구현으로 인한 컴파일 에러 수정 * [FIX] 순환참조로인한 OrderPointService 분리 * [FIX] 테이블 변화로 test용 ddl 업데이트 * [FIX] DeliveryOptions 추가사항 작성
- Loading branch information
Showing
24 changed files
with
442 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...s/smrtstore/domain/orderManagement/delivery/infrastructure/DeliveryInfoJpaRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.programmers.smrtstore.domain.orderManagement.delivery.infrastructure; | ||
|
||
import com.programmers.smrtstore.domain.orderManagement.delivery.entity.DeliveryInfo; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface DeliveryInfoJpaRepository extends JpaRepository<DeliveryInfo, Long> { | ||
|
||
} |
52 changes: 52 additions & 0 deletions
52
...com/programmers/smrtstore/domain/orderManagement/order/application/OrderPointService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.programmers.smrtstore.domain.orderManagement.order.application; | ||
|
||
import static com.programmers.smrtstore.core.properties.ErrorCode.ORDER_NOT_FOUND; | ||
import static com.programmers.smrtstore.core.properties.ErrorCode.USER_NOT_FOUND; | ||
|
||
import com.programmers.smrtstore.domain.orderManagement.order.domain.entity.Order; | ||
import com.programmers.smrtstore.domain.orderManagement.order.exception.OrderException; | ||
import com.programmers.smrtstore.domain.orderManagement.order.infrastructure.OrderJpaRepository; | ||
import com.programmers.smrtstore.domain.orderManagement.order.presentation.dto.res.OrderedProductResponse; | ||
import com.programmers.smrtstore.domain.user.domain.entity.User; | ||
import com.programmers.smrtstore.domain.user.exception.UserException; | ||
import com.programmers.smrtstore.domain.user.infrastructure.UserJpaRepository; | ||
import com.programmers.smrtstore.util.DateTimeUtils; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
public class OrderPointService { | ||
private final UserJpaRepository userJpaRepository; | ||
private final OrderJpaRepository orderJpaRepository; | ||
|
||
public Integer calculateUserMonthlyTotalSpending(Long userId, int month, int year) { | ||
checkUserExistence(userId); | ||
DateTimeUtils.validateMonth(month); | ||
DateTimeUtils.validateYear(year); | ||
return orderJpaRepository.calculateMonthlyTotalSpending(userId, month, year); | ||
} | ||
|
||
public Integer getTotalPriceByOrderId(String orderId) { | ||
Order order = orderJpaRepository.findByIdIncludeDeleted(orderId) | ||
.orElseThrow(() -> new OrderException(ORDER_NOT_FOUND, String.valueOf(orderId))); | ||
return order.getTotalPrice(); | ||
} | ||
|
||
public List<OrderedProductResponse> getProductsForOrder(String orderId) { | ||
return orderJpaRepository.findByIdWithOrderSheetIncludeDeleted(orderId) | ||
.orElseThrow(() -> new OrderException(ORDER_NOT_FOUND, String.valueOf(orderId))) | ||
.getOrderSheet().getOrderedProducts().stream() | ||
.map(OrderedProductResponse::from) | ||
.toList(); | ||
} | ||
|
||
private User checkUserExistence(Long userId) { | ||
return userJpaRepository.findById(userId) | ||
.orElseThrow(() -> new UserException(USER_NOT_FOUND, String.valueOf(userId))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.