From 59e849968e3eed85b1b98d0b84866756ad701c94 Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Wed, 22 Nov 2023 12:04:56 +0900 Subject: [PATCH 01/80] =?UTF-8?q?Fix:=20=EC=98=A4=EB=A5=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test_merge.yml | 30 +++++++++---------- .../src/order/dto/OrderMapper.java | 2 +- src/main/resources/application.properties | 25 ++++++++-------- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/.github/workflows/test_merge.yml b/.github/workflows/test_merge.yml index 8af0d40..e6b1b5b 100644 --- a/.github/workflows/test_merge.yml +++ b/.github/workflows/test_merge.yml @@ -29,20 +29,20 @@ jobs: - name: remove plain.jar run: rm -rf build/libs/*plain.jar - - name: file copy - uses: actions/upload-artifact@v3 - with: - name: libs - path: build/libs - deploy: - needs: build - runs-on: ubuntu-latest - steps: - - name: file download - uses: actions/download-artifact@v3 - with: - name: libs - path: libs + # - name: file copy + # uses: actions/upload-artifact@v3 + # with: + # name: libs + # path: build/libs + # deploy: + # needs: build + # runs-on: ubuntu-latest + # steps: + # - name: file download + # uses: actions/download-artifact@v3 + # with: + # name: libs + # path: libs - name: Upload to Cloudflare env: AWS_ACCESS_KEY_ID: ${{ secrets.CF_ACCESS_KEY_ID }} @@ -51,7 +51,7 @@ jobs: BUCKET_NAME: ${{ secrets.CF_BUCKET_NAME }} ENDPOINT_URL: ${{ secrets.CF_ENDPOINT_URL }} run: | - aws s3 sync libs/ s3://$BUCKET_NAME/java/main/test \ + aws s3 sync build/libs/ s3://$BUCKET_NAME/java/main/test \ --endpoint-url $ENDPOINT_URL --delete --exact-timestamps - name: SSH and deploy diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index c16ea04..620d596 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -128,7 +128,7 @@ private CartDto cartItemToCartDto(CartItem cartItem, Long inout) { .count(cartItem.getCount()) // img .imgUrl(cartItem.getFoodie().getImgUrl() != null - ? IMG_URL + cartItem.getFoodie().getImgUrl() + "/" + ? IMG_URL + cartItem.getFoodie().getFoodieCategory().getStore().getEngName() + "/" + cartItem.getFoodie().getImgUrl() : null) .totalPrice(cartItemTotalPrice(cartItem, inout)) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8e59010..fce25f1 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,21 +1,26 @@ -spring.datasource.url=jdbc:mysql://localhost:3306/readyvery -spring.datasource.username=root -spring.datasource.password=12345678 +spring.datasource.url=jdbc:mysql://test.readyvery.com:33306/readyvery +spring.datasource.username=ready +spring.datasource.password=readyverytestuser23! spring.jpa.hibernate.ddl-auto=update spring.jpa.generate-ddl=true -spring.jpa.show-sql=true spring.jackson.serialization.fail-on-empty-beans=false +#payment +##tosspay +payment.toss.client_key=test_ck_pP2YxJ4K87By0b4RZeo0rRGZwXLO +payment.toss.secret_key=test_sk_pP2YxJ4K87BbBaQPDwEJrRGZwXLO +payment.toss.success_url=https://test.readyvery.com/api/v1/order/toss/success +payment.toss.fail_url=https://test.readyvery.com/api/v1/order/toss/fail # JWT Configuration jwt.secretKey=Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkw jwt.access.expiration=86400 jwt.access.cookie=accessToken jwt.refresh.expiration=604800 jwt.refresh.cookie=refreshToken -jwt.redirect-uri=http://localhost:3000/login +jwt.redirect-uri=https://test.readyvery.com/login # Kakao spring.security.oauth2.client.registration.kakao.client-id=f5153d4ff1ef221bc332da3ccfec5e81 spring.security.oauth2.client.registration.kakao.client-secret=E1YuDOXrG22kymEaB53kqRYvMJrt4z5f -spring.security.oauth2.client.registration.kakao.redirect-uri=http://localhost:8080/login/oauth2/code/kakao +spring.security.oauth2.client.registration.kakao.redirect-uri=https://test.readyvery.com/login/oauth2/code/kakao spring.security.oauth2.client.registration.kakao.client-authentication-method=client_secret_post spring.security.oauth2.client.registration.kakao.authorization-grant-type=authorization_code spring.security.oauth2.client.registration.kakao.scope=profile_nickname, profile_image, account_email, phone_number, age_range, birthday @@ -23,10 +28,4 @@ spring.security.oauth2.client.registration.kakao.client-name=Kakao spring.security.oauth2.client.provider.kakao.authorization-uri=https://kauth.kakao.com/oauth/authorize spring.security.oauth2.client.provider.kakao.token-uri=https://kauth.kakao.com/oauth/token spring.security.oauth2.client.provider.kakao.user-info-uri=https://kapi.kakao.com/v2/user/me -spring.security.oauth2.client.provider.kakao.user-name-attribute=id -#payment -##tosspay -payment.toss.client_key=test_ck_pP2YxJ4K87By0b4RZeo0rRGZwXLO -payment.toss.secret_key=test_sk_pP2YxJ4K87BbBaQPDwEJrRGZwXLO -payment.toss.success_url=http://localhost:8080/api/v1/order/toss/success -payment.toss.fail_url=http://localhost:8080/api/v1/order/toss/fail +spring.security.oauth2.client.provider.kakao.user-name-attribute=id \ No newline at end of file From 2b579b02383eb9ca142071ed49727feb1e765837 Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Wed, 22 Nov 2023 12:06:34 +0900 Subject: [PATCH 02/80] =?UTF-8?q?Fix:=20=ED=94=84=EB=A1=9C=ED=8D=BC?= =?UTF-8?q?=ED=8B=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.properties | 25 ++++++++++++----------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index fce25f1..8e59010 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,26 +1,21 @@ -spring.datasource.url=jdbc:mysql://test.readyvery.com:33306/readyvery -spring.datasource.username=ready -spring.datasource.password=readyverytestuser23! +spring.datasource.url=jdbc:mysql://localhost:3306/readyvery +spring.datasource.username=root +spring.datasource.password=12345678 spring.jpa.hibernate.ddl-auto=update spring.jpa.generate-ddl=true +spring.jpa.show-sql=true spring.jackson.serialization.fail-on-empty-beans=false -#payment -##tosspay -payment.toss.client_key=test_ck_pP2YxJ4K87By0b4RZeo0rRGZwXLO -payment.toss.secret_key=test_sk_pP2YxJ4K87BbBaQPDwEJrRGZwXLO -payment.toss.success_url=https://test.readyvery.com/api/v1/order/toss/success -payment.toss.fail_url=https://test.readyvery.com/api/v1/order/toss/fail # JWT Configuration jwt.secretKey=Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkw jwt.access.expiration=86400 jwt.access.cookie=accessToken jwt.refresh.expiration=604800 jwt.refresh.cookie=refreshToken -jwt.redirect-uri=https://test.readyvery.com/login +jwt.redirect-uri=http://localhost:3000/login # Kakao spring.security.oauth2.client.registration.kakao.client-id=f5153d4ff1ef221bc332da3ccfec5e81 spring.security.oauth2.client.registration.kakao.client-secret=E1YuDOXrG22kymEaB53kqRYvMJrt4z5f -spring.security.oauth2.client.registration.kakao.redirect-uri=https://test.readyvery.com/login/oauth2/code/kakao +spring.security.oauth2.client.registration.kakao.redirect-uri=http://localhost:8080/login/oauth2/code/kakao spring.security.oauth2.client.registration.kakao.client-authentication-method=client_secret_post spring.security.oauth2.client.registration.kakao.authorization-grant-type=authorization_code spring.security.oauth2.client.registration.kakao.scope=profile_nickname, profile_image, account_email, phone_number, age_range, birthday @@ -28,4 +23,10 @@ spring.security.oauth2.client.registration.kakao.client-name=Kakao spring.security.oauth2.client.provider.kakao.authorization-uri=https://kauth.kakao.com/oauth/authorize spring.security.oauth2.client.provider.kakao.token-uri=https://kauth.kakao.com/oauth/token spring.security.oauth2.client.provider.kakao.user-info-uri=https://kapi.kakao.com/v2/user/me -spring.security.oauth2.client.provider.kakao.user-name-attribute=id \ No newline at end of file +spring.security.oauth2.client.provider.kakao.user-name-attribute=id +#payment +##tosspay +payment.toss.client_key=test_ck_pP2YxJ4K87By0b4RZeo0rRGZwXLO +payment.toss.secret_key=test_sk_pP2YxJ4K87BbBaQPDwEJrRGZwXLO +payment.toss.success_url=http://localhost:8080/api/v1/order/toss/success +payment.toss.fail_url=http://localhost:8080/api/v1/order/toss/fail From 8906620e0124002dd3cc46c00b45e66cf7ce1f88 Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Wed, 22 Nov 2023 12:17:21 +0900 Subject: [PATCH 03/80] =?UTF-8?q?Feat:=20=EA=B0=80=EA=B2=8C=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/store/StoreController.java | 7 +++++++ .../readyverydemo/src/store/StoreService.java | 3 +++ .../readyverydemo/src/store/StoreServiceImpl.java | 7 +++++++ .../readyverydemo/src/store/dto/StoreEventRes.java | 10 ++++++++++ .../readyverydemo/src/store/dto/StoreMapper.java | 6 ++++++ 5 files changed, 33 insertions(+) create mode 100644 src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreEventRes.java diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/StoreController.java b/src/main/java/com/readyvery/readyverydemo/src/store/StoreController.java index 82eec3b..00264c9 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/StoreController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/StoreController.java @@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RestController; import com.readyvery.readyverydemo.src.store.dto.StoreDetailRes; +import com.readyvery.readyverydemo.src.store.dto.StoreEventRes; import com.readyvery.readyverydemo.src.store.dto.StoreMenuRes; import lombok.RequiredArgsConstructor; @@ -29,4 +30,10 @@ public ResponseEntity getStoreMenu(@PathVariable("storeId") Long s StoreMenuRes storeMenuRes = storeService.getStoreMenu(storeId); return new ResponseEntity<>(storeMenuRes, HttpStatus.OK); } + + @GetMapping("/{storeId}/event") + public ResponseEntity getStoreEvent(@PathVariable("storeId") Long storeId) { + StoreEventRes storeEvent = storeService.getStoreEvent(storeId); + return new ResponseEntity<>(storeEvent, HttpStatus.OK); + } } diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/StoreService.java b/src/main/java/com/readyvery/readyverydemo/src/store/StoreService.java index fcf161c..362607b 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/StoreService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/StoreService.java @@ -1,10 +1,13 @@ package com.readyvery.readyverydemo.src.store; import com.readyvery.readyverydemo.src.store.dto.StoreDetailRes; +import com.readyvery.readyverydemo.src.store.dto.StoreEventRes; import com.readyvery.readyverydemo.src.store.dto.StoreMenuRes; public interface StoreService { StoreDetailRes getStoreDetail(Long storeId); StoreMenuRes getStoreMenu(Long storeId); + + StoreEventRes getStoreEvent(Long storeId); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/StoreServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/store/StoreServiceImpl.java index e524783..b12288b 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/StoreServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/StoreServiceImpl.java @@ -7,6 +7,7 @@ import com.readyvery.readyverydemo.global.exception.BusinessLogicException; import com.readyvery.readyverydemo.global.exception.ExceptionCode; import com.readyvery.readyverydemo.src.store.dto.StoreDetailRes; +import com.readyvery.readyverydemo.src.store.dto.StoreEventRes; import com.readyvery.readyverydemo.src.store.dto.StoreMapper; import com.readyvery.readyverydemo.src.store.dto.StoreMenuRes; @@ -35,4 +36,10 @@ public StoreMenuRes getStoreMenu(Long storeId) { return storeMapper.storeToStoreMenuRes(store); } + @Override + public StoreEventRes getStoreEvent(Long storeId) { + Store store = getStore(storeId); + return storeMapper.storeToStoreEventRes(store); + } + } diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreEventRes.java b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreEventRes.java new file mode 100644 index 0000000..c7bd9be --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreEventRes.java @@ -0,0 +1,10 @@ +package com.readyvery.readyverydemo.src.store.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class StoreEventRes { + private String eventImgUrl; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java index 6cb4a2c..c502133 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java @@ -56,4 +56,10 @@ private MenuItemDto foodieToMenuItems(Foodie foodie) { .hit(foodie.isHit()) .build(); } + + public StoreEventRes storeToStoreEventRes(Store store) { + return StoreEventRes.builder() + .eventImgUrl(store.getAdImgUrl()) + .build(); + } } From a02587efa00b7afe8c389ed5791adf86dfbbf4ee Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Wed, 22 Nov 2023 14:43:18 +0900 Subject: [PATCH 04/80] =?UTF-8?q?Feat:=20=ED=85=8C=EC=9D=B4=ED=81=AC=20?= =?UTF-8?q?=EC=95=84=EC=9B=83=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/readyvery/readyverydemo/domain/Order.java | 3 +++ .../readyvery/readyverydemo/src/order/OrderServiceImpl.java | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Order.java b/src/main/java/com/readyvery/readyverydemo/domain/Order.java index beeb015..81bdab6 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Order.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Order.java @@ -75,6 +75,9 @@ public class Order extends BaseTimeEntity { @Column private LocalDateTime estimatedTime; + @Column + private Long inOut; + // 가게 아이템 연관 관계 // @OneToMany(mappedBy = "order") // @Builder.Default diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 7f25ec3..82649c6 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -163,7 +163,7 @@ public TosspaymentMakeRes requestTossPayment(CustomUserDetails userDetails, Paym // Long amount = calculateAmount(store, paymentReq.getCarts(), paymentReq.getInout()); Long amount = calculateAmount2(cart, paymentReq.getInout()); //TODO: 쿠폰 추가 - Order order = makeOrder(user, store, amount, cart); + Order order = makeOrder(user, store, amount, cart, paymentReq.getInout()); cartOrder(cart); orderRepository.save(order); cartRepository.save(cart); @@ -278,7 +278,7 @@ private HttpHeaders makeTossHeader() { return headers; } - private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart) { + private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Long inout) { if (cart.getCartItems().isEmpty()) { throw new BusinessLogicException(ExceptionCode.CART_NOT_FOUND); } @@ -296,6 +296,7 @@ private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart) { .totalAmount(amount) .orderNumber(null) .progress(Progress.REQUEST) + .inOut(inout) .build(); } From 6e134486efb0bd6075b352321518abddf7c1d273 Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Wed, 22 Nov 2023 15:11:18 +0900 Subject: [PATCH 05/80] =?UTF-8?q?Fix:=20url=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/store/dto/StoreMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java index c502133..0f27300 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java @@ -59,7 +59,7 @@ private MenuItemDto foodieToMenuItems(Foodie foodie) { public StoreEventRes storeToStoreEventRes(Store store) { return StoreEventRes.builder() - .eventImgUrl(store.getAdImgUrl()) + .eventImgUrl("/images/" + store.getEngName() + "/" + store.getAdImgUrl()) .build(); } } From 314bb6e11be212b6c08b37239a83a9f08d791e01 Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Thu, 23 Nov 2023 14:46:10 +0900 Subject: [PATCH 06/80] =?UTF-8?q?Feat:=20=EA=B2=B0=EC=A0=9C=20=EC=B7=A8?= =?UTF-8?q?=EC=86=8C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/domain/Receipt.java | 2 + .../readyverydemo/global/Constant.java | 1 + .../global/exception/ExceptionCode.java | 4 +- .../src/order/OrderController.java | 8 +++ .../readyverydemo/src/order/OrderService.java | 3 + .../src/order/OrderServiceImpl.java | 61 +++++++++++++++++++ .../src/order/config/TossPaymentConfig.java | 1 + .../src/order/dto/DefaultRes.java | 10 +++ .../src/order/dto/OrderMapper.java | 6 ++ .../src/order/dto/TossCancelReq.java | 8 +++ 10 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/readyvery/readyverydemo/src/order/dto/DefaultRes.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/order/dto/TossCancelReq.java diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Receipt.java b/src/main/java/com/readyvery/readyverydemo/domain/Receipt.java index 2c1ce4a..a666c99 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Receipt.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Receipt.java @@ -12,9 +12,11 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; @Getter +@Setter @Entity @Builder @Table(name = "RECEIPT") diff --git a/src/main/java/com/readyvery/readyverydemo/global/Constant.java b/src/main/java/com/readyvery/readyverydemo/global/Constant.java index bf932a4..9aff2e9 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/Constant.java +++ b/src/main/java/com/readyvery/readyverydemo/global/Constant.java @@ -5,4 +5,5 @@ public class Constant { public static final Long TAKE_OUT = 2L; public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm"; public static final String IMG_URL = "/images/"; + public static final String USER_CANCEL_RESON = "단순 변심"; } diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index 8f70a77..1738ad7 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -17,8 +17,8 @@ public enum ExceptionCode { TOSS_PAYMENT_SUCCESS_FAIL(400, "Toss payment success fail."), ORDER_NOT_FOUND(400, "Order does not exists."), TOSS_PAYMENT_AMOUNT_NOT_MATCH(400, "Toss payment amount not match."), - ORDER_NOT_CURRENT(400, "Order is not current."); - + ORDER_NOT_CURRENT(400, "Order is not current."), + ORDER_NOT_CANCELABLE(400, "Order is not cancelable."); private int status; private String message; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index 2f44874..c3b8b08 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -27,6 +27,7 @@ import com.readyvery.readyverydemo.src.order.dto.FoodyDetailRes; import com.readyvery.readyverydemo.src.order.dto.HistoryRes; import com.readyvery.readyverydemo.src.order.dto.PaymentReq; +import com.readyvery.readyverydemo.src.order.dto.TossCancelReq; import com.readyvery.readyverydemo.src.order.dto.TosspaymentMakeRes; import lombok.RequiredArgsConstructor; @@ -97,6 +98,13 @@ public ResponseEntity requestTossPayment(@AuthenticationPrin return new ResponseEntity<>(tosspaymentMakeRes, HttpStatus.OK); } + @PostMapping("/toss/cancel") + public ResponseEntity cancelTossPayment(@AuthenticationPrincipal CustomUserDetails userDetails, + @RequestBody TossCancelReq tossCancelReq) { + Object result = orderService.cancelTossPayment(userDetails, tossCancelReq); + return new ResponseEntity<>(result, HttpStatus.OK); + } + @PutMapping("/cart") public ResponseEntity updateCart(@AuthenticationPrincipal CustomUserDetails userDetails, @RequestBody CartEditReq cartEditReq) { diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java index 48bca2e..2f16ffa 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -15,6 +15,7 @@ import com.readyvery.readyverydemo.src.order.dto.FoodyDetailRes; import com.readyvery.readyverydemo.src.order.dto.HistoryRes; import com.readyvery.readyverydemo.src.order.dto.PaymentReq; +import com.readyvery.readyverydemo.src.order.dto.TossCancelReq; import com.readyvery.readyverydemo.src.order.dto.TosspaymentMakeRes; public interface OrderService { @@ -39,4 +40,6 @@ public interface OrderService { HistoryRes getHistories(CustomUserDetails userDetails); CurrentRes getCurrent(String orderId); + + Object cancelTossPayment(CustomUserDetails userDetails, TossCancelReq tossCancelReq); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 7f25ec3..0f1bc65 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -1,5 +1,7 @@ package com.readyvery.readyverydemo.src.order; +import static com.readyvery.readyverydemo.global.Constant.*; + import java.nio.charset.StandardCharsets; import java.util.Base64; import java.util.Collections; @@ -55,6 +57,7 @@ import com.readyvery.readyverydemo.src.order.dto.HistoryRes; import com.readyvery.readyverydemo.src.order.dto.OrderMapper; import com.readyvery.readyverydemo.src.order.dto.PaymentReq; +import com.readyvery.readyverydemo.src.order.dto.TossCancelReq; import com.readyvery.readyverydemo.src.order.dto.TosspaymentDto; import com.readyvery.readyverydemo.src.order.dto.TosspaymentMakeRes; @@ -209,6 +212,64 @@ public CurrentRes getCurrent(String orderId) { return orderMapper.orderToCurrentRes(order); } + @Override + public Object cancelTossPayment(CustomUserDetails userDetails, TossCancelReq tossCancelReq) { + UserInfo user = getUserInfo(userDetails); + Order order = getOrder(tossCancelReq.getOrderId()); + verifyCancel(order, user); + + TosspaymentDto tosspaymentDto = requestTossPaymentCancel(order.getPaymentKey()); + + applyCancelTosspaymentDto(order, tosspaymentDto); + + orderRepository.save(order); + + return orderMapper.tosspaymentDtoToCancelRes(); + } + + private void applyCancelTosspaymentDto(Order order, TosspaymentDto tosspaymentDto) { + order.setProgress(Progress.CANCEL); + order.setPayStatus(false); + order.getReceipt().setCancels(tosspaymentDto.getCancels().toString()); + order.getReceipt().setStatus(tosspaymentDto.getStatus()); + } + + private TosspaymentDto requestTossPaymentCancel(String paymentKey) { + RestTemplate restTemplate = new RestTemplate(); + HttpHeaders headers = makeTossHeader(); + JSONObject params = new JSONObject(); + + params.put("cancelReason", USER_CANCEL_RESON); + + try { + return restTemplate.postForObject(TossPaymentConfig.PAYMENT_URL + paymentKey + "/cancel", + new HttpEntity<>(params, headers), + TosspaymentDto.class); + } catch (Exception e) { + System.out.println("e.getMessage() = " + e.getMessage()); + throw new BusinessLogicException(ExceptionCode.TOSS_PAYMENT_SUCCESS_FAIL); + } + } + + private void verifyCancel(Order order, UserInfo user) { + verifyCancelStatus(order); + verifyOrederUser(order, user); + } + + private void verifyOrederUser(Order order, UserInfo user) { + if (order.getUserInfo().equals(user)) { + return; + } + throw new BusinessLogicException(ExceptionCode.ORDER_NOT_CANCELABLE); + } + + private void verifyCancelStatus(Order order) { + if (order.getProgress().equals(Progress.ORDER)) { + return; + } + throw new BusinessLogicException(ExceptionCode.ORDER_NOT_CANCELABLE); + } + private void verifyOrderCurrent(Order order) { if (order.getProgress().equals(Progress.ORDER) || order.getProgress().equals(Progress.MAKE) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/config/TossPaymentConfig.java b/src/main/java/com/readyvery/readyverydemo/src/order/config/TossPaymentConfig.java index 1534597..0110a6f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/config/TossPaymentConfig.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/config/TossPaymentConfig.java @@ -8,6 +8,7 @@ @Configuration @Getter public class TossPaymentConfig { + public static final String PAYMENT_URL = "https://api.tosspayments.com/v1/payments/"; public static final String CONFIRM_URL = "https://api.tosspayments.com/v1/payments/confirm"; @Value("${payment.toss.client_key}") diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/DefaultRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/DefaultRes.java new file mode 100644 index 0000000..20d995d --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/DefaultRes.java @@ -0,0 +1,10 @@ +package com.readyvery.readyverydemo.src.order.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class DefaultRes { + private String message; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 620d596..8d7201d 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -245,4 +245,10 @@ public CurrentRes orderToCurrentRes(Order order) { ? order.getEstimatedTime().format(DateTimeFormatter.ofPattern(TIME_FORMAT)) : null) .build(); } + + public DefaultRes tosspaymentDtoToCancelRes() { + return DefaultRes.builder() + .message("취소 성공") + .build(); + } } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/TossCancelReq.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/TossCancelReq.java new file mode 100644 index 0000000..8b59d42 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/TossCancelReq.java @@ -0,0 +1,8 @@ +package com.readyvery.readyverydemo.src.order.dto; + +import lombok.Getter; + +@Getter +public class TossCancelReq { + private String orderId; +} From 990559dafa11ab0444321fb22c53af4f1cbc3392 Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Thu, 23 Nov 2023 15:00:14 +0900 Subject: [PATCH 07/80] =?UTF-8?q?Fix:=20=EB=B9=8C=EB=93=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/OrderServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 0f1bc65..56145a6 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -223,7 +223,6 @@ public Object cancelTossPayment(CustomUserDetails userDetails, TossCancelReq tos applyCancelTosspaymentDto(order, tosspaymentDto); orderRepository.save(order); - return orderMapper.tosspaymentDtoToCancelRes(); } From 3df6240fe2372bf531783c04c89aea65524d9a5d Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Thu, 23 Nov 2023 15:14:42 +0900 Subject: [PATCH 08/80] =?UTF-8?q?Fix:=20cart=20order=20=EB=A7=A4=ED=95=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/readyvery/readyverydemo/domain/Cart.java | 5 ++--- .../java/com/readyvery/readyverydemo/domain/Order.java | 2 +- .../readyverydemo/domain/repository/CartRepository.java | 3 ++- .../readyverydemo/src/order/OrderServiceImpl.java | 8 +++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java index 3fffc68..d3ac2d5 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java @@ -13,7 +13,6 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; -import jakarta.persistence.OneToOne; import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -57,8 +56,8 @@ public class Cart extends BaseTimeEntity { @Builder.Default private Boolean isDeleted = false; - @OneToOne(mappedBy = "cart") - private Order order; + @OneToMany(mappedBy = "cart") + private List orders = new ArrayList(); // 장바구니 장바구니 아이템 연관관계 매핑 @Builder.Default diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Order.java b/src/main/java/com/readyvery/readyverydemo/domain/Order.java index beeb015..9f90d5a 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Order.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Order.java @@ -90,7 +90,7 @@ public class Order extends BaseTimeEntity { @JoinColumn(name = "user_idx") private UserInfo userInfo; - @OneToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "cart_idx") private Cart cart; diff --git a/src/main/java/com/readyvery/readyverydemo/domain/repository/CartRepository.java b/src/main/java/com/readyvery/readyverydemo/domain/repository/CartRepository.java index e2cd86f..7e88389 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/repository/CartRepository.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/repository/CartRepository.java @@ -8,5 +8,6 @@ import com.readyvery.readyverydemo.domain.UserInfo; public interface CartRepository extends JpaRepository { - Optional findByUserInfoAndIsDeletedFalse(UserInfo userInfo); + Optional findByUserInfoAndIsDeletedFalseAndIsOrderedFalse(UserInfo userInfo); + } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 0f1bc65..6b7d38f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -96,7 +96,8 @@ public CartAddRes addCart(CustomUserDetails userDetails, CartAddReq cartAddReq) verifyFoodieInStore(store, foodie); verifyCartAddReq(foodie, cartAddReq); - Cart cart = cartRepository.findByUserInfoAndIsDeletedFalse(user).orElseGet(() -> makeCart(user, store)); + Cart cart = cartRepository.findByUserInfoAndIsDeletedFalseAndIsOrderedFalse(user) + .orElseGet(() -> makeCart(user, store)); verifyItemsInCart(cart, store); CartItem cartItem = makeCartItem(cart, foodie, cartAddReq.getCount()); List cartOptions = cartAddReq.getOptions().stream() @@ -223,7 +224,7 @@ public Object cancelTossPayment(CustomUserDetails userDetails, TossCancelReq tos applyCancelTosspaymentDto(order, tosspaymentDto); orderRepository.save(order); - + return orderMapper.tosspaymentDtoToCancelRes(); } @@ -352,6 +353,7 @@ private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart) { .store(store) .amount(amount) .orderId(UUID.randomUUID().toString()) + .cart(cart) .paymentKey(null) .orderName(orderName) .totalAmount(amount) @@ -397,7 +399,7 @@ private void resetCartItem(Cart cart) { } private Cart getCart(UserInfo user) { - return cartRepository.findByUserInfoAndIsDeletedFalse(user).orElseThrow( + return cartRepository.findByUserInfoAndIsDeletedFalseAndIsOrderedFalse(user).orElseThrow( () -> new BusinessLogicException(ExceptionCode.CART_NOT_FOUND) ); } From 2c039016e53f2e4ab8c937060b0e39597317f70d Mon Sep 17 00:00:00 2001 From: 1223v <1223v@naver.com> Date: Fri, 24 Nov 2023 22:46:09 +0900 Subject: [PATCH 09/80] =?UTF-8?q?Config:=20jwt=20=EC=BF=A0=ED=82=A4=20?= =?UTF-8?q?=EB=8F=84=EB=A9=94=EC=9D=B8=20@value=EB=A1=9C=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/config/SpringSecurityConfig.java | 3 ++- .../security/jwt/service/JwtService.java | 14 +++++++++++--- .../readyverydemo/src/board/dto/BoardMapper.java | 15 ++++++++++++++- src/main/resources/application.properties | 2 ++ 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java b/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java index 59d3c15..c692a03 100644 --- a/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java +++ b/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java @@ -59,7 +59,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { "/login", "/api/v1/store/**", "/api/v1/board/**", - "/api/v1/order/current" + "/api/v1/order/current", + "/api/v1/auth" ).permitAll() // 위를 제외한 나머지는 모두 허용 .anyRequest().authenticated() // 해당 요청은 인증이 필요함 ) diff --git a/src/main/java/com/readyvery/readyverydemo/security/jwt/service/JwtService.java b/src/main/java/com/readyvery/readyverydemo/security/jwt/service/JwtService.java index 7e94fbf..5623b92 100644 --- a/src/main/java/com/readyvery/readyverydemo/security/jwt/service/JwtService.java +++ b/src/main/java/com/readyvery/readyverydemo/security/jwt/service/JwtService.java @@ -50,6 +50,10 @@ public class JwtService { private String refreshCookie; @Value("${jwt.redirect-uri}") private String frontendUrl; + @Value("${jwt.access.cookie.domain}") + private String accessCookieDomain; + @Value("${jwt.refresh.cookie.domain}") + private String refreshCookieDomain; /** * AccessToken 생성 메소드 @@ -154,6 +158,8 @@ public void setAccessTokenCookie(HttpServletResponse response, String accessToke //accessTokenCookie.setHttpOnly(true); // JavaScript가 쿠키를 읽는 것을 방지 accessTokenCookie.setPath("/"); // 쿠키 경로 설정 + accessTokenCookie.setDomain(accessCookieDomain); + // 필요한 경우 Secure 플래그 설정 (HTTPS에서만 쿠키 전송) //accessTokenCookie.setSecure(true); @@ -171,11 +177,13 @@ public void setAccessTokenCookie(HttpServletResponse response, String accessToke /** * RefreshToken 헤더 설정 */ - public void setRefreshTokenCookie(HttpServletResponse response, String accessToken) { - Cookie refreshTokenCookie = new Cookie(refreshCookie, accessToken); // 쿠키 생성 + public void setRefreshTokenCookie(HttpServletResponse response, String refreshToken) { + Cookie refreshTokenCookie = new Cookie(refreshCookie, refreshToken); // 쿠키 생성 refreshTokenCookie.setHttpOnly(true); // JavaScript가 쿠키를 읽는 것을 방지 refreshTokenCookie.setPath("/api/v1/refresh/token"); // 쿠키 경로 설정 + refreshTokenCookie.setDomain(refreshCookieDomain); + // 필요한 경우 Secure 플래그 설정 (HTTPS에서만 쿠키 전송) // accessTokenCookie.setSecure(true); @@ -183,7 +191,7 @@ public void setRefreshTokenCookie(HttpServletResponse response, String accessTok // accessTokenCookie.setSameSite("Strict"); // 쿠키 만료 시간 설정 (예: 액세스 토큰 만료 시간과 같게 설정) - refreshTokenCookie.setMaxAge(accessTokenExpirationPeriod.intValue()); // 초 단위로 설정 + refreshTokenCookie.setMaxAge(refreshTokenExpirationPeriod.intValue()); // 초 단위로 설정 response.addCookie(refreshTokenCookie); // 응답에 쿠키 추가 } diff --git a/src/main/java/com/readyvery/readyverydemo/src/board/dto/BoardMapper.java b/src/main/java/com/readyvery/readyverydemo/src/board/dto/BoardMapper.java index 4b1b5f7..60cca00 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/board/dto/BoardMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/board/dto/BoardMapper.java @@ -30,7 +30,20 @@ public BoardSearchRes toBoardSearchRes(List stores) { throw new BusinessLogicException(ExceptionCode.STORE_NOT_FOUND); } return BoardSearchRes.builder() - .stores(stores.stream().map(this::toStoreDto).toList()) + .stores(stores.stream().map(this::toSearchStoreDto).toList()) + .build(); + } + + private StoreDto toSearchStoreDto(Store store) { + return StoreDto.builder() + .idx(store.getId()) + .name(store.getName()) + .address(store.getAddress()) + .imgUrl(store.getImgs().stream() + .filter(storeImg -> storeImg.getImgSize().equals(ImgSize.CAFE_LOGO)) + .findFirst() + .map(storeImg -> IMG_URL + store.getEngName() + "/" + storeImg.getImgUrl()) + .orElse(null)) .build(); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 2078b44..bd2b58a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -15,6 +15,8 @@ jwt.access.cookie=accessToken jwt.refresh.expiration=604800 jwt.refresh.cookie=refreshToken jwt.redirect-uri=http://localhost:3000/login +jwt.access.cookie.domain=localhost +jwt.refresh.cookie.domain=localhost # Kakao spring.security.oauth2.client.registration.kakao.client-id=f5153d4ff1ef221bc332da3ccfec5e81 spring.security.oauth2.client.registration.kakao.client-secret=E1YuDOXrG22kymEaB53kqRYvMJrt4z5f From 454fa47e6c6c2bb76fc404b8a8062dfe4a5cb0fa Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Fri, 24 Nov 2023 22:47:46 +0900 Subject: [PATCH 10/80] =?UTF-8?q?Feat:=20coupon=20domain=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/domain/Cart.java | 1 + .../readyverydemo/domain/CouponDetail.java | 16 ++++++++++++---- .../readyverydemo/domain/CouponMenu.java | 4 ---- .../readyvery/readyverydemo/domain/Foodie.java | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java index d3ac2d5..e1c444b 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java @@ -56,6 +56,7 @@ public class Cart extends BaseTimeEntity { @Builder.Default private Boolean isDeleted = false; + @Builder.Default @OneToMany(mappedBy = "cart") private List orders = new ArrayList(); diff --git a/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java b/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java index 2157f16..7fad25d 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java @@ -46,7 +46,15 @@ public class CouponDetail extends BaseTimeEntity { @Column private LocalDateTime expire; - // 발행처 레디베리 발행(0) / 사장님 발행(ceo_idx) + // 쿠폰 코드 + @Column(name = "coupon_code") + private String couponCode; + + // 발급 갯수 + @Column(name = "coupon_count") + private Long couponCount; + + // 발행처 레디베리 발행(0) / 사장님 발행(store_idx) @Column private Long publisher; @@ -54,9 +62,9 @@ public class CouponDetail extends BaseTimeEntity { @JoinColumn(name = "event_idx") private Event event; - @Builder.Default - @OneToMany(mappedBy = "couponDetail", cascade = CascadeType.ALL) - private List couponMenus = new ArrayList(); + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "foodie_idx") + private Foodie foodie; @Builder.Default @OneToMany(mappedBy = "couponDetail", cascade = CascadeType.ALL) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java b/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java index 53eddbb..cb0cfc3 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java @@ -32,8 +32,4 @@ public class CouponMenu extends BaseTimeEntity { @JoinColumn(name = "coupon_detail_idx") private CouponDetail couponDetail; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "foodie_idx") - private Foodie foodie; - } diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Foodie.java b/src/main/java/com/readyvery/readyverydemo/domain/Foodie.java index bfa78d7..6436b7f 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Foodie.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Foodie.java @@ -76,7 +76,7 @@ public class Foodie extends BaseTimeEntity { private List cartItems = new ArrayList(); @OneToMany(mappedBy = "foodie", cascade = CascadeType.ALL) - private List couponMenus = new ArrayList(); + private List couponDetails = new ArrayList(); @OneToMany(mappedBy = "foodie", cascade = CascadeType.ALL) private List orderItems = new ArrayList(); From 143662ab39661fcdc04a80a4228205ac86458a55 Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Fri, 24 Nov 2023 22:47:46 +0900 Subject: [PATCH 11/80] =?UTF-8?q?Feat:=20coupon=20domain=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/domain/Cart.java | 1 + .../readyverydemo/domain/CouponDetail.java | 16 ++++++++++++---- .../readyverydemo/domain/CouponMenu.java | 4 ---- .../readyvery/readyverydemo/domain/Event.java | 4 ++++ .../readyvery/readyverydemo/domain/Foodie.java | 2 +- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java index d3ac2d5..e1c444b 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java @@ -56,6 +56,7 @@ public class Cart extends BaseTimeEntity { @Builder.Default private Boolean isDeleted = false; + @Builder.Default @OneToMany(mappedBy = "cart") private List orders = new ArrayList(); diff --git a/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java b/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java index 2157f16..2ceb932 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java @@ -46,7 +46,15 @@ public class CouponDetail extends BaseTimeEntity { @Column private LocalDateTime expire; - // 발행처 레디베리 발행(0) / 사장님 발행(ceo_idx) + // 쿠폰 코드 + @Column(name = "coupon_code") + private String couponCode; + + // 발급 갯수 + @Column(name = "coupon_count") + private Long couponCount; + + // 발행처 레디베리 발행(null) / 사장님 발행(store_idx) @Column private Long publisher; @@ -54,9 +62,9 @@ public class CouponDetail extends BaseTimeEntity { @JoinColumn(name = "event_idx") private Event event; - @Builder.Default - @OneToMany(mappedBy = "couponDetail", cascade = CascadeType.ALL) - private List couponMenus = new ArrayList(); + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "foodie_idx") + private Foodie foodie; @Builder.Default @OneToMany(mappedBy = "couponDetail", cascade = CascadeType.ALL) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java b/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java index 53eddbb..cb0cfc3 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java @@ -32,8 +32,4 @@ public class CouponMenu extends BaseTimeEntity { @JoinColumn(name = "coupon_detail_idx") private CouponDetail couponDetail; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "foodie_idx") - private Foodie foodie; - } diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Event.java b/src/main/java/com/readyvery/readyverydemo/domain/Event.java index 60d84e1..2b89ad8 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Event.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Event.java @@ -39,6 +39,10 @@ public class Event extends BaseTimeEntity { @Column(name = "main_img") private String mainImg; + // 이벤트 진행 여부 + @Column(name = "is_active") + private boolean isActive; + @Builder.Default @OneToMany(mappedBy = "event", cascade = CascadeType.ALL) private List coupons = new ArrayList(); diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Foodie.java b/src/main/java/com/readyvery/readyverydemo/domain/Foodie.java index bfa78d7..6436b7f 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Foodie.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Foodie.java @@ -76,7 +76,7 @@ public class Foodie extends BaseTimeEntity { private List cartItems = new ArrayList(); @OneToMany(mappedBy = "foodie", cascade = CascadeType.ALL) - private List couponMenus = new ArrayList(); + private List couponDetails = new ArrayList(); @OneToMany(mappedBy = "foodie", cascade = CascadeType.ALL) private List orderItems = new ArrayList(); From 38f4f433e25bf781b9ee2a92ca135bdcdd72b05f Mon Sep 17 00:00:00 2001 From: 1223v <1223v@naver.com> Date: Sat, 25 Nov 2023 00:02:18 +0900 Subject: [PATCH 12/80] =?UTF-8?q?Feat:=20board=20=EC=8A=A4=ED=86=A0?= =?UTF-8?q?=EC=96=B4=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20eventMessage,=20statu?= =?UTF-8?q?s=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/domain/Store.java | 4 ++++ .../readyverydemo/src/board/dto/BoardMapper.java | 4 ++++ .../readyverydemo/src/board/dto/StoreDto.java | 2 ++ src/main/resources/application.properties | 14 +++++++------- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Store.java b/src/main/java/com/readyvery/readyverydemo/domain/Store.java index c39786e..8b5aa10 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Store.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Store.java @@ -63,6 +63,10 @@ public class Store extends BaseTimeEntity { @Column private String engName; + // 가게 이벤트 메세지 + @Column + private String eventMessage; + //가게 등급 @Column @Enumerated(EnumType.STRING) diff --git a/src/main/java/com/readyvery/readyverydemo/src/board/dto/BoardMapper.java b/src/main/java/com/readyvery/readyverydemo/src/board/dto/BoardMapper.java index 60cca00..9519131 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/board/dto/BoardMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/board/dto/BoardMapper.java @@ -44,6 +44,8 @@ private StoreDto toSearchStoreDto(Store store) { .findFirst() .map(storeImg -> IMG_URL + store.getEngName() + "/" + storeImg.getImgUrl()) .orElse(null)) + .eventMessage(store.getEventMessage()) + .status(store.isStatus()) .build(); } @@ -57,6 +59,8 @@ private StoreDto toStoreDto(Store store) { .findFirst() .map(storeImg -> IMG_URL + store.getEngName() + "/" + storeImg.getImgUrl()) .orElse(null)) + .eventMessage(store.getEventMessage()) + .status(store.isStatus()) .build(); } } diff --git a/src/main/java/com/readyvery/readyverydemo/src/board/dto/StoreDto.java b/src/main/java/com/readyvery/readyverydemo/src/board/dto/StoreDto.java index 5be5dd2..fae8c24 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/board/dto/StoreDto.java +++ b/src/main/java/com/readyvery/readyverydemo/src/board/dto/StoreDto.java @@ -10,4 +10,6 @@ public class StoreDto { private String name; private String address; private String imgUrl; + private String eventMessage; + private boolean status; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index bd2b58a..881d405 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,9 +1,9 @@ -spring.datasource.url=jdbc:mysql://localhost:3306/readyvery -#spring.datasource.url=jdbc:mysql://test.readyvery.com:33306/readyvery -spring.datasource.username=root -#spring.datasource.username=ready -spring.datasource.password=12345678 -#spring.datasource.password=readyverytestuser23! +#spring.datasource.url=jdbc:mysql://localhost:3306/readyvery +spring.datasource.url=jdbc:mysql://test.readyvery.com:33306/readyvery +#spring.datasource.username=root +spring.datasource.username=ready +#spring.datasource.password=12345678 +spring.datasource.password=readyverytestuser23! spring.jpa.hibernate.ddl-auto=update spring.jpa.generate-ddl=true spring.jpa.show-sql=true @@ -14,7 +14,7 @@ jwt.access.expiration=86400 jwt.access.cookie=accessToken jwt.refresh.expiration=604800 jwt.refresh.cookie=refreshToken -jwt.redirect-uri=http://localhost:3000/login +jwt.redirect-uri=http://localhost:3000/ jwt.access.cookie.domain=localhost jwt.refresh.cookie.domain=localhost # Kakao From d37cb7b7247aed5ab742067c11bea0b06ab5e2f4 Mon Sep 17 00:00:00 2001 From: 1223v <1223v@naver.com> Date: Sat, 25 Nov 2023 01:35:31 +0900 Subject: [PATCH 13/80] =?UTF-8?q?Fix:=20ceo=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=20brith,=20age=20=EC=BB=AC=EB=9F=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/readyvery/readyverydemo/domain/CeoInfo.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java b/src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java index 8e1c62b..bac174c 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java @@ -45,14 +45,6 @@ public class CeoInfo extends BaseTimeEntity { @Column(nullable = false, columnDefinition = "TEXT") private String imageUrl; - // 연령대 - @Column - private String age; - - // 생일 - @Column(nullable = false) - private String birth; - // 전화번호 @Column(nullable = false) private String phone; From 6e5d01cde221d1c92bc28337b607cb0ca76e25aa Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Sat, 25 Nov 2023 01:43:13 +0900 Subject: [PATCH 14/80] =?UTF-8?q?Feat:=20coupon=20domain=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/domain/CouponDetail.java | 19 +++++++--- .../readyverydemo/domain/CouponMenu.java | 35 ------------------- .../readyvery/readyverydemo/domain/Event.java | 14 -------- .../readyvery/readyverydemo/domain/Store.java | 4 +++ 4 files changed, 18 insertions(+), 54 deletions(-) delete mode 100644 src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java diff --git a/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java b/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java index 2ceb932..2c0f483 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/CouponDetail.java @@ -54,18 +54,27 @@ public class CouponDetail extends BaseTimeEntity { @Column(name = "coupon_count") private Long couponCount; - // 발행처 레디베리 발행(null) / 사장님 발행(store_idx) + // 쿠폰 설명 @Column - private Long publisher; + private String description; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "event_idx") - private Event event; + // 이벤트 진행 여부 + @Column(name = "is_active") + private boolean isActive; + + // 배너 이미지 url + @Column(name = "banner_img") + private String bannerImg; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "foodie_idx") private Foodie foodie; + // 발행처 레디베리 발행(null) / 사장님 발행(store_idx) + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "store_idx") + private Store store; + @Builder.Default @OneToMany(mappedBy = "couponDetail", cascade = CascadeType.ALL) private List coupons = new ArrayList(); diff --git a/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java b/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java deleted file mode 100644 index cb0cfc3..0000000 --- a/src/main/java/com/readyvery/readyverydemo/domain/CouponMenu.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.readyvery.readyverydemo.domain; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -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 jakarta.persistence.Table; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -@Getter -@Entity -@Builder -@Table(name = "COUPONMENU") -@AllArgsConstructor -@NoArgsConstructor -@Slf4j -public class CouponMenu extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "coupon_menu_idx") - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "coupon_detail_idx") - private CouponDetail couponDetail; - -} diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Event.java b/src/main/java/com/readyvery/readyverydemo/domain/Event.java index 2b89ad8..c484789 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Event.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Event.java @@ -1,15 +1,10 @@ package com.readyvery.readyverydemo.domain; -import java.util.ArrayList; -import java.util.List; - -import jakarta.persistence.CascadeType; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Builder; @@ -31,10 +26,6 @@ public class Event extends BaseTimeEntity { @Column(name = "event_idx") private Long id; - // 이벤트 베너 이미지 url - @Column(name = "banner_img") - private String bannerImg; - // 이벤트 메인 이미지 url @Column(name = "main_img") private String mainImg; @@ -42,9 +33,4 @@ public class Event extends BaseTimeEntity { // 이벤트 진행 여부 @Column(name = "is_active") private boolean isActive; - - @Builder.Default - @OneToMany(mappedBy = "event", cascade = CascadeType.ALL) - private List coupons = new ArrayList(); - } diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Store.java b/src/main/java/com/readyvery/readyverydemo/domain/Store.java index c39786e..b51f27a 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Store.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Store.java @@ -77,6 +77,10 @@ public class Store extends BaseTimeEntity { @OneToMany(mappedBy = "store", cascade = CascadeType.ALL) private List foodieCategories = new ArrayList(); + // 쿠폰 디테일 연관관계 매핑 + @OneToMany(mappedBy = "store", cascade = CascadeType.ALL) + private List couponDetails = new ArrayList(); + //가게 메뉴 연관관계 매핑 // @OneToMany(mappedBy = "store", cascade = CascadeType.ALL) // private List foodies = new ArrayList<>(); From af2c45d489966ac17a033400c77b1fc5a6a2b909 Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Sat, 25 Nov 2023 01:43:34 +0900 Subject: [PATCH 15/80] =?UTF-8?q?Feat:=20=EC=9C=A0=EC=A0=80=20coupon=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/coupon/CouponController.java | 26 ++++++++++++++ .../src/coupon/CouponService.java | 8 +++++ .../src/coupon/CouponServiceImpl.java | 32 +++++++++++++++++ .../src/coupon/dto/CouponDto.java | 16 +++++++++ .../src/coupon/dto/CouponMapper.java | 34 +++++++++++++++++++ .../src/coupon/dto/CouponsRes.java | 12 +++++++ 6 files changed, 128 insertions(+) create mode 100644 src/main/java/com/readyvery/readyverydemo/src/coupon/CouponController.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/coupon/CouponService.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/coupon/CouponServiceImpl.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponDto.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponsRes.java diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponController.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponController.java new file mode 100644 index 0000000..94a2a0f --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponController.java @@ -0,0 +1,26 @@ +package com.readyvery.readyverydemo.src.coupon; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; +import com.readyvery.readyverydemo.src.coupon.dto.CouponsRes; + +import lombok.RequiredArgsConstructor; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/coupon") +public class CouponController { + private final CouponService couponService; + + @GetMapping("") + public ResponseEntity getCoupon(@AuthenticationPrincipal CustomUserDetails userDetails) { + CouponsRes result = couponService.getCoupon(userDetails); + return new ResponseEntity<>(result, HttpStatus.OK); + } +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponService.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponService.java new file mode 100644 index 0000000..ac40a1a --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponService.java @@ -0,0 +1,8 @@ +package com.readyvery.readyverydemo.src.coupon; + +import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; +import com.readyvery.readyverydemo.src.coupon.dto.CouponsRes; + +public interface CouponService { + CouponsRes getCoupon(CustomUserDetails userDetails); +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponServiceImpl.java new file mode 100644 index 0000000..6cb8763 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponServiceImpl.java @@ -0,0 +1,32 @@ +package com.readyvery.readyverydemo.src.coupon; + +import org.springframework.stereotype.Service; + +import com.readyvery.readyverydemo.domain.UserInfo; +import com.readyvery.readyverydemo.domain.repository.UserRepository; +import com.readyvery.readyverydemo.global.exception.BusinessLogicException; +import com.readyvery.readyverydemo.global.exception.ExceptionCode; +import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; +import com.readyvery.readyverydemo.src.coupon.dto.CouponMapper; +import com.readyvery.readyverydemo.src.coupon.dto.CouponsRes; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class CouponServiceImpl implements CouponService { + private final CouponMapper couponMapper; + private final UserRepository userRepository; + + @Override + public CouponsRes getCoupon(CustomUserDetails userDetails) { + UserInfo userInfo = getUserInfo(userDetails); + return couponMapper.toCouponsRes(userInfo.getCoupons()); + } + + private UserInfo getUserInfo(CustomUserDetails userDetails) { + return userRepository.findById(userDetails.getId()).orElseThrow( + () -> new BusinessLogicException(ExceptionCode.USER_NOT_FOUND) + ); + } +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponDto.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponDto.java new file mode 100644 index 0000000..876a88c --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponDto.java @@ -0,0 +1,16 @@ +package com.readyvery.readyverydemo.src.coupon.dto; + +import java.time.LocalDateTime; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class CouponDto { + private String couponName; + private String publisher; + private String description; + private Long salePrice; + private LocalDateTime expirationDate; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java new file mode 100644 index 0000000..09139dc --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java @@ -0,0 +1,34 @@ +package com.readyvery.readyverydemo.src.coupon.dto; + +import java.util.List; + +import org.springframework.stereotype.Component; + +import com.readyvery.readyverydemo.domain.Coupon; + +import lombok.RequiredArgsConstructor; + +@Component +@RequiredArgsConstructor +public class CouponMapper { + public CouponsRes toCouponsRes(List coupons) { + return CouponsRes.builder() + //filter로 isUsed가 false인 쿠폰만 가져옴 + .coupons(coupons.stream() + .filter(coupon -> !coupon.isUsed()) + .map(this::toCouponDto) + .toList()) + .build(); + } + + private CouponDto toCouponDto(Coupon coupon) { + return CouponDto.builder() + .couponName(coupon.getCouponDetail().getName()) + .description(coupon.getCouponDetail().getDescription()) + .expirationDate(coupon.getCouponDetail().getExpire()) + .publisher(coupon.getCouponDetail().getStore() == null + ? "레디베리" : coupon.getCouponDetail().getStore().getName()) + .salePrice(coupon.getCouponDetail().getSalePrice()) + .build(); + } +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponsRes.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponsRes.java new file mode 100644 index 0000000..bb442d9 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponsRes.java @@ -0,0 +1,12 @@ +package com.readyvery.readyverydemo.src.coupon.dto; + +import java.util.List; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class CouponsRes { + private List coupons; +} From 01e866cd39a081786758d11347bcada4de381e1d Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sat, 25 Nov 2023 02:46:53 +0900 Subject: [PATCH 16/80] =?UTF-8?q?Fix:=20=EC=A3=BC=EB=AC=B8=20=EB=A6=AC?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EA=B2=B0=EC=A0=9C=20=EC=95=88=ED=95=9C?= =?UTF-8?q?=EA=B1=B0=20=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 8d7201d..54ee795 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -1,5 +1,6 @@ package com.readyvery.readyverydemo.src.order.dto; +import static com.readyvery.readyverydemo.domain.Progress.*; import static com.readyvery.readyverydemo.global.Constant.*; import static org.hibernate.type.descriptor.java.JdbcTimeJavaType.*; @@ -213,6 +214,7 @@ public HistoryRes ordersToHistoryRes(List orders) { .receipts( orders .stream() + .filter(order -> order.getProgress() != REQUEST) .map(this::orderToReceiptHistoryDto) .toList()) .build(); From 6bea7d886da73ff2cf16409591d3e61757b84bdc Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sat, 25 Nov 2023 03:53:36 +0900 Subject: [PATCH 17/80] =?UTF-8?q?Feat:=20=EC=9C=A0=EC=A0=80=20=EC=BF=A0?= =?UTF-8?q?=ED=8F=B0=20=EB=B0=9C=EA=B8=89=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/domain/Coupon.java | 4 -- .../readyvery/readyverydemo/domain/Store.java | 4 -- .../repository/CouponDetailRepository.java | 8 +++ .../global/exception/ExceptionCode.java | 6 +- .../src/coupon/CouponController.java | 13 ++++ .../src/coupon/CouponService.java | 4 ++ .../src/coupon/CouponServiceImpl.java | 71 +++++++++++++++++++ .../src/coupon/dto/CouponIssueReq.java | 9 +++ .../src/coupon/dto/CouponIssueRes.java | 10 +++ .../src/coupon/dto/CouponMapper.java | 6 ++ 10 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/readyvery/readyverydemo/domain/repository/CouponDetailRepository.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponIssueReq.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponIssueRes.java diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java b/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java index 8e3da7d..51e8a48 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java @@ -42,10 +42,6 @@ public class Coupon extends BaseTimeEntity { @JoinColumn(name = "user_idx") private UserInfo userInfo; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "store_idx") - private Store store; - @OneToOne(mappedBy = "coupon", fetch = FetchType.LAZY) private Order order; diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Store.java b/src/main/java/com/readyvery/readyverydemo/domain/Store.java index 48aa5e6..8b5aa10 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Store.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Store.java @@ -81,10 +81,6 @@ public class Store extends BaseTimeEntity { @OneToMany(mappedBy = "store", cascade = CascadeType.ALL) private List foodieCategories = new ArrayList(); - // 쿠폰 디테일 연관관계 매핑 - @OneToMany(mappedBy = "store", cascade = CascadeType.ALL) - private List couponDetails = new ArrayList(); - //가게 메뉴 연관관계 매핑 // @OneToMany(mappedBy = "store", cascade = CascadeType.ALL) // private List foodies = new ArrayList<>(); diff --git a/src/main/java/com/readyvery/readyverydemo/domain/repository/CouponDetailRepository.java b/src/main/java/com/readyvery/readyverydemo/domain/repository/CouponDetailRepository.java new file mode 100644 index 0000000..136d36e --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/domain/repository/CouponDetailRepository.java @@ -0,0 +1,8 @@ +package com.readyvery.readyverydemo.domain.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.readyvery.readyverydemo.domain.CouponDetail; + +public interface CouponDetailRepository extends JpaRepository { +} diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index 1738ad7..0fbc3fa 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -18,7 +18,11 @@ public enum ExceptionCode { ORDER_NOT_FOUND(400, "Order does not exists."), TOSS_PAYMENT_AMOUNT_NOT_MATCH(400, "Toss payment amount not match."), ORDER_NOT_CURRENT(400, "Order is not current."), - ORDER_NOT_CANCELABLE(400, "Order is not cancelable."); + ORDER_NOT_CANCELABLE(400, "Order is not cancelable."), + COUPON_NOT_FOUND(404, "Coupon does not exists."), + COUPON_NOT_ACTIVE(400, "Coupon is not active."), + COUPON_CODE_NOT_MATCH(400, "Coupon code is not match."), + COUPON_ISSUE_COUNT_EXCEED(400, "Coupon issue count exceed."); private int status; private String message; diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponController.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponController.java index 94a2a0f..1614649 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponController.java @@ -4,10 +4,14 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; +import com.readyvery.readyverydemo.src.coupon.dto.CouponIssueReq; +import com.readyvery.readyverydemo.src.coupon.dto.CouponIssueRes; import com.readyvery.readyverydemo.src.coupon.dto.CouponsRes; import lombok.RequiredArgsConstructor; @@ -23,4 +27,13 @@ public ResponseEntity getCoupon(@AuthenticationPrincipal CustomUserD CouponsRes result = couponService.getCoupon(userDetails); return new ResponseEntity<>(result, HttpStatus.OK); } + + //쿠폰 발급 + @PostMapping("") + public ResponseEntity issueCoupon(@AuthenticationPrincipal CustomUserDetails userDetails, + @RequestBody CouponIssueReq couponIssueReq) { + CouponIssueRes result = couponService.issueCoupon(userDetails, couponIssueReq); + return new ResponseEntity<>(result, HttpStatus.OK); + } + } diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponService.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponService.java index ac40a1a..aaa42bc 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponService.java @@ -1,8 +1,12 @@ package com.readyvery.readyverydemo.src.coupon; import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; +import com.readyvery.readyverydemo.src.coupon.dto.CouponIssueReq; +import com.readyvery.readyverydemo.src.coupon.dto.CouponIssueRes; import com.readyvery.readyverydemo.src.coupon.dto.CouponsRes; public interface CouponService { CouponsRes getCoupon(CustomUserDetails userDetails); + + CouponIssueRes issueCoupon(CustomUserDetails userDetails, CouponIssueReq couponIssueReq); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponServiceImpl.java index 6cb8763..d3c56c8 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/CouponServiceImpl.java @@ -1,12 +1,20 @@ package com.readyvery.readyverydemo.src.coupon; +import java.util.ArrayList; +import java.util.List; + import org.springframework.stereotype.Service; +import com.readyvery.readyverydemo.domain.Coupon; +import com.readyvery.readyverydemo.domain.CouponDetail; import com.readyvery.readyverydemo.domain.UserInfo; +import com.readyvery.readyverydemo.domain.repository.CouponDetailRepository; import com.readyvery.readyverydemo.domain.repository.UserRepository; import com.readyvery.readyverydemo.global.exception.BusinessLogicException; import com.readyvery.readyverydemo.global.exception.ExceptionCode; import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; +import com.readyvery.readyverydemo.src.coupon.dto.CouponIssueReq; +import com.readyvery.readyverydemo.src.coupon.dto.CouponIssueRes; import com.readyvery.readyverydemo.src.coupon.dto.CouponMapper; import com.readyvery.readyverydemo.src.coupon.dto.CouponsRes; @@ -17,6 +25,7 @@ public class CouponServiceImpl implements CouponService { private final CouponMapper couponMapper; private final UserRepository userRepository; + private final CouponDetailRepository couponDetailRepository; @Override public CouponsRes getCoupon(CustomUserDetails userDetails) { @@ -24,6 +33,68 @@ public CouponsRes getCoupon(CustomUserDetails userDetails) { return couponMapper.toCouponsRes(userInfo.getCoupons()); } + @Override + public CouponIssueRes issueCoupon(CustomUserDetails userDetails, CouponIssueReq couponIssueReq) { + UserInfo userInfo = getUserInfo(userDetails); + CouponDetail couponDetail = getCouponDetail(couponIssueReq); + Long issuedCouponCount = getCouponCount(userInfo, couponDetail); + + verifyCouponIssue(couponDetail, couponIssueReq, issuedCouponCount); + + userInfo.getCoupons().addAll(issueUserCoupon(userInfo, couponDetail, issuedCouponCount)); + userRepository.save(userInfo); + + return couponMapper.toCouponIssueRes(); + } + + private List issueUserCoupon(UserInfo userInfo, CouponDetail couponDetail, Long issuedCouponCount) { + List coupons = new ArrayList<>(); + for (int i = 0; i < couponDetail.getCouponCount() - issuedCouponCount; i++) { + coupons.add(Coupon.builder() + .couponDetail(couponDetail) + .userInfo(userInfo) + .build()); + } + return coupons; + } + + private Long getCouponCount(UserInfo userDetails, CouponDetail couponDetail) { + return userDetails.getCoupons().stream() + .filter(coupon -> coupon.getCouponDetail().equals(couponDetail)) + .count(); + } + + private void verifyCouponIssue(CouponDetail couponDetail, CouponIssueReq couponIssueReq, + Long issuedCouponCount) { + verifyCoupon(couponDetail); + verifyCouponCode(couponDetail, couponIssueReq); + verifyCouponIssueCount(issuedCouponCount, couponDetail); + } + + private void verifyCouponIssueCount(Long issuedCouponCount, CouponDetail couponDetail) { + if (issuedCouponCount >= couponDetail.getCouponCount()) { + throw new BusinessLogicException(ExceptionCode.COUPON_ISSUE_COUNT_EXCEED); + } + } + + private void verifyCouponCode(CouponDetail couponDetail, CouponIssueReq couponIssueReq) { + if (!couponDetail.getCouponCode().equals(couponIssueReq.getCouponCode())) { + throw new BusinessLogicException(ExceptionCode.COUPON_CODE_NOT_MATCH); + } + } + + private void verifyCoupon(CouponDetail couponDetail) { + if (!couponDetail.isActive()) { + throw new BusinessLogicException(ExceptionCode.COUPON_NOT_ACTIVE); + } + } + + private CouponDetail getCouponDetail(CouponIssueReq couponIssueReq) { + return couponDetailRepository.findById(couponIssueReq.getCouponId()).orElseThrow( + () -> new BusinessLogicException(ExceptionCode.COUPON_NOT_FOUND) + ); + } + private UserInfo getUserInfo(CustomUserDetails userDetails) { return userRepository.findById(userDetails.getId()).orElseThrow( () -> new BusinessLogicException(ExceptionCode.USER_NOT_FOUND) diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponIssueReq.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponIssueReq.java new file mode 100644 index 0000000..cc5e967 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponIssueReq.java @@ -0,0 +1,9 @@ +package com.readyvery.readyverydemo.src.coupon.dto; + +import lombok.Getter; + +@Getter +public class CouponIssueReq { + private String couponCode; + private Long couponId; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponIssueRes.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponIssueRes.java new file mode 100644 index 0000000..da0bc90 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponIssueRes.java @@ -0,0 +1,10 @@ +package com.readyvery.readyverydemo.src.coupon.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class CouponIssueRes { + private String message; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java index 09139dc..8e9f1b6 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java @@ -31,4 +31,10 @@ private CouponDto toCouponDto(Coupon coupon) { .salePrice(coupon.getCouponDetail().getSalePrice()) .build(); } + + public CouponIssueRes toCouponIssueRes() { + return CouponIssueRes.builder() + .message("쿠폰이 발급되었습니다.") + .build(); + } } From f75ebe46ddb2e488313f0196687a569988ea3bac Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sat, 25 Nov 2023 05:00:35 +0900 Subject: [PATCH 18/80] =?UTF-8?q?Feat:=20=EB=A9=94=EC=9D=B8=20=EC=BF=A0?= =?UTF-8?q?=ED=8F=B0=20=EB=B0=B0=EB=84=88=20=ED=99=95=EC=9D=B8=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/config/SpringSecurityConfig.java | 3 +- .../src/event/EventController.java | 21 +++++++++++++ .../readyverydemo/src/event/EventService.java | 7 +++++ .../src/event/EventServiceImpl.java | 25 ++++++++++++++++ .../src/event/dto/BannerDto.java | 12 ++++++++ .../src/event/dto/EventMapper.java | 30 +++++++++++++++++++ .../readyverydemo/src/event/dto/EventRes.java | 12 ++++++++ 7 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/readyvery/readyverydemo/src/event/EventController.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/event/EventService.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/event/EventServiceImpl.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/event/dto/BannerDto.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMapper.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/event/dto/EventRes.java diff --git a/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java b/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java index c692a03..2f44b1d 100644 --- a/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java +++ b/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java @@ -60,7 +60,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { "/api/v1/store/**", "/api/v1/board/**", "/api/v1/order/current", - "/api/v1/auth" + "/api/v1/auth", + "api/v1/event/**" ).permitAll() // 위를 제외한 나머지는 모두 허용 .anyRequest().authenticated() // 해당 요청은 인증이 필요함 ) diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java b/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java new file mode 100644 index 0000000..02d9064 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java @@ -0,0 +1,21 @@ +package com.readyvery.readyverydemo.src.event; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.readyvery.readyverydemo.src.event.dto.EventRes; + +import lombok.RequiredArgsConstructor; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/event") +public class EventController { + private final EventService eventService; + + @GetMapping("/banner") + public EventRes getBanners() { + return eventService.getBanners(); + } +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/EventService.java b/src/main/java/com/readyvery/readyverydemo/src/event/EventService.java new file mode 100644 index 0000000..9f77f2a --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/event/EventService.java @@ -0,0 +1,7 @@ +package com.readyvery.readyverydemo.src.event; + +import com.readyvery.readyverydemo.src.event.dto.EventRes; + +public interface EventService { + EventRes getBanners(); +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/EventServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/event/EventServiceImpl.java new file mode 100644 index 0000000..7b7de2a --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/event/EventServiceImpl.java @@ -0,0 +1,25 @@ +package com.readyvery.readyverydemo.src.event; + +import java.util.List; + +import org.springframework.stereotype.Service; + +import com.readyvery.readyverydemo.domain.CouponDetail; +import com.readyvery.readyverydemo.domain.repository.CouponDetailRepository; +import com.readyvery.readyverydemo.src.event.dto.EventMapper; +import com.readyvery.readyverydemo.src.event.dto.EventRes; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class EventServiceImpl implements EventService { + private final EventMapper eventMapper; + private final CouponDetailRepository couponDetailRepository; + + @Override + public EventRes getBanners() { + List couponDetails = couponDetailRepository.findAll(); + return eventMapper.toEventRes(couponDetails); + } +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/dto/BannerDto.java b/src/main/java/com/readyvery/readyverydemo/src/event/dto/BannerDto.java new file mode 100644 index 0000000..ccad796 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/event/dto/BannerDto.java @@ -0,0 +1,12 @@ +package com.readyvery.readyverydemo.src.event.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class BannerDto { + private Long idx; + private String bannerImg; + private String couponCode; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMapper.java b/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMapper.java new file mode 100644 index 0000000..13c9643 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMapper.java @@ -0,0 +1,30 @@ +package com.readyvery.readyverydemo.src.event.dto; + +import java.util.List; + +import org.springframework.stereotype.Component; + +import com.readyvery.readyverydemo.domain.CouponDetail; + +import lombok.RequiredArgsConstructor; + +@Component +@RequiredArgsConstructor +public class EventMapper { + public EventRes toEventRes(List couponDetails) { + return EventRes.builder() + .banners(couponDetailsToBannerDto(couponDetails)) + .build(); + } + + private List couponDetailsToBannerDto(List couponDetails) { + return couponDetails.stream() + .filter(CouponDetail::isActive) + .map(couponDetail -> BannerDto.builder() + .idx(couponDetail.getId()) + .bannerImg(couponDetail.getBannerImg()) + .couponCode(couponDetail.getCouponCode()) + .build() + ).toList(); + } +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventRes.java b/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventRes.java new file mode 100644 index 0000000..c0b8f04 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventRes.java @@ -0,0 +1,12 @@ +package com.readyvery.readyverydemo.src.event.dto; + +import java.util.List; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class EventRes { + private List banners; +} From afeb5528569c9ff8c15d8f0241511d2c4dcdc7ab Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sat, 25 Nov 2023 05:05:47 +0900 Subject: [PATCH 19/80] =?UTF-8?q?Fix:=20=EC=BF=A0=ED=8F=B0=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20id=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 --- .../com/readyvery/readyverydemo/src/coupon/dto/CouponDto.java | 1 + .../com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponDto.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponDto.java index 876a88c..06d605d 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponDto.java +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponDto.java @@ -8,6 +8,7 @@ @Getter @Builder public class CouponDto { + private Long couponId; private String couponName; private String publisher; private String description; diff --git a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java index 8e9f1b6..0dc53ab 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/coupon/dto/CouponMapper.java @@ -23,6 +23,7 @@ public CouponsRes toCouponsRes(List coupons) { private CouponDto toCouponDto(Coupon coupon) { return CouponDto.builder() + .couponId(coupon.getId()) .couponName(coupon.getCouponDetail().getName()) .description(coupon.getCouponDetail().getDescription()) .expirationDate(coupon.getCouponDetail().getExpire()) From 367cd71ea9b9fc255f7ae57f10198d46404e1409 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sat, 25 Nov 2023 20:47:30 +0900 Subject: [PATCH 20/80] =?UTF-8?q?Feat:=20=EC=A3=BC=EB=AC=B8=20=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/repository/OrdersRepository.java | 5 +++++ .../readyverydemo/src/order/OrderServiceImpl.java | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/repository/OrdersRepository.java b/src/main/java/com/readyvery/readyverydemo/domain/repository/OrdersRepository.java index b3669c8..17ea0b1 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/repository/OrdersRepository.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/repository/OrdersRepository.java @@ -1,15 +1,20 @@ package com.readyvery.readyverydemo.domain.repository; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import com.readyvery.readyverydemo.domain.Order; +import com.readyvery.readyverydemo.domain.Progress; import com.readyvery.readyverydemo.domain.UserInfo; public interface OrdersRepository extends JpaRepository { Optional findByOrderId(String orderId); Optional> findAllByUserInfo(UserInfo userInfo); + + Long countByCreatedAtBetweenAndProgressNot(LocalDateTime localDateTime, LocalDateTime localDateTime1, + Progress progress); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 7f5523f..898416c 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -291,11 +291,21 @@ private void applyOrderFail(Order order) { } private void applyTosspaymentDto(Order order, TosspaymentDto tosspaymentDto) { - //TODO: orderNumber 적용 + order.setOrderNumber(getOrderNumber(order)); order.setPaymentKey(tosspaymentDto.getPaymentKey()); order.setMethod(tosspaymentDto.getMethod()); order.setProgress(Progress.ORDER); order.setPayStatus(true); + order.getCart().setIsOrdered(true); + } + + private String getOrderNumber(Order order) { + long todayOrder = ordersRepository.countByCreatedAtBetweenAndProgressNot( + order.getCreatedAt().toLocalDate().atStartOfDay(), + order.getCreatedAt().toLocalDate().atTime(23, 59, 59), + Progress.REQUEST + ) + 1; + return Long.toString(todayOrder); } private void verifyOrder(Order order, Long amount) { From df6cf5d418b717dc5e499d1e0ddbdd9496496345 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 00:15:17 +0900 Subject: [PATCH 21/80] =?UTF-8?q?Feat:=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/domain/Event.java | 4 ++++ .../domain/repository/EventRepository.java | 8 ++++++++ .../readyverydemo/src/event/EventController.java | 14 ++++++++++++-- .../readyverydemo/src/event/EventService.java | 3 +++ .../readyverydemo/src/event/EventServiceImpl.java | 14 ++++++++++++++ .../readyverydemo/src/event/dto/EventMainRes.java | 12 ++++++++++++ .../readyverydemo/src/event/dto/EventMapper.java | 11 +++++++++++ .../readyverydemo/src/event/dto/MainEventDto.java | 11 +++++++++++ 8 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/readyvery/readyverydemo/domain/repository/EventRepository.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMainRes.java create mode 100644 src/main/java/com/readyvery/readyverydemo/src/event/dto/MainEventDto.java diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Event.java b/src/main/java/com/readyvery/readyverydemo/domain/Event.java index c484789..a2dd278 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Event.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Event.java @@ -30,6 +30,10 @@ public class Event extends BaseTimeEntity { @Column(name = "main_img") private String mainImg; + // 이벤트 리다이렉트 url + @Column(name = "redirect_url") + private String redirectUrl; + // 이벤트 진행 여부 @Column(name = "is_active") private boolean isActive; diff --git a/src/main/java/com/readyvery/readyverydemo/domain/repository/EventRepository.java b/src/main/java/com/readyvery/readyverydemo/domain/repository/EventRepository.java new file mode 100644 index 0000000..95969b1 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/domain/repository/EventRepository.java @@ -0,0 +1,8 @@ +package com.readyvery.readyverydemo.domain.repository; + +import org.springframework.data.jpa.repository.JpaRepository; + +import com.readyvery.readyverydemo.domain.Event; + +public interface EventRepository extends JpaRepository { +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java b/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java index 02d9064..bc6a9a3 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java @@ -1,9 +1,12 @@ package com.readyvery.readyverydemo.src.event; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.readyvery.readyverydemo.src.event.dto.EventMainRes; import com.readyvery.readyverydemo.src.event.dto.EventRes; import lombok.RequiredArgsConstructor; @@ -15,7 +18,14 @@ public class EventController { private final EventService eventService; @GetMapping("/banner") - public EventRes getBanners() { - return eventService.getBanners(); + public ResponseEntity getBanners() { + EventRes eventRes = eventService.getBanners(); + return new ResponseEntity<>(eventRes, HttpStatus.OK); + } + + @GetMapping("/main") + public ResponseEntity getMain() { + EventMainRes EventMainRes = eventService.getMainEvents(); + return new ResponseEntity<>(EventMainRes, HttpStatus.OK); } } diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/EventService.java b/src/main/java/com/readyvery/readyverydemo/src/event/EventService.java index 9f77f2a..d2755a4 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/event/EventService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/event/EventService.java @@ -1,7 +1,10 @@ package com.readyvery.readyverydemo.src.event; +import com.readyvery.readyverydemo.src.event.dto.EventMainRes; import com.readyvery.readyverydemo.src.event.dto.EventRes; public interface EventService { EventRes getBanners(); + + EventMainRes getMainEvents(); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/EventServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/event/EventServiceImpl.java index 7b7de2a..d54eda4 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/event/EventServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/event/EventServiceImpl.java @@ -5,7 +5,10 @@ import org.springframework.stereotype.Service; import com.readyvery.readyverydemo.domain.CouponDetail; +import com.readyvery.readyverydemo.domain.Event; import com.readyvery.readyverydemo.domain.repository.CouponDetailRepository; +import com.readyvery.readyverydemo.domain.repository.EventRepository; +import com.readyvery.readyverydemo.src.event.dto.EventMainRes; import com.readyvery.readyverydemo.src.event.dto.EventMapper; import com.readyvery.readyverydemo.src.event.dto.EventRes; @@ -16,10 +19,21 @@ public class EventServiceImpl implements EventService { private final EventMapper eventMapper; private final CouponDetailRepository couponDetailRepository; + private final EventRepository eventRepository; @Override public EventRes getBanners() { List couponDetails = couponDetailRepository.findAll(); return eventMapper.toEventRes(couponDetails); } + + @Override + public EventMainRes getMainEvents() { + List events = getEvents(); + return eventMapper.toEventMainRes(events); + } + + private List getEvents() { + return eventRepository.findAll(); + } } diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMainRes.java b/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMainRes.java new file mode 100644 index 0000000..711c98b --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMainRes.java @@ -0,0 +1,12 @@ +package com.readyvery.readyverydemo.src.event.dto; + +import java.util.List; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class EventMainRes { + private List mainEvents; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMapper.java b/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMapper.java index 13c9643..eed2074 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/event/dto/EventMapper.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Component; import com.readyvery.readyverydemo.domain.CouponDetail; +import com.readyvery.readyverydemo.domain.Event; import lombok.RequiredArgsConstructor; @@ -27,4 +28,14 @@ private List couponDetailsToBannerDto(List couponDetail .build() ).toList(); } + + public EventMainRes toEventMainRes(List events) { + return EventMainRes.builder() + .mainEvents(events.stream().filter(Event::isActive).map(event -> MainEventDto.builder() + .imgUrl(event.getMainImg()) + .redirectUrl(event.getRedirectUrl()) + .build() + ).toList()) + .build(); + } } diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/dto/MainEventDto.java b/src/main/java/com/readyvery/readyverydemo/src/event/dto/MainEventDto.java new file mode 100644 index 0000000..f68e010 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/event/dto/MainEventDto.java @@ -0,0 +1,11 @@ +package com.readyvery.readyverydemo.src.event.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class MainEventDto { + private String imgUrl; + private String redirectUrl; +} From a6017d02b7565fb6c792ab638e05faf246c5af16 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 00:16:54 +0900 Subject: [PATCH 22/80] =?UTF-8?q?Fix:=20=EB=B3=80=EC=88=98=EB=AA=85=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyvery/readyverydemo/src/event/EventController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java b/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java index bc6a9a3..aee3435 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/event/EventController.java @@ -25,7 +25,7 @@ public ResponseEntity getBanners() { @GetMapping("/main") public ResponseEntity getMain() { - EventMainRes EventMainRes = eventService.getMainEvents(); - return new ResponseEntity<>(EventMainRes, HttpStatus.OK); + EventMainRes eventMainRes = eventService.getMainEvents(); + return new ResponseEntity<>(eventMainRes, HttpStatus.OK); } } From d0ff0a3ec4479901d75ebc31c2bab36441a39251 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 03:15:56 +0900 Subject: [PATCH 23/80] =?UTF-8?q?Fix:=20progress=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + .../readyverydemo/src/order/dto/ReceiptHistoryDto.java | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 54ee795..4669693 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -224,6 +224,7 @@ private ReceiptHistoryDto orderToReceiptHistoryDto(Order order) { return ReceiptHistoryDto.builder() .dateTime(order.getCreatedAt().format(DateTimeFormatter.ofPattern(DATE_FORMAT))) .name(order.getStore().getName()) + .progress(order.getProgress()) .imgUrl(order.getStore() .getImgs() .stream() diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/ReceiptHistoryDto.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/ReceiptHistoryDto.java index 71d7d72..9095d55 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/ReceiptHistoryDto.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/ReceiptHistoryDto.java @@ -1,5 +1,7 @@ package com.readyvery.readyverydemo.src.order.dto; +import com.readyvery.readyverydemo.domain.Progress; + import lombok.Builder; import lombok.Getter; @@ -12,4 +14,5 @@ public class ReceiptHistoryDto { private String orderName; private Long amount; private String orderId; + private Progress progress; } From dc5251fc3e47114d2b4910a333ba205ed6adc0f5 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 03:33:22 +0900 Subject: [PATCH 24/80] =?UTF-8?q?Fix:=20progress=20Cancel=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 54ee795..d946251 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -215,6 +215,7 @@ public HistoryRes ordersToHistoryRes(List orders) { orders .stream() .filter(order -> order.getProgress() != REQUEST) + .filter(order -> order.getProgress() != FAIL) .map(this::orderToReceiptHistoryDto) .toList()) .build(); From 67a6f394896b66871d8fbb1502f069bf62348413 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 04:56:05 +0900 Subject: [PATCH 25/80] =?UTF-8?q?Feat:=20=EA=B2=B0=EC=A0=9C=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/exception/ExceptionCode.java | 3 +- .../src/order/OrderController.java | 8 ++++++ .../readyverydemo/src/order/OrderService.java | 3 ++ .../src/order/OrderServiceImpl.java | 28 ++++++++++++++++++- .../src/order/dto/CurrentRes.java | 2 +- .../src/order/dto/HistoryDetailRes.java | 17 +++++++++++ .../src/order/dto/OrderMapper.java | 18 +++++++++++- 7 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index 0fbc3fa..1562249 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -22,7 +22,8 @@ public enum ExceptionCode { COUPON_NOT_FOUND(404, "Coupon does not exists."), COUPON_NOT_ACTIVE(400, "Coupon is not active."), COUPON_CODE_NOT_MATCH(400, "Coupon code is not match."), - COUPON_ISSUE_COUNT_EXCEED(400, "Coupon issue count exceed."); + COUPON_ISSUE_COUNT_EXCEED(400, "Coupon issue count exceed."), + ORDER_NOT_RECEIPT(400, "Order is not receipt."); private int status; private String message; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index c3b8b08..5807c9c 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -25,6 +25,7 @@ import com.readyvery.readyverydemo.src.order.dto.CurrentRes; import com.readyvery.readyverydemo.src.order.dto.FailDto; import com.readyvery.readyverydemo.src.order.dto.FoodyDetailRes; +import com.readyvery.readyverydemo.src.order.dto.HistoryDetailRes; import com.readyvery.readyverydemo.src.order.dto.HistoryRes; import com.readyvery.readyverydemo.src.order.dto.PaymentReq; import com.readyvery.readyverydemo.src.order.dto.TossCancelReq; @@ -78,6 +79,13 @@ public ResponseEntity getHistories(@AuthenticationPrincipal CustomUs return new ResponseEntity<>(historyRes, HttpStatus.OK); } + @GetMapping("/receipt") + public ResponseEntity getReceipts(@AuthenticationPrincipal CustomUserDetails userDetails, + @RequestParam("orderId") String orderId) { + HistoryDetailRes historyRes = orderService.getReceipt(userDetails, orderId); + return new ResponseEntity<>(historyRes, HttpStatus.OK); + } + @GetMapping("/current") public ResponseEntity getCurrent(@RequestParam("orderId") String orderId) { CurrentRes currentRes = orderService.getCurrent(orderId); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java index 2f16ffa..72cb72e 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -13,6 +13,7 @@ import com.readyvery.readyverydemo.src.order.dto.CurrentRes; import com.readyvery.readyverydemo.src.order.dto.FailDto; import com.readyvery.readyverydemo.src.order.dto.FoodyDetailRes; +import com.readyvery.readyverydemo.src.order.dto.HistoryDetailRes; import com.readyvery.readyverydemo.src.order.dto.HistoryRes; import com.readyvery.readyverydemo.src.order.dto.PaymentReq; import com.readyvery.readyverydemo.src.order.dto.TossCancelReq; @@ -42,4 +43,6 @@ public interface OrderService { CurrentRes getCurrent(String orderId); Object cancelTossPayment(CustomUserDetails userDetails, TossCancelReq tossCancelReq); + + HistoryDetailRes getReceipt(CustomUserDetails userDetails, String orderId); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 898416c..e4cb8ce 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -54,6 +54,7 @@ import com.readyvery.readyverydemo.src.order.dto.CurrentRes; import com.readyvery.readyverydemo.src.order.dto.FailDto; import com.readyvery.readyverydemo.src.order.dto.FoodyDetailRes; +import com.readyvery.readyverydemo.src.order.dto.HistoryDetailRes; import com.readyvery.readyverydemo.src.order.dto.HistoryRes; import com.readyvery.readyverydemo.src.order.dto.OrderMapper; import com.readyvery.readyverydemo.src.order.dto.PaymentReq; @@ -227,6 +228,30 @@ public Object cancelTossPayment(CustomUserDetails userDetails, TossCancelReq tos return orderMapper.tosspaymentDtoToCancelRes(); } + @Override + public HistoryDetailRes getReceipt(CustomUserDetails userDetails, String orderId) { + UserInfo user = getUserInfo(userDetails); + Order order = getOrder(orderId); + verifyReceipt(order, user); + return orderMapper.orderToHistoryDetailRes(order); + } + + private void verifyReceipt(Order order, UserInfo user) { + verifyOrderReceipt(order); + verifyOrederUser(order, user); + } + + private void verifyOrderReceipt(Order order) { + if (order.getProgress().equals(Progress.COMPLETE) + || order.getProgress().equals(Progress.PICKUP) + || order.getProgress().equals(Progress.CANCEL) + || order.getProgress().equals(Progress.ORDER) + || order.getProgress().equals(Progress.MAKE)) { + return; + } + throw new BusinessLogicException(ExceptionCode.ORDER_NOT_RECEIPT); + } + private void applyCancelTosspaymentDto(Order order, TosspaymentDto tosspaymentDto) { order.setProgress(Progress.CANCEL); order.setPayStatus(false); @@ -353,7 +378,8 @@ private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Long if (cart.getCartItems().isEmpty()) { throw new BusinessLogicException(ExceptionCode.CART_NOT_FOUND); } - String orderName = cart.getCartItems().get(0).getFoodie().getName(); + String orderName = + cart.getCartItems().get(0).getFoodie().getName() + " * " + cart.getCartItems().get(0).getCount(); if (cart.getCartItems().size() > 1) { orderName += " 외 " + (cart.getCartItems().size() - 1) + "개"; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CurrentRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CurrentRes.java index 3a0bb9f..a576fe7 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CurrentRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CurrentRes.java @@ -9,7 +9,7 @@ @Builder public class CurrentRes { private String name; - private Long orderNum; + private String orderNum; private Progress progress; private String orderName; private String estimatedTime; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java new file mode 100644 index 0000000..cf34f9b --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java @@ -0,0 +1,17 @@ +package com.readyvery.readyverydemo.src.order.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class HistoryDetailRes { + private String orderStatus; + private String storeName; + private String orderTime; + private String orderId; + private String storePhone; + private CartGetRes cart; + private String salePrice; + private String method; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index d946251..59e5f8d 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -241,7 +241,7 @@ private ReceiptHistoryDto orderToReceiptHistoryDto(Order order) { public CurrentRes orderToCurrentRes(Order order) { return CurrentRes.builder() .name(order.getStore().getName()) - .orderNum(order.getId()) + .orderNum(order.getOrderNumber()) .progress(order.getProgress()) .orderName(order.getOrderName()) .estimatedTime(order.getEstimatedTime() != null @@ -254,4 +254,20 @@ public DefaultRes tosspaymentDtoToCancelRes() { .message("취소 성공") .build(); } + + public HistoryDetailRes orderToHistoryDetailRes(Order order) { + return HistoryDetailRes.builder() + .orderStatus(order.getProgress().toString()) + .storeName(order.getStore().getName()) + .orderTime(order.getCreatedAt().format(DateTimeFormatter.ofPattern(DATE_FORMAT))) + .orderId(order.getOrderId()) + .storePhone(order.getStore().getPhone()) + .cart(cartToCartGetRes(order.getCart(), order.getInOut())) + .salePrice( + String.valueOf(order.getCoupon() != null + ? order.getCoupon().getCouponDetail().getSalePrice() + : null)) + .method(order.getMethod()) + .build(); + } } From a35cfaee26789ddf513be55d15c93b7a6a332eda Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 04:59:59 +0900 Subject: [PATCH 26/80] =?UTF-8?q?Fix:=20delete=20body=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyvery/readyverydemo/src/order/OrderController.java | 5 ++--- .../com/readyvery/readyverydemo/src/order/OrderService.java | 3 +-- .../readyvery/readyverydemo/src/order/OrderServiceImpl.java | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index 5807c9c..33a79db 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -19,7 +19,6 @@ import com.readyvery.readyverydemo.src.order.dto.CartEditReq; import com.readyvery.readyverydemo.src.order.dto.CartEidtRes; import com.readyvery.readyverydemo.src.order.dto.CartGetRes; -import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteReq; import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteRes; import com.readyvery.readyverydemo.src.order.dto.CartResetRes; import com.readyvery.readyverydemo.src.order.dto.CurrentRes; @@ -122,8 +121,8 @@ public ResponseEntity updateCart(@AuthenticationPrincipal CustomUse @DeleteMapping("/cart") public ResponseEntity deleteCartItem(@AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody CartItemDeleteReq cartItemDeleteReq) { - CartItemDeleteRes cartItemDeleteRes = orderService.deleteCart(userDetails, cartItemDeleteReq); + @RequestParam Long idx) { + CartItemDeleteRes cartItemDeleteRes = orderService.deleteCart(userDetails, idx); return new ResponseEntity<>(cartItemDeleteRes, HttpStatus.OK); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java index 72cb72e..528f306 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -7,7 +7,6 @@ import com.readyvery.readyverydemo.src.order.dto.CartEditReq; import com.readyvery.readyverydemo.src.order.dto.CartEidtRes; import com.readyvery.readyverydemo.src.order.dto.CartGetRes; -import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteReq; import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteRes; import com.readyvery.readyverydemo.src.order.dto.CartResetRes; import com.readyvery.readyverydemo.src.order.dto.CurrentRes; @@ -26,7 +25,7 @@ public interface OrderService { CartEidtRes editCart(CustomUserDetails userDetails, CartEditReq cartEditReq); - CartItemDeleteRes deleteCart(CustomUserDetails userDetails, CartItemDeleteReq cartItemDeleteReq); + CartItemDeleteRes deleteCart(CustomUserDetails userDetails, Long idx); CartResetRes resetCart(CustomUserDetails userDetails); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index e4cb8ce..72f38ec 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -48,7 +48,6 @@ import com.readyvery.readyverydemo.src.order.dto.CartEditReq; import com.readyvery.readyverydemo.src.order.dto.CartEidtRes; import com.readyvery.readyverydemo.src.order.dto.CartGetRes; -import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteReq; import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteRes; import com.readyvery.readyverydemo.src.order.dto.CartResetRes; import com.readyvery.readyverydemo.src.order.dto.CurrentRes; @@ -130,8 +129,8 @@ public CartEidtRes editCart(CustomUserDetails userDetails, CartEditReq cartEditR } @Override - public CartItemDeleteRes deleteCart(CustomUserDetails userDetails, CartItemDeleteReq cartItemDeleteReq) { - CartItem cartItem = getCartItem(cartItemDeleteReq.getIdx()); + public CartItemDeleteRes deleteCart(CustomUserDetails userDetails, Long idx) { + CartItem cartItem = getCartItem(idx); verifyCartItem(cartItem, userDetails); From 9f1e0d1519b9adb906035682cec2dce82252646c Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 05:29:28 +0900 Subject: [PATCH 27/80] =?UTF-8?q?Fix:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=20=EC=95=84=EC=9D=B4=ED=85=9C=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 59e5f8d..0a3df64 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -112,6 +112,7 @@ public CartGetRes cartToCartGetRes(Cart cart, Long inout) { .carts( cart.getCartItems() .stream() + .filter(cartItem -> !cartItem.getIsDeleted()) .map(cartItem -> cartItemToCartDto(cartItem, inout)) .toList()) .totalPrice( From 19126f66d1a370635da64dc096d48d8f2ac4d543 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 05:39:43 +0900 Subject: [PATCH 28/80] =?UTF-8?q?Fix:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=20=EC=95=84=EC=9D=B4=ED=85=9C=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EA=B0=80=EA=B2=A9=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/OrderServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 72f38ec..bf0739a 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -418,6 +418,7 @@ private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Long private Long calculateAmount2(Cart cart, Long inout) { return cart.getCartItems().stream() + .filter(cartItem -> !cartItem.getIsDeleted()) .map(cartItem -> { Long price = orderMapper.determinePrice(cartItem.getFoodie(), inout); Long totalPrice = cartItem.getCartOptions().stream() From 87a8bf3cbad177a26f26f18b42f7483e27dbb147 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 05:46:59 +0900 Subject: [PATCH 29/80] =?UTF-8?q?Fix:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=20=EC=95=84=EC=9D=B4=ED=85=9C=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EA=B0=80=EA=B2=A9=20=EC=88=98=EC=A0=952?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 0a3df64..e98d941 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -118,6 +118,7 @@ public CartGetRes cartToCartGetRes(Cart cart, Long inout) { .totalPrice( cart.getCartItems() .stream() + .filter(cartItem -> !cartItem.getIsDeleted()) .mapToLong(cartItem -> cartItemTotalPrice(cartItem, inout)) .sum()) .build(); From 383d8a77781d55b9fa2f2a82f83d06cd8deca877 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 06:11:21 +0900 Subject: [PATCH 30/80] =?UTF-8?q?Fix:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=20=EC=95=84=EC=9D=B4=ED=85=9C=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EA=B0=80=EA=B2=A9=20=EC=88=98=EC=A0=953?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/config/SpringSecurityConfig.java | 2 +- .../readyverydemo/src/order/dto/OrderMapper.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java b/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java index 2f44b1d..589f113 100644 --- a/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java +++ b/src/main/java/com/readyvery/readyverydemo/security/config/SpringSecurityConfig.java @@ -61,7 +61,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { "/api/v1/board/**", "/api/v1/order/current", "/api/v1/auth", - "api/v1/event/**" + "/api/v1/event/**" ).permitAll() // 위를 제외한 나머지는 모두 허용 .anyRequest().authenticated() // 해당 요청은 인증이 필요함 ) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index e98d941..19a990d 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -119,7 +119,7 @@ public CartGetRes cartToCartGetRes(Cart cart, Long inout) { cart.getCartItems() .stream() .filter(cartItem -> !cartItem.getIsDeleted()) - .mapToLong(cartItem -> cartItemTotalPrice(cartItem, inout)) + .mapToLong(cartItem -> cartItemsTotalPrice(cartItem, inout))// .sum()) .build(); } @@ -161,6 +161,15 @@ private Long cartItemTotalPrice(CartItem cartItem, Long inout) { return totalPrice * cartItem.getCount(); } + private Long cartItemsTotalPrice(CartItem cartItem, Long inout) { + Long optionsPriceSum = cartItem.getCartOptions() + .stream() + .mapToLong(cartOption -> cartOption.getFoodieOption().getPrice()) + .sum(); + + return optionsPriceSum + determinePrice(cartItem.getFoodie(), inout); + } + public TosspaymentMakeRes orderToTosspaymentMakeRes(Order order) { return TosspaymentMakeRes.builder() .orderId(order.getOrderId()) From 73c6f659da446c8ac16e37968d8cfe79cf7db28e Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 06:20:07 +0900 Subject: [PATCH 31/80] =?UTF-8?q?Fix:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=20=EC=95=84=EC=9D=B4=ED=85=9C=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EA=B0=80=EA=B2=A9=20=EC=88=98=EC=A0=954?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 19a990d..11028c4 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -119,7 +119,7 @@ public CartGetRes cartToCartGetRes(Cart cart, Long inout) { cart.getCartItems() .stream() .filter(cartItem -> !cartItem.getIsDeleted()) - .mapToLong(cartItem -> cartItemsTotalPrice(cartItem, inout))// + .mapToLong(cartItem -> cartItemTotalPrice(cartItem, inout))// .sum()) .build(); } From 3611f44fca363285c82ad57c9d45e2f94daa9cac Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 06:22:02 +0900 Subject: [PATCH 32/80] =?UTF-8?q?Fix:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=20=EC=95=84=EC=9D=B4=ED=85=9C=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EA=B0=80=EA=B2=A9=20=EC=88=98=EC=A0=955?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 11028c4..1446d88 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -134,7 +134,7 @@ private CartDto cartItemToCartDto(CartItem cartItem, Long inout) { ? IMG_URL + cartItem.getFoodie().getFoodieCategory().getStore().getEngName() + "/" + cartItem.getFoodie().getImgUrl() : null) - .totalPrice(cartItemTotalPrice(cartItem, inout)) + .totalPrice(cartItemsTotalPrice(cartItem, inout)) .options( cartItem.getCartOptions() .stream() From 2801ce229850aaa92947fa725e09fd6ae9644c89 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 06:27:54 +0900 Subject: [PATCH 33/80] =?UTF-8?q?Fix:=20Put=20=EC=BF=BC=EB=A6=AC=20?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=EB=A7=81=20=EC=82=AC=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/order/OrderController.java | 6 +++--- .../readyverydemo/src/order/OrderService.java | 3 +-- .../readyverydemo/src/order/OrderServiceImpl.java | 11 +++++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index 33a79db..7df74fe 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -16,7 +16,6 @@ import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; import com.readyvery.readyverydemo.src.order.dto.CartAddReq; import com.readyvery.readyverydemo.src.order.dto.CartAddRes; -import com.readyvery.readyverydemo.src.order.dto.CartEditReq; import com.readyvery.readyverydemo.src.order.dto.CartEidtRes; import com.readyvery.readyverydemo.src.order.dto.CartGetRes; import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteRes; @@ -114,8 +113,9 @@ public ResponseEntity cancelTossPayment(@AuthenticationPrincipal CustomU @PutMapping("/cart") public ResponseEntity updateCart(@AuthenticationPrincipal CustomUserDetails userDetails, - @RequestBody CartEditReq cartEditReq) { - CartEidtRes cartEditRes = orderService.editCart(userDetails, cartEditReq); + @RequestParam Long idx, + @RequestParam Long count) { + CartEidtRes cartEditRes = orderService.editCart(userDetails, idx, count); return new ResponseEntity<>(cartEditRes, HttpStatus.OK); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java index 528f306..eaeb1d5 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -4,7 +4,6 @@ import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; import com.readyvery.readyverydemo.src.order.dto.CartAddReq; import com.readyvery.readyverydemo.src.order.dto.CartAddRes; -import com.readyvery.readyverydemo.src.order.dto.CartEditReq; import com.readyvery.readyverydemo.src.order.dto.CartEidtRes; import com.readyvery.readyverydemo.src.order.dto.CartGetRes; import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteRes; @@ -23,7 +22,7 @@ public interface OrderService { CartAddRes addCart(CustomUserDetails userDetails, CartAddReq cartAddReq); - CartEidtRes editCart(CustomUserDetails userDetails, CartEditReq cartEditReq); + CartEidtRes editCart(CustomUserDetails userDetails, Long idx, Long count); CartItemDeleteRes deleteCart(CustomUserDetails userDetails, Long idx); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index bf0739a..ff7bf10 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -45,7 +45,6 @@ import com.readyvery.readyverydemo.src.order.config.TossPaymentConfig; import com.readyvery.readyverydemo.src.order.dto.CartAddReq; import com.readyvery.readyverydemo.src.order.dto.CartAddRes; -import com.readyvery.readyverydemo.src.order.dto.CartEditReq; import com.readyvery.readyverydemo.src.order.dto.CartEidtRes; import com.readyvery.readyverydemo.src.order.dto.CartGetRes; import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteRes; @@ -118,12 +117,12 @@ private void verifyItemsInCart(Cart cart, Store store) { } @Override - public CartEidtRes editCart(CustomUserDetails userDetails, CartEditReq cartEditReq) { - CartItem cartItem = getCartItem(cartEditReq.getIdx()); + public CartEidtRes editCart(CustomUserDetails userDetails, Long idx, Long count) { + CartItem cartItem = getCartItem(idx); verifyCartItem(cartItem, userDetails); - editCartItem(cartItem, cartEditReq); + editCartItem(cartItem, count); cartItemRepository.save(cartItem); return orderMapper.cartToCartEditRes(cartItem); } @@ -444,8 +443,8 @@ private void deleteCartItem(CartItem cartItem) { cartItem.setIsDeleted(true); } - private void editCartItem(CartItem cartItem, CartEditReq cartEditReq) { - cartItem.setCount(cartEditReq.getCount()); + private void editCartItem(CartItem cartItem, Long count) { + cartItem.setCount(count); } private void verifyCartItem(CartItem cartItem, CustomUserDetails userDetails) { From 493d68f27d9833981280cddb862b4f62a7487f48 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 17:24:32 +0900 Subject: [PATCH 34/80] =?UTF-8?q?Fix:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=EC=97=90=20inout=20=EC=83=81=ED=83=9C=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 --- .../com/readyvery/readyverydemo/domain/Cart.java | 3 +++ .../global/exception/ExceptionCode.java | 3 ++- .../readyverydemo/src/order/OrderServiceImpl.java | 12 ++++++++++-- .../readyverydemo/src/order/dto/CartAddReq.java | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java index e1c444b..1f7531b 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java @@ -37,6 +37,9 @@ public class Cart extends BaseTimeEntity { @Column(name = "cart_idx") private Long id; + @Column(nullable = false) + private Long inout; + // 장바구니 유저 연관관계 매핑 @ManyToOne(fetch = FetchType.LAZY) diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index 1562249..beed4c5 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -23,7 +23,8 @@ public enum ExceptionCode { COUPON_NOT_ACTIVE(400, "Coupon is not active."), COUPON_CODE_NOT_MATCH(400, "Coupon code is not match."), COUPON_ISSUE_COUNT_EXCEED(400, "Coupon issue count exceed."), - ORDER_NOT_RECEIPT(400, "Order is not receipt."); + ORDER_NOT_RECEIPT(400, "Order is not receipt."), + INVALID_INOUT(400, "Invalid inout."); private int status; private String message; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index ff7bf10..ce6026b 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -96,7 +96,7 @@ public CartAddRes addCart(CustomUserDetails userDetails, CartAddReq cartAddReq) verifyCartAddReq(foodie, cartAddReq); Cart cart = cartRepository.findByUserInfoAndIsDeletedFalseAndIsOrderedFalse(user) - .orElseGet(() -> makeCart(user, store)); + .orElseGet(() -> makeCart(user, store, cartAddReq.getInout())); verifyItemsInCart(cart, store); CartItem cartItem = makeCartItem(cart, foodie, cartAddReq.getCount()); List cartOptions = cartAddReq.getOptions().stream() @@ -482,10 +482,11 @@ private CartItem makeCartItem(Cart cart, Foodie foodie, Long count) { .build(); } - private Cart makeCart(UserInfo user, Store store) { + private Cart makeCart(UserInfo user, Store store, Long inout) { return Cart.builder() .userInfo(user) .store(store) + .inout(inout) .build(); } @@ -504,6 +505,13 @@ private Store getStore(Long storeId) { private void verifyCartAddReq(Foodie foodie, CartAddReq cartAddReq) { verifyOption(foodie, cartAddReq.getOptions()); verifyEssentialOption(foodie, cartAddReq.getOptions()); + verifyInout(cartAddReq.getInout()); + } + + private void verifyInout(Long inout) { + if (!inout.equals(EAT_IN) && !inout.equals(TAKE_OUT)) { + throw new BusinessLogicException(ExceptionCode.INVALID_INOUT); + } } private Foodie getFoody(Long foodieId) { diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartAddReq.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartAddReq.java index 3da1c57..ccd368f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartAddReq.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartAddReq.java @@ -10,4 +10,5 @@ public class CartAddReq { private Long foodieId; private List options; private Long count; + private Long inout; } From 75ea2662da0b12d6c261f74dc96b3f7ad3f226f4 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 19:00:57 +0900 Subject: [PATCH 35/80] =?UTF-8?q?Fix:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=EC=97=90=20inout=20=EC=83=81=ED=83=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=802?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyvery/readyverydemo/domain/Cart.java | 2 +- .../global/exception/ExceptionCode.java | 3 +- .../src/order/OrderController.java | 5 ++- .../readyverydemo/src/order/OrderService.java | 2 +- .../src/order/OrderServiceImpl.java | 31 +++++++++++++------ .../src/order/dto/OrderMapper.java | 12 +++---- .../src/order/dto/PaymentReq.java | 1 - src/main/resources/application.properties | 2 +- 8 files changed, 34 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java index 1f7531b..32c95aa 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Cart.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Cart.java @@ -38,7 +38,7 @@ public class Cart extends BaseTimeEntity { private Long id; @Column(nullable = false) - private Long inout; + private Long inOut; // 장바구니 유저 연관관계 매핑 diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index beed4c5..c783e86 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -24,7 +24,8 @@ public enum ExceptionCode { COUPON_CODE_NOT_MATCH(400, "Coupon code is not match."), COUPON_ISSUE_COUNT_EXCEED(400, "Coupon issue count exceed."), ORDER_NOT_RECEIPT(400, "Order is not receipt."), - INVALID_INOUT(400, "Invalid inout."); + INVALID_INOUT(400, "Invalid inout."), + CART_NOT_EDITABLE(400, "Cart is not editable."); private int status; private String message; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index 7df74fe..b6d1563 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -47,9 +47,8 @@ public ResponseEntity getFoody( } @GetMapping("/cart") - public ResponseEntity getCart(@AuthenticationPrincipal CustomUserDetails userDetails, - @RequestParam("inout") Long inout) { - CartGetRes cartGetRes = orderService.getCart(userDetails, inout); + public ResponseEntity getCart(@AuthenticationPrincipal CustomUserDetails userDetails) { + CartGetRes cartGetRes = orderService.getCart(userDetails); return new ResponseEntity<>(cartGetRes, HttpStatus.OK); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java index eaeb1d5..346b2d8 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -28,7 +28,7 @@ public interface OrderService { CartResetRes resetCart(CustomUserDetails userDetails); - CartGetRes getCart(CustomUserDetails userDetails, Long inout); + CartGetRes getCart(CustomUserDetails userDetails); TosspaymentMakeRes requestTossPayment(CustomUserDetails userDetails, PaymentReq paymentReq); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index ce6026b..8763015 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -97,6 +97,8 @@ public CartAddRes addCart(CustomUserDetails userDetails, CartAddReq cartAddReq) Cart cart = cartRepository.findByUserInfoAndIsDeletedFalseAndIsOrderedFalse(user) .orElseGet(() -> makeCart(user, store, cartAddReq.getInout())); + + verifyCart(cart); verifyItemsInCart(cart, store); CartItem cartItem = makeCartItem(cart, foodie, cartAddReq.getCount()); List cartOptions = cartAddReq.getOptions().stream() @@ -119,7 +121,7 @@ private void verifyItemsInCart(Cart cart, Store store) { @Override public CartEidtRes editCart(CustomUserDetails userDetails, Long idx, Long count) { CartItem cartItem = getCartItem(idx); - + verifyCart(cartItem.getCart()); verifyCartItem(cartItem, userDetails); editCartItem(cartItem, count); @@ -127,6 +129,15 @@ public CartEidtRes editCart(CustomUserDetails userDetails, Long idx, Long count) return orderMapper.cartToCartEditRes(cartItem); } + private void verifyCart(Cart cart) { + if (cart.getIsOrdered()) { + throw new BusinessLogicException(ExceptionCode.CART_NOT_EDITABLE); + } + if (cart.getIsDeleted()) { + throw new BusinessLogicException(ExceptionCode.CART_NOT_EDITABLE); + } + } + @Override public CartItemDeleteRes deleteCart(CustomUserDetails userDetails, Long idx) { CartItem cartItem = getCartItem(idx); @@ -150,11 +161,11 @@ public CartResetRes resetCart(CustomUserDetails userDetails) { } @Override - public CartGetRes getCart(CustomUserDetails userDetails, Long inout) { + public CartGetRes getCart(CustomUserDetails userDetails) { UserInfo user = getUserInfo(userDetails); Cart cart = getCart(user); - return orderMapper.cartToCartGetRes(cart, inout); + return orderMapper.cartToCartGetRes(cart); } @Override @@ -164,9 +175,9 @@ public TosspaymentMakeRes requestTossPayment(CustomUserDetails userDetails, Paym Store store = cart.getStore(); // Long amount = calculateAmount(store, paymentReq.getCarts(), paymentReq.getInout()); - Long amount = calculateAmount2(cart, paymentReq.getInout()); + Long amount = calculateAmount2(cart); //TODO: 쿠폰 추가 - Order order = makeOrder(user, store, amount, cart, paymentReq.getInout()); + Order order = makeOrder(user, store, amount, cart); cartOrder(cart); orderRepository.save(order); cartRepository.save(cart); @@ -372,7 +383,7 @@ private HttpHeaders makeTossHeader() { return headers; } - private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Long inout) { + private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart) { if (cart.getCartItems().isEmpty()) { throw new BusinessLogicException(ExceptionCode.CART_NOT_FOUND); } @@ -392,7 +403,7 @@ private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Long .totalAmount(amount) .orderNumber(null) .progress(Progress.REQUEST) - .inOut(inout) + .inOut(cart.getInOut()) .build(); } @@ -415,11 +426,11 @@ private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Long // .reduce(0L, Long::sum); // } - private Long calculateAmount2(Cart cart, Long inout) { + private Long calculateAmount2(Cart cart) { return cart.getCartItems().stream() .filter(cartItem -> !cartItem.getIsDeleted()) .map(cartItem -> { - Long price = orderMapper.determinePrice(cartItem.getFoodie(), inout); + Long price = orderMapper.determinePrice(cartItem.getFoodie(), cart.getInOut()); Long totalPrice = cartItem.getCartOptions().stream() .map(CartOption::getFoodieOption) .map(FoodieOption::getPrice) @@ -486,7 +497,7 @@ private Cart makeCart(UserInfo user, Store store, Long inout) { return Cart.builder() .userInfo(user) .store(store) - .inout(inout) + .inOut(inout) .build(); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index c086942..0834420 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -99,7 +99,7 @@ public CartResetRes cartToCartResetRes(Cart cart) { .build(); } - public CartGetRes cartToCartGetRes(Cart cart, Long inout) { + public CartGetRes cartToCartGetRes(Cart cart) { return CartGetRes.builder() .name(cart.getStore().getName()) .imgUrl(cart.getStore() @@ -113,13 +113,13 @@ public CartGetRes cartToCartGetRes(Cart cart, Long inout) { cart.getCartItems() .stream() .filter(cartItem -> !cartItem.getIsDeleted()) - .map(cartItem -> cartItemToCartDto(cartItem, inout)) + .map(cartItem -> cartItemToCartDto(cartItem, cart.getInOut())) .toList()) .totalPrice( cart.getCartItems() .stream() .filter(cartItem -> !cartItem.getIsDeleted()) - .mapToLong(cartItem -> cartItemTotalPrice(cartItem, inout))// + .mapToLong(cartItem -> cartItemTotalPrice(cartItem, cart.getInOut()))// .sum()) .build(); } @@ -176,8 +176,8 @@ public TosspaymentMakeRes orderToTosspaymentMakeRes(Order order) { .orderName(order.getOrderName()) .successUrl(tossPaymentConfig.getTossSuccessUrl()) .failUrl(tossPaymentConfig.getTossFailUrl()) - .customerEmail("test@naver.com") - .customerName("test") + .customerEmail(order.getUserInfo().getEmail()) + .customerName(order.getUserInfo().getNickName()) .amount(order.getAmount()) .build(); } @@ -274,7 +274,7 @@ public HistoryDetailRes orderToHistoryDetailRes(Order order) { .orderTime(order.getCreatedAt().format(DateTimeFormatter.ofPattern(DATE_FORMAT))) .orderId(order.getOrderId()) .storePhone(order.getStore().getPhone()) - .cart(cartToCartGetRes(order.getCart(), order.getInOut())) + .cart(cartToCartGetRes(order.getCart())) .salePrice( String.valueOf(order.getCoupon() != null ? order.getCoupon().getCouponDetail().getSalePrice() diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/PaymentReq.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/PaymentReq.java index 750894c..1b96a89 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/PaymentReq.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/PaymentReq.java @@ -5,5 +5,4 @@ @Getter public class PaymentReq { private Long couponId; - private Long inout; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 881d405..d1fa228 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,7 +4,7 @@ spring.datasource.url=jdbc:mysql://test.readyvery.com:33306/readyvery spring.datasource.username=ready #spring.datasource.password=12345678 spring.datasource.password=readyverytestuser23! -spring.jpa.hibernate.ddl-auto=update +spring.jpa.hibernate.ddl-auto=none spring.jpa.generate-ddl=true spring.jpa.show-sql=true spring.jackson.serialization.fail-on-empty-beans=false From 07d57933d7980f2daafc17193a5504400517c7f5 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 26 Nov 2023 23:21:35 +0900 Subject: [PATCH 36/80] =?UTF-8?q?Feat:=20=EC=BF=A0=ED=8F=B0=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/domain/Coupon.java | 6 +++ .../domain/repository/CouponRepository.java | 15 ++++++ .../global/exception/ExceptionCode.java | 3 +- .../src/order/OrderServiceImpl.java | 53 +++++++++++++++++-- src/main/resources/application.properties | 2 +- 5 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/readyvery/readyverydemo/domain/repository/CouponRepository.java diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java b/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java index 51e8a48..1c8f2f1 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java @@ -10,13 +10,16 @@ import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToOne; import jakarta.persistence.Table; +import jakarta.persistence.Version; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; @Getter +@Setter @Entity @Builder @Table(name = "COUPON") @@ -42,6 +45,9 @@ public class Coupon extends BaseTimeEntity { @JoinColumn(name = "user_idx") private UserInfo userInfo; + @Version + private Long version; + @OneToOne(mappedBy = "coupon", fetch = FetchType.LAZY) private Order order; diff --git a/src/main/java/com/readyvery/readyverydemo/domain/repository/CouponRepository.java b/src/main/java/com/readyvery/readyverydemo/domain/repository/CouponRepository.java new file mode 100644 index 0000000..9303ea5 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/domain/repository/CouponRepository.java @@ -0,0 +1,15 @@ +package com.readyvery.readyverydemo.domain.repository; + +import java.util.Optional; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Lock; + +import com.readyvery.readyverydemo.domain.Coupon; + +import jakarta.persistence.LockModeType; + +public interface CouponRepository extends JpaRepository { + @Lock(LockModeType.OPTIMISTIC) + Optional findById(Long id); +} diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index c783e86..079d0f4 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -25,7 +25,8 @@ public enum ExceptionCode { COUPON_ISSUE_COUNT_EXCEED(400, "Coupon issue count exceed."), ORDER_NOT_RECEIPT(400, "Order is not receipt."), INVALID_INOUT(400, "Invalid inout."), - CART_NOT_EDITABLE(400, "Cart is not editable."); + CART_NOT_EDITABLE(400, "Cart is not editable."), + COUPON_NOT_VALID(400, "Coupon is not valid."); private int status; private String message; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 8763015..946be20 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -3,6 +3,7 @@ import static com.readyvery.readyverydemo.global.Constant.*; import java.nio.charset.StandardCharsets; +import java.time.LocalDateTime; import java.util.Base64; import java.util.Collections; import java.util.List; @@ -21,6 +22,7 @@ import com.readyvery.readyverydemo.domain.Cart; import com.readyvery.readyverydemo.domain.CartItem; import com.readyvery.readyverydemo.domain.CartOption; +import com.readyvery.readyverydemo.domain.Coupon; import com.readyvery.readyverydemo.domain.Foodie; import com.readyvery.readyverydemo.domain.FoodieOption; import com.readyvery.readyverydemo.domain.FoodieOptionCategory; @@ -32,6 +34,7 @@ import com.readyvery.readyverydemo.domain.repository.CartItemRepository; import com.readyvery.readyverydemo.domain.repository.CartOptionRepository; import com.readyvery.readyverydemo.domain.repository.CartRepository; +import com.readyvery.readyverydemo.domain.repository.CouponRepository; import com.readyvery.readyverydemo.domain.repository.FoodieOptionRepository; import com.readyvery.readyverydemo.domain.repository.FoodieRepository; import com.readyvery.readyverydemo.domain.repository.OrderRepository; @@ -60,6 +63,7 @@ import com.readyvery.readyverydemo.src.order.dto.TosspaymentDto; import com.readyvery.readyverydemo.src.order.dto.TosspaymentMakeRes; +import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; @Service @@ -77,6 +81,7 @@ public class OrderServiceImpl implements OrderService { private final TossPaymentConfig tosspaymentConfig; private final OrdersRepository ordersRepository; private final ReceiptRepository receiptRepository; + private final CouponRepository couponRepository; @Override public FoodyDetailRes getFoody(Long storeId, Long foodyId, Long inout) { @@ -173,22 +178,58 @@ public TosspaymentMakeRes requestTossPayment(CustomUserDetails userDetails, Paym UserInfo user = getUserInfo(userDetails); Cart cart = getCart(user); Store store = cart.getStore(); + Coupon coupon = getCoupon(paymentReq.getCouponId()); + verifyCoupon(user, coupon); // Long amount = calculateAmount(store, paymentReq.getCarts(), paymentReq.getInout()); Long amount = calculateAmount2(cart); - //TODO: 쿠폰 추가 - Order order = makeOrder(user, store, amount, cart); + Order order = makeOrder(user, store, amount, cart, coupon); cartOrder(cart); orderRepository.save(order); cartRepository.save(cart); return orderMapper.orderToTosspaymentMakeRes(order); } + private void verifyCoupon(UserInfo user, Coupon coupon) { + isCoupon(coupon); + isUserCoupon(user, coupon); + } + + private void isUserCoupon(UserInfo user, Coupon coupon) { + if (coupon.getUserInfo().equals(user)) { + return; + } + throw new BusinessLogicException(ExceptionCode.COUPON_NOT_ACTIVE); + } + + private void isCoupon(Coupon coupon) { + if (coupon == null) { + return; + } + if (!coupon.isUsed()) { + return; + } + if (coupon.getCouponDetail().getExpire().isAfter(LocalDateTime.now())) { + return; + } + throw new BusinessLogicException(ExceptionCode.COUPON_NOT_VALID); + } + + private Coupon getCoupon(Long couponId) { + if (couponId == null) { + return null; + } + return couponRepository.findById(couponId).orElseThrow( + () -> new BusinessLogicException(ExceptionCode.COUPON_NOT_FOUND) + ); + } + private void cartOrder(Cart cart) { cart.setIsOrdered(true); } @Override + @Transactional public String tossPaymentSuccess(String paymentKey, String orderId, Long amount) { Order order = getOrder(orderId); verifyOrder(order, amount); @@ -331,6 +372,7 @@ private void applyTosspaymentDto(Order order, TosspaymentDto tosspaymentDto) { order.setProgress(Progress.ORDER); order.setPayStatus(true); order.getCart().setIsOrdered(true); + order.getCoupon().setUsed(true); } private String getOrderNumber(Order order) { @@ -343,7 +385,7 @@ private String getOrderNumber(Order order) { } private void verifyOrder(Order order, Long amount) { - if (!order.getTotalAmount().equals(amount)) { + if (!order.getAmount().equals(amount)) { throw new BusinessLogicException(ExceptionCode.TOSS_PAYMENT_AMOUNT_NOT_MATCH); } } @@ -383,7 +425,7 @@ private HttpHeaders makeTossHeader() { return headers; } - private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart) { + private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Coupon coupon) { if (cart.getCartItems().isEmpty()) { throw new BusinessLogicException(ExceptionCode.CART_NOT_FOUND); } @@ -395,9 +437,10 @@ private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart) { return Order.builder() .userInfo(user) .store(store) - .amount(amount) + .amount(amount - coupon.getCouponDetail().getSalePrice()) .orderId(UUID.randomUUID().toString()) .cart(cart) + .coupon(coupon) .paymentKey(null) .orderName(orderName) .totalAmount(amount) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index d1fa228..1712aea 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -5,7 +5,7 @@ spring.datasource.username=ready #spring.datasource.password=12345678 spring.datasource.password=readyverytestuser23! spring.jpa.hibernate.ddl-auto=none -spring.jpa.generate-ddl=true +spring.jpa.generate-ddl=false spring.jpa.show-sql=true spring.jackson.serialization.fail-on-empty-beans=false # JWT Configuration From 2f1b26f413f509a47d946719851d044e9c6f4786 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 02:08:43 +0900 Subject: [PATCH 37/80] =?UTF-8?q?Fix:=20=EC=BF=A0=ED=8F=B0=20null=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/domain/Coupon.java | 10 ++++++---- .../java/com/readyvery/readyverydemo/domain/Order.java | 2 +- .../readyverydemo/src/order/OrderServiceImpl.java | 3 +++ src/main/resources/application.properties | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java b/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java index 1c8f2f1..dd94844 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java @@ -1,5 +1,8 @@ package com.readyvery.readyverydemo.domain; +import java.util.ArrayList; +import java.util.List; + import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.FetchType; @@ -8,7 +11,7 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToOne; +import jakarta.persistence.OneToMany; import jakarta.persistence.Table; import jakarta.persistence.Version; import lombok.AllArgsConstructor; @@ -48,7 +51,6 @@ public class Coupon extends BaseTimeEntity { @Version private Long version; - @OneToOne(mappedBy = "coupon", fetch = FetchType.LAZY) - private Order order; - + @OneToMany(mappedBy = "coupon", fetch = FetchType.LAZY) + private List orders = new ArrayList(); } diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Order.java b/src/main/java/com/readyvery/readyverydemo/domain/Order.java index c4f20df..0ceb3f5 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Order.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Order.java @@ -97,7 +97,7 @@ public class Order extends BaseTimeEntity { @JoinColumn(name = "cart_idx") private Cart cart; - @OneToOne(fetch = FetchType.LAZY) + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "coupon_idx") private Coupon coupon; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 946be20..2a8620f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -196,6 +196,9 @@ private void verifyCoupon(UserInfo user, Coupon coupon) { } private void isUserCoupon(UserInfo user, Coupon coupon) { + if (coupon == null) { + return; + } if (coupon.getUserInfo().equals(user)) { return; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 1712aea..881d405 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -4,8 +4,8 @@ spring.datasource.url=jdbc:mysql://test.readyvery.com:33306/readyvery spring.datasource.username=ready #spring.datasource.password=12345678 spring.datasource.password=readyverytestuser23! -spring.jpa.hibernate.ddl-auto=none -spring.jpa.generate-ddl=false +spring.jpa.hibernate.ddl-auto=update +spring.jpa.generate-ddl=true spring.jpa.show-sql=true spring.jackson.serialization.fail-on-empty-beans=false # JWT Configuration From 440b8a0462f61931c94e1396112f05c96c836c1c Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 02:25:33 +0900 Subject: [PATCH 38/80] =?UTF-8?q?Fix:=20=EC=BF=A0=ED=8F=B0=20null=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/OrderServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 2a8620f..ba5ab62 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -440,7 +440,7 @@ private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Coup return Order.builder() .userInfo(user) .store(store) - .amount(amount - coupon.getCouponDetail().getSalePrice()) + .amount(amount - (coupon != null ? coupon.getCouponDetail().getSalePrice() : 0)) .orderId(UUID.randomUUID().toString()) .cart(cart) .coupon(coupon) From 2cc253430e070e603c82aefd46ee3c339a660d02 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 02:31:40 +0900 Subject: [PATCH 39/80] =?UTF-8?q?Fix:=20=EC=BF=A0=ED=8F=B0=20null=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyvery/readyverydemo/src/order/OrderServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index ba5ab62..d92bdfd 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -375,7 +375,9 @@ private void applyTosspaymentDto(Order order, TosspaymentDto tosspaymentDto) { order.setProgress(Progress.ORDER); order.setPayStatus(true); order.getCart().setIsOrdered(true); - order.getCoupon().setUsed(true); + if (order.getCoupon() != null) { + order.getCoupon().setUsed(true); + } } private String getOrderNumber(Order order) { From 50ebdbf3da1405580c7da2722ead2b36fec44359 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 02:58:00 +0900 Subject: [PATCH 40/80] =?UTF-8?q?Feat:=20=EA=B3=84=EC=82=B0=20=EB=82=B4?= =?UTF-8?q?=EC=97=AD=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/order/dto/HistoryDetailRes.java | 3 +++ .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java index cf34f9b..920e411 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java @@ -14,4 +14,7 @@ public class HistoryDetailRes { private CartGetRes cart; private String salePrice; private String method; + private Long cartId; + private Long storeId; + private Long inOut; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 0834420..c69b7d2 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -269,6 +269,9 @@ public DefaultRes tosspaymentDtoToCancelRes() { public HistoryDetailRes orderToHistoryDetailRes(Order order) { return HistoryDetailRes.builder() + .cartId(order.getCart().getId()) + .storeId(order.getStore().getId()) + .inOut(order.getInOut()) .orderStatus(order.getProgress().toString()) .storeName(order.getStore().getName()) .orderTime(order.getCreatedAt().format(DateTimeFormatter.ofPattern(DATE_FORMAT))) From e270c53cd1e723f5659aeb4fd9808983f6cec2b1 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 03:04:23 +0900 Subject: [PATCH 41/80] =?UTF-8?q?Feat:=20=EA=B3=84=EC=82=B0=20=EB=82=B4?= =?UTF-8?q?=EC=97=AD=20=EC=B6=94=EA=B0=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/order/dto/HistoryDetailRes.java | 3 --- .../readyvery/readyverydemo/src/order/dto/OrderMapper.java | 6 +++--- .../readyverydemo/src/order/dto/ReceiptHistoryDto.java | 3 +++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java index 920e411..cf34f9b 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java @@ -14,7 +14,4 @@ public class HistoryDetailRes { private CartGetRes cart; private String salePrice; private String method; - private Long cartId; - private Long storeId; - private Long inOut; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index c69b7d2..708069b 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -236,6 +236,9 @@ private ReceiptHistoryDto orderToReceiptHistoryDto(Order order) { return ReceiptHistoryDto.builder() .dateTime(order.getCreatedAt().format(DateTimeFormatter.ofPattern(DATE_FORMAT))) .name(order.getStore().getName()) + .cartId(order.getCart().getId()) + .storeId(order.getStore().getId()) + .inOut(order.getInOut()) .progress(order.getProgress()) .imgUrl(order.getStore() .getImgs() @@ -269,9 +272,6 @@ public DefaultRes tosspaymentDtoToCancelRes() { public HistoryDetailRes orderToHistoryDetailRes(Order order) { return HistoryDetailRes.builder() - .cartId(order.getCart().getId()) - .storeId(order.getStore().getId()) - .inOut(order.getInOut()) .orderStatus(order.getProgress().toString()) .storeName(order.getStore().getName()) .orderTime(order.getCreatedAt().format(DateTimeFormatter.ofPattern(DATE_FORMAT))) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/ReceiptHistoryDto.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/ReceiptHistoryDto.java index 9095d55..ac61a7f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/ReceiptHistoryDto.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/ReceiptHistoryDto.java @@ -15,4 +15,7 @@ public class ReceiptHistoryDto { private Long amount; private String orderId; private Progress progress; + private Long cartId; + private Long storeId; + private Long inOut; } From 97a31f5e3c148f3b743f6e0ed66706fc0039e678 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 03:10:01 +0900 Subject: [PATCH 42/80] =?UTF-8?q?Fix:=20cart=20Id=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/CartGetRes.java | 1 + .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java index 32a81fd..a3a28d0 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java @@ -11,5 +11,6 @@ public class CartGetRes { private String name; private String imgUrl; private Long totalPrice; + private Long cartId; private List carts; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 708069b..6cf846a 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -101,6 +101,7 @@ public CartResetRes cartToCartResetRes(Cart cart) { public CartGetRes cartToCartGetRes(Cart cart) { return CartGetRes.builder() + .cartId(cart.getId()) .name(cart.getStore().getName()) .imgUrl(cart.getStore() .getImgs() From f29ff9e2c50ff16c04829202d7969a16243c285f Mon Sep 17 00:00:00 2001 From: 1223v <1223v@naver.com> Date: Mon, 27 Nov 2023 03:18:40 +0900 Subject: [PATCH 43/80] =?UTF-8?q?Feat:=20=EA=B3=84=EC=A0=95=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/domain/UserInfo.java | 9 +++ .../service/CustomOAuth2UserService.java | 3 + .../src/user/UserController.java | 15 ++++ .../readyverydemo/src/user/UserService.java | 5 ++ .../src/user/UserServiceImpl.java | 68 +++++++++++++++++++ .../src/user/dto/UserRemoveRes.java | 12 ++++ src/main/resources/application.properties | 1 + 7 files changed, 113 insertions(+) create mode 100644 src/main/java/com/readyvery/readyverydemo/src/user/dto/UserRemoveRes.java diff --git a/src/main/java/com/readyvery/readyverydemo/domain/UserInfo.java b/src/main/java/com/readyvery/readyverydemo/domain/UserInfo.java index 5e37501..9016dc0 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/UserInfo.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/UserInfo.java @@ -108,4 +108,13 @@ public class UserInfo extends BaseTimeEntity { public void updateRefresh(String updateRefreshToken) { this.refreshToken = updateRefreshToken; } + + public void updateRemoveUserDate() { + this.status = true; + this.deleteDate = LocalDateTime.now(); + } + + public void updateStatus(boolean status) { + this.status = status; + } } diff --git a/src/main/java/com/readyvery/readyverydemo/security/oauth2/service/CustomOAuth2UserService.java b/src/main/java/com/readyvery/readyverydemo/security/oauth2/service/CustomOAuth2UserService.java index d8fe15b..1a662ad 100644 --- a/src/main/java/com/readyvery/readyverydemo/security/oauth2/service/CustomOAuth2UserService.java +++ b/src/main/java/com/readyvery/readyverydemo/security/oauth2/service/CustomOAuth2UserService.java @@ -82,6 +82,9 @@ private UserInfo getUser(OAuthAttributes attributes, SocialType socialType) { if (findUser == null) { return saveUser(attributes, socialType); + } else if (findUser.isStatus()) { + findUser.updateStatus(false); + userRepository.save(findUser); } return findUser; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/user/UserController.java b/src/main/java/com/readyvery/readyverydemo/src/user/UserController.java index f1a6432..5ac1050 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/user/UserController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/user/UserController.java @@ -1,5 +1,7 @@ package com.readyvery.readyverydemo.src.user; +import java.io.IOException; + import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -8,6 +10,7 @@ import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; import com.readyvery.readyverydemo.src.user.dto.UserAuthRes; import com.readyvery.readyverydemo.src.user.dto.UserInfoRes; +import com.readyvery.readyverydemo.src.user.dto.UserRemoveRes; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; @@ -76,4 +79,16 @@ public boolean refreshEndpoint() { return true; } + /** + * 회원 탈퇴 + * @param userDetails + * @return + * @throws IOException + */ + @GetMapping("/user/remove") + public UserRemoveRes remove(@AuthenticationPrincipal CustomUserDetails userDetails, + HttpServletResponse response) throws IOException { + return userServiceImpl.removeUser(userDetails.getId(), response); + } + } diff --git a/src/main/java/com/readyvery/readyverydemo/src/user/UserService.java b/src/main/java/com/readyvery/readyverydemo/src/user/UserService.java index 8a3c797..c80b2fc 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/user/UserService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/user/UserService.java @@ -1,8 +1,11 @@ package com.readyvery.readyverydemo.src.user; +import java.io.IOException; + import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; import com.readyvery.readyverydemo.src.user.dto.UserAuthRes; import com.readyvery.readyverydemo.src.user.dto.UserInfoRes; +import com.readyvery.readyverydemo.src.user.dto.UserRemoveRes; import jakarta.servlet.http.HttpServletResponse; @@ -13,4 +16,6 @@ public interface UserService { void removeRefreshTokenInDB(Long id, HttpServletResponse response); + UserRemoveRes removeUser(Long id, HttpServletResponse response) throws IOException; + } diff --git a/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java index 4908183..34dc943 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java @@ -1,5 +1,13 @@ package com.readyvery.readyverydemo.src.user; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.charset.StandardCharsets; + import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -12,11 +20,14 @@ import com.readyvery.readyverydemo.src.user.dto.UserAuthRes; import com.readyvery.readyverydemo.src.user.dto.UserInfoRes; import com.readyvery.readyverydemo.src.user.dto.UserMapper; +import com.readyvery.readyverydemo.src.user.dto.UserRemoveRes; import jakarta.servlet.http.Cookie; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; +import lombok.extern.log4j.Log4j2; +@Log4j2 @Service @Transactional @RequiredArgsConstructor @@ -26,6 +37,8 @@ public class UserServiceImpl implements UserService { private final UserMapper userMapper; @Value("${jwt.refresh.cookie}") private String refreshCookie; + @Value("${service.app.admin.key}") + private String serviceAppAdminKey; @Override public UserAuthRes getUserAuthByCustomUserDetails(CustomUserDetails userDetails) { @@ -54,6 +67,21 @@ public void removeRefreshTokenInDB(Long id, HttpServletResponse response) { invalidateRefreshTokenCookie(response); // 쿠키 무효화 } + @Override + public UserRemoveRes removeUser(Long id, HttpServletResponse response) throws IOException { + UserInfo user = getUserInfo(id); + String kakaoRes = requestToServer("https://kapi.kakao.com/v1/user/unlink", "KakaoAK " + serviceAppAdminKey, + "target_id_type=user_id&target_id=" + user.getSocialId()); + user.updateRemoveUserDate(); + user.updateRefresh(null); // Refresh Token을 null 또는 빈 문자열로 업데이트 + userRepository.save(user); + invalidateRefreshTokenCookie(response); // 쿠키 무효화 + return UserRemoveRes.builder() + .message("회원 탈퇴가 완료되었습니다.") + .success(true) + .build(); + } + /** * 로그아웃 * @param response @@ -71,6 +99,46 @@ private UserInfo getUserInfo(Long id) { () -> new BusinessLogicException(ExceptionCode.USER_NOT_FOUND) ); } + + private String requestToServer(String kakaoApiurl, String headerStr, String postData) throws IOException { + URL url = new URL(kakaoApiurl); + HttpURLConnection connectReq = null; + + try { + connectReq = (HttpURLConnection)url.openConnection(); + connectReq.setRequestMethod("POST"); + connectReq.setDoOutput(true); // Enable writing to the connection output stream + + // Set headers + connectReq.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); + if (headerStr != null && !headerStr.isEmpty()) { + connectReq.setRequestProperty("Authorization", headerStr); + } + + // Write the post data to the request body + try (OutputStream os = connectReq.getOutputStream()) { + byte[] input = postData.getBytes(StandardCharsets.UTF_8); + os.write(input, 0, input.length); + } + + int responseCode = connectReq.getResponseCode(); + try (BufferedReader br = new BufferedReader(new InputStreamReader( + responseCode == 200 ? connectReq.getInputStream() : connectReq.getErrorStream()))) { + String inputLine; + StringBuilder response = new StringBuilder(); + log.info("responseCode: {}", responseCode); + while ((inputLine = br.readLine()) != null) { + response.append(inputLine); + } + return responseCode == 200 ? response.toString().replaceAll("'", "") : null; + } + } finally { + if (connectReq != null) { + connectReq.disconnect(); + } + } + } + } diff --git a/src/main/java/com/readyvery/readyverydemo/src/user/dto/UserRemoveRes.java b/src/main/java/com/readyvery/readyverydemo/src/user/dto/UserRemoveRes.java new file mode 100644 index 0000000..08db8f7 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/user/dto/UserRemoveRes.java @@ -0,0 +1,12 @@ +package com.readyvery.readyverydemo.src.user.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class UserRemoveRes { + + private String message; + private boolean success; +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 881d405..b46c52c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -17,6 +17,7 @@ jwt.refresh.cookie=refreshToken jwt.redirect-uri=http://localhost:3000/ jwt.access.cookie.domain=localhost jwt.refresh.cookie.domain=localhost +service.app.admin.key=e6a775436b076da9cc0c380ffbca3911 # Kakao spring.security.oauth2.client.registration.kakao.client-id=f5153d4ff1ef221bc332da3ccfec5e81 spring.security.oauth2.client.registration.kakao.client-secret=E1YuDOXrG22kymEaB53kqRYvMJrt4z5f From dff91d6846b4a74f8aeac0299b36aa3385c81b6e Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 03:20:03 +0900 Subject: [PATCH 44/80] =?UTF-8?q?Fix:=20cart=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/order/OrderController.java | 5 +++-- .../readyverydemo/src/order/OrderService.java | 2 +- .../readyverydemo/src/order/OrderServiceImpl.java | 11 +++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index b6d1563..042b84f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -47,8 +47,9 @@ public ResponseEntity getFoody( } @GetMapping("/cart") - public ResponseEntity getCart(@AuthenticationPrincipal CustomUserDetails userDetails) { - CartGetRes cartGetRes = orderService.getCart(userDetails); + public ResponseEntity getCart(@AuthenticationPrincipal CustomUserDetails userDetails, + @RequestParam("cartId") Long cartId) { + CartGetRes cartGetRes = orderService.getCart(userDetails, cartId); return new ResponseEntity<>(cartGetRes, HttpStatus.OK); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java index 346b2d8..ae52721 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -28,7 +28,7 @@ public interface OrderService { CartResetRes resetCart(CustomUserDetails userDetails); - CartGetRes getCart(CustomUserDetails userDetails); + CartGetRes getCart(CustomUserDetails userDetails, Long cartId); TosspaymentMakeRes requestTossPayment(CustomUserDetails userDetails, PaymentReq paymentReq); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index d92bdfd..5fc1633 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -7,6 +7,7 @@ import java.util.Base64; import java.util.Collections; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -166,13 +167,19 @@ public CartResetRes resetCart(CustomUserDetails userDetails) { } @Override - public CartGetRes getCart(CustomUserDetails userDetails) { + public CartGetRes getCart(CustomUserDetails userDetails, Long cartId) { UserInfo user = getUserInfo(userDetails); - Cart cart = getCart(user); + Cart cart = getCartId(user, cartId); return orderMapper.cartToCartGetRes(cart); } + private Cart getCartId(UserInfo user, Long cartId) { + return Optional.ofNullable(cartId) + .flatMap(id -> cartRepository.findById(cartId)) + .orElseGet(() -> getCart(user)); + } + @Override public TosspaymentMakeRes requestTossPayment(CustomUserDetails userDetails, PaymentReq paymentReq) { UserInfo user = getUserInfo(userDetails); From a9c004e612383ca4546952272b0b7b8fbfc509a7 Mon Sep 17 00:00:00 2001 From: 1223v <1223v@naver.com> Date: Mon, 27 Nov 2023 03:35:19 +0900 Subject: [PATCH 45/80] =?UTF-8?q?Fix:=20UserLogoutRes=EB=A1=9C=20req=5Fbod?= =?UTF-8?q?y=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/user/UserController.java | 8 ++++++-- .../readyverydemo/src/user/dto/UserLogoutRes.java | 11 +++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/readyvery/readyverydemo/src/user/dto/UserLogoutRes.java diff --git a/src/main/java/com/readyvery/readyverydemo/src/user/UserController.java b/src/main/java/com/readyvery/readyverydemo/src/user/UserController.java index 5ac1050..f233934 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/user/UserController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/user/UserController.java @@ -10,6 +10,7 @@ import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; import com.readyvery.readyverydemo.src.user.dto.UserAuthRes; import com.readyvery.readyverydemo.src.user.dto.UserInfoRes; +import com.readyvery.readyverydemo.src.user.dto.UserLogoutRes; import com.readyvery.readyverydemo.src.user.dto.UserRemoveRes; import jakarta.servlet.http.HttpServletResponse; @@ -63,10 +64,13 @@ public CustomUserDetails userDetail(@AuthenticationPrincipal CustomUserDetails u * 사용자 로그아웃 */ @GetMapping("/user/logout") - public boolean logout(@AuthenticationPrincipal CustomUserDetails userDetails, HttpServletResponse response) { + public UserLogoutRes logout(@AuthenticationPrincipal CustomUserDetails userDetails, HttpServletResponse response) { userServiceImpl.removeRefreshTokenInDB(userDetails.getId(), response); - return true; + return UserLogoutRes.builder() + .success(true) + .message("로그아웃 성공") + .build(); } /** diff --git a/src/main/java/com/readyvery/readyverydemo/src/user/dto/UserLogoutRes.java b/src/main/java/com/readyvery/readyverydemo/src/user/dto/UserLogoutRes.java new file mode 100644 index 0000000..9aaae9b --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/user/dto/UserLogoutRes.java @@ -0,0 +1,11 @@ +package com.readyvery.readyverydemo.src.user.dto; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class UserLogoutRes { + private boolean success; + private String message; +} From 1c52edfe3583c72df336a8c4dc8f7a77ca153c26 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 03:37:16 +0900 Subject: [PATCH 46/80] =?UTF-8?q?Fix:=20cart=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EB=B6=88=EA=B0=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/OrderController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index 042b84f..9fbfb23 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -48,7 +48,7 @@ public ResponseEntity getFoody( @GetMapping("/cart") public ResponseEntity getCart(@AuthenticationPrincipal CustomUserDetails userDetails, - @RequestParam("cartId") Long cartId) { + @RequestParam(value = "cartId", required = false) Long cartId) { CartGetRes cartGetRes = orderService.getCart(userDetails, cartId); return new ResponseEntity<>(cartGetRes, HttpStatus.OK); } From 9e17fd82e6fefbcd8f2a11d7f241334600861b6e Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 03:49:33 +0900 Subject: [PATCH 47/80] =?UTF-8?q?Feat:=20=EC=B9=B4=ED=8A=B8=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/order/OrderServiceImpl.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 5fc1633..c74df36 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -7,7 +7,6 @@ import java.util.Base64; import java.util.Collections; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -170,14 +169,23 @@ public CartResetRes resetCart(CustomUserDetails userDetails) { public CartGetRes getCart(CustomUserDetails userDetails, Long cartId) { UserInfo user = getUserInfo(userDetails); Cart cart = getCartId(user, cartId); + verifyMyCart(user, cart); return orderMapper.cartToCartGetRes(cart); } + private void verifyMyCart(UserInfo user, Cart cart) { + if (cart.getUserInfo().equals(user)) { + return; + } + throw new BusinessLogicException(ExceptionCode.CART_NOT_FOUND); + } + private Cart getCartId(UserInfo user, Long cartId) { - return Optional.ofNullable(cartId) - .flatMap(id -> cartRepository.findById(cartId)) - .orElseGet(() -> getCart(user)); + if (cartId == null) { + return getCart(user); + } + return cartRepository.findById(cartId).orElse(getCart(user)); } @Override From addb3a584a7f08091c006ed3cc38023e0c579de0 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 03:56:15 +0900 Subject: [PATCH 48/80] =?UTF-8?q?Fix:=20=EA=B2=B0=EC=A0=9C=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/OrderServiceImpl.java | 2 +- .../com/readyvery/readyverydemo/src/order/dto/PaymentReq.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index c74df36..2f36f79 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -191,7 +191,7 @@ private Cart getCartId(UserInfo user, Long cartId) { @Override public TosspaymentMakeRes requestTossPayment(CustomUserDetails userDetails, PaymentReq paymentReq) { UserInfo user = getUserInfo(userDetails); - Cart cart = getCart(user); + Cart cart = getCartId(user, paymentReq.getCartId()); Store store = cart.getStore(); Coupon coupon = getCoupon(paymentReq.getCouponId()); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/PaymentReq.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/PaymentReq.java index 1b96a89..f229b75 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/PaymentReq.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/PaymentReq.java @@ -5,4 +5,5 @@ @Getter public class PaymentReq { private Long couponId; + private Long cartId; } From 092c2e1355241276b5ecbd3f18e1fcb2bf2e1f96 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 04:05:20 +0900 Subject: [PATCH 49/80] =?UTF-8?q?Fix:=20=EA=B2=B0=EC=A0=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyvery/readyverydemo/src/order/OrderServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 2f36f79..a2855e2 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -452,7 +452,8 @@ private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Coup String orderName = cart.getCartItems().get(0).getFoodie().getName() + " * " + cart.getCartItems().get(0).getCount(); if (cart.getCartItems().size() > 1) { - orderName += " 외 " + (cart.getCartItems().size() - 1) + "개"; + orderName += " 외 " + + (cart.getCartItems().stream().filter(cartItem -> !cartItem.getIsDeleted()).count() - 1) + "개"; } return Order.builder() .userInfo(user) From 8304842b146983f99d9c99a52dd8ca604ce64f11 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 05:18:57 +0900 Subject: [PATCH 50/80] =?UTF-8?q?Fix:=20=EC=84=B1=EA=B3=B5,=EC=8B=A4?= =?UTF-8?q?=ED=8C=A8=20url=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b46c52c..9302dd8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -34,5 +34,5 @@ spring.security.oauth2.client.provider.kakao.user-name-attribute=id ##tosspay payment.toss.client_key=test_ck_pP2YxJ4K87By0b4RZeo0rRGZwXLO payment.toss.secret_key=test_sk_pP2YxJ4K87BbBaQPDwEJrRGZwXLO -payment.toss.success_url=http://localhost:8080/api/v1/order/toss/success -payment.toss.fail_url=http://localhost:8080/api/v1/order/toss/fail +payment.toss.success_url=http://localhost:3000/payment/success +payment.toss.fail_url=http://localhost:3000/payment/fail From 77ae5789d326402d003e056ed42b0afaa3e5a698 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 05:31:00 +0900 Subject: [PATCH 51/80] =?UTF-8?q?Fix:=20=EA=B2=B0=EC=A0=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EC=88=98=EC=A0=952?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/order/OrderServiceImpl.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index a2855e2..d320792 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -446,14 +446,20 @@ private HttpHeaders makeTossHeader() { } private Order makeOrder(UserInfo user, Store store, Long amount, Cart cart, Coupon coupon) { - if (cart.getCartItems().isEmpty()) { + List cartItems = cart.getCartItems().stream() + .filter(cartItem -> !cartItem.getIsDeleted()) + .toList(); + + if (cartItems.stream().allMatch(CartItem::getIsDeleted)) { throw new BusinessLogicException(ExceptionCode.CART_NOT_FOUND); } + CartItem firstItem = cartItems.get(0); String orderName = - cart.getCartItems().get(0).getFoodie().getName() + " * " + cart.getCartItems().get(0).getCount(); - if (cart.getCartItems().size() > 1) { + firstItem.getCount() == 1 ? firstItem.getFoodie().getName() : + firstItem.getFoodie().getName() + " * " + firstItem.getCount(); + if (cartItems.size() > 1) { orderName += " 외 " - + (cart.getCartItems().stream().filter(cartItem -> !cartItem.getIsDeleted()).count() - 1) + "개"; + + (cartItems.stream().filter(cartItem -> !cartItem.getIsDeleted()).count() - 1) + "개"; } return Order.builder() .userInfo(user) From d457deee5800f361398a2e843197543b81c547e1 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 06:22:37 +0900 Subject: [PATCH 52/80] =?UTF-8?q?Fix:=20cart=20=EB=AA=BB=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A4=EB=8A=94=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 --- .../readyverydemo/global/exception/ExceptionCode.java | 3 ++- .../readyverydemo/src/order/OrderServiceImpl.java | 9 ++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index 079d0f4..eea8dba 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -26,7 +26,8 @@ public enum ExceptionCode { ORDER_NOT_RECEIPT(400, "Order is not receipt."), INVALID_INOUT(400, "Invalid inout."), CART_NOT_EDITABLE(400, "Cart is not editable."), - COUPON_NOT_VALID(400, "Coupon is not valid."); + COUPON_NOT_VALID(400, "Coupon is not valid."), + NOT_MY_CART(400, "Not my cart."); private int status; private String message; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index d320792..031b37d 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -178,14 +178,13 @@ private void verifyMyCart(UserInfo user, Cart cart) { if (cart.getUserInfo().equals(user)) { return; } - throw new BusinessLogicException(ExceptionCode.CART_NOT_FOUND); + System.out.println("asdf"); + throw new BusinessLogicException(ExceptionCode.NOT_MY_CART); } private Cart getCartId(UserInfo user, Long cartId) { - if (cartId == null) { - return getCart(user); - } - return cartRepository.findById(cartId).orElse(getCart(user)); + return (cartId == null) ? getCart(user) + : cartRepository.findById(cartId).orElseGet(() -> getCart(user)); } @Override From 859107267becea83947dc9fd148e8ecab8f710f9 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 08:31:39 +0900 Subject: [PATCH 53/80] =?UTF-8?q?Fix:=20=EB=B9=88=20cart=EC=97=90=20?= =?UTF-8?q?=EC=9D=8C=EC=8B=9D=20=EC=B6=94=EA=B0=80=EC=8B=9C=20store=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/order/OrderServiceImpl.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 031b37d..a8fe88f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -85,9 +85,7 @@ public class OrderServiceImpl implements OrderService { @Override public FoodyDetailRes getFoody(Long storeId, Long foodyId, Long inout) { - Foodie foodie = foodieRepository.findById(foodyId).orElseThrow( - () -> new BusinessLogicException(ExceptionCode.FOODY_NOT_FOUND) - ); + Foodie foodie = getFoody(foodyId); return orderMapper.foodieToFoodyDetailRes(foodie, inout); } @@ -104,7 +102,7 @@ public CartAddRes addCart(CustomUserDetails userDetails, CartAddReq cartAddReq) .orElseGet(() -> makeCart(user, store, cartAddReq.getInout())); verifyCart(cart); - verifyItemsInCart(cart, store); + verifyItemsInCart(cart, store, cartAddReq.getInout()); CartItem cartItem = makeCartItem(cart, foodie, cartAddReq.getCount()); List cartOptions = cartAddReq.getOptions().stream() .map(option -> makeCartOption(cartItem, option)) @@ -117,12 +115,21 @@ public CartAddRes addCart(CustomUserDetails userDetails, CartAddReq cartAddReq) return orderMapper.cartToCartAddRes(cartItem); } - private void verifyItemsInCart(Cart cart, Store store) { + private void verifyItemsInCart(Cart cart, Store store, Long inout) { + if (cart.getCartItems().stream().allMatch(CartItem::getIsDeleted)) { + changeCartStore(cart, store, inout); + } if (!cart.getStore().equals(store)) { throw new BusinessLogicException(ExceptionCode.ITEM_NOT_SAME_STORE); } } + private void changeCartStore(Cart cart, Store store, Long inout) { + cart.setStore(store); + cart.setInOut(inout); + cart.getCartItems().forEach(cartItem -> cartItem.setIsDeleted(true)); + } + @Override public CartEidtRes editCart(CustomUserDetails userDetails, Long idx, Long count) { CartItem cartItem = getCartItem(idx); From bcef3ec9ef154b2d97a6caa64d78ada297a631dc Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 27 Nov 2023 08:43:42 +0900 Subject: [PATCH 54/80] =?UTF-8?q?Fix:=20cart=EC=97=90=20edit=EA=B0=92=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/CartGetRes.java | 1 + .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java index a3a28d0..566371f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java @@ -9,6 +9,7 @@ @Builder public class CartGetRes { private String name; + private Boolean edit; private String imgUrl; private Long totalPrice; private Long cartId; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 6cf846a..a02ddea 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -103,6 +103,7 @@ public CartGetRes cartToCartGetRes(Cart cart) { return CartGetRes.builder() .cartId(cart.getId()) .name(cart.getStore().getName()) + .edit(!cart.getIsOrdered() && !cart.getIsDeleted()) .imgUrl(cart.getStore() .getImgs() .stream() From ce9f0dfac851c1760b78610b44c5340f03f676b3 Mon Sep 17 00:00:00 2001 From: 1223v <1223v@naver.com> Date: Mon, 27 Nov 2023 20:31:59 +0900 Subject: [PATCH 55/80] =?UTF-8?q?Fix:=20Store=20subName=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/readyvery/readyverydemo/domain/Store.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Store.java b/src/main/java/com/readyvery/readyverydemo/domain/Store.java index 8b5aa10..1fb4d5f 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Store.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Store.java @@ -63,6 +63,10 @@ public class Store extends BaseTimeEntity { @Column private String engName; + // 가게 서브 이름 + @Column + private String subName; + // 가게 이벤트 메세지 @Column private String eventMessage; From 9933d361470b51bd50d0833458a10dc651dac4cb Mon Sep 17 00:00:00 2001 From: marinesnow34 Date: Mon, 27 Nov 2023 23:08:03 +0900 Subject: [PATCH 56/80] =?UTF-8?q?Feat:=20=EC=A3=BC=EB=AC=B8=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java | 1 + .../com/readyvery/readyverydemo/src/order/dto/OptionDto.java | 1 + .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 2 ++ 3 files changed, 4 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java index cf34f9b..2b28bca 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java @@ -14,4 +14,5 @@ public class HistoryDetailRes { private CartGetRes cart; private String salePrice; private String method; + private String orderNumber; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OptionDto.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OptionDto.java index 37ca33c..677eadd 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OptionDto.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OptionDto.java @@ -9,4 +9,5 @@ public class OptionDto { private Long idx; private String name; private Long price; + private Boolean required; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 6cf846a..d63344c 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -147,6 +147,7 @@ private CartDto cartItemToCartDto(CartItem cartItem, Long inout) { private OptionDto cartOptionToOptionDto(CartOption cartOption) { return OptionDto.builder() .idx(cartOption.getId()) + .required(cartOption.getFoodieOption().getFoodieOptionCategory().isRequired()) .name(cartOption.getFoodieOption().getName()) .price(cartOption.getFoodieOption().getPrice()) .build(); @@ -274,6 +275,7 @@ public DefaultRes tosspaymentDtoToCancelRes() { public HistoryDetailRes orderToHistoryDetailRes(Order order) { return HistoryDetailRes.builder() .orderStatus(order.getProgress().toString()) + .orderNumber(order.getOrderNumber()) .storeName(order.getStore().getName()) .orderTime(order.getCreatedAt().format(DateTimeFormatter.ofPattern(DATE_FORMAT))) .orderId(order.getOrderId()) From ffcc255e9a67f49bb2107b151d94778e1d034f4e Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Wed, 29 Nov 2023 23:46:24 +0900 Subject: [PATCH 57/80] =?UTF-8?q?Feat:=20sold=20out,=20=EC=98=81=EC=97=85?= =?UTF-8?q?=20=EC=A2=85=EB=A3=8C=20=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/exception/ExceptionCode.java | 4 +++- .../src/order/OrderServiceImpl.java | 21 +++++++++++++++++++ .../src/store/dto/StoreMapper.java | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index eea8dba..1398041 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -27,7 +27,9 @@ public enum ExceptionCode { INVALID_INOUT(400, "Invalid inout."), CART_NOT_EDITABLE(400, "Cart is not editable."), COUPON_NOT_VALID(400, "Coupon is not valid."), - NOT_MY_CART(400, "Not my cart."); + NOT_MY_CART(400, "Not my cart."), + STORE_NOT_OPEN(400, "Store is not open."), + CART_SOLD_OUT(400, "Cart is sold out."); private int status; private String message; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index a8fe88f..3983042 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -202,6 +202,7 @@ public TosspaymentMakeRes requestTossPayment(CustomUserDetails userDetails, Paym Coupon coupon = getCoupon(paymentReq.getCouponId()); verifyCoupon(user, coupon); + verifyCartSoldOut(cart); // Long amount = calculateAmount(store, paymentReq.getCarts(), paymentReq.getInout()); Long amount = calculateAmount2(cart); Order order = makeOrder(user, store, amount, cart, coupon); @@ -211,6 +212,12 @@ public TosspaymentMakeRes requestTossPayment(CustomUserDetails userDetails, Paym return orderMapper.orderToTosspaymentMakeRes(order); } + private void verifyCartSoldOut(Cart cart) { + if (cart.getCartItems().stream().anyMatch(cartItem -> cartItem.getFoodie().isSoldOut())) { + throw new BusinessLogicException(ExceptionCode.CART_SOLD_OUT); + } + } + private void verifyCoupon(UserInfo user, Coupon coupon) { isCoupon(coupon); isUserCoupon(user, coupon); @@ -590,11 +597,25 @@ private Store getStore(Long storeId) { } private void verifyCartAddReq(Foodie foodie, CartAddReq cartAddReq) { + verifyStoreOpen(foodie.getFoodieCategory().getStore()); + verifyFoodyNotSoldOut(foodie); verifyOption(foodie, cartAddReq.getOptions()); verifyEssentialOption(foodie, cartAddReq.getOptions()); verifyInout(cartAddReq.getInout()); } + private void verifyFoodyNotSoldOut(Foodie foodie) { + if (foodie.isSoldOut()) { + throw new BusinessLogicException(ExceptionCode.FOODY_NOT_FOUND); + } + } + + private void verifyStoreOpen(Store store) { + if (!store.isStatus()) { + throw new BusinessLogicException(ExceptionCode.STORE_NOT_OPEN); + } + } + private void verifyInout(Long inout) { if (!inout.equals(EAT_IN) && !inout.equals(TAKE_OUT)) { throw new BusinessLogicException(ExceptionCode.INVALID_INOUT); diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java index 0f27300..86495cc 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java @@ -40,6 +40,7 @@ private MenuDto categoryToMenuDto(FoodieCategory category) { .category(category.getName()) .menuItems(category.getFoodies() .stream() + .filter(foodie -> !foodie.isSoldOut()) .map(this::foodieToMenuItems) .toList()) .build(); From 207455798ef249a15f388b07b3c0dd797af3cd2e Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Wed, 29 Nov 2023 23:53:47 +0900 Subject: [PATCH 58/80] =?UTF-8?q?Feat:=20cart=20inout=20=EB=8B=A4=EB=A6=84?= =?UTF-8?q?=20=EC=97=AC=EB=B6=80=20=ED=8C=90=EB=8B=A8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/exception/ExceptionCode.java | 3 ++- .../readyverydemo/src/order/OrderServiceImpl.java | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index 1398041..0d20fe7 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -29,7 +29,8 @@ public enum ExceptionCode { COUPON_NOT_VALID(400, "Coupon is not valid."), NOT_MY_CART(400, "Not my cart."), STORE_NOT_OPEN(400, "Store is not open."), - CART_SOLD_OUT(400, "Cart is sold out."); + CART_SOLD_OUT(400, "Cart is sold out."), + CART_INOUT_NOT_MATCH(400, "Cart inout is not match."); private int status; private String message; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 3983042..c04e1a0 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -101,7 +101,7 @@ public CartAddRes addCart(CustomUserDetails userDetails, CartAddReq cartAddReq) Cart cart = cartRepository.findByUserInfoAndIsDeletedFalseAndIsOrderedFalse(user) .orElseGet(() -> makeCart(user, store, cartAddReq.getInout())); - verifyCart(cart); + verifyCart(cart, cartAddReq.getInout()); verifyItemsInCart(cart, store, cartAddReq.getInout()); CartItem cartItem = makeCartItem(cart, foodie, cartAddReq.getCount()); List cartOptions = cartAddReq.getOptions().stream() @@ -133,7 +133,7 @@ private void changeCartStore(Cart cart, Store store, Long inout) { @Override public CartEidtRes editCart(CustomUserDetails userDetails, Long idx, Long count) { CartItem cartItem = getCartItem(idx); - verifyCart(cartItem.getCart()); + verifyCart(cartItem.getCart(), null); verifyCartItem(cartItem, userDetails); editCartItem(cartItem, count); @@ -141,13 +141,19 @@ public CartEidtRes editCart(CustomUserDetails userDetails, Long idx, Long count) return orderMapper.cartToCartEditRes(cartItem); } - private void verifyCart(Cart cart) { + private void verifyCart(Cart cart, Long inout) { if (cart.getIsOrdered()) { throw new BusinessLogicException(ExceptionCode.CART_NOT_EDITABLE); } if (cart.getIsDeleted()) { throw new BusinessLogicException(ExceptionCode.CART_NOT_EDITABLE); } + if (inout == null) { + return; + } + if (!cart.getInOut().equals(inout)) { + throw new BusinessLogicException(ExceptionCode.CART_INOUT_NOT_MATCH); + } } @Override From ed617d5aeef3667034152db3db9054680378f44b Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Thu, 30 Nov 2023 00:27:22 +0900 Subject: [PATCH 59/80] =?UTF-8?q?Fix:=20cart=EC=97=90=20inout=EC=97=AC?= =?UTF-8?q?=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/CartGetRes.java | 1 + .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java index 566371f..030d31e 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java @@ -14,4 +14,5 @@ public class CartGetRes { private Long totalPrice; private Long cartId; private List carts; + private Long inOut; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index a02ddea..049618b 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -102,6 +102,7 @@ public CartResetRes cartToCartResetRes(Cart cart) { public CartGetRes cartToCartGetRes(Cart cart) { return CartGetRes.builder() .cartId(cart.getId()) + .inOut(cart.getInOut()) .name(cart.getStore().getName()) .edit(!cart.getIsOrdered() && !cart.getIsDeleted()) .imgUrl(cart.getStore() From 9ce54f25f4a7b5ec673ce7983d196fb10845a7de Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Thu, 30 Nov 2023 20:59:53 +0900 Subject: [PATCH 60/80] =?UTF-8?q?Feat:=20cart=20=EA=B0=AF=EC=88=98=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/order/OrderController.java | 7 +++++++ .../readyverydemo/src/order/OrderService.java | 3 +++ .../readyverydemo/src/order/OrderServiceImpl.java | 8 ++++++++ .../readyverydemo/src/order/dto/CartCountRes.java | 10 ++++++++++ .../readyverydemo/src/order/dto/OrderMapper.java | 9 +++++++++ 5 files changed, 37 insertions(+) create mode 100644 src/main/java/com/readyvery/readyverydemo/src/order/dto/CartCountRes.java diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index 9fbfb23..c2bb3c7 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -16,6 +16,7 @@ import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; import com.readyvery.readyverydemo.src.order.dto.CartAddReq; import com.readyvery.readyverydemo.src.order.dto.CartAddRes; +import com.readyvery.readyverydemo.src.order.dto.CartCountRes; import com.readyvery.readyverydemo.src.order.dto.CartEidtRes; import com.readyvery.readyverydemo.src.order.dto.CartGetRes; import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteRes; @@ -53,6 +54,12 @@ public ResponseEntity getCart(@AuthenticationPrincipal CustomUserDet return new ResponseEntity<>(cartGetRes, HttpStatus.OK); } + @GetMapping("/cart/count") + public ResponseEntity getCartCount(@AuthenticationPrincipal CustomUserDetails userDetails) { + CartCountRes cartCount = orderService.getCartCount(userDetails); + return new ResponseEntity<>(cartCount, HttpStatus.OK); + } + @GetMapping("/toss/success") public ResponseEntity tossPaymentSuccess( @RequestParam("paymentKey") String paymentKey, diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java index ae52721..d7bc78e 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -4,6 +4,7 @@ import com.readyvery.readyverydemo.security.jwt.dto.CustomUserDetails; import com.readyvery.readyverydemo.src.order.dto.CartAddReq; import com.readyvery.readyverydemo.src.order.dto.CartAddRes; +import com.readyvery.readyverydemo.src.order.dto.CartCountRes; import com.readyvery.readyverydemo.src.order.dto.CartEidtRes; import com.readyvery.readyverydemo.src.order.dto.CartGetRes; import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteRes; @@ -43,4 +44,6 @@ public interface OrderService { Object cancelTossPayment(CustomUserDetails userDetails, TossCancelReq tossCancelReq); HistoryDetailRes getReceipt(CustomUserDetails userDetails, String orderId); + + CartCountRes getCartCount(CustomUserDetails userDetails); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index c04e1a0..3c48cf3 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -48,6 +48,7 @@ import com.readyvery.readyverydemo.src.order.config.TossPaymentConfig; import com.readyvery.readyverydemo.src.order.dto.CartAddReq; import com.readyvery.readyverydemo.src.order.dto.CartAddRes; +import com.readyvery.readyverydemo.src.order.dto.CartCountRes; import com.readyvery.readyverydemo.src.order.dto.CartEidtRes; import com.readyvery.readyverydemo.src.order.dto.CartGetRes; import com.readyvery.readyverydemo.src.order.dto.CartItemDeleteRes; @@ -323,6 +324,13 @@ public HistoryDetailRes getReceipt(CustomUserDetails userDetails, String orderId return orderMapper.orderToHistoryDetailRes(order); } + @Override + public CartCountRes getCartCount(CustomUserDetails userDetails) { + UserInfo user = getUserInfo(userDetails); + Cart cart = getCart(user); + return orderMapper.cartToCartCountRes(cart); + } + private void verifyReceipt(Order order, UserInfo user) { verifyOrderReceipt(order); verifyOrederUser(order, user); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartCountRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartCountRes.java new file mode 100644 index 0000000..e0e4fc5 --- /dev/null +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartCountRes.java @@ -0,0 +1,10 @@ +package com.readyvery.readyverydemo.src.order.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class CartCountRes { + private Long count; +} diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 79d1be5..8d7b4e8 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -290,4 +290,13 @@ public HistoryDetailRes orderToHistoryDetailRes(Order order) { .method(order.getMethod()) .build(); } + + public CartCountRes cartToCartCountRes(Cart cart) { + return CartCountRes.builder() + .count(cart.getCartItems() + .stream() + .filter(cartItem -> !cartItem.getIsDeleted()) + .count()) + .build(); + } } From 4a52267cfdd65bac453e334a388ee0c1ff550780 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Thu, 30 Nov 2023 21:43:03 +0900 Subject: [PATCH 61/80] =?UTF-8?q?Feat:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=EC=97=90=20=EA=B0=80=EA=B2=8C=20=EC=98=A4=ED=94=88=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/CartGetRes.java | 1 + .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java index 030d31e..cd8ca07 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java @@ -15,4 +15,5 @@ public class CartGetRes { private Long cartId; private List carts; private Long inOut; + private Boolean isOpened; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 8d7b4e8..6d92ba8 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -103,6 +103,7 @@ public CartGetRes cartToCartGetRes(Cart cart) { return CartGetRes.builder() .cartId(cart.getId()) .inOut(cart.getInOut()) + .isOpened(cart.getStore().isStatus()) .name(cart.getStore().getName()) .edit(!cart.getIsOrdered() && !cart.getIsDeleted()) .imgUrl(cart.getStore() From 41c524db7dc82a26373454b1697ab880a15afe66 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Thu, 30 Nov 2023 22:11:37 +0900 Subject: [PATCH 62/80] =?UTF-8?q?Feat:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=EC=97=90=20=EC=98=B5=EC=85=98=20=EC=B9=B4=ED=85=8C?= =?UTF-8?q?=EA=B3=A0=EB=A6=AC=20=EC=9D=B4=EB=A6=84=20=ED=91=9C=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/OptionDto.java | 1 + .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OptionDto.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OptionDto.java index 677eadd..512ce79 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OptionDto.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OptionDto.java @@ -10,4 +10,5 @@ public class OptionDto { private String name; private Long price; private Boolean required; + private String categoryName; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 6d92ba8..ec39ed9 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -152,6 +152,7 @@ private OptionDto cartOptionToOptionDto(CartOption cartOption) { .idx(cartOption.getId()) .required(cartOption.getFoodieOption().getFoodieOptionCategory().isRequired()) .name(cartOption.getFoodieOption().getName()) + .categoryName(cartOption.getFoodieOption().getFoodieOptionCategory().getName()) .price(cartOption.getFoodieOption().getPrice()) .build(); } From f17f5fb8e8045e53c54838068fccb8f16e833e27 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Fri, 1 Dec 2023 02:44:54 +0900 Subject: [PATCH 63/80] =?UTF-8?q?Feat:=20=EC=A3=BC=EB=AC=B8=20=EB=82=B4?= =?UTF-8?q?=EC=97=AD=20=EC=8B=A0,=20=EA=B5=AC=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/order/OrderController.java | 8 +++++++- .../readyverydemo/src/order/OrderService.java | 2 ++ .../readyverydemo/src/order/OrderServiceImpl.java | 8 ++++++++ .../src/order/dto/HistoryDetailRes.java | 1 + .../readyverydemo/src/order/dto/OrderMapper.java | 15 ++++++++++++++- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index c2bb3c7..6de3386 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -78,12 +78,18 @@ public ResponseEntity tossPaymentFail( return new ResponseEntity<>(result, HttpStatus.OK); } - @GetMapping("/history") + @GetMapping("/history/old") public ResponseEntity getHistories(@AuthenticationPrincipal CustomUserDetails userDetails) { HistoryRes historyRes = orderService.getHistories(userDetails); return new ResponseEntity<>(historyRes, HttpStatus.OK); } + @GetMapping("/history/new") + public ResponseEntity getNewHistories(@AuthenticationPrincipal CustomUserDetails userDetails) { + HistoryRes historyRes = orderService.getNewHistories(userDetails); + return new ResponseEntity<>(historyRes, HttpStatus.OK); + } + @GetMapping("/receipt") public ResponseEntity getReceipts(@AuthenticationPrincipal CustomUserDetails userDetails, @RequestParam("orderId") String orderId) { diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java index d7bc78e..601845f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -46,4 +46,6 @@ public interface OrderService { HistoryDetailRes getReceipt(CustomUserDetails userDetails, String orderId); CartCountRes getCartCount(CustomUserDetails userDetails); + + HistoryRes getNewHistories(CustomUserDetails userDetails); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 3c48cf3..bdda823 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -331,6 +331,14 @@ public CartCountRes getCartCount(CustomUserDetails userDetails) { return orderMapper.cartToCartCountRes(cart); } + @Override + public HistoryRes getNewHistories(CustomUserDetails userDetails) { + UserInfo user = getUserInfo(userDetails); + List orders = getOrders(user); + return orderMapper.ordersToNewHistoryRes(orders); + + } + private void verifyReceipt(Order order, UserInfo user) { verifyOrderReceipt(order); verifyOrederUser(order, user); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java index 2b28bca..3b578d6 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java @@ -15,4 +15,5 @@ public class HistoryDetailRes { private String salePrice; private String method; private String orderNumber; + private Object cancelReason; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index ec39ed9..b1968cf 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -231,7 +231,19 @@ public HistoryRes ordersToHistoryRes(List orders) { .receipts( orders .stream() - .filter(order -> order.getProgress() != REQUEST) + .filter(order -> order.getProgress() == PICKUP) + .map(this::orderToReceiptHistoryDto) + .toList()) + .build(); + } + + public HistoryRes ordersToNewHistoryRes(List orders) { + return HistoryRes.builder() + .receipts( + orders + .stream() + .filter(order -> order.getProgress() != CANCEL) + .filter(order -> order.getProgress() != PICKUP) .filter(order -> order.getProgress() != FAIL) .map(this::orderToReceiptHistoryDto) .toList()) @@ -281,6 +293,7 @@ public HistoryDetailRes orderToHistoryDetailRes(Order order) { .orderStatus(order.getProgress().toString()) .orderNumber(order.getOrderNumber()) .storeName(order.getStore().getName()) + .cancelReason(order.getReceipt().getCancels()) .orderTime(order.getCreatedAt().format(DateTimeFormatter.ofPattern(DATE_FORMAT))) .orderId(order.getOrderId()) .storePhone(order.getStore().getPhone()) From c5e6848f04bf8b5024303aa07e8fa58b33d68fcb Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Fri, 1 Dec 2023 02:55:37 +0900 Subject: [PATCH 64/80] =?UTF-8?q?Fix:=20=ED=86=A0=EC=8A=A4=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=EC=9D=84=20=EA=B8=B0=EB=A1=9D=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=A0=9C=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index b1968cf..228a2d3 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -242,6 +242,7 @@ public HistoryRes ordersToNewHistoryRes(List orders) { .receipts( orders .stream() + .filter(order -> order.getProgress() != REQUEST) .filter(order -> order.getProgress() != CANCEL) .filter(order -> order.getProgress() != PICKUP) .filter(order -> order.getProgress() != FAIL) From cff7f3224546db5ec9f4b1daea3b421442b62287 Mon Sep 17 00:00:00 2001 From: 1223v <1223v@naver.com> Date: Fri, 1 Dec 2023 19:48:32 +0900 Subject: [PATCH 65/80] =?UTF-8?q?Fix:=20Oauth=20=ED=8F=B0=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/security/oauth2/OAuthAttributes.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/security/oauth2/OAuthAttributes.java b/src/main/java/com/readyvery/readyverydemo/security/oauth2/OAuthAttributes.java index 66241aa..024e26e 100644 --- a/src/main/java/com/readyvery/readyverydemo/security/oauth2/OAuthAttributes.java +++ b/src/main/java/com/readyvery/readyverydemo/security/oauth2/OAuthAttributes.java @@ -58,7 +58,7 @@ public UserInfo toEntity(SocialType socialType, OAuth2UserInfo oauth2UserInfo) { .socialType(socialType) .socialId(oauth2UserInfo.getId()) .email(oauth2UserInfo.getEmail()) - .phone(oauth2UserInfo.getId()) + .phone(oauth2UserInfo.getPhoneNumber()) .age(oauth2UserInfo.getAge()) .birth(oauth2UserInfo.getBirth()) .nickName(oauth2UserInfo.getNickName()) From 508a87319ee02e79cb9f868070a977e125936a93 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Fri, 1 Dec 2023 21:44:30 +0900 Subject: [PATCH 66/80] =?UTF-8?q?Feat:=20=EA=B0=80=EA=B2=8C=EC=97=90=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyvery/readyverydemo/src/store/dto/StoreDetailRes.java | 1 + .../com/readyvery/readyverydemo/src/store/dto/StoreMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreDetailRes.java b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreDetailRes.java index 583620c..e089956 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreDetailRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreDetailRes.java @@ -13,4 +13,5 @@ public class StoreDetailRes { private String phone; private String address; private String openTime; + private Boolean status; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java index 86495cc..36e5755 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java @@ -13,6 +13,7 @@ public class StoreMapper { public StoreDetailRes storeToStoreDetailRes(Store store) { return StoreDetailRes.builder() + .status(store.isStatus()) .imgs(store.getImgs() .stream() .filter(storeImg -> storeImg.getImgSize() == ImgSize.CAFE_BANNER) From 98bdfc789932f952de5f393f97b1d6f2ad1974e1 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Fri, 1 Dec 2023 22:17:41 +0900 Subject: [PATCH 67/80] =?UTF-8?q?Fix:=20cart=EC=97=90=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=ED=85=9C=20=EC=97=86=EC=9D=84=20=EB=95=8C=20=EB=A1=9C=EC=A7=81?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/global/Constant.java | 1 + .../readyverydemo/src/order/OrderServiceImpl.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/global/Constant.java b/src/main/java/com/readyvery/readyverydemo/global/Constant.java index 9aff2e9..1cbeae1 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/Constant.java +++ b/src/main/java/com/readyvery/readyverydemo/global/Constant.java @@ -6,4 +6,5 @@ public class Constant { public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm"; public static final String IMG_URL = "/images/"; public static final String USER_CANCEL_RESON = "단순 변심"; + public static final Integer EMPTY_CART = 0; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index bdda823..e4afa24 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -117,7 +117,7 @@ public CartAddRes addCart(CustomUserDetails userDetails, CartAddReq cartAddReq) } private void verifyItemsInCart(Cart cart, Store store, Long inout) { - if (cart.getCartItems().stream().allMatch(CartItem::getIsDeleted)) { + if (getCartItemCount(cart) == EMPTY_CART) { changeCartStore(cart, store, inout); } if (!cart.getStore().equals(store)) { @@ -152,11 +152,21 @@ private void verifyCart(Cart cart, Long inout) { if (inout == null) { return; } + if (getCartItemCount(cart) == EMPTY_CART) { + return; + } if (!cart.getInOut().equals(inout)) { throw new BusinessLogicException(ExceptionCode.CART_INOUT_NOT_MATCH); } } + private int getCartItemCount(Cart cart) { + return cart.getCartItems().stream() + .filter(cartItem -> !cartItem.getIsDeleted()) + .toList() + .size(); + } + @Override public CartItemDeleteRes deleteCart(CustomUserDetails userDetails, Long idx) { CartItem cartItem = getCartItem(idx); From dc7bbc1be5517bbdf76983e8aeba1127acf185f0 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Fri, 1 Dec 2023 22:38:36 +0900 Subject: [PATCH 68/80] =?UTF-8?q?Fix:=20=EC=97=90=EB=9F=AC=20=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/global/exception/ExceptionCode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index 0d20fe7..88ad498 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -24,11 +24,11 @@ public enum ExceptionCode { COUPON_CODE_NOT_MATCH(400, "Coupon code is not match."), COUPON_ISSUE_COUNT_EXCEED(400, "Coupon issue count exceed."), ORDER_NOT_RECEIPT(400, "Order is not receipt."), - INVALID_INOUT(400, "Invalid inout."), + INVALID_INOUT(409, "Invalid inout."), CART_NOT_EDITABLE(400, "Cart is not editable."), COUPON_NOT_VALID(400, "Coupon is not valid."), NOT_MY_CART(400, "Not my cart."), - STORE_NOT_OPEN(400, "Store is not open."), + STORE_NOT_OPEN(401, "Store is not open."), CART_SOLD_OUT(400, "Cart is sold out."), CART_INOUT_NOT_MATCH(400, "Cart inout is not match."); From 90859c34c63f14d0b80c0d8e4fd20d9f024551a1 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Fri, 1 Dec 2023 22:45:42 +0900 Subject: [PATCH 69/80] =?UTF-8?q?Fix:=20=EC=97=90=EB=9F=AC=20=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EC=88=98=EC=A0=952?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/global/exception/ExceptionCode.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java index 88ad498..0e2ae4c 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java +++ b/src/main/java/com/readyvery/readyverydemo/global/exception/ExceptionCode.java @@ -24,13 +24,13 @@ public enum ExceptionCode { COUPON_CODE_NOT_MATCH(400, "Coupon code is not match."), COUPON_ISSUE_COUNT_EXCEED(400, "Coupon issue count exceed."), ORDER_NOT_RECEIPT(400, "Order is not receipt."), - INVALID_INOUT(409, "Invalid inout."), + INVALID_INOUT(400, "Invalid inout."), CART_NOT_EDITABLE(400, "Cart is not editable."), COUPON_NOT_VALID(400, "Coupon is not valid."), NOT_MY_CART(400, "Not my cart."), STORE_NOT_OPEN(401, "Store is not open."), CART_SOLD_OUT(400, "Cart is sold out."), - CART_INOUT_NOT_MATCH(400, "Cart inout is not match."); + CART_INOUT_NOT_MATCH(409, "Cart inout is not match."); private int status; private String message; From d078a82c46b75b035dcd4c491e9e86409bb049f8 Mon Sep 17 00:00:00 2001 From: 1223v <1223v@naver.com> Date: Fri, 1 Dec 2023 22:48:13 +0900 Subject: [PATCH 70/80] =?UTF-8?q?Fix:=20=EC=95=A1=EC=84=B8=EC=8A=A4=20?= =?UTF-8?q?=ED=86=A0=ED=81=B0=20=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/user/UserServiceImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java index 34dc943..549e3a5 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java @@ -37,8 +37,14 @@ public class UserServiceImpl implements UserService { private final UserMapper userMapper; @Value("${jwt.refresh.cookie}") private String refreshCookie; + @Value("${jwt.access.cookie}") + private String accessToken; @Value("${service.app.admin.key}") private String serviceAppAdminKey; + @Value("${jwt.access.cookie.domain}") + private String accessCookieDomain; + @Value("${jwt.refresh.cookie.domain}") + private String refreshCookieDomain; @Override public UserAuthRes getUserAuthByCustomUserDetails(CustomUserDetails userDetails) { @@ -90,8 +96,14 @@ private void invalidateRefreshTokenCookie(HttpServletResponse response) { Cookie refreshTokenCookie = new Cookie(refreshCookie, null); // 쿠키 이름을 동일하게 설정 refreshTokenCookie.setHttpOnly(true); refreshTokenCookie.setPath("/api/v1/refresh/token"); // 기존과 동일한 경로 설정 + refreshTokenCookie.setDomain(refreshCookieDomain); refreshTokenCookie.setMaxAge(0); // 만료 시간을 0으로 설정하여 즉시 만료 response.addCookie(refreshTokenCookie); + Cookie accessTokenCookie = new Cookie(accessToken, null); // 쿠키 이름을 동일하게 설정 + accessTokenCookie.setPath("/"); // 기존과 동일한 경로 설정 + accessTokenCookie.setDomain(accessCookieDomain); + accessTokenCookie.setMaxAge(0); // 만료 시간을 0으로 설정하여 즉시 만료 + response.addCookie(accessTokenCookie); } private UserInfo getUserInfo(Long id) { From 74a74022e76fa58a33a3d952e16afe87eb41fee3 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sat, 2 Dec 2023 01:20:43 +0900 Subject: [PATCH 71/80] =?UTF-8?q?Fix:=20=EC=82=AC=EC=9E=A5=EB=8B=98=20?= =?UTF-8?q?=EA=B0=80=EA=B2=8C=20=EC=97=B0=EA=B4=80=EA=B4=80=EA=B3=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/readyvery/readyverydemo/domain/CeoInfo.java | 9 +++++---- .../java/com/readyvery/readyverydemo/domain/Store.java | 8 ++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java b/src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java index bac174c..10591e2 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/CeoInfo.java @@ -1,17 +1,17 @@ package com.readyvery.readyverydemo.domain; -import static jakarta.persistence.FetchType.*; - import java.time.LocalDateTime; import jakarta.persistence.Column; 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.OneToOne; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Builder; @@ -79,7 +79,8 @@ public class CeoInfo extends BaseTimeEntity { private LocalDateTime lastLoginDate; // 사장님 가게 연관관계 매핑 - @OneToOne(mappedBy = "ceoInfo", fetch = LAZY) + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "store_idx") private Store store; } diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Store.java b/src/main/java/com/readyvery/readyverydemo/domain/Store.java index 1fb4d5f..64a5555 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Store.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Store.java @@ -8,13 +8,10 @@ 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.OneToMany; -import jakarta.persistence.OneToOne; import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; @@ -77,9 +74,8 @@ public class Store extends BaseTimeEntity { private Grade grade; //가게 사장님 연관관계 매핑 - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "ceo_idx") - private CeoInfo ceoInfo; + @OneToMany(mappedBy = "store") + private List ceoInfos = new ArrayList(); //가게 메뉴 카테고리 연관관계 매핑 @OneToMany(mappedBy = "store", cascade = CascadeType.ALL) From 29c7c00fcea8de53fedd0f2fa3859b6601d70fd1 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sat, 2 Dec 2023 03:39:13 +0900 Subject: [PATCH 72/80] =?UTF-8?q?Fix:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=20=EC=B6=A9=EB=8F=8C=20=EC=88=9C=EC=84=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/readyvery/readyverydemo/domain/Coupon.java | 1 + .../com/readyvery/readyverydemo/src/order/OrderServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java b/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java index dd94844..1ccd31b 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Coupon.java @@ -51,6 +51,7 @@ public class Coupon extends BaseTimeEntity { @Version private Long version; + @Builder.Default @OneToMany(mappedBy = "coupon", fetch = FetchType.LAZY) private List orders = new ArrayList(); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index e4afa24..16dc88e 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -102,8 +102,8 @@ public CartAddRes addCart(CustomUserDetails userDetails, CartAddReq cartAddReq) Cart cart = cartRepository.findByUserInfoAndIsDeletedFalseAndIsOrderedFalse(user) .orElseGet(() -> makeCart(user, store, cartAddReq.getInout())); - verifyCart(cart, cartAddReq.getInout()); verifyItemsInCart(cart, store, cartAddReq.getInout()); + verifyCart(cart, cartAddReq.getInout()); CartItem cartItem = makeCartItem(cart, foodie, cartAddReq.getCount()); List cartOptions = cartAddReq.getOptions().stream() .map(option -> makeCartOption(cartItem, option)) From ae78fc90bbfc6b84b9d3c376d8591bff49068727 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sat, 2 Dec 2023 03:44:33 +0900 Subject: [PATCH 73/80] =?UTF-8?q?Feat:=20=EC=9E=A5=EB=B0=94=EA=B5=AC?= =?UTF-8?q?=EB=8B=88=EC=97=90=20=EA=B0=80=EA=B2=8Cid=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/dto/CartGetRes.java | 1 + .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java index cd8ca07..31835e8 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CartGetRes.java @@ -8,6 +8,7 @@ @Getter @Builder public class CartGetRes { + private Long storeId; private String name; private Boolean edit; private String imgUrl; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 228a2d3..6efda4e 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -101,6 +101,7 @@ public CartResetRes cartToCartResetRes(Cart cart) { public CartGetRes cartToCartGetRes(Cart cart) { return CartGetRes.builder() + .storeId(cart.getStore().getId()) .cartId(cart.getId()) .inOut(cart.getInOut()) .isOpened(cart.getStore().isStatus()) From 17479dbcc50875957b229e198febf94efa7c3644 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 3 Dec 2023 22:17:09 +0900 Subject: [PATCH 74/80] =?UTF-8?q?Feat:=20=EB=B0=94=EB=A1=9C=20=EC=A3=BC?= =?UTF-8?q?=EB=AC=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/global/Constant.java | 1 + .../src/order/OrderController.java | 6 +++++ .../readyverydemo/src/order/OrderService.java | 2 ++ .../src/order/OrderServiceImpl.java | 7 +++++ .../src/order/dto/HistoryDetailRes.java | 2 +- .../src/order/dto/OrderMapper.java | 27 ++++++++++++++----- 6 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/global/Constant.java b/src/main/java/com/readyvery/readyverydemo/global/Constant.java index 1cbeae1..361ff46 100644 --- a/src/main/java/com/readyvery/readyverydemo/global/Constant.java +++ b/src/main/java/com/readyvery/readyverydemo/global/Constant.java @@ -7,4 +7,5 @@ public class Constant { public static final String IMG_URL = "/images/"; public static final String USER_CANCEL_RESON = "단순 변심"; public static final Integer EMPTY_CART = 0; + public static final Integer MAX_FASTORDER_SIZE = 5; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java index 6de3386..3a0963f 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderController.java @@ -78,6 +78,12 @@ public ResponseEntity tossPaymentFail( return new ResponseEntity<>(result, HttpStatus.OK); } + @GetMapping("/history/fast") + public ResponseEntity getFastHistories(@AuthenticationPrincipal CustomUserDetails userDetails) { + HistoryRes historyRes = orderService.getFastHistories(userDetails); + return new ResponseEntity<>(historyRes, HttpStatus.OK); + } + @GetMapping("/history/old") public ResponseEntity getHistories(@AuthenticationPrincipal CustomUserDetails userDetails) { HistoryRes historyRes = orderService.getHistories(userDetails); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java index 601845f..8a2bbb4 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderService.java @@ -48,4 +48,6 @@ public interface OrderService { CartCountRes getCartCount(CustomUserDetails userDetails); HistoryRes getNewHistories(CustomUserDetails userDetails); + + HistoryRes getFastHistories(CustomUserDetails userDetails); } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 16dc88e..3ed33eb 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -349,6 +349,13 @@ public HistoryRes getNewHistories(CustomUserDetails userDetails) { } + @Override + public HistoryRes getFastHistories(CustomUserDetails userDetails) { + UserInfo user = getUserInfo(userDetails); + List orders = getOrders(user); + return orderMapper.ordersToFastOrderRes(orders); + } + private void verifyReceipt(Order order, UserInfo user) { verifyOrderReceipt(order); verifyOrederUser(order, user); diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java index 3b578d6..15d14b0 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/HistoryDetailRes.java @@ -12,7 +12,7 @@ public class HistoryDetailRes { private String orderId; private String storePhone; private CartGetRes cart; - private String salePrice; + private Long salePrice; private String method; private String orderNumber; private Object cancelReason; diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 6efda4e..84c2439 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -232,21 +232,34 @@ public HistoryRes ordersToHistoryRes(List orders) { .receipts( orders .stream() - .filter(order -> order.getProgress() == PICKUP) + .filter(order -> order.getProgress() == PICKUP + || order.getProgress() == FAIL + || order.getProgress() == CANCEL) .map(this::orderToReceiptHistoryDto) .toList()) .build(); } + public HistoryRes ordersToFastOrderRes(List orders) { + return HistoryRes.builder() + .receipts( + orders + .stream() + .filter(order -> order.getProgress() == COMPLETE + || order.getProgress() == PICKUP) + .map(this::orderToReceiptHistoryDto) + .toList().subList(Math.max(orders.size() - MAX_FASTORDER_SIZE, 0), orders.size())) + .build(); + } + public HistoryRes ordersToNewHistoryRes(List orders) { return HistoryRes.builder() .receipts( orders .stream() - .filter(order -> order.getProgress() != REQUEST) - .filter(order -> order.getProgress() != CANCEL) - .filter(order -> order.getProgress() != PICKUP) - .filter(order -> order.getProgress() != FAIL) + .filter(order -> order.getProgress() == ORDER + || order.getProgress() == MAKE + || order.getProgress() == COMPLETE) .map(this::orderToReceiptHistoryDto) .toList()) .build(); @@ -301,9 +314,9 @@ public HistoryDetailRes orderToHistoryDetailRes(Order order) { .storePhone(order.getStore().getPhone()) .cart(cartToCartGetRes(order.getCart())) .salePrice( - String.valueOf(order.getCoupon() != null + order.getCoupon() != null ? order.getCoupon().getCouponDetail().getSalePrice() - : null)) + : 0L) .method(order.getMethod()) .build(); } From cba1d79fc5fcf706544bf4d59dbc6a86af57eade Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 3 Dec 2023 23:02:38 +0900 Subject: [PATCH 75/80] =?UTF-8?q?Feat:=20=ED=98=84=EC=9E=AC=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=20=EC=B7=A8=EC=86=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyvery/readyverydemo/src/order/OrderServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 3ed33eb..76a6c74 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -419,7 +419,8 @@ private void verifyOrderCurrent(Order order) { if (order.getProgress().equals(Progress.ORDER) || order.getProgress().equals(Progress.MAKE) || order.getProgress().equals(Progress.COMPLETE) - || order.getProgress().equals(Progress.PICKUP)) { + || order.getProgress().equals(Progress.PICKUP) + || order.getProgress().equals(Progress.CANCEL)) { return; } throw new BusinessLogicException(ExceptionCode.ORDER_NOT_CURRENT); From 1599da3076e7140a346d045a5d706fa69b9f626e Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Sun, 3 Dec 2023 23:16:09 +0900 Subject: [PATCH 76/80] =?UTF-8?q?Feat:=20=EC=B5=9C=EC=8B=A0=20=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=B7=A8=EC=86=8C=20=EC=82=AC=EC=9C=A0=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 --- .../com/readyvery/readyverydemo/src/order/dto/CurrentRes.java | 1 + .../com/readyvery/readyverydemo/src/order/dto/OrderMapper.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CurrentRes.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CurrentRes.java index a576fe7..c2643f1 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/CurrentRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/CurrentRes.java @@ -13,4 +13,5 @@ public class CurrentRes { private Progress progress; private String orderName; private String estimatedTime; + private String cancels; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index 84c2439..c8dd220 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -288,6 +288,7 @@ private ReceiptHistoryDto orderToReceiptHistoryDto(Order order) { public CurrentRes orderToCurrentRes(Order order) { return CurrentRes.builder() + .cancels(order.getReceipt().getCancels().toString()) .name(order.getStore().getName()) .orderNum(order.getOrderNumber()) .progress(order.getProgress()) From b9009b2faf1f14177a28a1fc6010bf6ccd89c61f Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 4 Dec 2023 00:27:49 +0900 Subject: [PATCH 77/80] =?UTF-8?q?Fix:=20System.out=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../readyverydemo/src/order/OrderServiceImpl.java | 7 ++++--- .../readyvery/readyverydemo/src/order/dto/OrderMapper.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 76a6c74..7fce38d 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -66,8 +66,10 @@ import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Service +@Slf4j @RequiredArgsConstructor public class OrderServiceImpl implements OrderService { private final CartRepository cartRepository; @@ -202,7 +204,6 @@ private void verifyMyCart(UserInfo user, Cart cart) { if (cart.getUserInfo().equals(user)) { return; } - System.out.println("asdf"); throw new BusinessLogicException(ExceptionCode.NOT_MY_CART); } @@ -391,7 +392,7 @@ private TosspaymentDto requestTossPaymentCancel(String paymentKey) { new HttpEntity<>(params, headers), TosspaymentDto.class); } catch (Exception e) { - System.out.println("e.getMessage() = " + e.getMessage()); + log.error("e.getMessage() = " + e.getMessage()); throw new BusinessLogicException(ExceptionCode.TOSS_PAYMENT_SUCCESS_FAIL); } } @@ -483,7 +484,7 @@ private TosspaymentDto requestTossPaymentAccept(String paymentKey, String orderI new HttpEntity<>(params, headers), TosspaymentDto.class); } catch (Exception e) { - System.out.println("e.getMessage() = " + e.getMessage()); + log.error("e.getMessage() = " + e.getMessage()); throw new BusinessLogicException(ExceptionCode.TOSS_PAYMENT_SUCCESS_FAIL); } } diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java index c8dd220..d4a8b49 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/dto/OrderMapper.java @@ -288,7 +288,7 @@ private ReceiptHistoryDto orderToReceiptHistoryDto(Order order) { public CurrentRes orderToCurrentRes(Order order) { return CurrentRes.builder() - .cancels(order.getReceipt().getCancels().toString()) + .cancels(order.getReceipt().getCancels()) .name(order.getStore().getName()) .orderNum(order.getOrderNumber()) .progress(order.getProgress()) From 966a2ad0442c9bd304e47de620623308d6f419a9 Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 4 Dec 2023 00:32:42 +0900 Subject: [PATCH 78/80] =?UTF-8?q?Feat:=20=ED=99=98=EB=B6=88=EC=8B=9C=20?= =?UTF-8?q?=EC=BF=A0=ED=8F=B0=20=EC=B2=98=EB=A6=AC=20=EC=B7=A8=EC=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/readyvery/readyverydemo/src/order/OrderServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java index 16dc88e..5f309e8 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/order/OrderServiceImpl.java @@ -370,6 +370,7 @@ private void applyCancelTosspaymentDto(Order order, TosspaymentDto tosspaymentDt order.setPayStatus(false); order.getReceipt().setCancels(tosspaymentDto.getCancels().toString()); order.getReceipt().setStatus(tosspaymentDto.getStatus()); + order.getCoupon().setUsed(false); } private TosspaymentDto requestTossPaymentCancel(String paymentKey) { From 28dafdb87b95492c6c851c7d189f23de490a14ee Mon Sep 17 00:00:00 2001 From: Joowon Lim Date: Mon, 4 Dec 2023 00:57:41 +0900 Subject: [PATCH 79/80] =?UTF-8?q?Feat:=20=EA=B0=80=EA=B2=8C=20=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=ED=81=AC=20=EC=95=84=EC=9B=83=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/readyvery/readyverydemo/domain/Store.java | 4 ++++ .../readyvery/readyverydemo/src/store/dto/StoreEventRes.java | 1 + .../readyvery/readyverydemo/src/store/dto/StoreMapper.java | 1 + 3 files changed, 6 insertions(+) diff --git a/src/main/java/com/readyvery/readyverydemo/domain/Store.java b/src/main/java/com/readyvery/readyverydemo/domain/Store.java index 64a5555..dcd33d5 100644 --- a/src/main/java/com/readyvery/readyverydemo/domain/Store.java +++ b/src/main/java/com/readyvery/readyverydemo/domain/Store.java @@ -68,6 +68,10 @@ public class Store extends BaseTimeEntity { @Column private String eventMessage; + // 가게 테이크 아웃 이벤트 메시지 + @Column + private String takeOutEventMessage; + //가게 등급 @Column @Enumerated(EnumType.STRING) diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreEventRes.java b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreEventRes.java index c7bd9be..ada6c32 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreEventRes.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreEventRes.java @@ -7,4 +7,5 @@ @Builder public class StoreEventRes { private String eventImgUrl; + private String takeOutEvent; } diff --git a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java index 36e5755..5603347 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java +++ b/src/main/java/com/readyvery/readyverydemo/src/store/dto/StoreMapper.java @@ -61,6 +61,7 @@ private MenuItemDto foodieToMenuItems(Foodie foodie) { public StoreEventRes storeToStoreEventRes(Store store) { return StoreEventRes.builder() + .takeOutEvent(store.getTakeOutEventMessage()) .eventImgUrl("/images/" + store.getEngName() + "/" + store.getAdImgUrl()) .build(); } From a08368316e562640fe7e23b5717efd7af4ea7550 Mon Sep 17 00:00:00 2001 From: 1223v <1223v@naver.com> Date: Mon, 4 Dec 2023 01:06:56 +0900 Subject: [PATCH 80/80] =?UTF-8?q?Fix:=20auth=20log=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/jwt/filter/JwtAuthenticationProcessingFilter.java | 2 +- .../com/readyvery/readyverydemo/src/user/UserServiceImpl.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/readyvery/readyverydemo/security/jwt/filter/JwtAuthenticationProcessingFilter.java b/src/main/java/com/readyvery/readyverydemo/security/jwt/filter/JwtAuthenticationProcessingFilter.java index 91fb32d..d89ee72 100644 --- a/src/main/java/com/readyvery/readyverydemo/security/jwt/filter/JwtAuthenticationProcessingFilter.java +++ b/src/main/java/com/readyvery/readyverydemo/security/jwt/filter/JwtAuthenticationProcessingFilter.java @@ -105,7 +105,7 @@ private String reIssueRefreshToken(UserInfo userInfo) { */ public void checkAccessTokenAndAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - log.info("checkAccessTokenAndAuthentication() 호출"); + jwtService.extractAccessTokenFromCookies(request) .filter(jwtService::isTokenValid) .ifPresent(accessToken -> jwtService.extractEmail(accessToken) diff --git a/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java b/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java index 549e3a5..b81ca4c 100644 --- a/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java +++ b/src/main/java/com/readyvery/readyverydemo/src/user/UserServiceImpl.java @@ -104,6 +104,7 @@ private void invalidateRefreshTokenCookie(HttpServletResponse response) { accessTokenCookie.setDomain(accessCookieDomain); accessTokenCookie.setMaxAge(0); // 만료 시간을 0으로 설정하여 즉시 만료 response.addCookie(accessTokenCookie); + } private UserInfo getUserInfo(Long id) {