diff --git a/src/main/java/cart/controller/CartController.java b/src/main/java/cart/controller/CartController.java index 1cfe7eb..df26b9b 100644 --- a/src/main/java/cart/controller/CartController.java +++ b/src/main/java/cart/controller/CartController.java @@ -2,6 +2,7 @@ import cart.model.Cart; import cart.service.CartService; +import com.podzilla.mq.events.ConfirmationType; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -48,8 +49,7 @@ public class CartController { description = "Internal server error", content = @Content) }) - - + @PostMapping("/create") public ResponseEntity createCart( @RequestHeader("X-User-Id") final String customerId) { @@ -235,14 +235,14 @@ public ResponseEntity unarchiveCart( @PostMapping("/checkout") public ResponseEntity checkoutCart( @RequestHeader("X-User-Id") final String customerId, - @RequestParam(required = true) final com.podzilla.mq.events.ConfirmationType confirmationType, + @RequestParam(required = true) final ConfirmationType confirmationType, @RequestParam(required = false) final String signature, @RequestParam(required = true) final Double longitude, @RequestParam(required = true) final Double latitude, @RequestParam(required = true) final DeliveryAddress address ) { - log.debug("Entering checkoutCart endpoint with customerId: {}," + - " confirmationType: {}, signature: {}", + log.debug("Entering checkoutCart endpoint with customerId: {}," + + " confirmationType: {}, signature: {}", customerId, confirmationType, signature); try { Cart updatedCart = cartService.checkoutCart(customerId, confirmationType, diff --git a/src/main/java/cart/service/CartService.java b/src/main/java/cart/service/CartService.java index 2945d27..f292b05 100644 --- a/src/main/java/cart/service/CartService.java +++ b/src/main/java/cart/service/CartService.java @@ -252,8 +252,8 @@ private BigDecimal calculateSubTotal(final Cart cart) { } public Cart checkoutCart(final String customerId, final ConfirmationType confirmationType, - final String signature, final Double longitude, final Double latitude, DeliveryAddress address) { - log.debug("Entering checkoutCart for customerId: {} with confirmationType: {}", + final String signature, final Double longitude, final Double latitude, final DeliveryAddress address) { + log.debug("Entering checkoutCart for customerId: {} with confirmationType: {}", customerId, confirmationType); Cart cart = getActiveCart(customerId); @@ -265,7 +265,8 @@ public Cart checkoutCart(final String customerId, final ConfirmationType confirm } if (confirmationType == ConfirmationType.SIGNATURE && (signature == null || signature.trim().isEmpty())) { - throw new GlobalHandlerException(HttpStatus.BAD_REQUEST, "Signature is required for SIGNATURE confirmation type"); + throw new GlobalHandlerException(HttpStatus.BAD_REQUEST, + "Signature is required for SIGNATURE confirmation type"); } List orderItems = cart.getItems().stream() @@ -279,7 +280,7 @@ public Cart checkoutCart(final String customerId, final ConfirmationType confirm CartCheckedoutEvent checkoutEvent = CartCheckedoutEvent.builder() .cartId(cart.getId()) .customerId(customerId) - .items(orderItems) + .items(orderItems) .totalAmount(cart.getTotalPrice()) .deliveryAddress(address) .orderLatitude(latitude != null ? latitude : 0.0) @@ -289,8 +290,10 @@ public Cart checkoutCart(final String customerId, final ConfirmationType confirm .build(); try { - log.debug("Publishing checkout event for cartId: {} with totals: Sub={}, Discount={}, Total={}, ConfirmationType={}", - cart.getId(), cart.getSubTotal(), cart.getDiscountAmount(), cart.getTotalPrice(), confirmationType); + log.debug("Publishing checkout event for cartId: {} with totals: Sub={}," + + " Discount={}, Total={}, ConfirmationType={}", + cart.getId(), cart.getSubTotal(), cart.getDiscountAmount(), + cart.getTotalPrice(), confirmationType); eventPublisher.publishEvent(EventsConstants.ORDER_PLACED, checkoutEvent); log.info("Checkout event published successfully for cartId: {}. Clearing cart.", cart.getId());