public class DefaultPromotionEngineService extends AbstractBusinessService implements PromotionEngineService, PromotionsService
AbstractService.SerializableDTOmodelService, sessionService, txManagertenant| Constructor and Description |
|---|
DefaultPromotionEngineService() |
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManagerafterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, setTenantScope, writeReplacepublic RuleEvaluationResult evaluate(ProductModel product, Collection<PromotionGroupModel> promotionGroups)
evaluate in interface PromotionEngineServiceproduct - to evaluate promotions forpromotionGroups - collection of promotion groups to apply promotions for@Deprecated public RuleEvaluationResult evaluate(CartModel cart, Collection<PromotionGroupModel> promotionGroups)
evaluate in interface PromotionEngineServicecart - the cart to evaluatepromotionGroups - collection of promotion groups to apply promotions forpublic RuleEvaluationResult evaluate(AbstractOrderModel order, Collection<PromotionGroupModel> promotionGroups)
PromotionEngineServiceevaluate in interface PromotionEngineServiceorder - the cart or order to evaluatepromotionGroups - collection of promotion groups to apply promotions forprotected RuleEvaluationContext prepareContext(FactContext factContext)
defaultRuleEngineContextName property to look up which rule engine context is to be used.factContext - FactContext to use for the evaluationprotected Set<Object> provideRAOs(FactContext factContext)
source object into an RAO using the configured raoProviders.factContext - FactContext containing rao providersRuntimeException - if no raoProvider is registered for the given source objectpublic List<? extends AbstractPromotionModel> getAbstractProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product)
PromotionsServiceAbstractPromotionModel instances that are related to the ProductModel
specified.getAbstractProductPromotions in interface PromotionsServicepromotionGroups - The promotion groups to evaluateproduct - The product that the promotions are related toAbstractPromotionModel related to the ProductModel specifiedpublic List<? extends AbstractPromotionModel> getAbstractProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, Date date)
PromotionsServiceAbstractPromotionModel instances that are related to the ProductModel
specified.getAbstractProductPromotions in interface PromotionsServicepromotionGroups - 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 dateAbstractPromotionModel related to the ProductModel specifiedpublic List<ProductPromotionModel> getProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product)
PromotionsServiceProductPromotion instances that are related to the ProductModel specified.getProductPromotions in interface PromotionsServicepromotionGroups - The promotion groups to evaluateproduct - The product that the promotions are related toProductPromotion related to the ProductModel specifiedpublic List<ProductPromotionModel> getProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, Date date)
PromotionsServiceProductPromotion instances that are related to the ProductModel specified.getProductPromotions in interface PromotionsServicepromotionGroups - 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 dateProductPromotion related to the ProductModel specifiedpublic List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups)
PromotionsServiceOrderPromotion instances.getOrderPromotions in interface PromotionsServicepromotionGroups - The promotion groups to evaluateOrderPromotionpublic List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, Date date)
PromotionsServiceOrderPromotion instances.getOrderPromotions in interface PromotionsServicepromotionGroups - The promotion groups to evaluatedate - The date to check for promotions, typically the current dateOrderPromotionpublic List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product)
PromotionsServiceOrderPromotion instances.getOrderPromotions in interface PromotionsServicepromotionGroups - The promotion groups to evaluateproduct - The product to pass to restrictionsOrderPromotionpublic List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product, Date date)
PromotionsServiceOrderPromotion instances.getOrderPromotions in interface PromotionsServicepromotionGroups - The promotion groups to evaluateproduct - The product to pass to restrictionsdate - The date to check for promotions, typically the current dateOrderPromotionpublic List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions)
PromotionsServiceOrderPromotion instances.getOrderPromotions in interface PromotionsServicepromotionGroups - The promotion groups to evaluateevaluateRestrictions - Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the
restrictions.OrderPromotionpublic List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, Date date)
PromotionsServiceOrderPromotion instances.getOrderPromotions in interface PromotionsServicepromotionGroups - 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 dateOrderPromotionpublic List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product)
PromotionsServiceOrderPromotion instances.getOrderPromotions in interface PromotionsServicepromotionGroups - 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 trueOrderPromotionpublic List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product, Date date)
PromotionsServiceOrderPromotion instances.getOrderPromotions in interface PromotionsServicepromotionGroups - 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 dateOrderPromotionpublic PromotionOrderResults updatePromotions(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)
PromotionsServiceAbstractOrder 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 same PromotionOrderResults can be obtained later
by calling PromotionsService.getPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel).updatePromotions in interface PromotionsServicepromotionGroups - The promotion groups to evaluateorder - The order object to update with the results of the promotionsprotected PromotionOrderResults updatePromotionsNotThreadSafe(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order)
public PromotionOrderResults updatePromotions(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date)
PromotionsServiceAbstractOrderModel object.
The resulting promotions can be retrieved later by calling PromotionsService.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 calling
AbstractOrder.recalculate() on the AbstractOrderModel. Where the PromotionsManager.AutoApplyMode is set to
PromotionsManager.AutoApplyMode.KEEP_APPLIED the state of any previously applied PromotionResult 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 same PromotionOrderResults can be obtained later
by calling PromotionsService.getPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel). After this method is called, please call getModelService().refresh(order)
or getModelService().save(order).updatePromotions in interface PromotionsServicepromotionGroups - 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.public PromotionOrderResults getPromotionResults(AbstractOrderModel order)
PromotionsServicePromotionsService.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.getPromotionResults in interface PromotionsServiceorder - The order to get the promotion results forpublic PromotionOrderResults getPromotionResults(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date)
PromotionsServicePromotionsService.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 calling
PromotionsService.updatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel).getPromotionResults in interface PromotionsServicepromotionGroups - 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.public void cleanupCart(CartModel cart)
PromotionsServicecleanupCart in interface PromotionsServicecart - The Cart to delete the results forprotected void cleanupAbstractOrder(AbstractOrderModel cart)
protected void undoPromotionAction(AbstractPromotionActionModel action)
public void transferPromotionsToOrder(AbstractOrderModel source, OrderModel target, boolean onlyTransferAppliedPromotions)
PromotionsServicetransferPromotionsToOrder in interface PromotionsServicesource - 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 transferedprotected String getDataUniqueKey(AbstractPromotionModel sourcePromotion)
protected <T> T findImmutablePromotionByUniqueKey(String immutableKeyHash, Predicate<T> immutableKeyPredicate)
public PromotionGroupModel getDefaultPromotionGroup()
PromotionsServicegetDefaultPromotionGroup in interface PromotionsServicepublic PromotionGroupModel getPromotionGroup(String identifier)
PromotionsServicegetPromotionGroup in interface PromotionsServiceidentifier - identifier of the promotion group to look forpublic Collection<AbstractPromotionRestrictionModel> getRestrictions(AbstractPromotionModel promotion)
PromotionsServiceAbstractPromotionRestrictionModel instances.getRestrictions in interface PromotionsServicepromotion - the promotion which restrictions should be returnedAbstractPromotionRestrictionModel instances attached to this promotion.public String getPromotionDescription(AbstractPromotionModel promotion)
PromotionsServicegetPromotionDescription in interface PromotionsServicepromotion - the promotion to get the description forprotected RuleActionStrategy getRuleActionStrategy(String strategyId)
RuleActionStrategy defined in the strategies attribute of this service by looking up
it's bean id.strategyId - the bean id of the RuleActionStrategy to look upprotected List<RuleActionStrategy> getStrategies()
public void setStrategies(List<RuleActionStrategy> strategies)
protected boolean recalculateCart(AbstractOrderModel order)
protected EngineRuleDao getEngineRuleDao()
public void setEngineRuleDao(EngineRuleDao engineRuleDao)
protected FlexibleSearchService getFlexibleSearchService()
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
protected PromotionDao getPromotionDao()
public void setPromotionDao(PromotionDao promotionDao)
protected FactContextFactory getFactContextFactory()
public void setFactContextFactory(FactContextFactory factContextFactory)
public DefaultPromotionsService getDefaultPromotionsService()
public void setDefaultPromotionsService(DefaultPromotionsService defaultPromotionsService)
protected RuleEngineService getCommerceRuleEngineService()
public void setCommerceRuleEngineService(RuleEngineService ruleEngineService)
protected CalculationService getCalculationService()
public void setCalculationService(CalculationService calculationService)
protected RuleActionService getRuleActionService()
public void setRuleActionService(RuleActionService ruleActionService)
protected String getDefaultRuleEngineContextName()
public void setDefaultRuleEngineContextName(String defaultRuleEngineContextName)
protected RuleEngineContextDao getRuleEngineContextDao()
public void setRuleEngineContextDao(RuleEngineContextDao ruleEngineContextDao)
protected List<RuleBasedPromotionModel> getPromotionsForProduct(Collection<PromotionGroupModel> promotionGroups, ProductModel product)
promotionGroups - collection of promotion groups to apply promotions forproduct - product to get promotions forRuleBasedPromotionModel which could be applied to the given product and are sorted by
priority or empty list if promotionengineservices.getpromotionsforproduct.disable is set to trueprotected Set<String> getCategoryCodesForProduct(ProductModel product)
protected PromotionSourceRuleDao getPromotionSourceRuleDao()
public void setPromotionSourceRuleDao(PromotionSourceRuleDao promotionSourceRuleDao)
protected CategoryService getCategoryService()
public void setCategoryService(CategoryService categoryService)
protected ConfigurationService getConfigurationService()
public void setConfigurationService(ConfigurationService configurationService)
Copyright © 2017 SAP SE. All Rights Reserved.