Class DefaultAddProductToCartActionStrategy
java.lang.Object
de.hybris.platform.promotionengineservices.action.impl.AbstractRuleActionStrategy<RuleBasedOrderAddProductActionModel>
de.hybris.platform.promotionengineservices.action.impl.DefaultAddProductToCartActionStrategy
- All Implemented Interfaces:
RuleActionStrategy,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware
public class DefaultAddProductToCartActionStrategy
extends AbstractRuleActionStrategy<RuleBasedOrderAddProductActionModel>
Encapsulates logic of adding new order entry and give a 100% discount for it.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractOrderEntryModeladdNewEntry(AbstractOrderModel order, ProductModel product, int quantityToAdd) apply(AbstractRuleActionRAO action) If the parameter action is of typeDiscountRAOand is applied to Order Entry the discount is added to corresponding Order Entry model.protected RuleBasedOrderAddProductActionModelcreateOrderAddProductAction(AbstractRuleActionRAO action, int quantity, ProductModel product, PromotionResultModel promoResult) protected AbstractOrderEntryModelfindMatchingGiveAwayEntry(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action, BiPredicate<RuleBasedOrderAddProductActionModel, AbstractOrderEntryModel> matchingCondition) protected AbstractOrderEntryModeltries to find an order entry usable for theundo(ItemModel)method based on matching product, quantity andgiveAwayflag: First tries to match an order entry that is marked asgiveAwaywith the same product and quantity.protected CartServiceprotected Optional<AbstractOrderEntryModel>getExistingGiveAwayEntry(AbstractOrderModel order, ProductModel product) protected OrderServiceprotected OrderUtilsprotected ProductServiceprotected RuleEngineCalculationServiceprotected UnitModelgetUnit(ProductModel productModel) protected voidnormalizes the givenorder's entries by assigning them increasing entry numbers starting from 0.voidsetCartService(CartService cartService) voidsetOrderService(OrderService orderService) voidsetOrderUtils(OrderUtils orderUtils) voidsetProductService(ProductService productService) voidsetRuleEngineCalculationService(RuleEngineCalculationService ruleEngineCalculationService) voidRevokes the Promotion Action that was applied.Methods inherited from class de.hybris.platform.promotionengineservices.action.impl.AbstractRuleActionStrategy
createPromotionAction, getActionUtils, getCalculationService, getDefaultRuleMetadataKeys, getExtendedOrderDao, getForceImmediateRecalculation, getMetadataHandlers, getModelService, getPromotionAction, getPromotionActionService, getPromotionResultUtils, getRuleActionMetadataHandlers, getStrategyId, handleActionMetadata, handleUndoActionMetadata, recalculateIfNeeded, setActionUtils, setBeanName, setCalculationService, setDefaultRuleMetadataKeys, setExtendedOrderDao, setForceImmediateRecalculation, setModelService, setPromotionAction, setPromotionActionService, setPromotionResultUtils, setRuleActionMetadataHandlers, undoInternal
-
Constructor Details
-
DefaultAddProductToCartActionStrategy
public DefaultAddProductToCartActionStrategy()
-
-
Method Details
-
apply
If the parameter action is of typeDiscountRAOand is applied to Order Entry the discount is added to corresponding Order Entry model.- Parameters:
action- the action to apply- Returns:
- list of
PromotionResultModelas a result of theDiscountRAOapplication.
-
addNewEntry
protected AbstractOrderEntryModel addNewEntry(AbstractOrderModel order, ProductModel product, int quantityToAdd) -
getExistingGiveAwayEntry
protected Optional<AbstractOrderEntryModel> getExistingGiveAwayEntry(AbstractOrderModel order, ProductModel product) -
createOrderAddProductAction
protected RuleBasedOrderAddProductActionModel createOrderAddProductAction(AbstractRuleActionRAO action, int quantity, ProductModel product, PromotionResultModel promoResult) -
undo
Description copied from interface:RuleActionStrategyRevokes the Promotion Action that was applied.- Parameters:
item- the action to be undone
-
normalizeEntryNumbers
normalizes the givenorder's entries by assigning them increasing entry numbers starting from 0. This method is called during theundo(ItemModel)call of this action if the undo removes an order entry completely.- Parameters:
order- the order to normalize
-
findOrderEntryForUndo
protected AbstractOrderEntryModel findOrderEntryForUndo(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action) tries to find an order entry usable for theundo(ItemModel)method based on matching product, quantity andgiveAwayflag: First tries to match an order entry that is marked asgiveAwaywith the same product and quantity. If none is found, tries to find an entry with just matching product and quantity. If still none is found, tries to find an entry for the given product with higher quantity.- Parameters:
order- the order to look for an order entry foraction- the action- Returns:
- an order entry or null if no matching one is found
-
findMatchingGiveAwayEntry
protected AbstractOrderEntryModel findMatchingGiveAwayEntry(AbstractOrderModel order, RuleBasedOrderAddProductActionModel action, BiPredicate<RuleBasedOrderAddProductActionModel, AbstractOrderEntryModel> matchingCondition) - Returns:
- if exists give-away order entry with matching product and quantity , null otherwise
-
getUnit
-
getCartService
-
setCartService
-
getProductService
-
setProductService
-
getRuleEngineCalculationService
-
setRuleEngineCalculationService
public void setRuleEngineCalculationService(RuleEngineCalculationService ruleEngineCalculationService) -
getOrderService
-
setOrderService
-
getOrderUtils
-
setOrderUtils
-