Class ShoppingCartServiceImpl
- java.lang.Object
-
- co.mastermindcms.modules.services.ShoppingCartServiceImpl
-
- All Implemented Interfaces:
ShoppingCartService
@Service public class ShoppingCartServiceImpl extends java.lang.Object implements ShoppingCartService
-
-
Field Summary
Fields Modifier and Type Field Description private CommerceItemRepository
commerceItemRepository
private CommerceItemService
commerceItemService
private SellerRegistrationService
sellerRegistrationService
private SellerRepository
sellerRepository
private SellerSkuRepository
sellerSkuRepository
private SequenceGeneratorService
sequenceGenerator
private ShoppingCartRepository
shoppingCartRepository
-
Constructor Summary
Constructors Constructor Description ShoppingCartServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ShoppingCartDTO
addCommerceItem(java.lang.String sellerSkuId)
Adds item.boolean
canAddItem(java.lang.String sellerSkuId)
Checks if item is available to add.boolean
checkRestQuantity(java.lang.String sellerSkuId)
Checks if at least minimum order of the inventory could be added to the cart.void
clearCart()
Removes all commerce items from cart.ShoppingCartDTO
decreaseQuantity(java.lang.String itemId)
Decreases quantity of commerce item.private ShoppingCart
getCart()
ShoppingCartDTO
getCartDTO()
Returns DTO of a current cart.private java.util.Optional<SellerSKU>
getSellerSkuFromCommerceItem(java.util.Optional<CommerceItem> item)
ShoppingCartDTO
increaseQuantity(java.lang.String itemId)
Increases quantity of commerce item.private ShoppingCartDTO
mapToDTO(ShoppingCart cart)
ShoppingCartDTO
removeCommerceItem(java.lang.String itemId)
Removes item.
-
-
-
Field Detail
-
shoppingCartRepository
@Autowired private ShoppingCartRepository shoppingCartRepository
-
sellerRegistrationService
@Autowired private SellerRegistrationService sellerRegistrationService
-
commerceItemRepository
@Autowired private CommerceItemRepository commerceItemRepository
-
sellerSkuRepository
@Autowired private SellerSkuRepository sellerSkuRepository
-
sellerRepository
@Autowired private SellerRepository sellerRepository
-
sequenceGenerator
@Autowired private SequenceGeneratorService sequenceGenerator
-
commerceItemService
@Autowired private CommerceItemService commerceItemService
-
-
Method Detail
-
getCartDTO
@Transactional public ShoppingCartDTO getCartDTO()
Description copied from interface:ShoppingCartService
Returns DTO of a current cart.- Specified by:
getCartDTO
in interfaceShoppingCartService
- Returns:
- DTO
-
addCommerceItem
@Transactional public ShoppingCartDTO addCommerceItem(java.lang.String sellerSkuId)
Description copied from interface:ShoppingCartService
Adds item.- Specified by:
addCommerceItem
in interfaceShoppingCartService
- Parameters:
sellerSkuId
- id of SellerSKU to add- Returns:
- DTO of the cart
-
removeCommerceItem
@Transactional public ShoppingCartDTO removeCommerceItem(java.lang.String itemId)
Description copied from interface:ShoppingCartService
Removes item.- Specified by:
removeCommerceItem
in interfaceShoppingCartService
- Parameters:
itemId
- id of commerce item to remove- Returns:
- DTO of the cart
-
clearCart
@Transactional public void clearCart()
Description copied from interface:ShoppingCartService
Removes all commerce items from cart.- Specified by:
clearCart
in interfaceShoppingCartService
-
decreaseQuantity
public ShoppingCartDTO decreaseQuantity(java.lang.String itemId)
Description copied from interface:ShoppingCartService
Decreases quantity of commerce item.- Specified by:
decreaseQuantity
in interfaceShoppingCartService
- Parameters:
itemId
- id of the item- Returns:
- DTO of the cart
-
increaseQuantity
public ShoppingCartDTO increaseQuantity(java.lang.String itemId)
Description copied from interface:ShoppingCartService
Increases quantity of commerce item.- Specified by:
increaseQuantity
in interfaceShoppingCartService
- Parameters:
itemId
- id of the item- Returns:
- DTO of the cart
-
canAddItem
public boolean canAddItem(java.lang.String sellerSkuId)
Description copied from interface:ShoppingCartService
Checks if item is available to add.- Specified by:
canAddItem
in interfaceShoppingCartService
- Parameters:
sellerSkuId
- seller sku ID- Returns:
true
— if item is available to add
-
checkRestQuantity
public boolean checkRestQuantity(java.lang.String sellerSkuId)
Description copied from interface:ShoppingCartService
Checks if at least minimum order of the inventory could be added to the cart.- Specified by:
checkRestQuantity
in interfaceShoppingCartService
- Parameters:
sellerSkuId
- sellerSKU id- Returns:
- true if the quantity could be increased
-
getSellerSkuFromCommerceItem
private java.util.Optional<SellerSKU> getSellerSkuFromCommerceItem(java.util.Optional<CommerceItem> item)
-
getCart
private ShoppingCart getCart()
-
mapToDTO
private ShoppingCartDTO mapToDTO(ShoppingCart cart)
-
-