Class DefaultPromotionActionService
- java.lang.Object
-
- de.hybris.platform.promotionengineservices.promotionengine.impl.DefaultPromotionActionService
-
- All Implemented Interfaces:
PromotionActionService
public class DefaultPromotionActionService extends java.lang.Object implements PromotionActionService
Default implementation ofPromotionActionService.
-
-
Constructor Summary
Constructors Constructor Description DefaultPromotionActionService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Collection<PromotionOrderEntryConsumedModel>createConsumedEntries(AbstractRuleActionRAO action)Creates a list of consumed order entries for the given action.voidcreateDiscountValue(DiscountRAO discountRao, java.lang.String code, AbstractOrderEntryModel orderEntry)Creates aDiscountValuefrom the givendiscountRaoand adds it to the givenorderEntry.voidcreateDiscountValue(DiscountRAO discountRao, java.lang.String code, AbstractOrderModel order)Creates aDiscountValuefrom the givendiscountRaoand adds it to the givenorder.PromotionResultModelcreatePromotionResult(AbstractRuleActionRAO actionRao)Creates aPromotionResultModelobject for the givenAbstractRuleActionRAO.protected PromotionResultModelfindExistingPromotionResultModel(AbstractRuleEngineRuleModel rule, AbstractOrderModel order)Tries to find an existing promotion result that has been fired by the same rule as the given rule.protected CalculationServicegetCalculationService()protected CartServicegetCartService()protected EngineRuleDaogetEngineRuleDao()protected ExtendedOrderDaogetExtendedOrderDao()protected ModelServicegetModelService()protected ModuleVersioningServicegetModuleVersioningService()protected AbstractOrderModelgetOrder(AbstractOrderRAO orderRao)AbstractOrderModelgetOrder(AbstractRuleActionRAO action)Returns the order for the givenaction.AbstractOrderEntryModelgetOrderEntry(AbstractRuleActionRAO action)Looks up theAbstractOrderEntryModelbased on the given AbstractRuleActionRAO.protected AbstractOrderEntryModelgetOrderEntry(OrderEntryRAO orderEntryRao)protected AbstractOrderModelgetOrderInternal(AbstractRuleActionRAO action)tries to look up the order for the given action.protected ProductDaogetProductDao()protected RuleBasedPromotionModelgetPromotion(AbstractRuleActionRAO abstractRao)returns theRuleBasedPromotionModelfor the givenAbstractRuleActionRAOby looking up the rule code as stored inAbstractRuleActionRAO.getFiredRuleCode().protected PromotionResultServicegetPromotionResultService()AbstractRuleEngineRuleModelgetRule(AbstractRuleActionRAO abstractRao)returns theAbstractRuleEngineRuleModelfor the givenAbstractRuleActionRAOby looking up the rule code as stored inAbstractRuleActionRAO.getFiredRuleCode().voidrecalculateFiredPromotionMessage(PromotionResultModel promoResult)Recalculates promotion fired message and stores it in providedPromotionResultModel.voidrecalculateTotals(AbstractOrderModel order)Recalculates totals for the givenorder.protected booleanremoveDiscount(java.lang.String code, java.util.List<DiscountValue> discountValuesList, java.util.function.Consumer<java.util.List<DiscountValue>> setNewDiscountValues)Removes theDiscountValuewith the given code from the given list ofDiscountValue.java.util.List<ItemModel>removeDiscountValue(java.lang.String code, AbstractOrderModel order)Removes theDiscountValuewith the given code from the givenorderand its order entries.protected booleanremoveOrderEntryLevelDiscount(java.lang.String code, AbstractOrderEntryModel orderEntry)Removes theDiscountValuewith the given code from the givenorderEntry.protected java.util.List<ItemModel>removeOrderEntryLevelDiscounts(java.lang.String code, AbstractOrderModel order)Removes theDiscountValuewith the given code from the OrderEntries of the givenorder.protected booleanremoveOrderLevelDiscount(java.lang.String code, AbstractOrderModel order)Removes theDiscountValuewith the given code from the givenorder.voidsetCalculationService(CalculationService calculationService)voidsetCartService(CartService cartService)voidsetEngineRuleDao(EngineRuleDao engineRuleDao)voidsetExtendedOrderDao(ExtendedOrderDao extendedOrderDao)voidsetModelService(ModelService modelService)voidsetModuleVersioningService(ModuleVersioningService moduleVersioningService)voidsetProductDao(ProductDao productDao)voidsetPromotionResultService(PromotionResultService promotionResultService)protected voidsetRuleModuleVersionIfApplicable(PromotionResultModel promoResult, AbstractRuleEngineRuleModel rule)
-
-
-
Method Detail
-
recalculateTotals
public void recalculateTotals(AbstractOrderModel order)
Description copied from interface:PromotionActionServiceRecalculates totals for the givenorder.- Specified by:
recalculateTotalsin interfacePromotionActionService- Parameters:
order- the order to recalculate its totals
-
recalculateFiredPromotionMessage
public void recalculateFiredPromotionMessage(PromotionResultModel promoResult)
Description copied from interface:PromotionActionServiceRecalculates promotion fired message and stores it in providedPromotionResultModel. This method should be used for potential promotion only to update computed values displayed in the message- Specified by:
recalculateFiredPromotionMessagein interfacePromotionActionService- Parameters:
promoResult- a promotion result that holds fired promotion message which needs to be updated
-
createPromotionResult
public PromotionResultModel createPromotionResult(AbstractRuleActionRAO actionRao)
Description copied from interface:PromotionActionServiceCreates aPromotionResultModelobject for the givenAbstractRuleActionRAO.- Specified by:
createPromotionResultin interfacePromotionActionService- Parameters:
actionRao- the action rao to use for the promotion result creation- Returns:
- the newly created (not persisted!)
PromotionResultModel.
-
setRuleModuleVersionIfApplicable
protected void setRuleModuleVersionIfApplicable(PromotionResultModel promoResult, AbstractRuleEngineRuleModel rule)
-
findExistingPromotionResultModel
protected PromotionResultModel findExistingPromotionResultModel(AbstractRuleEngineRuleModel rule, AbstractOrderModel order)
Tries to find an existing promotion result that has been fired by the same rule as the given rule.- Parameters:
rule- the ruleorder- the order- Returns:
- an existing promotion result or null if none is found
-
createConsumedEntries
protected java.util.Collection<PromotionOrderEntryConsumedModel> createConsumedEntries(AbstractRuleActionRAO action)
Creates a list of consumed order entries for the given action.- Parameters:
action- Action for which consumed order entries should be created- Returns:
- Collection of created consumed order entries for given action
-
createDiscountValue
public void createDiscountValue(DiscountRAO discountRao, java.lang.String code, AbstractOrderModel order)
Description copied from interface:PromotionActionServiceCreates aDiscountValuefrom the givendiscountRaoand adds it to the givenorder. Note: The order is not saved!- Specified by:
createDiscountValuein interfacePromotionActionService- Parameters:
discountRao- the discountRao to take the values fromcode- the code for the new DiscountValue (e.g. UUID from the respectiveAbstractPromotionActionModelthat creates this discount)order- the order to apply the discount value to
-
removeDiscount
protected boolean removeDiscount(java.lang.String code, java.util.List<DiscountValue> discountValuesList, java.util.function.Consumer<java.util.List<DiscountValue>> setNewDiscountValues)Removes theDiscountValuewith the given code from the given list ofDiscountValue. Then calls setNewDiscountValues handler to process the newly gotten list (already w/o the removed item) ofDiscountValue.- Parameters:
setNewDiscountValues- if null its method accept(..) is not called.- Returns:
- true if the DiscountValue is removed, false - otherwise
-
removeOrderLevelDiscount
protected boolean removeOrderLevelDiscount(java.lang.String code, AbstractOrderModel order)Removes theDiscountValuewith the given code from the givenorder. Note: The Order is not saved!- Returns:
- true if the DiscountValue is removed, false - otherwise
-
removeOrderEntryLevelDiscount
protected boolean removeOrderEntryLevelDiscount(java.lang.String code, AbstractOrderEntryModel orderEntry)Removes theDiscountValuewith the given code from the givenorderEntry. Note: The OrderEntry is not saved!- Returns:
- true if the DiscountValue is removed, false - otherwise
-
removeOrderEntryLevelDiscounts
protected java.util.List<ItemModel> removeOrderEntryLevelDiscounts(java.lang.String code, AbstractOrderModel order)
Removes theDiscountValuewith the given code from the OrderEntries of the givenorder. Note: The OrderEntries and Order are not saved!- Returns:
- list of affected OrderEntries
-
removeDiscountValue
public java.util.List<ItemModel> removeDiscountValue(java.lang.String code, AbstractOrderModel order)
Description copied from interface:PromotionActionServiceRemoves theDiscountValuewith the given code from the givenorderand its order entries. Returns the list of all modified items (order, order entries). Note: The returned items are not saved!- Specified by:
removeDiscountValuein interfacePromotionActionService- Parameters:
code- the code for the DiscountValue to be removedorder- the order to remove the discount value from- Returns:
- all items (order, order entries) that have been modified and need saving
-
createDiscountValue
public void createDiscountValue(DiscountRAO discountRao, java.lang.String code, AbstractOrderEntryModel orderEntry)
Description copied from interface:PromotionActionServiceCreates aDiscountValuefrom the givendiscountRaoand adds it to the givenorderEntry. Note: The orderEntry is not saved!- Specified by:
createDiscountValuein interfacePromotionActionService- Parameters:
discountRao- the discountRao to take the values fromcode- the code for the new DiscountValue (e.g. UUID from the respectiveAbstractPromotionActionModelthat creates this discount)orderEntry- the orderEntry to apply the discount value to
-
getOrderEntry
public AbstractOrderEntryModel getOrderEntry(AbstractRuleActionRAO action)
Description copied from interface:PromotionActionServiceLooks up theAbstractOrderEntryModelbased on the given AbstractRuleActionRAO.- Specified by:
getOrderEntryin interfacePromotionActionService- Parameters:
action- the action to use for the look-up- Returns:
- the AbstractOrderEntryModel
-
getOrderEntry
protected AbstractOrderEntryModel getOrderEntry(OrderEntryRAO orderEntryRao)
-
getOrder
public AbstractOrderModel getOrder(AbstractRuleActionRAO action)
Description copied from interface:PromotionActionServiceReturns the order for the givenaction.- Specified by:
getOrderin interfacePromotionActionService- Parameters:
action- the orderRao- Returns:
- the order or null if no order is found
-
getOrderInternal
protected AbstractOrderModel getOrderInternal(AbstractRuleActionRAO action)
tries to look up the order for the given action.- Parameters:
action- the action- Returns:
- the order or null
-
getPromotion
protected RuleBasedPromotionModel getPromotion(AbstractRuleActionRAO abstractRao)
returns theRuleBasedPromotionModelfor the givenAbstractRuleActionRAOby looking up the rule code as stored inAbstractRuleActionRAO.getFiredRuleCode().- Parameters:
abstractRao- the rao to get the promotion for- Returns:
- the promotion or null
-
getRule
public AbstractRuleEngineRuleModel getRule(AbstractRuleActionRAO abstractRao)
returns theAbstractRuleEngineRuleModelfor the givenAbstractRuleActionRAOby looking up the rule code as stored inAbstractRuleActionRAO.getFiredRuleCode().- Specified by:
getRulein interfacePromotionActionService- Parameters:
abstractRao- the rao to get the rule for- Returns:
- the rule or null if the rao is null, its firedRuleCode is null or if the rule cannot be found
-
getOrder
protected AbstractOrderModel getOrder(AbstractOrderRAO orderRao)
-
getExtendedOrderDao
protected ExtendedOrderDao getExtendedOrderDao()
-
setExtendedOrderDao
public void setExtendedOrderDao(ExtendedOrderDao extendedOrderDao)
-
setModelService
public void setModelService(ModelService modelService)
-
getModelService
protected ModelService getModelService()
-
getCalculationService
protected CalculationService getCalculationService()
-
setCalculationService
public void setCalculationService(CalculationService calculationService)
-
getProductDao
protected ProductDao getProductDao()
-
setProductDao
public void setProductDao(ProductDao productDao)
-
getEngineRuleDao
protected EngineRuleDao getEngineRuleDao()
-
setEngineRuleDao
public void setEngineRuleDao(EngineRuleDao engineRuleDao)
-
getModuleVersioningService
protected ModuleVersioningService getModuleVersioningService()
-
setModuleVersioningService
public void setModuleVersioningService(ModuleVersioningService moduleVersioningService)
-
getPromotionResultService
protected PromotionResultService getPromotionResultService()
-
setPromotionResultService
public void setPromotionResultService(PromotionResultService promotionResultService)
-
getCartService
protected CartService getCartService()
-
setCartService
public void setCartService(CartService cartService)
-
-