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 void
cleanupAbstractOrder(AbstractOrderModel cart)
void
cleanupCart(CartModel cart)
Delete the the stored promotion results for a Cart.protected AbstractRuleEngineContextModel
determineRuleEngineContext(AbstractOrderModel order)
determines the rule engine context to be used for the given order.protected AbstractRuleEngineContextModel
determineRuleEngineContext(ProductModel product)
determines the rule engine context to be used for the given product.RuleEvaluationResult
evaluate(AbstractOrderModel order, java.util.Collection<PromotionGroupModel> promotionGroups)
evaluate the promotions for the given cart or order and for now.RuleEvaluationResult
evaluate(AbstractOrderModel order, java.util.Collection<PromotionGroupModel> promotionGroups, java.util.Date date)
evaluate the promotions for the given cart or order and for the date.RuleEvaluationResult
evaluate(ProductModel product, java.util.Collection<PromotionGroupModel> promotionGroups)
Evaluates promotion against a product taking into context which is set by promotions groupprotected <T> T
findImmutablePromotionByUniqueKey(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 ofAbstractPromotionModel
instances that are related to theProductModel
specified.java.util.List<? extends AbstractPromotionModel>
getAbstractProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofAbstractPromotionModel
instances that are related to theProductModel
specified.protected CalculationService
getCalculationService()
protected CatalogVersionService
getCatalogVersionService()
protected java.util.Set<java.lang.String>
getCategoryCodesForProduct(ProductModel product)
protected CategoryService
getCategoryService()
protected RuleEngineService
getCommerceRuleEngineService()
protected ConfigurationService
getConfigurationService()
protected java.lang.String
getDataUniqueKey(AbstractPromotionModel sourcePromotion)
PromotionGroupModel
getDefaultPromotionGroup()
Lookup the default promotion group created by the promotions extension.DefaultPromotionsService
getDefaultPromotionsService()
protected EngineRuleDao
getEngineRuleDao()
protected FactContextFactory
getFactContextFactory()
protected FlexibleSearchService
getFlexibleSearchService()
protected ModelService
getModelService()
java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product, java.util.Date date)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, java.util.Date date)
Get the ordered list ofOrderPromotion
instances.java.util.List<OrderPromotionModel>
getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, java.util.Date date)
Get the ordered list ofOrderPromotion
instances.java.util.List<ProductPromotionModel>
getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Get the ordered list ofProductPromotion
instances that are related to theProductModel
specified.java.util.List<ProductPromotionModel>
getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Get the ordered list ofProductPromotion
instances that are related to theProductModel
specified.protected ProductUtils
getProductUtils()
protected PromotionDao
getPromotionDao()
java.lang.String
getPromotionDescription(AbstractPromotionModel promotion)
Get the description of given promotion.PromotionGroupModel
getPromotionGroup(java.lang.String identifier)
Lookup a promotion group with the given identifier.PromotionOrderResults
getPromotionResults(AbstractOrderModel order)
Get the promotion results for the specified order.PromotionOrderResults
getPromotionResults(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 PromotionSourceRuleDao
getPromotionSourceRuleDao()
java.util.Collection<AbstractPromotionRestrictionModel>
getRestrictions(AbstractPromotionModel promotion)
Get the collection ofAbstractPromotionRestrictionModel
instances.protected RuleActionService
getRuleActionService()
protected RuleActionStrategy
getRuleActionStrategy(java.lang.String strategyId)
returns theRuleActionStrategy
defined in thestrategies
attribute of this service by looking up it's bean id.protected RuleBasedPromotionsContextValidator
getRuleBasedPromotionsContextValidator()
protected RuleEngineContextDao
getRuleEngineContextDao()
protected RuleEngineContextFinderStrategy
getRuleEngineContextFinderStrategy()
protected RuleEngineContextForCatalogVersionsFinderStrategy
getRuleEngineContextForCatalogVersionsFinderStrategy()
protected SessionService
getSessionService()
protected java.util.List<RuleActionStrategy>
getStrategies()
protected TimeService
getTimeService()
protected boolean
isApplicable(ProductModel product, RuleBasedPromotionModel promotion)
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.protected java.util.Set<java.lang.Object>
provideRAOs(FactContext factContext)
Converts the givensource
object into an RAO using the configuredraoProviders
.protected boolean
recalculateCart(AbstractOrderModel order)
void
setCalculationService(CalculationService calculationService)
void
setCatalogVersionService(CatalogVersionService catalogVersionService)
void
setCategoryService(CategoryService categoryService)
void
setCommerceRuleEngineService(RuleEngineService ruleEngineService)
void
setConfigurationService(ConfigurationService configurationService)
void
setDefaultPromotionsService(DefaultPromotionsService defaultPromotionsService)
void
setEngineRuleDao(EngineRuleDao engineRuleDao)
void
setFactContextFactory(FactContextFactory factContextFactory)
void
setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
void
setModelService(ModelService modelService)
void
setProductUtils(ProductUtils productUtils)
void
setPromotionDao(PromotionDao promotionDao)
void
setPromotionSourceRuleDao(PromotionSourceRuleDao promotionSourceRuleDao)
void
setRuleActionService(RuleActionService ruleActionService)
void
setRuleBasedPromotionsContextValidator(RuleBasedPromotionsContextValidator ruleBasedPromotionsContextValidator)
void
setRuleEngineContextDao(RuleEngineContextDao ruleEngineContextDao)
void
setRuleEngineContextFinderStrategy(RuleEngineContextFinderStrategy ruleEngineContextFinderStrategy)
void
setRuleEngineContextForCatalogVersionsFinderStrategy(RuleEngineContextForCatalogVersionsFinderStrategy ruleEngineContextForCatalogVersionsFinderStrategy)
void
setSessionService(SessionService sessionService)
void
setStrategies(java.util.List<RuleActionStrategy> strategies)
void
setTimeService(TimeService timeService)
void
transferPromotionsToOrder(AbstractOrderModel source, OrderModel target, boolean onlyTransferAppliedPromotions)
Transfer the promotions applied to a cart to a new order.protected void
undoPromotionAction(AbstractPromotionActionModel action)
PromotionOrderResults
updatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)
Update the promotions on the specifiedAbstractOrder
object.PromotionOrderResults
updatePromotions(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, java.util.Date date)
Update the promotions on the specifiedAbstractOrderModel
object.protected PromotionOrderResults
updatePromotionsNotThreadSafe(java.util.Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)
protected PromotionOrderResults
updatePromotionsNotThreadSafe(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:PromotionEngineService
Evaluates promotion against a product taking into context which is set by promotions group- Specified by:
evaluate
in 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:PromotionEngineService
evaluate the promotions for the given cart or order and for now. This does not apply the result to the cart/order.- Specified by:
evaluate
in 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:PromotionEngineService
evaluate the promotions for the given cart or order and for the date. This does not apply the result to the cart/order.- Specified by:
evaluate
in 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 givensource
object 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:PromotionsService
Get the ordered list ofAbstractPromotionModel
instances that are related to theProductModel
specified.- Specified by:
getAbstractProductPromotions
in interfacePromotionsService
- Parameters:
promotionGroups
- The promotion groups to evaluateproduct
- The product that the promotions are related to- Returns:
- The list of
AbstractPromotionModel
related to theProductModel
specified
-
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:PromotionsService
Get the ordered list ofAbstractPromotionModel
instances that are related to theProductModel
specified.- Specified by:
getAbstractProductPromotions
in 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
AbstractPromotionModel
related to theProductModel
specified
-
getProductPromotions
public java.util.List<ProductPromotionModel> getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product)
Description copied from interface:PromotionsService
Get the ordered list ofProductPromotion
instances that are related to theProductModel
specified.- Specified by:
getProductPromotions
in interfacePromotionsService
- Parameters:
promotionGroups
- The promotion groups to evaluateproduct
- The product that the promotions are related to- Returns:
- The list of
ProductPromotion
related to theProductModel
specified
-
getProductPromotions
public java.util.List<ProductPromotionModel> getProductPromotions(java.util.Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, java.util.Date date)
Description copied from interface:PromotionsService
Get the ordered list ofProductPromotion
instances that are related to theProductModel
specified.- Specified by:
getProductPromotions
in 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
ProductPromotion
related to theProductModel
specified
-
getOrderPromotions
public java.util.List<OrderPromotionModel> getOrderPromotions(java.util.Collection<PromotionGroupModel> promotionGroups)
Description copied from interface:PromotionsService
Get the ordered list ofOrderPromotion
instances.- Specified by:
getOrderPromotions
in 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:PromotionsService
Get the ordered list ofOrderPromotion
instances.- Specified by:
getOrderPromotions
in 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:PromotionsService
Get the ordered list ofOrderPromotion
instances.- Specified by:
getOrderPromotions
in 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:PromotionsService
Get the ordered list ofOrderPromotion
instances.- Specified by:
getOrderPromotions
in 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:PromotionsService
Get the ordered list ofOrderPromotion
instances.- Specified by:
getOrderPromotions
in 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:PromotionsService
Get the ordered list ofOrderPromotion
instances.- Specified by:
getOrderPromotions
in 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:PromotionsService
Get the ordered list ofOrderPromotion
instances.- Specified by:
getOrderPromotions
in 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:PromotionsService
Get the ordered list ofOrderPromotion
instances.- Specified by:
getOrderPromotions
in 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:PromotionsService
Update the promotions on the specifiedAbstractOrder
object. 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 samePromotionOrderResults
can be obtained later by callingPromotionsService.getPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel)
.- Specified by:
updatePromotions
in 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:PromotionsService
Update the promotions on the specifiedAbstractOrderModel
object. 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.AutoApplyMode
is set toPromotionsManager.AutoApplyMode.KEEP_APPLIED
the state of any previously appliedPromotionResult
is 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 samePromotionOrderResults
can 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:
updatePromotions
in 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:PromotionsService
Get 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:
getPromotionResults
in 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:PromotionsService
Get 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:
getPromotionResults
in 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:PromotionsService
Delete the the stored promotion results for a Cart.- Specified by:
cleanupCart
in interfacePromotionsService
- Parameters:
cart
- TheCart
to 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:PromotionsService
Transfer the promotions applied to a cart to a new order. This is used when an order is created from a cart.- Specified by:
transferPromotionsToOrder
in 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:PromotionsService
Lookup the default promotion group created by the promotions extension.- Specified by:
getDefaultPromotionGroup
in interfacePromotionsService
- Returns:
- the default promotion group
-
getPromotionGroup
public PromotionGroupModel getPromotionGroup(java.lang.String identifier)
Description copied from interface:PromotionsService
Lookup a promotion group with the given identifier.- Specified by:
getPromotionGroup
in 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:PromotionsService
Get the collection ofAbstractPromotionRestrictionModel
instances.- Specified by:
getRestrictions
in interfacePromotionsService
- Parameters:
promotion
- the promotion which restrictions should be returned- Returns:
- A collection of
AbstractPromotionRestrictionModel
instances attached to this promotion.
-
getPromotionDescription
public java.lang.String getPromotionDescription(AbstractPromotionModel promotion)
Description copied from interface:PromotionsService
Get the description of given promotion.- Specified by:
getPromotionDescription
in interfacePromotionsService
- Parameters:
promotion
- the promotion to get the description for- Returns:
- String representing promotion description
-
getRuleActionStrategy
protected RuleActionStrategy getRuleActionStrategy(java.lang.String strategyId)
returns theRuleActionStrategy
defined in thestrategies
attribute 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
RuleBasedPromotionModel
which 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)
-
-