From 9afc50932cae2ee9662e5fa67b674ad832a21dc7 Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 12:20:02 +0900 Subject: [PATCH 01/15] =?UTF-8?q?[refactor]=20=EB=A9=94=EB=89=B4=20?= =?UTF-8?q?=EA=B0=80=EA=B2=A9=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EC=9D=84=20Long=20=EC=9C=BC=EB=A1=9C=20=ED=86=B5?= =?UTF-8?q?=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../camp/woowak/lab/menu/domain/Menu.java | 4 +-- .../woowak/lab/menu/domain/MenuValidator.java | 4 +-- .../store/service/command/MenuLineItem.java | 2 +- .../camp/woowak/lab/fixture/CartFixture.java | 2 +- .../java/camp/woowak/lab/menu/TestMenu.java | 2 +- .../camp/woowak/lab/menu/domain/MenuTest.java | 32 +++++++++---------- .../StoreMenuRegistrationServiceTest.java | 4 +-- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/java/camp/woowak/lab/menu/domain/Menu.java b/src/main/java/camp/woowak/lab/menu/domain/Menu.java index 9219b30b..d69cd821 100644 --- a/src/main/java/camp/woowak/lab/menu/domain/Menu.java +++ b/src/main/java/camp/woowak/lab/menu/domain/Menu.java @@ -34,7 +34,7 @@ public class Menu { private String name; @Column(nullable = false) - private Integer price; + private Long price; @Column(nullable = false) private Long stockCount; @@ -43,7 +43,7 @@ public class Menu { private String imageUrl; public Menu(Store store, MenuCategory menuCategory, String name, - Integer price, Long stockCount, String imageUrl + Long price, Long stockCount, String imageUrl ) { MenuValidator.validate(store, menuCategory, name, price, stockCount, imageUrl); this.store = store; diff --git a/src/main/java/camp/woowak/lab/menu/domain/MenuValidator.java b/src/main/java/camp/woowak/lab/menu/domain/MenuValidator.java index d6519173..086e39f9 100644 --- a/src/main/java/camp/woowak/lab/menu/domain/MenuValidator.java +++ b/src/main/java/camp/woowak/lab/menu/domain/MenuValidator.java @@ -10,7 +10,7 @@ public class MenuValidator { private static final int MAX_NAME_LENGTH = 10; public static void validate(final Store store, final MenuCategory menuCategory, final String name, - final Integer price, final Long stockCount, final String imageUrl) { + final Long price, final Long stockCount, final String imageUrl) { validateNotNull(store, menuCategory, name, price, stockCount, imageUrl); validateNotBlank(name, imageUrl); validateNameLength(name); @@ -40,7 +40,7 @@ private static void validateNameLength(final String name) { } } - private static void validatePriceNegative(final Integer price) { + private static void validatePriceNegative(final Long price) { if (price <= 0) { throw new InvalidMenuCreationException(INVALID_PRICE, "메뉴의 가격은 양수만 가능합니다. cur: " + price); } diff --git a/src/main/java/camp/woowak/lab/store/service/command/MenuLineItem.java b/src/main/java/camp/woowak/lab/store/service/command/MenuLineItem.java index af73cb87..05cd2d77 100644 --- a/src/main/java/camp/woowak/lab/store/service/command/MenuLineItem.java +++ b/src/main/java/camp/woowak/lab/store/service/command/MenuLineItem.java @@ -17,7 +17,7 @@ public record MenuLineItem( String categoryName, @NotNull(message = "음식 상품 가격은 필수값입니다.") - Integer price + Long price ) { } diff --git a/src/test/java/camp/woowak/lab/fixture/CartFixture.java b/src/test/java/camp/woowak/lab/fixture/CartFixture.java index 431bce91..f507d9ed 100644 --- a/src/test/java/camp/woowak/lab/fixture/CartFixture.java +++ b/src/test/java/camp/woowak/lab/fixture/CartFixture.java @@ -25,7 +25,7 @@ default Store createSavedStore(Long id, Vendor vendor, String name, int minOrder return new TestStore(id, vendor, name, "송파", "010-1234-5678", minOrderPrice, startTIme, endTime); } - default Menu createSavedMenu(Long id, Store store, MenuCategory menuCategory, String name, int price) { + default Menu createSavedMenu(Long id, Store store, MenuCategory menuCategory, String name, Long price) { return new TestMenu(id, store, menuCategory, name, price); } } diff --git a/src/test/java/camp/woowak/lab/menu/TestMenu.java b/src/test/java/camp/woowak/lab/menu/TestMenu.java index 7e20ee23..98edb26c 100644 --- a/src/test/java/camp/woowak/lab/menu/TestMenu.java +++ b/src/test/java/camp/woowak/lab/menu/TestMenu.java @@ -8,7 +8,7 @@ public class TestMenu extends Menu { private Long id; public TestMenu(Long id, Store store, MenuCategory menuCategory, - String name, Integer price) { + String name, Long price) { super(store, menuCategory, name, price, 50L, "imageUrl"); this.id = id; } diff --git a/src/test/java/camp/woowak/lab/menu/domain/MenuTest.java b/src/test/java/camp/woowak/lab/menu/domain/MenuTest.java index 8e3ce995..e34dff84 100644 --- a/src/test/java/camp/woowak/lab/menu/domain/MenuTest.java +++ b/src/test/java/camp/woowak/lab/menu/domain/MenuTest.java @@ -41,7 +41,7 @@ void isNull() { // when Throwable thrown = catchThrowable( - () -> new Menu(null, menuCategoryFixture, "1234", 1000, 50L, "image")); + () -> new Menu(null, menuCategoryFixture, "1234", 1000L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -61,7 +61,7 @@ void isNull() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, null, "1234", 1000, 50L, "image")); + () -> new Menu(storeFixture, null, "1234", 1000L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -77,7 +77,7 @@ class MenuName { @DisplayName("[Success] 10글자 이하만 가능하다") void success() { // given & when & then - assertThatCode(() -> new Menu(storeFixture, menuCategoryFixture, "1234567890", 1000, 50L, "image")) + assertThatCode(() -> new Menu(storeFixture, menuCategoryFixture, "1234567890", 1000L, 50L, "image")) .doesNotThrowAnyException(); } @@ -89,7 +89,7 @@ void isNull() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, null, 1000, 50L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, null, 1000L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -103,7 +103,7 @@ void isEmpty() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, "", 1000, 50L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, "", 1000L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -117,7 +117,7 @@ void isBlank() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, " ", 1000, 50L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, " ", 1000L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -131,7 +131,7 @@ void greaterThanMaxNameLength() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, "12345678901", 1000, 50L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, "12345678901", 1000L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -147,7 +147,7 @@ class MenuPrice { @DisplayName("[Success] 양수만 가능하다") void success() { // given & when & then - assertThatCode(() -> new Menu(storeFixture, menuCategoryFixture, "1234567890", 1, 50L, "image")) + assertThatCode(() -> new Menu(storeFixture, menuCategoryFixture, "1234567890", 1L, 50L, "image")) .doesNotThrowAnyException(); } @@ -173,7 +173,7 @@ void isNegative() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", -1, 50L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", -1L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -187,7 +187,7 @@ void isZero() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", 0, 50L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", 0L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -207,7 +207,7 @@ void isNull() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, null, 1000, 50L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, null, 1000L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -221,7 +221,7 @@ void isEmpty() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, "", 1000, 50L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, "", 1000L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -235,7 +235,7 @@ void isBlank() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, " ", 1000, 50L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, " ", 1000L, 50L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -254,7 +254,7 @@ void isNull() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", 1000, null, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", 1000L, null, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -268,7 +268,7 @@ void isEmpty() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", 1000, -1L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", 1000L, -1L, "image")); // then assertExceptionAndErrorCode(thrown, expected); @@ -282,7 +282,7 @@ void isBlank() { // when Throwable thrown = catchThrowable( - () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", 1000, 0L, "image")); + () -> new Menu(storeFixture, menuCategoryFixture, "메뉴이름", 1000L, 0L, "image")); // then assertExceptionAndErrorCode(thrown, expected); diff --git a/src/test/java/camp/woowak/lab/store/service/StoreMenuRegistrationServiceTest.java b/src/test/java/camp/woowak/lab/store/service/StoreMenuRegistrationServiceTest.java index 13e1cf42..18df9c86 100644 --- a/src/test/java/camp/woowak/lab/store/service/StoreMenuRegistrationServiceTest.java +++ b/src/test/java/camp/woowak/lab/store/service/StoreMenuRegistrationServiceTest.java @@ -62,7 +62,7 @@ void storeMenuRegistrationSuccess() { Long storeId = 1L; UUID vendorId = UUID.randomUUID(); List menuItems = List.of( - new MenuLineItem("메뉴1", 50L, "image1.jpg", "카테고리1", 10000) + new MenuLineItem("메뉴1", 50L, "image1.jpg", "카테고리1", 10000L) ); StoreMenuRegistrationCommand request = new StoreMenuRegistrationCommand(vendorId, storeId, menuItems); @@ -88,7 +88,7 @@ void storeMenuRegistrationStoreNotFound() { Long storeId = 1L; UUID vendorId = UUID.randomUUID(); List menuItems = List.of( - new MenuLineItem("메뉴1", 50L, "image1.jpg", "카테고리1", 10000) + new MenuLineItem("메뉴1", 50L, "image1.jpg", "카테고리1", 10000L) ); StoreMenuRegistrationCommand command = new StoreMenuRegistrationCommand(vendorId, storeId, menuItems); From 88a1ac2fc53d54cf40226e22578e6a79425d682f Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 12:24:18 +0900 Subject: [PATCH 02/15] =?UTF-8?q?[refactor]=20=EB=A9=94=EB=89=B4=20?= =?UTF-8?q?=EA=B0=80=EA=B2=A9=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EC=9D=84=20Long=20=EC=9C=BC=EB=A1=9C=20=ED=86=B5?= =?UTF-8?q?=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/camp/woowak/lab/cart/domain/CartTest.java | 12 ++++++------ .../woowak/lab/cart/service/CartServiceTest.java | 14 +++++++------- .../lab/web/api/cart/CartApiControllerTest.java | 14 +++++++------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/test/java/camp/woowak/lab/cart/domain/CartTest.java b/src/test/java/camp/woowak/lab/cart/domain/CartTest.java index a69a4586..e7fdf774 100644 --- a/src/test/java/camp/woowak/lab/cart/domain/CartTest.java +++ b/src/test/java/camp/woowak/lab/cart/domain/CartTest.java @@ -42,7 +42,7 @@ void setUp() { store = createSavedStore(1L, vendor, "중화반점", minPrice, LocalDateTime.now().minusMinutes(10).withSecond(0).withNano(0), LocalDateTime.now().plusMinutes(10).withSecond(0).withNano(0)); - menu = createSavedMenu(1L, store, new MenuCategory(store, "중식"), "짜장면", 9000); + menu = createSavedMenu(1L, store, new MenuCategory(store, "중식"), "짜장면", 9000L); } @Nested @@ -67,7 +67,7 @@ void storeNotOpenExceptionTest() { Store closedStore = createSavedStore(2L, vendor, "closed", minPrice, LocalDateTime.now().minusMinutes(30).withSecond(0).withNano(0), LocalDateTime.now().minusMinutes(10).withSecond(0).withNano(0)); - Menu closedMenu = createSavedMenu(2L, closedStore, new MenuCategory(closedStore, "중식"), "짬뽕", 9000); + Menu closedMenu = createSavedMenu(2L, closedStore, new MenuCategory(closedStore, "중식"), "짬뽕", 9000L); //when & then assertThatThrownBy(() -> cart.addMenu(closedMenu)) @@ -84,7 +84,7 @@ void otherStoreMenuExceptionTest() { Store otherStore = createSavedStore(2L, vendor, "closed", minPrice, LocalDateTime.now().minusMinutes(30).withSecond(0).withNano(0), LocalDateTime.now().plusMinutes(30).withSecond(0).withNano(0)); - Menu otherStoreMenu = createSavedMenu(2L, otherStore, new MenuCategory(otherStore, "중식"), "짬뽕", 9000); + Menu otherStoreMenu = createSavedMenu(2L, otherStore, new MenuCategory(otherStore, "중식"), "짬뽕", 9000L); //when & then assertThatThrownBy(() -> cart.addMenu(otherStoreMenu)) @@ -114,15 +114,15 @@ void getTotalPriceWithEmptyList() { void getTotalPriceTest() { //given MenuCategory menuCategory = new MenuCategory(store, "중식"); - int price1 = 1000; + Long price1 = 1000L; Menu menu1 = createSavedMenu(2L, store, menuCategory, "짜장면1", price1); cart.addMenu(menu1); - int price2 = 2000; + Long price2 = 2000L; Menu menu2 = createSavedMenu(3L, store, menuCategory, "짬뽕1", price2); cart.addMenu(menu2); - int price3 = Integer.MAX_VALUE; + Long price3 = Long.MAX_VALUE; Menu menu3 = createSavedMenu(4L, store, menuCategory, "황제정식", price3); cart.addMenu(menu3); diff --git a/src/test/java/camp/woowak/lab/cart/service/CartServiceTest.java b/src/test/java/camp/woowak/lab/cart/service/CartServiceTest.java index 51919fa5..b8319c22 100644 --- a/src/test/java/camp/woowak/lab/cart/service/CartServiceTest.java +++ b/src/test/java/camp/woowak/lab/cart/service/CartServiceTest.java @@ -81,7 +81,7 @@ void setUp() { menuCategory = createMenuCategory(store, "중식"); - menu = createMenu(store, menuCategory, "짜장면", 90000); + menu = createMenu(store, menuCategory, "짜장면", 90000L); } @Nested @@ -123,7 +123,7 @@ void throwExceptionWhenAddMenuInCartWithClosedStoresMenu() { LocalDateTime endTime = LocalDateTime.now().minusMinutes(1).withSecond(0).withNano(0); Store closedStore = createStore(vendor, "오픈 전의 중화반점", 8000, startTime, endTime); MenuCategory closedMenuCategory = createMenuCategory(closedStore, "닫힌 카테고리"); - Menu menu = createMenu(closedStore, closedMenuCategory, "닫힌 가게의 메뉴", 1000); + Menu menu = createMenu(closedStore, closedMenuCategory, "닫힌 가게의 메뉴", 1000L); AddCartCommand command = new AddCartCommand(customer.getId().toString(), menu.getId()); @@ -138,7 +138,7 @@ void throwExceptionWhenAddMenuInCartWithOtherStoresMenu() { //given Store otherStore = createStore(vendor, "다른집", 8000, startTime, endTime); MenuCategory otherMenuCategory = createMenuCategory(otherStore, "다른집 카테고리"); - Menu otherStoresMenu = createMenu(otherStore, otherMenuCategory, "다른집 짜장면", 9000); + Menu otherStoresMenu = createMenu(otherStore, otherMenuCategory, "다른집 짜장면", 9000L); AddCartCommand command1 = new AddCartCommand(customer.getId().toString(), menu.getId()); cartService.addMenu(command1); @@ -173,15 +173,15 @@ void getTotalPriceWithEmptyList() { @DisplayName("현재 장바구니에 담긴 모든 메뉴의 총 금액을 return 받는다.") void getTotalPriceTest() { //given - int price1 = 1000; + Long price1 = 1000L; Menu menu1 = createMenu(store, menuCategory, "짜장면1", price1); cartService.addMenu(new AddCartCommand(customer.getId().toString(), menu1.getId())); - int price2 = 2000; + Long price2 = 2000L; Menu menu2 = createMenu(store, menuCategory, "짬뽕1", price2); cartService.addMenu(new AddCartCommand(customer.getId().toString(), menu2.getId())); - int price3 = Integer.MAX_VALUE; + Long price3 = Long.MAX_VALUE; Menu menu3 = createMenu(store, menuCategory, "황제정식", price3); cartService.addMenu(new AddCartCommand(customer.getId().toString(), menu3.getId())); @@ -201,7 +201,7 @@ private MenuCategory createMenuCategory(Store store, String name) { return menuCategoryRepository.saveAndFlush(menuCategory1); } - private Menu createMenu(Store store, MenuCategory menuCategory, String name, int price) { + private Menu createMenu(Store store, MenuCategory menuCategory, String name, Long price) { Menu menu1 = new Menu(store, menuCategory, name, price, 1L, "imageUrl"); menuRepository.saveAndFlush(menu1); diff --git a/src/test/java/camp/woowak/lab/web/api/cart/CartApiControllerTest.java b/src/test/java/camp/woowak/lab/web/api/cart/CartApiControllerTest.java index b47b97e9..92bc79dd 100644 --- a/src/test/java/camp/woowak/lab/web/api/cart/CartApiControllerTest.java +++ b/src/test/java/camp/woowak/lab/web/api/cart/CartApiControllerTest.java @@ -100,7 +100,7 @@ class AddMenu { @BeforeEach void setUp() throws Exception { - menu = createMenu(store, menuCategory, "짜장면", 90000); + menu = createMenu(store, menuCategory, "짜장면", 90000L); } @Test @@ -143,7 +143,7 @@ void cantAddMenuWithClosedStoresMenu() throws Exception { LocalDateTime closedEndTime = LocalDateTime.now().minusMinutes(1).withSecond(0).withNano(0); Store closedStore = createStore(vendor, "닫힌 가게", minOrderPrice, closedStartTime, closedEndTime); MenuCategory closedStoreMenuCategory = createMenuCategory(closedStore, "닫힌 카테고리"); - Menu closedStoresMenu = createMenu(closedStore, closedStoreMenuCategory, "닫힌 가게의 메뉴", 1000); + Menu closedStoresMenu = createMenu(closedStore, closedStoreMenuCategory, "닫힌 가게의 메뉴", 1000L); AddCartRequest request = new AddCartRequest(closedStoresMenu.getId()); String content = mapper.writeValueAsString(request); @@ -164,7 +164,7 @@ void cantAddMenuWithOtherStoresMenu() throws Exception { //given Store otherStore = createStore(vendor, "옆집 가게", minOrderPrice, startTime, endTime); MenuCategory otherStoreMenuCategory = createMenuCategory(otherStore, "옆집 카테고리"); - Menu otherStoreMenu = createMenu(otherStore, otherStoreMenuCategory, "옆집 가게 메뉴", 10000); + Menu otherStoreMenu = createMenu(otherStore, otherStoreMenuCategory, "옆집 가게 메뉴", 10000L); AddCartRequest givenRequest = new AddCartRequest(menu.getId()); String givenContent = mapper.writeValueAsString(givenRequest); @@ -212,15 +212,15 @@ void getTotalPriceTest() throws Exception { //given Cart cart = new Cart(customer.getId().toString()); - int price1 = 1000; + Long price1 = 1000L; Menu menu1 = createMenu(store, menuCategory, "짜장면1", price1); cart.addMenu(menu1); - int price2 = 2000; + Long price2 = 2000L; Menu menu2 = createMenu(store, menuCategory, "짬뽕1", price2); cart.addMenu(menu2); - int price3 = Integer.MAX_VALUE; + Long price3 = Long.MAX_VALUE; Menu menu3 = createMenu(store, menuCategory, "황제정식", price3); cart.addMenu(menu3); cartRepository.save(cart); @@ -241,7 +241,7 @@ private MenuCategory createMenuCategory(Store store, String name) { return menuCategoryRepository.saveAndFlush(menuCategory); } - private Menu createMenu(Store store, MenuCategory menuCategory, String name, int price) { + private Menu createMenu(Store store, MenuCategory menuCategory, String name, Long price) { Menu menu1 = new Menu(store, menuCategory, name, price, 1L, "imageUrl"); menuRepository.saveAndFlush(menu1); From 2f5494bcea61da45572bc666eab5aff2a2b17a6c Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 20:32:29 +0900 Subject: [PATCH 03/15] =?UTF-8?q?[feat]=20=EB=AA=A8=EB=93=A0=20=EC=A0=90?= =?UTF-8?q?=EC=A3=BC=EB=A5=BC=20=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OrderPaymentAdjustmentService.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java diff --git a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java new file mode 100644 index 00000000..96dd0dd1 --- /dev/null +++ b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java @@ -0,0 +1,40 @@ +package camp.woowak.lab.payment.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import camp.woowak.lab.menu.repository.MenuRepository; +import camp.woowak.lab.payment.repository.OrderPaymentRepository; +import camp.woowak.lab.vendor.domain.Vendor; +import camp.woowak.lab.vendor.exception.NotFoundVendorException; +import camp.woowak.lab.vendor.repository.VendorRepository; +import lombok.RequiredArgsConstructor; + +/** + * 정산을 담당하는 서비스 + */ +@Service +@RequiredArgsConstructor +public class OrderPaymentAdjustmentService { + + private final VendorRepository vendorRepository; + private final MenuRepository menuRepository; + private final OrderPaymentRepository orderPaymentRepository; + + /** + * @throws NotFoundVendorException vendorId에 해당하는 점주를 찾을 수 없을 떄 + */ + @Transactional + public void adjustment() { + // 1. 모든 점주 조회 + List vendors = findAllVendors(); + } + + // 모든 점주 조회 + private List findAllVendors() { + return vendorRepository.findAll(); + } + +} From ddfd06f77bdf0e28918ff1fbe02edcc01ac6bb88 Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 20:34:15 +0900 Subject: [PATCH 04/15] =?UTF-8?q?[feat]=20=EA=B0=81=20=EC=A0=90=EC=A3=BC?= =?UTF-8?q?=EC=9D=98=20=EC=A0=95=EC=82=B0=ED=95=B4=EC=95=BC=ED=95=A0=20Ord?= =?UTF-8?q?erPayment=20=EB=AA=A9=EB=A1=9D=EC=9D=84=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/OrderPaymentAdjustmentService.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java index 96dd0dd1..09ca4105 100644 --- a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java +++ b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java @@ -6,6 +6,8 @@ import org.springframework.transaction.annotation.Transactional; import camp.woowak.lab.menu.repository.MenuRepository; +import camp.woowak.lab.payment.domain.OrderPayment; +import camp.woowak.lab.payment.domain.OrderPaymentStatus; import camp.woowak.lab.payment.repository.OrderPaymentRepository; import camp.woowak.lab.vendor.domain.Vendor; import camp.woowak.lab.vendor.exception.NotFoundVendorException; @@ -30,6 +32,10 @@ public class OrderPaymentAdjustmentService { public void adjustment() { // 1. 모든 점주 조회 List vendors = findAllVendors(); + for (Vendor vendor : vendors) { + // 2. 각 점주의 정산해야할 OrderPayment 목록을 조회 + List orderPayments = findOrderPaymentsToAdjustment(vendor); + } } // 모든 점주 조회 @@ -37,4 +43,12 @@ private List findAllVendors() { return vendorRepository.findAll(); } + // 각 점주의 정산해야할 OrderPayment 목록을 조회 + private List findOrderPaymentsToAdjustment(final Vendor vendor) { + List orderPayments = orderPaymentRepository.findByRecipientIdAndOrderPaymentStatus( + vendor.getId(), OrderPaymentStatus.ORDER_SUCCESS); + + return orderPayments; + } + } From 7bbacc67014e5cdef420c3b2b0a4ccbe3a5c54d7 Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 20:37:29 +0900 Subject: [PATCH 05/15] =?UTF-8?q?[feat]=20PointPayment=20->=20OrderPayment?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=9E=90=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lab/payment/domain/OrderPayment.java | 53 +++++++++++++++++++ .../lab/payment/domain/PointPayment.java | 24 --------- 2 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java delete mode 100644 src/main/java/camp/woowak/lab/payment/domain/PointPayment.java diff --git a/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java b/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java new file mode 100644 index 00000000..150796e8 --- /dev/null +++ b/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java @@ -0,0 +1,53 @@ +package camp.woowak.lab.payment.domain; + +import java.time.LocalDateTime; + +import camp.woowak.lab.customer.domain.Customer; +import camp.woowak.lab.order.domain.Order; +import camp.woowak.lab.vendor.domain.Vendor; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class OrderPayment { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + private Order order; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "sendor_id", nullable = false) + private Customer sender; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "recipient_id", nullable = false) + private Vendor recipient; + + @Enumerated(value = EnumType.STRING) + private OrderPaymentStatus orderPaymentStatus; + + private LocalDateTime createdAt; + + public OrderPayment(Order order, Customer sender, Vendor recipient, + OrderPaymentStatus orderPaymentStatus, LocalDateTime createdAt + ) { + this.order = order; + this.sender = sender; + this.recipient = recipient; + this.orderPaymentStatus = orderPaymentStatus; + this.createdAt = createdAt; + } + +} diff --git a/src/main/java/camp/woowak/lab/payment/domain/PointPayment.java b/src/main/java/camp/woowak/lab/payment/domain/PointPayment.java deleted file mode 100644 index f0d46b2d..00000000 --- a/src/main/java/camp/woowak/lab/payment/domain/PointPayment.java +++ /dev/null @@ -1,24 +0,0 @@ -package camp.woowak.lab.payment.domain; - -import camp.woowak.lab.customer.domain.Customer; -import camp.woowak.lab.order.domain.Order; -import camp.woowak.lab.vendor.domain.Vendor; -import jakarta.persistence.Entity; -import jakarta.persistence.FetchType; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.ManyToOne; - -@Entity -public class PointPayment { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - @ManyToOne(fetch = FetchType.LAZY) - private Order order; - @ManyToOne(fetch = FetchType.LAZY) - private Customer sender; - @ManyToOne(fetch = FetchType.LAZY) - private Vendor recipient; -} From 8e4af08e2276822150da961546baab08a6f44c40 Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 20:39:06 +0900 Subject: [PATCH 06/15] =?UTF-8?q?[feat]=20=EC=A0=95=EC=82=B0=ED=95=B4?= =?UTF-8?q?=EC=95=BC=ED=95=A0=20OrderPayment=20=EA=B0=80=20=EC=98=AC?= =?UTF-8?q?=EB=B0=94=EB=A5=B8=EC=A7=80=20=EA=B2=80=EC=A6=9D=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Vendor가 동일한지 검증 - OrderPaymentStatus 상태 검증 --- .../woowak/lab/payment/domain/OrderPayment.java | 15 +++++++++++++++ .../service/OrderPaymentAdjustmentService.java | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java b/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java index 150796e8..948c05b8 100644 --- a/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java +++ b/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java @@ -50,4 +50,19 @@ public OrderPayment(Order order, Customer sender, Vendor recipient, this.createdAt = createdAt; } + public void validateReadyToAdjustment(final Vendor adjustmentTarget) { + if (isEqualsRecipient(adjustmentTarget) && orderPaymentStatusIsSuccess()) { + return; + } + throw new IllegalArgumentException(); + } + + private boolean isEqualsRecipient(Vendor recipient) { + return this.recipient.equals(recipient); + } + + private boolean orderPaymentStatusIsSuccess() { + return this.orderPaymentStatus.equals(OrderPaymentStatus.ORDER_SUCCESS); + } + } diff --git a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java index 09ca4105..8c1ecf23 100644 --- a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java +++ b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java @@ -48,6 +48,11 @@ private List findOrderPaymentsToAdjustment(final Vendor vendor) { List orderPayments = orderPaymentRepository.findByRecipientIdAndOrderPaymentStatus( vendor.getId(), OrderPaymentStatus.ORDER_SUCCESS); + for (OrderPayment orderPayment : orderPayments) { + // 정산해야할 OrderPayment 가 맞는지 검증 + orderPayment.validateReadyToAdjustment(vendor); + } + return orderPayments; } From 30b60e8b2848e02f4bc76f0b74ffbb91c18259bf Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 21:05:47 +0900 Subject: [PATCH 07/15] =?UTF-8?q?[feat]=20OrderPayment=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=EC=9D=98=20OrderPaymentStatus=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EB=A5=BC=20ADJUSTMENT=5FSUCCESS=20=EB=A1=9C=20=EA=B0=B1?= =?UTF-8?q?=EC=8B=A0=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/service/OrderPaymentAdjustmentService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java index 8c1ecf23..c49f985b 100644 --- a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java +++ b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java @@ -35,6 +35,9 @@ public void adjustment() { for (Vendor vendor : vendors) { // 2. 각 점주의 정산해야할 OrderPayment 목록을 조회 List orderPayments = findOrderPaymentsToAdjustment(vendor); + + // 6. 송금을 성공하면, OrderPayment 목록의 OrderPaymentStatus 상태를 ADJUSTMENT_SUCCESS 로 갱신 + updateOrderPaymentStatus(orderPayments); } } @@ -56,4 +59,11 @@ private List findOrderPaymentsToAdjustment(final Vendor vendor) { return orderPayments; } + // OrderPayment 목록의 OrderPaymentStatus 상태를 ADJUSTMENT_SUCCESS 로 갱신 + private void updateOrderPaymentStatus(List orderPayments) { + orderPaymentRepository.updateOrderPaymentStatus( + orderPayments.stream().map(OrderPayment::getId).toList(), + OrderPaymentStatus.ADJUSTMENT_SUCCESS); + } + } From 7b0ed7e3412b99a6feb649253803e9f78ec32375 Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 21:08:33 +0900 Subject: [PATCH 08/15] =?UTF-8?q?[style]=20=EC=A3=BC=EB=AC=B8=20=EA=B8=88?= =?UTF-8?q?=EC=95=A1=20=EC=A0=95=EC=82=B0=20=EA=B8=B0=EB=8A=A5=20=EB=BC=88?= =?UTF-8?q?=EB=8C=80=20=EC=BD=94=EB=93=9C=20TODO=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OrderPaymentAdjustmentService.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java index c49f985b..8c3367df 100644 --- a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java +++ b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java @@ -6,6 +6,7 @@ import org.springframework.transaction.annotation.Transactional; import camp.woowak.lab.menu.repository.MenuRepository; +import camp.woowak.lab.order.domain.OrderItem; import camp.woowak.lab.payment.domain.OrderPayment; import camp.woowak.lab.payment.domain.OrderPaymentStatus; import camp.woowak.lab.payment.repository.OrderPaymentRepository; @@ -36,6 +37,14 @@ public void adjustment() { // 2. 각 점주의 정산해야할 OrderPayment 목록을 조회 List orderPayments = findOrderPaymentsToAdjustment(vendor); + // 3. 각 OrderPayment 의 Order 주문 금액을 계산 + Long totalOrderPrice = calculateTotalOrderPrice(orderPayments); + + // 4. 총 주문 금액에서 수수료 5%를 계산 + Double commission = calculateCommission(totalOrderPrice); + + // 5. 수수료를 제외한 금액을 점주에게 송금 + // 6. 송금을 성공하면, OrderPayment 목록의 OrderPaymentStatus 상태를 ADJUSTMENT_SUCCESS 로 갱신 updateOrderPaymentStatus(orderPayments); } @@ -59,6 +68,27 @@ private List findOrderPaymentsToAdjustment(final Vendor vendor) { return orderPayments; } + // TODO: OrderPayment 목록의 Order 총 주문 금액을 계산한다. + // 메뉴의 가격은 계속 바뀔 수 있어서, 정산 시점에 주문 - 메뉴 정보로 금액을 다시 계산하는 부분이 제약이 있음 + private long calculateTotalOrderPrice(final List orderPayments) { + Long totalOrderPrice = 0L; + + return totalOrderPrice; + } + + // TODO: 각 OrderPayment 의 Order 주문 금액을 계산한다. + private Long calculateOrderPrice(List orderItems) { + long totalOrderPrice = 0L; + + return totalOrderPrice; + } + + // 총 주문 금액에서 수수료 5%를 계산한다. + private Double calculateCommission(Long totalOrderPrice) { + + return 0.0; + } + // OrderPayment 목록의 OrderPaymentStatus 상태를 ADJUSTMENT_SUCCESS 로 갱신 private void updateOrderPaymentStatus(List orderPayments) { orderPaymentRepository.updateOrderPaymentStatus( From 94293b3360d1b8cc7b9db1e7a4795d63155ecd58 Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 21:18:50 +0900 Subject: [PATCH 09/15] =?UTF-8?q?[feat]=20VendorId=EC=99=80=20OrderPayment?= =?UTF-8?q?Status=20=EA=B8=B0=EC=A4=80=EC=9C=BC=EB=A1=9C=20OrderPayment=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=EC=9D=84=20=EC=A1=B0=ED=9A=8C=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repository/OrderPaymentRepository.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/camp/woowak/lab/payment/repository/OrderPaymentRepository.java diff --git a/src/main/java/camp/woowak/lab/payment/repository/OrderPaymentRepository.java b/src/main/java/camp/woowak/lab/payment/repository/OrderPaymentRepository.java new file mode 100644 index 00000000..8887bbba --- /dev/null +++ b/src/main/java/camp/woowak/lab/payment/repository/OrderPaymentRepository.java @@ -0,0 +1,21 @@ +package camp.woowak.lab.payment.repository; + +import java.util.List; +import java.util.UUID; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import camp.woowak.lab.payment.domain.OrderPayment; +import camp.woowak.lab.payment.domain.OrderPaymentStatus; + +public interface OrderPaymentRepository extends JpaRepository { + + @Query("SELECT op FROM OrderPayment op " + + "WHERE op.recipient.id = :recipientId " + + "AND op.orderPaymentStatus = :orderPaymentStatus") + List findByRecipientIdAndOrderPaymentStatus(@Param("recipientId") UUID recipientId, + @Param("orderPaymentStatus") OrderPaymentStatus orderPaymentStatus); + +} From 0388fad9ebae752f91e4b4003ffc2a470433a825 Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 21:20:38 +0900 Subject: [PATCH 10/15] =?UTF-8?q?[feat]=20OrderPaymentStatus=20=EB=A5=BC?= =?UTF-8?q?=20=EC=9D=BC=EA=B4=84=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - clearAutomatically 옵션 true 설정 영속성 컨텍스트에서 관리하는 엔티티와 DB 데이터의 동기화 이슈를 예방하기 위함 --- .../lab/payment/repository/OrderPaymentRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/camp/woowak/lab/payment/repository/OrderPaymentRepository.java b/src/main/java/camp/woowak/lab/payment/repository/OrderPaymentRepository.java index 8887bbba..d2661bd9 100644 --- a/src/main/java/camp/woowak/lab/payment/repository/OrderPaymentRepository.java +++ b/src/main/java/camp/woowak/lab/payment/repository/OrderPaymentRepository.java @@ -4,6 +4,7 @@ import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -18,4 +19,10 @@ public interface OrderPaymentRepository extends JpaRepository findByRecipientIdAndOrderPaymentStatus(@Param("recipientId") UUID recipientId, @Param("orderPaymentStatus") OrderPaymentStatus orderPaymentStatus); + @Modifying(clearAutomatically = true) + @Query("UPDATE OrderPayment op " + + "SET op.orderPaymentStatus = :newStatus " + + "WHERE op.id IN :ids") + int updateOrderPaymentStatus(@Param("ids") List ids, @Param("newStatus") OrderPaymentStatus newStatus); + } From 9eff555771c12c6bc663b62dc3627cb00a4d8cdd Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 21:21:00 +0900 Subject: [PATCH 11/15] =?UTF-8?q?[feat]=20OrderPaymentStatus=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20Enum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../camp/woowak/lab/payment/domain/OrderPaymentStatus.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/camp/woowak/lab/payment/domain/OrderPaymentStatus.java diff --git a/src/main/java/camp/woowak/lab/payment/domain/OrderPaymentStatus.java b/src/main/java/camp/woowak/lab/payment/domain/OrderPaymentStatus.java new file mode 100644 index 00000000..81851325 --- /dev/null +++ b/src/main/java/camp/woowak/lab/payment/domain/OrderPaymentStatus.java @@ -0,0 +1,6 @@ +package camp.woowak.lab.payment.domain; + +public enum OrderPaymentStatus { + ORDER_SUCCESS, + ADJUSTMENT_SUCCESS, +} From 87885dca0f5a5f3f6b990686fd87addf63475ba3 Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 21:21:14 +0900 Subject: [PATCH 12/15] =?UTF-8?q?[feat]=20@Getter=20Lombok=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java b/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java index 948c05b8..e7cf7967 100644 --- a/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java +++ b/src/main/java/camp/woowak/lab/payment/domain/OrderPayment.java @@ -15,10 +15,12 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import lombok.AccessLevel; +import lombok.Getter; import lombok.NoArgsConstructor; @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) +@Getter public class OrderPayment { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) From b6549fa6ecf7f7499ff8c0c4bf54a2c7f91537af Mon Sep 17 00:00:00 2001 From: june-777 Date: Fri, 16 Aug 2024 21:22:10 +0900 Subject: [PATCH 13/15] =?UTF-8?q?[style]=20=EC=97=90=EB=9F=AC=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/camp/woowak/lab/menu/exception/MenuErrorCode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/camp/woowak/lab/menu/exception/MenuErrorCode.java b/src/main/java/camp/woowak/lab/menu/exception/MenuErrorCode.java index 8d72c39f..b52f6a08 100644 --- a/src/main/java/camp/woowak/lab/menu/exception/MenuErrorCode.java +++ b/src/main/java/camp/woowak/lab/menu/exception/MenuErrorCode.java @@ -16,7 +16,8 @@ public enum MenuErrorCode implements ErrorCode { INVALID_PRICE(HttpStatus.BAD_REQUEST, "m_6", "메뉴의 가격 범위를 벗어났습니다."), INVALID_STOCK_COUNT(HttpStatus.BAD_REQUEST, "m_7", "메뉴의 재고 개수는 1개 이상이어야 합니다."), - NOT_FOUND_MENU_CATEGORY(HttpStatus.BAD_REQUEST, "M3", "메뉴 카테고리를 찾을 수 없습니다."); + NOT_FOUND_MENU(HttpStatus.BAD_REQUEST, "m_8", "메뉴를 찾을 수 없습니다."), + NOT_FOUND_MENU_CATEGORY(HttpStatus.BAD_REQUEST, "m_9", "메뉴 카테고리를 찾을 수 없습니다."); private final int status; private final String errorCode; From 203ee1139cacb3d161cc469bbb5089cfb05a15bb Mon Sep 17 00:00:00 2001 From: june-777 Date: Sat, 17 Aug 2024 23:35:16 +0900 Subject: [PATCH 14/15] =?UTF-8?q?[fix]=20=EC=A3=BC=EB=AC=B8=20=EA=B0=80?= =?UTF-8?q?=EA=B2=A9=20=ED=83=80=EC=9E=85=EC=9D=84=20long=20=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD=ED=95=98=EC=97=AC=20=EC=BB=B4?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/camp/woowak/lab/order/domain/vo/OrderItem.java | 8 ++++---- src/test/java/camp/woowak/lab/cart/domain/CartTest.java | 6 +++--- .../woowak/lab/order/domain/WithdrawPointServiceTest.java | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/camp/woowak/lab/order/domain/vo/OrderItem.java b/src/main/java/camp/woowak/lab/order/domain/vo/OrderItem.java index 89098567..cbcd6a60 100644 --- a/src/main/java/camp/woowak/lab/order/domain/vo/OrderItem.java +++ b/src/main/java/camp/woowak/lab/order/domain/vo/OrderItem.java @@ -5,21 +5,21 @@ @Embeddable public class OrderItem { private Long menuId; - private int price; + private long price; private int quantity; - private int totalPrice; + private long totalPrice; protected OrderItem() { } - public OrderItem(Long menuId, int price, int quantity) { + public OrderItem(Long menuId, long price, int quantity) { this.menuId = menuId; this.price = price; this.quantity = quantity; this.totalPrice = price * quantity; } - public int getTotalPrice() { + public long getTotalPrice() { return totalPrice; } } diff --git a/src/test/java/camp/woowak/lab/cart/domain/CartTest.java b/src/test/java/camp/woowak/lab/cart/domain/CartTest.java index db4189db..735eb883 100644 --- a/src/test/java/camp/woowak/lab/cart/domain/CartTest.java +++ b/src/test/java/camp/woowak/lab/cart/domain/CartTest.java @@ -43,7 +43,7 @@ void setUp() { store = createSavedStore(1L, vendor, "중화반점", minPrice, LocalDateTime.now().minusMinutes(10).withSecond(0).withNano(0), LocalDateTime.now().plusMinutes(10).withSecond(0).withNano(0)); - menu = createSavedMenu(1L, store, new MenuCategory(store, "중식"), "짜장면", 9000); + menu = createSavedMenu(1L, store, new MenuCategory(store, "중식"), "짜장면", 9000L); } @Nested @@ -70,7 +70,7 @@ void storeNotOpenExceptionTest() { Store closedStore = createSavedStore(2L, vendor, "closed", minPrice, LocalDateTime.now().minusMinutes(30).withSecond(0).withNano(0), LocalDateTime.now().minusMinutes(10).withSecond(0).withNano(0)); - Menu closedMenu = createSavedMenu(2L, closedStore, new MenuCategory(closedStore, "중식"), "짬뽕", 9000); + Menu closedMenu = createSavedMenu(2L, closedStore, new MenuCategory(closedStore, "중식"), "짬뽕", 9000L); //when & then assertThatThrownBy(() -> cart.addMenu(closedMenu)) @@ -87,7 +87,7 @@ void otherStoreMenuExceptionTest() { Store otherStore = createSavedStore(2L, vendor, "otherStore", minPrice, LocalDateTime.now().minusMinutes(30).withSecond(0).withNano(0), LocalDateTime.now().plusMinutes(30).withSecond(0).withNano(0)); - Menu otherStoreMenu = createSavedMenu(2L, otherStore, new MenuCategory(otherStore, "중식"), "짬뽕", 9000); + Menu otherStoreMenu = createSavedMenu(2L, otherStore, new MenuCategory(otherStore, "중식"), "짬뽕", 9000L); //when & then assertThatThrownBy(() -> cart.addMenu(otherStoreMenu)) diff --git a/src/test/java/camp/woowak/lab/order/domain/WithdrawPointServiceTest.java b/src/test/java/camp/woowak/lab/order/domain/WithdrawPointServiceTest.java index f98ec0cc..426a56fa 100644 --- a/src/test/java/camp/woowak/lab/order/domain/WithdrawPointServiceTest.java +++ b/src/test/java/camp/woowak/lab/order/domain/WithdrawPointServiceTest.java @@ -54,8 +54,8 @@ void withdraw_ValidPayAccount_WithdrawsPointsSuccessfully() { OrderItem orderItem1 = mock(OrderItem.class); OrderItem orderItem2 = mock(OrderItem.class); - when(orderItem1.getTotalPrice()).thenReturn(500); - when(orderItem2.getTotalPrice()).thenReturn(1500); + when(orderItem1.getTotalPrice()).thenReturn(500L); + when(orderItem2.getTotalPrice()).thenReturn(1500L); List orderItems = List.of(orderItem1, orderItem2); From 71a034926e65a96d4acba1503868292bacad4c4b Mon Sep 17 00:00:00 2001 From: june-777 Date: Sat, 17 Aug 2024 23:35:32 +0900 Subject: [PATCH 15/15] =?UTF-8?q?[fix]=20OrderItem=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EC=9D=B4=EB=8F=99=20=EB=B3=80=EA=B2=BD=EC=82=AC?= =?UTF-8?q?=ED=95=AD=20=EB=B0=98=EC=98=81=ED=95=98=EC=97=AC=20=EC=BB=B4?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lab/payment/service/OrderPaymentAdjustmentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java index 8c3367df..8e58592e 100644 --- a/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java +++ b/src/main/java/camp/woowak/lab/payment/service/OrderPaymentAdjustmentService.java @@ -6,7 +6,7 @@ import org.springframework.transaction.annotation.Transactional; import camp.woowak.lab.menu.repository.MenuRepository; -import camp.woowak.lab.order.domain.OrderItem; +import camp.woowak.lab.order.domain.vo.OrderItem; import camp.woowak.lab.payment.domain.OrderPayment; import camp.woowak.lab.payment.domain.OrderPaymentStatus; import camp.woowak.lab.payment.repository.OrderPaymentRepository;