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 CommerceItemRepositorycommerceItemRepositoryprivate InventoryRepositoryinventoryRepositoryprivate SellerSkuRepositorysellerSkuRepository
-
Constructor Summary
Constructors Constructor Description CommerceItemServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimalcalculateTotalPrice(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.CommerceItemRepositorygetRepository()java.util.List<CommerceItemDTO>mapItems(java.util.Collection<CommerceItem> items)Maps items to DTOs.private SellerSkuDTOmapSellerSku(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.voidrefundCommerceItems(Order order)Refunds all commerce items in the given order.voidremoveCommerceItem(java.lang.String id)Removes a commerce item based on its id.voidremoveCommerceItems(java.util.List<java.lang.String> ids)Removes multiple commerce items based on an array of ids.booleanupdateInventoriesLockedQuantity(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:
getRepositoryin interfaceCommerceItemService
-
calculateTotalPrice
public java.math.BigDecimal calculateTotalPrice(java.util.Collection<CommerceItem> items)
Description copied from interface:CommerceItemServiceSums prices of commerce items.- Specified by:
calculateTotalPricein interfaceCommerceItemService- Parameters:
items- items- Returns:
- sum.
-
mapItems
public java.util.List<CommerceItemDTO> mapItems(java.util.Collection<CommerceItem> items)
Description copied from interface:CommerceItemServiceMaps items to DTOs.- Specified by:
mapItemsin 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:CommerceItemServiceExtracting specs of sku to list of maps.- Specified by:
extractSpecsin interfaceCommerceItemService- Parameters:
sku- sellerSKU- Returns:
- map of specs
-
removeCommerceItem
public void removeCommerceItem(java.lang.String id)
Description copied from interface:CommerceItemServiceRemoves a commerce item based on its id.- Specified by:
removeCommerceItemin 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:CommerceItemServiceRemoves multiple commerce items based on an array of ids.- Specified by:
removeCommerceItemsin interfaceCommerceItemService- Parameters:
ids- an collection of ids of the commerce items to be removed
-
refundCommerceItems
public void refundCommerceItems(Order order)
Description copied from interface:CommerceItemServiceRefunds all commerce items in the given order.- Specified by:
refundCommerceItemsin 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:CommerceItemServiceUpdates 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:
updateInventoriesLockedQuantityin 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:CommerceItemServiceThis method creates a mapping between each CommerceItem and its corresponding Inventory.- Specified by:
obtainItemToInventoryMapin 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)
-
-