-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from Orange-Co/feature/order
Feat: implement Order APIs
- Loading branch information
Showing
18 changed files
with
366 additions
and
13 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
9 changes: 9 additions & 0 deletions
9
src/main/java/co/orange/ddanzi/common/exception/DiscountNotFoundException.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,9 @@ | ||
package co.orange.ddanzi.common.exception; | ||
|
||
import co.orange.ddanzi.common.error.Error; | ||
|
||
public class DiscountNotFoundException extends ApiException{ | ||
public DiscountNotFoundException() { | ||
super(Error.DISCOUNT_INFO_NOT_FOUND, Error.DISCOUNT_INFO_NOT_FOUND.getMessage()); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/co/orange/ddanzi/common/exception/OrderNotFoundException.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,9 @@ | ||
package co.orange.ddanzi.common.exception; | ||
|
||
import co.orange.ddanzi.common.error.Error; | ||
|
||
public class OrderNotFoundException extends ApiException { | ||
public OrderNotFoundException() { | ||
super(Error.ORDER_NOT_FOUND, Error.ORDER_NOT_FOUND.getMessage()); | ||
} | ||
} |
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
20 changes: 19 additions & 1 deletion
20
src/main/java/co/orange/ddanzi/dto/order/CreateOrderRequestDto.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 |
---|---|---|
@@ -1,13 +1,31 @@ | ||
package co.orange.ddanzi.dto.order; | ||
|
||
import co.orange.ddanzi.domain.order.Order; | ||
import co.orange.ddanzi.domain.order.enums.OrderStatus; | ||
import co.orange.ddanzi.domain.product.Item; | ||
import co.orange.ddanzi.domain.product.OptionDetail; | ||
import co.orange.ddanzi.domain.user.User; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
public class CreateOrderRequestDto { | ||
private String itemId; | ||
private String paymentId; | ||
private Long paymentId; | ||
private Long selectedOptionDetailId; | ||
private Boolean orderTerm1; | ||
private Boolean orderTerm2; | ||
private Boolean orderTerm3; | ||
|
||
public Order toOrder(String orderId, User buyer, Item item, OptionDetail optionDetail) { | ||
return Order.builder() | ||
.id(orderId) | ||
.buyer(buyer) | ||
.item(item) | ||
.selectedOptionDetail(optionDetail) | ||
.createdAt(LocalDateTime.now()) | ||
.status(OrderStatus.ORDER_PLACE) | ||
.build(); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/co/orange/ddanzi/dto/order/OrderResponseDto.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,26 @@ | ||
package co.orange.ddanzi.dto.order; | ||
|
||
|
||
import co.orange.ddanzi.domain.order.enums.OrderStatus; | ||
import co.orange.ddanzi.domain.order.enums.PayMethod; | ||
import co.orange.ddanzi.dto.AddressInfo; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@Getter | ||
@Builder | ||
public class OrderResponseDto { | ||
private String orderId; | ||
private OrderStatus orderStatus; | ||
private String productName; | ||
private String imgUrl; | ||
private Integer originPrice; | ||
private AddressInfo addressInfo; | ||
private PayMethod paymentMethod; | ||
private LocalDateTime paidAt; | ||
private Integer discountPrice; | ||
private Integer charge; | ||
private Integer totalPrice; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/co/orange/ddanzi/dto/order/UpdateOrderResponseDto.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,12 @@ | ||
package co.orange.ddanzi.dto.order; | ||
|
||
import co.orange.ddanzi.domain.order.enums.OrderStatus; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class UpdateOrderResponseDto { | ||
private String orderId; | ||
private OrderStatus orderStatus; | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/main/java/co/orange/ddanzi/repository/OrderRepository.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,7 @@ | ||
package co.orange.ddanzi.repository; | ||
|
||
import co.orange.ddanzi.domain.order.Order; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface OrderRepository extends JpaRepository<Order, String> { | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/java/co/orange/ddanzi/repository/PaymentRepository.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 |
---|---|---|
@@ -1,7 +1,13 @@ | ||
package co.orange.ddanzi.repository; | ||
|
||
import co.orange.ddanzi.domain.order.Payment; | ||
import co.orange.ddanzi.domain.product.Item; | ||
import co.orange.ddanzi.domain.user.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.data.repository.query.Param; | ||
|
||
public interface PaymentRepository extends JpaRepository<Payment, Long> { | ||
@Query("SELECT p from Payment p WHERE p.buyer = :buyer and p.item = :item and p.payStatus = 'PAID'") | ||
Payment findByBuyerAndItem(@Param("buyer") User buyer, @Param("item")Item item); | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/co/orange/ddanzi/repository/term/OrderAgreementRepository.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 co.orange.ddanzi.repository.term; | ||
|
||
import co.orange.ddanzi.domain.order.OrderAgreement; | ||
import co.orange.ddanzi.domain.order.pk.OrderAgreementId; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface OrderAgreementRepository extends JpaRepository<OrderAgreement, OrderAgreementId> { | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/co/orange/ddanzi/repository/term/TermOrderRepository.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,7 @@ | ||
package co.orange.ddanzi.repository.term; | ||
|
||
import co.orange.ddanzi.domain.term.TermOrder; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface TermOrderRepository extends JpaRepository<TermOrder, Long> { | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/co/orange/ddanzi/service/AddressService.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,40 @@ | ||
package co.orange.ddanzi.service; | ||
|
||
import co.orange.ddanzi.domain.user.Address; | ||
import co.orange.ddanzi.domain.user.User; | ||
import co.orange.ddanzi.dto.AddressInfo; | ||
import co.orange.ddanzi.dto.setting.AddressResponseDto; | ||
import co.orange.ddanzi.repository.AddressRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Service | ||
public class AddressService { | ||
private final AddressRepository addressRepository; | ||
|
||
public AddressInfo setAddressInfo(User user){ | ||
Address address = addressRepository.findByUser(user); | ||
return AddressInfo.builder() | ||
.recipient(address != null ? address.getRecipient() : null) | ||
.zipCode(address != null ? address.getZipCode() : null) | ||
.address(address != null ? address.getAddress() + " " + address.getDetailAddress() : null) | ||
.recipientPhone(address != null ? address.getRecipientPhone() : null) | ||
.build(); | ||
} | ||
|
||
public AddressResponseDto setAddressDto(User user){ | ||
Address address = addressRepository.findByUser(user); | ||
return AddressResponseDto.builder() | ||
.addressId(address != null ? address.getId() : null) | ||
.recipient(address != null ? address.getRecipient() : null) | ||
.zipCode(address != null ? address.getZipCode() : null) | ||
.type(address != null ? address.getType() : null) | ||
.address(address != null ? address.getAddress() : null) | ||
.detailAddress(address != null ? address.getDetailAddress() : null) | ||
.recipientPhone(address != null ? address.getRecipientPhone() : null) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.