Class DefaultPromotionActionService
java.lang.Object
de.hybris.platform.promotionengineservices.promotionengine.impl.DefaultPromotionActionService
- All Implemented Interfaces:
PromotionActionService
Default implementation of
PromotionActionService.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddPromoResultIntoConsumedEntriesIfNecessary(Collection<PromotionOrderEntryConsumedModel> newConsumedEntries, PromotionResultModel promoResult) protected Collection<PromotionOrderEntryConsumedModel>Creates a list of consumed order entries for the given action.voidcreateDiscountValue(DiscountRAO discountRao, String code, AbstractOrderEntryModel orderEntry) Creates aDiscountValuefrom the givendiscountRaoand adds it to the givenorderEntry.voidcreateDiscountValue(DiscountRAO discountRao, String code, AbstractOrderModel order) Creates aDiscountValuefrom the givendiscountRaoand adds it to the givenorder.createPromotionResult(AbstractRuleActionRAO actionRao) Creates aPromotionResultModelobject for the givenAbstractRuleActionRAO.protected PromotionResultModelTries to find an existing promotion result that has been fired by the same rule as the given rule.protected CalculationServiceprotected CartServiceprotected EngineRuleDaoprotected ExtendedOrderDaoprotected ModelServiceprotected ModuleVersioningServiceprotected AbstractOrderModelgetOrder(AbstractOrderRAO orderRao) getOrder(AbstractRuleActionRAO action) Returns the order for the givenaction.getOrderEntry(AbstractRuleActionRAO action) Looks up theAbstractOrderEntryModelbased on the given AbstractRuleActionRAO.protected AbstractOrderEntryModelgetOrderEntry(OrderEntryRAO orderEntryRao) protected AbstractOrderModeltries to look up the order for the given action.protected ProductDaoprotected RuleBasedPromotionModelgetPromotion(AbstractRuleActionRAO abstractRao) returns theRuleBasedPromotionModelfor the givenAbstractRuleActionRAOby looking up the rule code as stored inAbstractRuleActionRAO.getFiredRuleCode().protected PromotionResultServicegetRule(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.voidRecalculates totals for the givenorder.protected booleanremoveDiscount(String code, List<DiscountValue> discountValuesList, Consumer<List<DiscountValue>> setNewDiscountValues) Removes theDiscountValuewith the given code from the given list ofDiscountValue.removeDiscountValue(String code, AbstractOrderModel order) Removes theDiscountValuewith the given code from the givenorderand its order entries.protected booleanremoveOrderEntryLevelDiscount(String code, AbstractOrderEntryModel orderEntry) Removes theDiscountValuewith the given code from the givenorderEntry.removeOrderEntryLevelDiscounts(String code, AbstractOrderModel order) Removes theDiscountValuewith the given code from the OrderEntries of the givenorder.protected booleanremoveOrderLevelDiscount(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)
-
Constructor Details
-
DefaultPromotionActionService
public DefaultPromotionActionService()
-
-
Method Details
-
recalculateTotals
Description copied from interface:PromotionActionServiceRecalculates totals for the givenorder.- Specified by:
recalculateTotalsin interfacePromotionActionService- Parameters:
order- the order to recalculate its totals
-
recalculateFiredPromotionMessage
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
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.
-
addPromoResultIntoConsumedEntriesIfNecessary
protected void addPromoResultIntoConsumedEntriesIfNecessary(Collection<PromotionOrderEntryConsumedModel> newConsumedEntries, PromotionResultModel promoResult) -
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 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
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(String code, List<DiscountValue> discountValuesList, Consumer<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
Removes theDiscountValuewith the given code from the givenorder. Note: The Order is not saved!- Returns:
- true if the DiscountValue is removed, false - otherwise
-
removeOrderEntryLevelDiscount
Removes theDiscountValuewith the given code from the givenorderEntry. Note: The OrderEntry is not saved!- Returns:
- true if the DiscountValue is removed, false - otherwise
-
removeOrderEntryLevelDiscounts
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
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, 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
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
-
getOrder
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
tries to look up the order for the given action.- Parameters:
action- the action- Returns:
- the order or null
-
getPromotion
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
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
-
getExtendedOrderDao
-
setExtendedOrderDao
-
setModelService
-
getModelService
-
getCalculationService
-
setCalculationService
-
getProductDao
-
setProductDao
-
getEngineRuleDao
-
setEngineRuleDao
-
getModuleVersioningService
-
setModuleVersioningService
-
getPromotionResultService
-
setPromotionResultService
-
getCartService
-
setCartService
-