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 AccessManagementService
accessManagementService
private CommerceItemRepository
commerceItemRepository
private CommerceItemService
commerceItemService
private static com.fasterxml.jackson.databind.ObjectMapper
mapper
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(AddToCartRequest request)
Adds item.ShoppingCartDTO
addCommerceItem(java.lang.String sellerSkuId)
Adds item, simplified approach.ShoppingCartDTO
addCommerceItem(java.util.LinkedHashMap<java.lang.String,java.lang.Object> data)
Adds item.ShoppingCartDTO
addCommerceItems(MultipleAddToCartRequest request)
Adds item.ShoppingCartDTO
addCommerceItems(java.util.LinkedHashMap<java.lang.String,java.lang.Object> data)
Adds item.boolean
canAddItem(java.lang.String sellerSkuId)
Checks if item is available to add.boolean
checkCurrencyForCart(SellerSKU sellerSku)
Checking an item to be added to cart with the same currency as the first item.boolean
checkInventory(SellerSKU sellerSku)
Checks if default price is definedboolean
checkPrice(SellerSKU sellerSku)
Checks if default price is definedboolean
checkRestQuantity(SellerSKU sellerSku)
Checks if at least minimum order of the inventory could be added to the cart.boolean
checkStripeConnect(SellerSKU sellerSku)
Checking a stripe connect activation for the sellervoid
clearCart()
Removes all commerce items from cart.ShoppingCartDTO
decreaseQuantity(java.lang.String itemId)
Decreases quantity of commerce item.private ShoppingCart
getCart()
private ShoppingCart
getCart(java.lang.String buyerId)
ShoppingCartDTO
getCartDTO()
Returns DTO of a current cart.ShoppingCartDTO
getCartDTO(java.lang.String buyerId)
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.ShoppingCartDTO
updateQuantity(java.lang.String itemId, java.lang.String quantity)
Decreases quantity of commerce item.
-
-
-
Field Detail
-
shoppingCartRepository
@Autowired private ShoppingCartRepository shoppingCartRepository
-
accessManagementService
@Autowired private AccessManagementService accessManagementService
-
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
-
mapper
private static final com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
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
-
getCartDTO
public ShoppingCartDTO getCartDTO(java.lang.String buyerId)
Description copied from interface:ShoppingCartService
Returns DTO of a current cart.- Specified by:
getCartDTO
in interfaceShoppingCartService
- Parameters:
buyerId
- identification of buyer id- Returns:
- DTO of buyer cart
-
addCommerceItem
@Transactional public ShoppingCartDTO addCommerceItem(java.lang.String sellerSkuId)
Description copied from interface:ShoppingCartService
Adds item, simplified approach.- Specified by:
addCommerceItem
in interfaceShoppingCartService
- Parameters:
sellerSkuId
- id of SellerSKU to add- Returns:
- DTO of the cart
-
addCommerceItems
public ShoppingCartDTO addCommerceItems(java.util.LinkedHashMap<java.lang.String,java.lang.Object> data)
Description copied from interface:ShoppingCartService
Adds item.- Specified by:
addCommerceItems
in interfaceShoppingCartService
- Parameters:
data
- request object which contains all necessary information to add multiple items to cart- Returns:
- DTO of the cart
-
addCommerceItems
public ShoppingCartDTO addCommerceItems(MultipleAddToCartRequest request)
Description copied from interface:ShoppingCartService
Adds item.- Specified by:
addCommerceItems
in interfaceShoppingCartService
- Parameters:
request
- multiple items of SellerSKU to add- Returns:
- DTO of the cart
-
addCommerceItem
public ShoppingCartDTO addCommerceItem(java.util.LinkedHashMap<java.lang.String,java.lang.Object> data)
Description copied from interface:ShoppingCartService
Adds item.- Specified by:
addCommerceItem
in interfaceShoppingCartService
- Parameters:
data
- request object which contains all necessary information to add item to cart- Returns:
- DTO of the cart
-
addCommerceItem
public ShoppingCartDTO addCommerceItem(AddToCartRequest request)
Description copied from interface:ShoppingCartService
Adds item.- Specified by:
addCommerceItem
in interfaceShoppingCartService
- Parameters:
request
- 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
-
updateQuantity
public ShoppingCartDTO updateQuantity(java.lang.String itemId, java.lang.String quantity)
Description copied from interface:ShoppingCartService
Decreases quantity of commerce item.- Specified by:
updateQuantity
in interfaceShoppingCartService
- Parameters:
itemId
- id of the itemquantity
- string value to update item quantity- 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
-
checkPrice
public boolean checkPrice(SellerSKU sellerSku)
Description copied from interface:ShoppingCartService
Checks if default price is defined- Specified by:
checkPrice
in interfaceShoppingCartService
- Parameters:
sellerSku
- sellerSKU as entity- Returns:
- true if the price is defined
-
checkInventory
public boolean checkInventory(SellerSKU sellerSku)
Description copied from interface:ShoppingCartService
Checks if default price is defined- Specified by:
checkInventory
in interfaceShoppingCartService
- Parameters:
sellerSku
- sellerSKU as entity- Returns:
- true if the inventory is contains requested item
-
checkRestQuantity
public boolean checkRestQuantity(SellerSKU sellerSku)
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:
sellerSku
- SellerSKU as entity- Returns:
- true if the quantity could be increased
-
checkCurrencyForCart
public boolean checkCurrencyForCart(SellerSKU sellerSku)
Description copied from interface:ShoppingCartService
Checking an item to be added to cart with the same currency as the first item.- Specified by:
checkCurrencyForCart
in interfaceShoppingCartService
- Parameters:
sellerSku
- SellerSKU as entity- Returns:
- true if the quantity could be increased
-
checkStripeConnect
public boolean checkStripeConnect(SellerSKU sellerSku)
Description copied from interface:ShoppingCartService
Checking a stripe connect activation for the seller- Specified by:
checkStripeConnect
in interfaceShoppingCartService
- Parameters:
sellerSku
- SellerSKU as entity- Returns:
- check if stripe connect is activated
-
getSellerSkuFromCommerceItem
private java.util.Optional<SellerSKU> getSellerSkuFromCommerceItem(java.util.Optional<CommerceItem> item)
-
getCart
private ShoppingCart getCart()
-
getCart
private ShoppingCart getCart(java.lang.String buyerId)
-
mapToDTO
private ShoppingCartDTO mapToDTO(ShoppingCart cart)
-
-