Class DefaultPromotionEngineService
- java.lang.Object
-
- de.hybris.platform.promotionengineservices.promotionengine.impl.DefaultPromotionEngineService
-
- All Implemented Interfaces:
PromotionEngineService,PromotionsService
- Direct Known Subclasses:
DefaultSapPromotionEngineService
public class DefaultPromotionEngineService extends java.lang.Object implements PromotionEngineService, PromotionsService
Default implementation of Promotion Engine Service that uses Rule Engine Service to evaluate promotions.
-
-
Constructor Summary
Constructors Constructor Description DefaultPromotionEngineService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcleanupAbstractOrder(AbstractOrderModel cart)voidcleanupCart(CartModel cart)Delete the the stored promotion results for a Cart.protected AbstractRuleEngineContextModeldetermineRuleEngineContext(AbstractOrderModel order)determines the rule engine context to be used for the given order.protected AbstractRuleEngineContextModeldetermineRuleEngineContext(ProductModel product)determines the rule engine context to be used for the given product.RuleEvaluationResultevaluate(AbstractOrderModel order, java.util.Collection<PromotionGroupModel> promotionGroups)evaluate the promotions for the given cart or order and for now.RuleEvaluationResultevaluate(AbstractOrderModel order, java.util.Collection<PromotionGroupModel> promotionGroups, java.util.Date date)evaluate the promotions for the given cart or order and for the date.RuleEvaluationResultevaluate(ProductModel product, java.util.Collection<PromotionGroupModel> promotionGroups)Evaluates promotion against a product taking into context which is set by promotions groupprotected <T> TfindImmutablePromotionByUniqueKey(java.lang.String immutableKeyHash, java.util.function.Predicate<T> immutableKeyPredicate)java.util.List<? extends AbstractPromotionModel>getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)Get the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.java.util.List<? extends AbstractPromotionModel>getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)Get the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.protected CalculationServicegetCalculationService()protected CatalogVersionServicegetCatalogVersionService()protected java.util.Set<java.lang.String>getCategoryCodesForProduct(ProductModel product)protected CategoryServicegetCategoryService()protected RuleEngineServicegetCommerceRuleEngineService()protected ConfigurationServicegetConfigurationService()protected java.lang.StringgetDataUniqueKey(AbstractPromotionModel sourcePromotion)PromotionGroupModelgetDefaultPromotionGroup()Lookup the default promotion group created by the promotions extension.DefaultPromotionsServicegetDefaultPromotionsService()protected EngineRuleDaogetEngineRuleDao()protected FactContextFactorygetFactContextFactory()protected FlexibleSearchServicegetFlexibleSearchService()protected ModelServicegetModelService()java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product, java.util.Date date)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, java.util.Date date)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, java.util.Date date)Get the ordered list ofOrderPromotioninstances.java.util.List<OrderPromotionModel>getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, java.util.Date date)Get the ordered list ofOrderPromotioninstances.java.util.List<ProductPromotionModel>getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)Get the ordered list ofProductPromotioninstances that are related to theProductModelspecified.java.util.List<ProductPromotionModel>getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)Get the ordered list ofProductPromotioninstances that are related to theProductModelspecified.protected ProductUtilsgetProductUtils()protected PromotionDaogetPromotionDao()java.lang.StringgetPromotionDescription(AbstractPromotionModel promotion)Get the description of given promotion.PromotionGroupModelgetPromotionGroup(java.lang.String identifier)Lookup a promotion group with the given identifier.PromotionOrderResultsgetPromotionResults(AbstractOrderModel order)Get the promotion results for the specified order.PromotionOrderResultsgetPromotionResults(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)Get the promotion results for the specified order.protected java.util.ArrayList<RuleBasedPromotionModel>getPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)protected java.util.List<RuleBasedPromotionModel>getPromotionsForProduct(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)Get all promotions, sorted by priority, that could be applied for the given product and promotion groups.protected PromotionSourceRuleDaogetPromotionSourceRuleDao()java.util.Collection<AbstractPromotionRestrictionModel>getRestrictions(AbstractPromotionModel promotion)Get the collection ofAbstractPromotionRestrictionModelinstances.protected RuleActionServicegetRuleActionService()protected RuleActionStrategygetRuleActionStrategy(java.lang.String strategyId)returns theRuleActionStrategydefined in thestrategiesattribute of this service by looking up it's bean id.protected RuleBasedPromotionsContextValidatorgetRuleBasedPromotionsContextValidator()protected RuleEngineContextDaogetRuleEngineContextDao()protected RuleEngineContextFinderStrategygetRuleEngineContextFinderStrategy()protected RuleEngineContextForCatalogVersionsFinderStrategygetRuleEngineContextForCatalogVersionsFinderStrategy()protected SessionServicegetSessionService()protected java.util.List<RuleActionStrategy>getStrategies()protected TimeServicegetTimeService()protected booleanisApplicable(ProductModel product, RuleBasedPromotionModel promotion)protected RuleEvaluationContextprepareContext(FactContext factContext, AbstractRuleEngineContextModel ruleEngineContext)Sets up the rule evaluation context using the provided factContext with facts and rao providers and sets the given ruleEngineContext.protected java.util.Set<java.lang.Object>provideRAOs(FactContext factContext)Converts the givensourceobject into an RAO using the configuredraoProviders.protected booleanrecalculateCart(AbstractOrderModel order)voidsetCalculationService(CalculationService calculationService)voidsetCatalogVersionService(CatalogVersionService catalogVersionService)voidsetCategoryService(CategoryService categoryService)voidsetCommerceRuleEngineService(RuleEngineService ruleEngineService)voidsetConfigurationService(ConfigurationService configurationService)voidsetDefaultPromotionsService(DefaultPromotionsService defaultPromotionsService)voidsetEngineRuleDao(EngineRuleDao engineRuleDao)voidsetFactContextFactory(FactContextFactory factContextFactory)voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService)voidsetModelService(ModelService modelService)voidsetProductUtils(ProductUtils productUtils)voidsetPromotionDao(PromotionDao promotionDao)voidsetPromotionSourceRuleDao(PromotionSourceRuleDao promotionSourceRuleDao)voidsetRuleActionService(RuleActionService ruleActionService)voidsetRuleBasedPromotionsContextValidator(RuleBasedPromotionsContextValidator ruleBasedPromotionsContextValidator)voidsetRuleEngineContextDao(RuleEngineContextDao ruleEngineContextDao)voidsetRuleEngineContextFinderStrategy(RuleEngineContextFinderStrategy ruleEngineContextFinderStrategy)voidsetRuleEngineContextForCatalogVersionsFinderStrategy(RuleEngineContextForCatalogVersionsFinderStrategy ruleEngineContextForCatalogVersionsFinderStrategy)voidsetSessionService(SessionService sessionService)voidsetStrategies(java.util.List<RuleActionStrategy> strategies)voidsetTimeService(TimeService timeService)voidtransferPromotionsToOrder(AbstractOrderModel source, OrderModel target, boolean onlyTransferAppliedPromotions)Transfer the promotions applied to a cart to a new order.protected voidundoPromotionAction(AbstractPromotionActionModel action)PromotionOrderResultsupdatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)Update the promotions on the specifiedAbstractOrderobject.PromotionOrderResultsupdatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)Update the promotions on the specifiedAbstractOrderModelobject.protected PromotionOrderResultsupdatePromotionsNotThreadSafe(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)protected PromotionOrderResultsupdatePromotionsNotThreadSafe(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, java.util.Date date)
-
-
-
Method Detail
-
evaluate
public RuleEvaluationResult evaluate(ProductModel product, java.util.Collection<PromotionGroupModel> promotionGroups)
Description copied from interface:PromotionEngineServiceEvaluates promotion against a product taking into context which is set by promotions group- Specified by:
evaluatein interfacePromotionEngineService- Parameters:
product- to evaluate promotions forpromotionGroups- collection of promotion groups to apply promotions for- Returns:
- Map containing Promotion data as its values along with corresponding identifiers as its keys
-
evaluate
public RuleEvaluationResult evaluate(AbstractOrderModel order, java.util.Collection<PromotionGroupModel> promotionGroups)
Description copied from interface:PromotionEngineServiceevaluate the promotions for the given cart or order and for now. This does not apply the result to the cart/order.- Specified by:
evaluatein interfacePromotionEngineService- Parameters:
order- the cart or order to evaluatepromotionGroups- collection of promotion groups to apply promotions for- Returns:
- the result of the evaluation
-
evaluate
public RuleEvaluationResult evaluate(AbstractOrderModel order, java.util.Collection<PromotionGroupModel> promotionGroups, java.util.Date date)
Description copied from interface:PromotionEngineServiceevaluate the promotions for the given cart or order and for the date. This does not apply the result to the cart/order.- Specified by:
evaluatein interfacePromotionEngineService- Parameters:
order- the cart or order to evaluatepromotionGroups- collection of promotion groups to apply promotions fordate- the moment of evaluation- Returns:
- the result of the evaluation
-
prepareContext
protected RuleEvaluationContext prepareContext(FactContext factContext, AbstractRuleEngineContextModel ruleEngineContext)
Sets up the rule evaluation context using the provided factContext with facts and rao providers and sets the given ruleEngineContext.- Parameters:
factContext- FactContext to use for the evaluationruleEngineContext- the rule engine context to be used during rule evaluation- Returns:
- the rule evaluation context
-
determineRuleEngineContext
protected AbstractRuleEngineContextModel determineRuleEngineContext(AbstractOrderModel order)
determines the rule engine context to be used for the given order. This method usesRuleEngineContextFinderStrategy.findRuleEngineContext(AbstractOrderModel, RuleType)to determine the rule engine context to be used.- Parameters:
order- the order to be used- Returns:
- the rule engine context to be used
-
determineRuleEngineContext
protected AbstractRuleEngineContextModel determineRuleEngineContext(ProductModel product)
determines the rule engine context to be used for the given product. This method usesRuleEngineContextFinderStrategy.findRuleEngineContext(ProductModel, RuleType)to determine the rule engine context to be used.- Parameters:
product- the product to be used- Returns:
- the rule engine context to be used
-
provideRAOs
protected java.util.Set<java.lang.Object> provideRAOs(FactContext factContext)
Converts the givensourceobject into an RAO using the configuredraoProviders.- Parameters:
factContext- FactContext containing rao providers- Throws:
java.lang.RuntimeException- if no raoProvider is registered for the given source object
-
getAbstractProductPromotions
public java.util.List<? extends AbstractPromotionModel> getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Description copied from interface:PromotionsServiceGet the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.- Specified by:
getAbstractProductPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related to- Returns:
- The list of
AbstractPromotionModelrelated to theProductModelspecified
-
getAbstractProductPromotions
public java.util.List<? extends AbstractPromotionModel> getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Description copied from interface:PromotionsServiceGet the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.- Specified by:
getAbstractProductPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related toevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.date- The date to check for promotions, typically the current date- Returns:
- The list of
AbstractPromotionModelrelated to theProductModelspecified
-
getProductPromotions
public java.util.List<ProductPromotionModel> getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Description copied from interface:PromotionsServiceGet the ordered list ofProductPromotioninstances that are related to theProductModelspecified.- Specified by:
getProductPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related to- Returns:
- The list of
ProductPromotionrelated to theProductModelspecified
-
getProductPromotions
public java.util.List<ProductPromotionModel> getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Description copied from interface:PromotionsServiceGet the ordered list ofProductPromotioninstances that are related to theProductModelspecified.- Specified by:
getProductPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related toevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.date- The date to check for promotions, typically the current date- Returns:
- The list of
ProductPromotionrelated to theProductModelspecified
-
getOrderPromotions
public java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups)
Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluate- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, java.util.Date date)
Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluatedate- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product to pass to restrictions- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, java.util.Date date)
Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product to pass to restrictionsdate- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions)
Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, java.util.Date date)
Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.date- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product)
Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.product- The product to pass to restrictions if evaluateRestrictions is true- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product, java.util.Date date)
Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.product- The product to pass to restrictions if evaluateRestrictions is truedate- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
updatePromotions
public PromotionOrderResults updatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)
Description copied from interface:PromotionsServiceUpdate the promotions on the specifiedAbstractOrderobject. This method will automatically apply all possible product promotional updates to the cart, but not apply order level promotions. Any previously applied order level promotions will remain applied. Promotions are evaluated at the current system time. The promotion results are stored in the database and the samePromotionOrderResultscan be obtained later by callingPromotionsService.getPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel).- Specified by:
updatePromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateorder- The order object to update with the results of the promotions- Returns:
- The promotion results
-
updatePromotionsNotThreadSafe
protected PromotionOrderResults updatePromotionsNotThreadSafe(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)
-
updatePromotionsNotThreadSafe
protected PromotionOrderResults updatePromotionsNotThreadSafe(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, java.util.Date date)
-
updatePromotions
public PromotionOrderResults updatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)
Description copied from interface:PromotionsServiceUpdate the promotions on the specifiedAbstractOrderModelobject. The resulting promotions can be retrieved later by callingPromotionsService.getPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel). The order must be calculated before calling this method.PromotionsService.updatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel)must be called after callingAbstractOrder.recalculate()on theAbstractOrderModel. Where thePromotionsManager.AutoApplyModeis set toPromotionsManager.AutoApplyMode.KEEP_APPLIEDthe state of any previously appliedPromotionResultis recorded and if it is still in the fired state (PromotionResult.isApplied()) after reevaluating the promotions it will be automatically reapplied. The promotion results are stored in the database and the samePromotionOrderResultscan be obtained later by callingPromotionsService.getPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel). After this method is called, please call getModelService().refresh(order) or getModelService().save(order).- Specified by:
updatePromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateorder- The AbstractOrder object to update the promotions forevaluateRestrictions- If true any promotion restrictions will be observed, if false all promotion restrictions are ignoredproductPromotionMode- The auto apply mode. This determines whether this method applies any product promotional changes to line items or discounts to the overall amountorderPromotionMode- The auto apply mode. This determines whether this method applies any order promotional changes to line items or discounts to the overall amountdate- The effective date for the promotions to check. Use this to to see the effects of promotions in the past or future.- Returns:
- The promotion results
-
getPromotionResults
public PromotionOrderResults getPromotionResults(AbstractOrderModel order)
Description copied from interface:PromotionsServiceGet the promotion results for the specified order. These are the promotion results stored in the database for the specified order as generated by the last call toPromotionsService.updatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel)for the same order. If any of the promotion results are invalid then they will be ignored.- Specified by:
getPromotionResultsin interfacePromotionsService- Parameters:
order- The order to get the promotion results for- Returns:
- The promotion results
-
getPromotionResults
public PromotionOrderResults getPromotionResults(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)
Description copied from interface:PromotionsServiceGet the promotion results for the specified order. These are the promotion results stored in the database for the specified order as generated by the last call toPromotionsService.updatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel)for the same order. If any of the promotion results are invalid then this method will recalculate the promotions by callingPromotionsService.updatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel).- Specified by:
getPromotionResultsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateorder- The AbstractOrder object to get the promotions forevaluateRestrictions- If true any promotion restrictions will be observed, if false all promotion restrictions are ignoredproductPromotionMode- The auto apply mode. This determines whether this method applies any product promotional changes to line items or discounts to the overall amountorderPromotionMode- The auto apply mode. This determines whether this method applies any order promotional changes to line items or discounts to the overall amountdate- The effective date for the promotions to check. Use this to to see the effects of promotions in the past or future.- Returns:
- The promotion results
-
cleanupCart
public void cleanupCart(CartModel cart)
Description copied from interface:PromotionsServiceDelete the the stored promotion results for a Cart.- Specified by:
cleanupCartin interfacePromotionsService- Parameters:
cart- TheCartto delete the results for
-
cleanupAbstractOrder
protected void cleanupAbstractOrder(AbstractOrderModel cart)
-
undoPromotionAction
protected void undoPromotionAction(AbstractPromotionActionModel action)
-
transferPromotionsToOrder
public void transferPromotionsToOrder(AbstractOrderModel source, OrderModel target, boolean onlyTransferAppliedPromotions)
Description copied from interface:PromotionsServiceTransfer the promotions applied to a cart to a new order. This is used when an order is created from a cart.- Specified by:
transferPromotionsToOrderin interfacePromotionsService- Parameters:
source- The cart that has promotionstarget- The order that promotions should be applied toonlyTransferAppliedPromotions- Flag to indicate that only applied promotions should be transfered. If false all promotion results will be transfered
-
getDataUniqueKey
protected java.lang.String getDataUniqueKey(AbstractPromotionModel sourcePromotion)
-
findImmutablePromotionByUniqueKey
protected <T> T findImmutablePromotionByUniqueKey(java.lang.String immutableKeyHash, java.util.function.Predicate<T> immutableKeyPredicate)
-
getDefaultPromotionGroup
public PromotionGroupModel getDefaultPromotionGroup()
Description copied from interface:PromotionsServiceLookup the default promotion group created by the promotions extension.- Specified by:
getDefaultPromotionGroupin interfacePromotionsService- Returns:
- the default promotion group
-
getPromotionGroup
public PromotionGroupModel getPromotionGroup(java.lang.String identifier)
Description copied from interface:PromotionsServiceLookup a promotion group with the given identifier.- Specified by:
getPromotionGroupin interfacePromotionsService- Parameters:
identifier- identifier of the promotion group to look for- Returns:
- the promotion group or null if no group with the given identifier is found
-
getRestrictions
public java.util.Collection<AbstractPromotionRestrictionModel> getRestrictions(AbstractPromotionModel promotion)
Description copied from interface:PromotionsServiceGet the collection ofAbstractPromotionRestrictionModelinstances.- Specified by:
getRestrictionsin interfacePromotionsService- Parameters:
promotion- the promotion which restrictions should be returned- Returns:
- A collection of
AbstractPromotionRestrictionModelinstances attached to this promotion.
-
getPromotionDescription
public java.lang.String getPromotionDescription(AbstractPromotionModel promotion)
Description copied from interface:PromotionsServiceGet the description of given promotion.- Specified by:
getPromotionDescriptionin interfacePromotionsService- Parameters:
promotion- the promotion to get the description for- Returns:
- String representing promotion description
-
getRuleActionStrategy
protected RuleActionStrategy getRuleActionStrategy(java.lang.String strategyId)
returns theRuleActionStrategydefined in thestrategiesattribute of this service by looking up it's bean id.- Parameters:
strategyId- the bean id of the RuleActionStrategy to look up- Returns:
- the found bean id
-
getStrategies
protected java.util.List<RuleActionStrategy> getStrategies()
-
setStrategies
public void setStrategies(java.util.List<RuleActionStrategy> strategies)
-
recalculateCart
protected boolean recalculateCart(AbstractOrderModel order)
-
getEngineRuleDao
protected EngineRuleDao getEngineRuleDao()
-
setEngineRuleDao
public void setEngineRuleDao(EngineRuleDao engineRuleDao)
-
getFlexibleSearchService
protected FlexibleSearchService getFlexibleSearchService()
-
setFlexibleSearchService
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
-
getPromotionDao
protected PromotionDao getPromotionDao()
-
setPromotionDao
public void setPromotionDao(PromotionDao promotionDao)
-
getFactContextFactory
protected FactContextFactory getFactContextFactory()
-
setFactContextFactory
public void setFactContextFactory(FactContextFactory factContextFactory)
-
getDefaultPromotionsService
public DefaultPromotionsService getDefaultPromotionsService()
-
setDefaultPromotionsService
public void setDefaultPromotionsService(DefaultPromotionsService defaultPromotionsService)
-
getCommerceRuleEngineService
protected RuleEngineService getCommerceRuleEngineService()
-
setCommerceRuleEngineService
public void setCommerceRuleEngineService(RuleEngineService ruleEngineService)
-
getCalculationService
protected CalculationService getCalculationService()
-
setCalculationService
public void setCalculationService(CalculationService calculationService)
-
getRuleActionService
protected RuleActionService getRuleActionService()
-
setRuleActionService
public void setRuleActionService(RuleActionService ruleActionService)
-
getRuleEngineContextDao
protected RuleEngineContextDao getRuleEngineContextDao()
-
setRuleEngineContextDao
public void setRuleEngineContextDao(RuleEngineContextDao ruleEngineContextDao)
-
getPromotionsForProduct
protected java.util.List<RuleBasedPromotionModel> getPromotionsForProduct(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Get all promotions, sorted by priority, that could be applied for the given product and promotion groups. If property promotionengineservices.getpromotionsforproduct.disable is set to true, returns an empty list.- Parameters:
promotionGroups- collection of promotion groups to apply promotions forproduct- product to get promotions for- Returns:
- List of
RuleBasedPromotionModelwhich could be applied to the given product and are sorted by priority or empty list if promotionengineservices.getpromotionsforproduct.disable is set to true
-
getPromotions
protected java.util.ArrayList<RuleBasedPromotionModel> getPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
-
isApplicable
protected boolean isApplicable(ProductModel product, RuleBasedPromotionModel promotion)
-
getCategoryCodesForProduct
protected java.util.Set<java.lang.String> getCategoryCodesForProduct(ProductModel product)
-
getPromotionSourceRuleDao
protected PromotionSourceRuleDao getPromotionSourceRuleDao()
-
setPromotionSourceRuleDao
public void setPromotionSourceRuleDao(PromotionSourceRuleDao promotionSourceRuleDao)
-
getCategoryService
protected CategoryService getCategoryService()
-
setCategoryService
public void setCategoryService(CategoryService categoryService)
-
getConfigurationService
protected ConfigurationService getConfigurationService()
-
setConfigurationService
public void setConfigurationService(ConfigurationService configurationService)
-
getCatalogVersionService
protected CatalogVersionService getCatalogVersionService()
-
setCatalogVersionService
public void setCatalogVersionService(CatalogVersionService catalogVersionService)
-
getRuleEngineContextForCatalogVersionsFinderStrategy
protected RuleEngineContextForCatalogVersionsFinderStrategy getRuleEngineContextForCatalogVersionsFinderStrategy()
-
setRuleEngineContextForCatalogVersionsFinderStrategy
public void setRuleEngineContextForCatalogVersionsFinderStrategy(RuleEngineContextForCatalogVersionsFinderStrategy ruleEngineContextForCatalogVersionsFinderStrategy)
-
getRuleEngineContextFinderStrategy
protected RuleEngineContextFinderStrategy getRuleEngineContextFinderStrategy()
-
setRuleEngineContextFinderStrategy
public void setRuleEngineContextFinderStrategy(RuleEngineContextFinderStrategy ruleEngineContextFinderStrategy)
-
getRuleBasedPromotionsContextValidator
protected RuleBasedPromotionsContextValidator getRuleBasedPromotionsContextValidator()
-
setRuleBasedPromotionsContextValidator
public void setRuleBasedPromotionsContextValidator(RuleBasedPromotionsContextValidator ruleBasedPromotionsContextValidator)
-
getSessionService
protected SessionService getSessionService()
-
setSessionService
public void setSessionService(SessionService sessionService)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getTimeService
protected TimeService getTimeService()
-
setTimeService
public void setTimeService(TimeService timeService)
-
getProductUtils
protected ProductUtils getProductUtils()
-
setProductUtils
public void setProductUtils(ProductUtils productUtils)
-
-