From 937d8dcb3252f6efa5a50ba0df2f391a4510d693 Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 8 Oct 2024 06:23:42 +0900 Subject: [PATCH 01/10] chore: update yml --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 924c25f..77043dd 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: product, db, gcs + active: product, develop, gcs From a7a8570ff4b27ad68d676c93d65d06d0c5c3b800 Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 8 Oct 2024 07:22:12 +0900 Subject: [PATCH 02/10] chore: update yml --- DDANZI_Server_yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDANZI_Server_yml b/DDANZI_Server_yml index 6e08a66..7b9bdca 160000 --- a/DDANZI_Server_yml +++ b/DDANZI_Server_yml @@ -1 +1 @@ -Subproject commit 6e08a66bdbd89b087f1460ce60e613d526fb1eb0 +Subproject commit 7b9bdca016a9c0c0ade5c338738123ef98aab23d From 6af4b7860ecb52e1aedd86e9b9700ee2955ada83 Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 8 Oct 2024 15:24:13 +0900 Subject: [PATCH 03/10] chore: update scheduling time --- .../java/co/orange/ddanzi/service/SchedulerService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/co/orange/ddanzi/service/SchedulerService.java b/src/main/java/co/orange/ddanzi/service/SchedulerService.java index 8914bba..87a0ffb 100644 --- a/src/main/java/co/orange/ddanzi/service/SchedulerService.java +++ b/src/main/java/co/orange/ddanzi/service/SchedulerService.java @@ -32,25 +32,25 @@ public void updateExpiredItems() { /** * 1시간마다 실행 * */ - @Scheduled(fixedRate = 60000) + @Scheduled(fixedRate = 120000) public void scheduleCheckOrderPlacedOrder() { log.info("입금 후 1일(24시간)이 지났는데, 판매확정이 되지 않은 주문 확인"); orderService.checkOrderPlacedOrder(); } - @Scheduled(fixedRate = 60000) + @Scheduled(fixedRate = 120000) public void scheduleCheckShippingOrder() { log.info("판매확정 후 3일 (72시간)이 지났는데, 구매확정이 되지 않은 주문 확인"); orderService.checkShippingOrder(); } - @Scheduled(fixedRate = 60000) + @Scheduled(fixedRate = 120000) public void scheduleCheckDelayedShippingOrder() { log.info("판매확정 후 6일 (144시간)이 지났는데, 구매확정이 되지 않았고, 신고도 하지 않은 주문 확인"); orderService.checkDelayedShippingOrder(); } - @Scheduled(fixedRate = 60000) + @Scheduled(fixedRate = 120000) public void scheduleCheckWarningOrder() { log.info("판매확정 후 7일 (168시간)이 지났는데, 구매확정이 되지 않았고, 신고도 하지 않은 주문 확인"); orderService.checkWarningOrder(); From 87afaeaed86953d2cf3b45d386975478c1d8332c Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 15 Oct 2024 21:36:07 +0900 Subject: [PATCH 04/10] refactor: --- .../java/co/orange/ddanzi/service/PaymentService.java | 11 ++++++----- .../java/co/orange/ddanzi/service/ProductService.java | 2 -- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/co/orange/ddanzi/service/PaymentService.java b/src/main/java/co/orange/ddanzi/service/PaymentService.java index 3a05d6a..00ac531 100644 --- a/src/main/java/co/orange/ddanzi/service/PaymentService.java +++ b/src/main/java/co/orange/ddanzi/service/PaymentService.java @@ -173,14 +173,15 @@ public String getPortOneAccessToken(){ HttpHeaders headers = new HttpHeaders(); headers.set("Content-Type", "application/json"); - Map requestBody = new HashMap<>(); - requestBody.put("imp_key", accessKey); - requestBody.put("imp_secret", accessSecret); + PortOneTokenRequestDto requestDto = PortOneTokenRequestDto.builder() + .imp_key(accessKey) + .imp_secret(accessSecret) + .build(); - HttpEntity> entity = new HttpEntity<>(requestBody, headers); + HttpEntity entity = new HttpEntity<>(requestDto, headers); try { - log.info("Request Body: {}", new ObjectMapper().writeValueAsString(requestBody)); + log.info("Request Body: {}", new ObjectMapper().writeValueAsString(entity)); } catch (JsonProcessingException e) { log.error("JSON 직렬화 오류: {}", e.getMessage()); } diff --git a/src/main/java/co/orange/ddanzi/service/ProductService.java b/src/main/java/co/orange/ddanzi/service/ProductService.java index 2208de6..52a3d13 100644 --- a/src/main/java/co/orange/ddanzi/service/ProductService.java +++ b/src/main/java/co/orange/ddanzi/service/ProductService.java @@ -1,12 +1,10 @@ package co.orange.ddanzi.service; -import co.orange.ddanzi.common.error.Error; import co.orange.ddanzi.common.exception.DiscountNotFoundException; import co.orange.ddanzi.common.exception.ProductNotFoundException; import co.orange.ddanzi.domain.product.Discount; import co.orange.ddanzi.domain.product.Product; import co.orange.ddanzi.domain.user.Account; -import co.orange.ddanzi.domain.user.Address; import co.orange.ddanzi.domain.user.User; import co.orange.ddanzi.common.response.ApiResponse; import co.orange.ddanzi.common.response.Success; From 89762c0b14fc2d20e3a103e91956406a12e293c3 Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 5 Nov 2024 16:45:28 +0900 Subject: [PATCH 05/10] refactor: delete unused code --- .../java/co/orange/ddanzi/service/PaymentService.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/main/java/co/orange/ddanzi/service/PaymentService.java b/src/main/java/co/orange/ddanzi/service/PaymentService.java index 00ac531..2af567a 100644 --- a/src/main/java/co/orange/ddanzi/service/PaymentService.java +++ b/src/main/java/co/orange/ddanzi/service/PaymentService.java @@ -178,16 +178,9 @@ public String getPortOneAccessToken(){ .imp_secret(accessSecret) .build(); - HttpEntity entity = new HttpEntity<>(requestDto, headers); - - try { - log.info("Request Body: {}", new ObjectMapper().writeValueAsString(entity)); - } catch (JsonProcessingException e) { - log.error("JSON 직렬화 오류: {}", e.getMessage()); - } RestTemplate restTemplate = new RestTemplate(); try { - ResponseEntity response = restTemplate.postForEntity(url, entity, PortOneTokenResponseDto.class); + ResponseEntity response = restTemplate.postForEntity(url, new HttpEntity<>(requestDto, headers), PortOneTokenResponseDto.class); log.info("포트원 Access key Get 성공"); return response.getBody().getResponse().getAccess_token(); } catch (HttpClientErrorException e) { From 7676fbfae80dbe6c5305e9a71494a9c8e359b4c3 Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 5 Nov 2024 16:45:41 +0900 Subject: [PATCH 06/10] chore: add json property --- .../co/orange/ddanzi/dto/payment/PortOneTokenRequestDto.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/co/orange/ddanzi/dto/payment/PortOneTokenRequestDto.java b/src/main/java/co/orange/ddanzi/dto/payment/PortOneTokenRequestDto.java index e547057..1e19739 100644 --- a/src/main/java/co/orange/ddanzi/dto/payment/PortOneTokenRequestDto.java +++ b/src/main/java/co/orange/ddanzi/dto/payment/PortOneTokenRequestDto.java @@ -1,5 +1,6 @@ package co.orange.ddanzi.dto.payment; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -10,6 +11,8 @@ @NoArgsConstructor @AllArgsConstructor public class PortOneTokenRequestDto { + @JsonProperty("imp_key") private String imp_key; + @JsonProperty("imp_secret") private String imp_secret; } From d4963d66835643e02f6bea5fc129675c7508489f Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 5 Nov 2024 17:44:29 +0900 Subject: [PATCH 07/10] feat: update closest due date of product --- .../co/orange/ddanzi/service/ItemService.java | 16 ++++++++++++++-- .../co/orange/ddanzi/service/PaymentService.java | 4 ++++ .../co/orange/ddanzi/service/ProductService.java | 10 ++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main/java/co/orange/ddanzi/service/ItemService.java b/src/main/java/co/orange/ddanzi/service/ItemService.java index 1343f7f..1b0c887 100644 --- a/src/main/java/co/orange/ddanzi/service/ItemService.java +++ b/src/main/java/co/orange/ddanzi/service/ItemService.java @@ -30,6 +30,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; import java.time.LocalDate; @@ -37,6 +38,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.Optional; @Slf4j @@ -54,6 +56,7 @@ public class ItemService { private final GcsService gcsService; private final TermService termService; private final AddressService addressService; + private final ProductService productService; private final PaymentService paymentService; private final PaymentRepository paymentRepository; private final HistoryService historyService; @@ -87,8 +90,12 @@ public ApiResponse saveItem(SaveItemRequestDto requestDto){ product.updateStock(product.getStock() + 1); log.info("상품의 재고 수량 업데이트 -> {}개", product.getStock()); - if(product.getClosestDueDate()==null || dueDate.isBefore(product.getClosestDueDate())) + + if(product.getClosestDueDate()==null || dueDate.isBefore(product.getClosestDueDate())) { product.updateClosestDueDate(dueDate); + log.info("가장 가까운 마감일을 수정 -> {}", dueDate); + + } SaveItemResponseDto responseDto = SaveItemResponseDto.builder() .itemId(newItem.getId()) @@ -167,9 +174,14 @@ public ApiResponse deleteItem(String itemId){ } log.info("제품을 삭제합니다."); item.updateStatus(ItemStatus.DELETED); - log.info("재고를 감소시킵니다."); + Product product = item.getProduct(); product.updateStock(product.getStock() - 1); + log.info("재고를 감소시킴 -> {}개", product.getClosestDueDate()); + + productService.updateClosestDueDate(product); + + log.info("가장 가까운 마감일을 수정합 -> {}", product.getClosestDueDate()); return ApiResponse.onSuccess(Success.DELETE_ITEM_SUCCESS, true); } diff --git a/src/main/java/co/orange/ddanzi/service/PaymentService.java b/src/main/java/co/orange/ddanzi/service/PaymentService.java index 2af567a..139f2ee 100644 --- a/src/main/java/co/orange/ddanzi/service/PaymentService.java +++ b/src/main/java/co/orange/ddanzi/service/PaymentService.java @@ -50,6 +50,8 @@ public class PaymentService { private final OrderService orderService; private final HistoryService historyService; private final FcmService fcmService; + private final ProductService productService; + private final ItemService itemService; @Value("${ddanzi.portone.access-key}") private String accessKey; @@ -132,6 +134,8 @@ else if(payment.getPayStatus().equals(PayStatus.PAID)){ log.info("Payment is paid!!"); item.updateStatus(ItemStatus.CLOSED); product.updateStock(product.getStock() - 1); + productService.updateClosestDueDate(product); + log.info("가장 가까운 마감일을 수정합 -> {}", product.getClosestDueDate()); fcmService.sendMessageToAdmins("⚠️관리자 알림: 구매실행", "결제가 실행되었습니다. orderId:" + order.getId()); } diff --git a/src/main/java/co/orange/ddanzi/service/ProductService.java b/src/main/java/co/orange/ddanzi/service/ProductService.java index 52a3d13..97e8291 100644 --- a/src/main/java/co/orange/ddanzi/service/ProductService.java +++ b/src/main/java/co/orange/ddanzi/service/ProductService.java @@ -3,6 +3,7 @@ import co.orange.ddanzi.common.exception.DiscountNotFoundException; import co.orange.ddanzi.common.exception.ProductNotFoundException; import co.orange.ddanzi.domain.product.Discount; +import co.orange.ddanzi.domain.product.Item; import co.orange.ddanzi.domain.product.Product; import co.orange.ddanzi.domain.user.Account; import co.orange.ddanzi.domain.user.User; @@ -23,6 +24,7 @@ import org.springframework.web.client.RestTemplate; import java.util.Map; +import java.util.Optional; @Slf4j @@ -31,6 +33,7 @@ public class ProductService { private final AuthUtils authUtils; private final ProductRepository productRepository; + private final ItemRepository itemRepository; private final DiscountRepository discountRepository; private final AccountRepository accountRepository; @@ -88,6 +91,13 @@ public String getMostSimilarProductId(ProductRequestDto requestDto){ } } + public void updateClosestDueDate(Product product){ + Optional item = itemRepository.findNearestExpiryItem(product); + if(item.isPresent()) + product.updateClosestDueDate(item.get().getDueDate()); + else + product.updateClosestDueDate(null); + } /* @Transactional From ee4721d85fbb99fec0e68538a9fdf8268b48b021 Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 5 Nov 2024 17:55:08 +0900 Subject: [PATCH 08/10] fix: resolve xircular reference --- src/main/java/co/orange/ddanzi/service/MyPageService.java | 6 ++---- src/main/java/co/orange/ddanzi/service/PaymentService.java | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/co/orange/ddanzi/service/MyPageService.java b/src/main/java/co/orange/ddanzi/service/MyPageService.java index a928906..480da325 100644 --- a/src/main/java/co/orange/ddanzi/service/MyPageService.java +++ b/src/main/java/co/orange/ddanzi/service/MyPageService.java @@ -26,10 +26,8 @@ public class MyPageService { private final HomeService homeService; private final InterestProductRepository interestProductRepository; - @Autowired - OrderService orderService; - @Autowired - ItemService itemService; + private final OrderService orderService; + private final ItemService itemService; @Transactional public ApiResponse getMyPage(){ diff --git a/src/main/java/co/orange/ddanzi/service/PaymentService.java b/src/main/java/co/orange/ddanzi/service/PaymentService.java index 139f2ee..2065881 100644 --- a/src/main/java/co/orange/ddanzi/service/PaymentService.java +++ b/src/main/java/co/orange/ddanzi/service/PaymentService.java @@ -51,7 +51,6 @@ public class PaymentService { private final HistoryService historyService; private final FcmService fcmService; private final ProductService productService; - private final ItemService itemService; @Value("${ddanzi.portone.access-key}") private String accessKey; From 21b096f76301ead21b17aa2d9ab20d58cc22ddba Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 5 Nov 2024 17:57:42 +0900 Subject: [PATCH 09/10] chore: update yml --- src/main/resources/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 77043dd..924c25f 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: product, develop, gcs + active: product, db, gcs From 45dbc7a5f96e75b3ae9fcd548a91922362c47d77 Mon Sep 17 00:00:00 2001 From: kang Date: Tue, 5 Nov 2024 18:19:42 +0900 Subject: [PATCH 10/10] chore: update yml --- DDANZI_Server_yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DDANZI_Server_yml b/DDANZI_Server_yml index 0686e1b..7bf0bab 160000 --- a/DDANZI_Server_yml +++ b/DDANZI_Server_yml @@ -1 +1 @@ -Subproject commit 0686e1b336e22d1db60e3ba27d3a9dfaa7578fdf +Subproject commit 7bf0bab0656daeaddb9f9351ac3eefd485e6e7cf