Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ LF1-861 주문 차감 롤백 주문 결제 롤백 추가 #58

Merged
merged 3 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 0 additions & 51 deletions src/main/java/kr/bb/product/common/dto/NewOrderEvent.java

This file was deleted.

18 changes: 0 additions & 18 deletions src/main/java/kr/bb/product/common/dto/ReviewRegisterEvent.java

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/java/kr/bb/product/common/dto/ReviewType.java

This file was deleted.

17 changes: 0 additions & 17 deletions src/main/java/kr/bb/product/common/dto/StorePolicy.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kr.bb.product.domain.product.adapter.out.mongo;

import bloomingblooms.domain.order.NewOrderEvent.ProductCount;
import bloomingblooms.domain.review.ReviewRegisterEvent;
import java.util.List;
import kr.bb.product.common.dto.NewOrderEvent.ProductCount;
import kr.bb.product.common.dto.ReviewRegisterEvent;
import kr.bb.product.domain.product.application.port.out.ProductCommandOutPort;
import kr.bb.product.domain.product.entity.Product;
import kr.bb.product.domain.product.entity.ProductSaleStatus;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package kr.bb.product.domain.product.application.handler;

import kr.bb.product.common.dto.NewOrderEvent;
import kr.bb.product.common.dto.ReviewRegisterEvent;
import bloomingblooms.domain.order.NewOrderEvent;
import bloomingblooms.domain.review.ReviewRegisterEvent;
import kr.bb.product.domain.product.application.usecase.ProductCommandUseCase;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@RequiredArgsConstructor
public class ProductQueryHandler {
private static final String STORE_AVERAGE_RATING_UPDATE_TOPIC = "store-average-rating-update";
private static final String STOCK_DECREASE_ROLLBACK = "stock-decrease-rollback";
private static final String ORDER_CREATE = "order-create";
private final ProductQueryUseCase productQueryUseCase;
private final StoreServiceClient storeServiceClient;
Expand All @@ -23,10 +24,17 @@ public void getStoreAverageRating() {
STORE_AVERAGE_RATING_UPDATE_TOPIC, productQueryUseCase.getStoreAverageRating());
}

