Class CommerceItemServiceImpl
- java.lang.Object
-
- co.mastermindcms.modules.services.CommerceItemServiceImpl
-
- All Implemented Interfaces:
CommerceItemService
@Service public class CommerceItemServiceImpl extends java.lang.Object implements CommerceItemService
-
-
Field Summary
Fields Modifier and Type Field Description private CommerceItemRepository
commerceItemRepository
private InventoryRepository
inventoryRepository
private SellerSkuRepository
sellerSkuRepository
-
Constructor Summary
Constructors Constructor Description CommerceItemServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimal
calculateTotalPrice(java.util.Collection<CommerceItem> items)
Sums prices of commerce items.java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
extractAttributeValues(SellerSKU sku)
java.util.Map<java.lang.String,java.lang.Object>
extractSpecs(SellerSKU sku)
Extracting specs of sku to list of maps.CommerceItemRepository
getRepository()
java.util.List<CommerceItemDTO>
mapItems(java.util.Collection<CommerceItem> items)
Maps items to DTOs.private SellerSkuDTO
mapSellerSku(SellerSKU sellerSKU)
java.util.Map<CommerceItem,Inventory>
obtainItemToInventoryMap(java.util.List<CommerceItem> items)
This method creates a mapping between each CommerceItem and its corresponding Inventory.void
refundCommerceItems(Order order)
Refunds all commerce items in the given order.void
removeCommerceItem(java.lang.String id)
Removes a commerce item based on its id.void
removeCommerceItems(java.util.List<java.lang.String> ids)
Removes multiple commerce items based on an array of ids.boolean
updateInventoriesLockedQuantity(java.util.Map<CommerceItem,Inventory> map, boolean increase)
Updates the locked quantity in the inventories based on the map of commerce items and their corresponding inventory objects.
-
-
-
Field Detail
-
sellerSkuRepository
@Autowired private SellerSkuRepository sellerSkuRepository
-
commerceItemRepository
@Autowired private CommerceItemRepository commerceItemRepository
-
inventoryRepository
@Autowired private InventoryRepository inventoryRepository
-
-
Method Detail
-
getRepository
public CommerceItemRepository getRepository()
- Specified by:
getRepository
in interfaceCommerceItemService
-
calculateTotalPrice
public java.math.BigDecimal calculateTotalPrice(java.util.Collection<CommerceItem> items)
Description copied from interface:CommerceItemService
Sums prices of commerce items.- Specified by:
calculateTotalPrice
in interfaceCommerceItemService
- Parameters:
items
- items- Returns:
- sum.
-
mapItems
public java.util.List<CommerceItemDTO> mapItems(java.util.Collection<CommerceItem> items)
Description copied from interface:CommerceItemService
Maps items to DTOs.- Specified by:
mapItems
in interfaceCommerceItemService
- Parameters:
items
- commerce items- Returns:
- list of dto
-
extractSpecs
public java.util.Map<java.lang.String,java.lang.Object> extractSpecs(SellerSKU sku)
Description copied from interface:CommerceItemService
Extracting specs of sku to list of maps.- Specified by:
extractSpecs
in interfaceCommerceItemService
- Parameters:
sku
- sellerSKU- Returns:
- map of specs
-
removeCommerceItem
public void removeCommerceItem(java.lang.String id)
Description copied from interface:CommerceItemService
Removes a commerce item based on its id.- Specified by:
removeCommerceItem
in interfaceCommerceItemService
- Parameters:
id
- the id of the commerce item to be removed
-
removeCommerceItems
public void removeCommerceItems(java.util.List<java.lang.String> ids)
Description copied from interface:CommerceItemService
Removes multiple commerce items based on an array of ids.- Specified by:
removeCommerceItems
in interfaceCommerceItemService
- Parameters:
ids
- an collection of ids of the commerce items to be removed
-
refundCommerceItems
public void refundCommerceItems(Order order)
Description copied from interface:CommerceItemService
Refunds all commerce items in the given order.- Specified by:
refundCommerceItems
in interfaceCommerceItemService
- Parameters:
order
- the order containing the commerce items to be refunded
-
updateInventoriesLockedQuantity
public boolean updateInventoriesLockedQuantity(java.util.Map<CommerceItem,Inventory> map, boolean increase)
Description copied from interface:CommerceItemService
Updates the locked quantity in the inventories based on the map of commerce items and their corresponding inventory objects. If increase is true, the locked quantity will be increased; if increase is false, the locked quantity will be decreased.- Specified by:
updateInventoriesLockedQuantity
in interfaceCommerceItemService
- Parameters:
map
- A map of CommerceItem objects and their corresponding Inventory objectsincrease
- A boolean value to indicate whether to increase or decrease the locked quantity- Returns:
- true if the locked quantity was successfully updated, false otherwise
-
obtainItemToInventoryMap
public java.util.Map<CommerceItem,Inventory> obtainItemToInventoryMap(java.util.List<CommerceItem> items)
Description copied from interface:CommerceItemService
This method creates a mapping between each CommerceItem and its corresponding Inventory.- Specified by:
obtainItemToInventoryMap
in interfaceCommerceItemService
- Parameters:
items
- the list of CommerceItems for which the mapping needs to be created- Returns:
- a Map containing the CommerceItem as the key and its corresponding Inventory as the value
-
extractAttributeValues
public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> extractAttributeValues(SellerSKU sku)
-
mapSellerSku
private SellerSkuDTO mapSellerSku(SellerSKU sellerSKU)
-
-