public void getFlowerAmountForOrder(ProcessOrderDto processOrderDto) {
public void getFlowerStockDecrease(ProcessOrderDto processOrderDto) {
storeServiceClient.flowerStockDecreaseRequest(
productQueryUseCase.getFlowerAmountGroupByStoreId(processOrderDto));
// order create request kafka
processOrderDtoProductKafkaProcessor.send(ORDER_CREATE, processOrderDto);
}

public void getFlowerStockRollback(ProcessOrderDto processOrderDto) {
storeServiceClient.flowerStockIncreaseRequest(
productQueryUseCase.getFlowerAmountGroupByStoreId(processOrderDto));
// stock decrease rollback kafka
processOrderDtoProductKafkaProcessor.send(STOCK_DECREASE_ROLLBACK, processOrderDto);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kr.bb.product.domain.product.application.port.in;

import bloomingblooms.domain.order.NewOrderEvent;
import bloomingblooms.domain.review.ReviewRegisterEvent;
import java.util.List;
import kr.bb.product.common.dto.NewOrderEvent;
import kr.bb.product.common.dto.ReviewRegisterEvent;
import kr.bb.product.domain.category.entity.Category;
import kr.bb.product.domain.category.repository.jpa.CategoryRepository;
import kr.bb.product.domain.flower.mapper.FlowerCommand.ProductFlowers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import bloomingblooms.domain.product.ProductInformation;
import bloomingblooms.domain.product.ProductThumbnail;
import bloomingblooms.domain.product.StoreSubscriptionProductId;
import bloomingblooms.domain.store.StorePolicy;
import bloomingblooms.domain.wishlist.cart.GetUserCartItemsResponse;
import bloomingblooms.domain.wishlist.likes.LikedProductInfoResponse;
import bloomingblooms.errors.EntityNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import kr.bb.product.common.dto.StorePolicy;
import kr.bb.product.domain.flower.adapter.out.jpa.FlowerJpaRepository;
import kr.bb.product.domain.flower.application.port.out.FlowerQueryOutPort;
import kr.bb.product.domain.flower.entity.Flower;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kr.bb.product.domain.product.application.port.out;

import bloomingblooms.domain.order.NewOrderEvent.ProductCount;
import bloomingblooms.domain.review.ReviewRegisterEvent;
import java.util.List;
import kr.bb.product.common.dto.NewOrderEvent.ProductCount;
import kr.bb.product.common.dto.ReviewRegisterEvent;
import kr.bb.product.domain.product.entity.Product;
import kr.bb.product.domain.product.entity.ProductSaleStatus;
import kr.bb.product.domain.product.mapper.ProductCommand;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kr.bb.product.domain.product.application.usecase;

import bloomingblooms.domain.order.NewOrderEvent.ProductCount;
import bloomingblooms.domain.review.ReviewRegisterEvent;
import java.util.List;
import kr.bb.product.common.dto.NewOrderEvent.ProductCount;
import kr.bb.product.common.dto.ReviewRegisterEvent;
import kr.bb.product.domain.product.mapper.ProductCommand;

public interface ProductCommandUseCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import bloomingblooms.domain.flower.StockChangeDto;
import bloomingblooms.domain.store.StoreName;
import bloomingblooms.domain.store.StorePolicy;
import bloomingblooms.response.CommonResponse;
import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import kr.bb.product.common.dto.StorePolicy;
import kr.bb.product.config.OpenFeignClientConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down Expand Up @@ -42,6 +42,9 @@ CommonResponse<Map<Long, StorePolicy>> getCartItemProductInformation(
@PutMapping("/client/stores/flowers/stocks/subtract")
void flowerStockDecreaseRequest(@RequestBody List<StockChangeDto> stockChangeDto);

@PutMapping("/client/stores/flowers/stocks/add")
void flowerStockIncreaseRequest(@RequestBody List<StockChangeDto> flowerAmountGroupByStoreId);

default CommonResponse<StoreName> getStoreNameOfProductDetailFallback(Long storeId, Throwable t) {
return CommonResponse.success(StoreName.builder().storeName("가게명").build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ public class ProductKafkaListener {

@KafkaListener(topics = "stock-decrease", groupId = "stock-decrease")
public void stockDecreaseRequestListener(ProcessOrderDto processOrderDto) {
productQueryHandler.getFlowerAmountForOrder(processOrderDto);
productQueryHandler.getFlowerStockDecrease(processOrderDto);
}

@KafkaListener(topics = "order-create-rollback", groupId = "order-rollback")
public void orderRollbackRequestListener(ProcessOrderDto processOrderDto) {
productQueryHandler.getFlowerStockRollback(processOrderDto);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package kr.bb.product.domain.product.infrastructure.message;

import bloomingblooms.domain.order.NewOrderEvent;
import bloomingblooms.domain.review.ReviewRegisterEvent;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Map;
import kr.bb.product.common.dto.NewOrderEvent;
import kr.bb.product.common.dto.ReviewRegisterEvent;
import kr.bb.product.domain.product.application.handler.ProductCommandHandler;
import kr.bb.product.domain.product.application.handler.ProductQueryHandler;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import bloomingblooms.domain.product.ProductInformation;
import bloomingblooms.domain.product.ProductThumbnail;
import bloomingblooms.domain.product.StoreSubscriptionProductId;
import bloomingblooms.domain.store.StorePolicy;
import bloomingblooms.domain.wishlist.cart.CartProductItemInfo;
import bloomingblooms.domain.wishlist.cart.GetUserCartItemsResponse;
import bloomingblooms.domain.wishlist.likes.LikedProductInfoResponse;
Expand All @@ -15,7 +16,6 @@
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import kr.bb.product.common.dto.StorePolicy;
import kr.bb.product.domain.category.entity.CategoryCommand;
import kr.bb.product.domain.category.entity.CategoryCommand.CategoryDetail;
import kr.bb.product.domain.flower.entity.Flower;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kr.bb.product.domain.review.infrastructure.event;

import bloomingblooms.domain.review.ReviewRegisterEvent;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import kr.bb.product.common.dto.ReviewRegisterEvent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package kr.bb.product.domain.review.mapper;

import bloomingblooms.domain.review.ReviewRegisterEvent;
import bloomingblooms.domain.review.ReviewType;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import kr.bb.product.common.dto.ReviewRegisterEvent;
import kr.bb.product.common.dto.ReviewType;
import kr.bb.product.domain.review.entity.Review;
import kr.bb.product.domain.review.entity.ReviewImages;
import kr.bb.product.domain.review.mapper.mapper.ReviewImageMapper;
Expand All @@ -21,7 +21,6 @@ public static ReviewRegisterEvent getReviewRegisterEventData(String productId, R
return ReviewRegisterEvent.builder()
.reviewRating(review.getRating())
.productId(productId)
.id(review.id)
.reviewType(review.reviewType) // TODO: review type required
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

import bloomingblooms.domain.order.NewOrderEvent.ProductCount;
import bloomingblooms.domain.review.ReviewRegisterEvent;
import bloomingblooms.domain.review.ReviewType;
import java.util.ArrayList;
import java.util.List;
import kr.bb.product.common.dto.NewOrderEvent.ProductCount;
import kr.bb.product.common.dto.ReviewRegisterEvent;
import kr.bb.product.common.dto.ReviewType;
import kr.bb.product.domain.product.entity.Product;
import kr.bb.product.domain.product.mapper.ProductCommand;
import org.junit.jupiter.api.DisplayName;
Expand Down
Loading