Package de.hybris.platform.promotions
Interface PromotionResultService
-
- All Known Implementing Classes:
DefaultPromotionEngineResultService,DefaultPromotionResultService
public interface PromotionResultServicePromotionResultService. The result of evaluating a promotion against a cart or order is a set of promotion results. Each promotion my produce zero or more results to express the results of its evaluation. APromotionResultis associated with a singleAbstractPromotionand is either fired (getFired(PromotionResultModel)) or potentially could fire (getCouldFire(PromotionResultModel)). A result that has fired as met all the requirements of the promotion. A result that potentially could fire has not met all the requirements of the promotion. When the result could fire the promotion also assigns a certainty value to the result to indicate how close the result is to firing. This is a value in the range 0 to 1, where 1 indicates that the promotion has fired. This value can be used to rank potential promotion results. A promotion result holds a number ofPromotionOrderEntryConsumedinstances to represent the entries in the order that have been consumed by the promotion in generating this result. If the promotion has fired then these consumed entries are not available to other promotions. If the promotion has not fired then these consumed entries are just an indication of the entries that will be consumed when the promotion can fire. If the promotion has fired the promotion result also holds a number ofAbstractPromotionActioninstances to represent the actions that the promotion takes. These actions are either applied or not (isApplied(PromotionResultModel)). When the promotions are evaluated byPromotionsManager.updatePromotions(de.hybris.platform.jalo.SessionContext, java.util.Collection, de.hybris.platform.jalo.order.AbstractOrder, boolean, de.hybris.platform.promotions.jalo.PromotionsManager.AutoApplyMode, de.hybris.platform.promotions.jalo.PromotionsManager.AutoApplyMode, java.util.Date)a firing promotion result may be automatically applied depending on the parameters passed to the method. The actions of a specific promotion result can be applied by calling theapply(PromotionResultModel)method. The actions of a specific promotion result can be reversed by calling theundo(PromotionResultModel)method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanapply(PromotionResultModel promotionResult)Apply all of the actions that this promotion generated to the order.longgetConsumedCount(PromotionResultModel promotionResult, boolean includeCouldFirePromotions)Get the total number of items consumed by this promotion.booleangetCouldFire(PromotionResultModel promotionResult)Is this a potential result.java.util.Optional<java.util.Set<java.lang.String>>getCouponCodesFromPromotion(PromotionResultModel promotionResult)Return give way coupon code for promotion.java.lang.StringgetDescription(PromotionResultModel promotionResult)Get the description of this promotion result.java.lang.StringgetDescription(PromotionResultModel promotionResult, java.util.Locale locale)Get the description of this promotion result.booleangetFired(PromotionResultModel promotionResult)Returns true if the promotion fired and has produced a result.java.util.List<PromotionResultModel>getFiredOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)Return a list of results for promotions that fired and did not consume products.java.util.List<PromotionResultModel>getFiredProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)Return a list of results for promotions that fired and consumed products.java.util.List<PromotionResultModel>getPotentialOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)Return a list of results for potential promotions that fired and did not consume products and have been applied.java.util.List<PromotionResultModel>getPotentialProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)Return a list of results for potential promotions that fired and consumed products and have been applied.doublegetTotalDiscount(PromotionResultModel promotionResult)Get the total value of all discounts in this result.booleanisApplied(PromotionResultModel promotionResult)Returns true if the promotion fired and all of its actions have been applied to the order.booleanisAppliedToOrder(PromotionResultModel promotionResult)Returns true if the promotion fired and all of its actions have been applied to the order.booleanundo(PromotionResultModel promotionResult)Undo all of the changes that this promotion made to the order.
-
-
-
Method Detail
-
isApplied
boolean isApplied(PromotionResultModel promotionResult)
Returns true if the promotion fired and all of its actions have been applied to the order.- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Whether the promotion has been applied
-
isAppliedToOrder
boolean isAppliedToOrder(PromotionResultModel promotionResult)
Returns true if the promotion fired and all of its actions have been applied to the order. This method checks that all the actions are still applied to the order.- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Whether the promotion has been applied
-
getFired
boolean getFired(PromotionResultModel promotionResult)
Returns true if the promotion fired and has produced a result.- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Whether the promotion fired
-
getCouldFire
boolean getCouldFire(PromotionResultModel promotionResult)
Is this a potential result. Returns true if the promotion believes it has a chance of firing, for instance if it requires 3 qualifying products but can only find 1.- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Whether the promotion could fire
-
getDescription
java.lang.String getDescription(PromotionResultModel promotionResult)
Get the description of this promotion result. This method uses the default locale (Locale.getDefault())- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- A description of the promotion result
- See Also:
getDescription(PromotionResultModel, java.util.Locale)
-
getDescription
java.lang.String getDescription(PromotionResultModel promotionResult, java.util.Locale locale)
Get the description of this promotion result. Gets the description for this promotion result. This description is based on the state of the result, the promotion that generated the result and the user supplied formatting strings. TheLocalespecified is used to format any numbers, dates or currencies for display to the user. It is important that this locale best represents the formatting options appropriate for display to the user. The default currency for the locale is ignored. The currency is always explicitly taken from theGeneratedAbstractOrder.getCurrency(). The currency is then formatted appropriately in the locale specified. For example, this does mean that values in the EURO currency will be formatted differently depending on the locale specified as each locale can specify currency specific formatting. The currency formatting is part of the Java VM configuration to support multiple locales. If the formatting is incorrect check your VM configuration for the locale and currency combination.- Parameters:
locale- The locale to use to format the messages. This locale must support currency formatting, i.e. this should be a region specific local. e.g de_DE, en_US, en_GBpromotionResult- - instance ofPromotionResultModel- Returns:
- A description of the promotion result
-
apply
boolean apply(PromotionResultModel promotionResult)
Apply all of the actions that this promotion generated to the order.- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- true if calculateTotals() should be called to update the order totals.
-
undo
boolean undo(PromotionResultModel promotionResult)
Undo all of the changes that this promotion made to the order.- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- true if calculateTotals() should be called to update the order totals.
-
getConsumedCount
long getConsumedCount(PromotionResultModel promotionResult, boolean includeCouldFirePromotions)
Get the total number of items consumed by this promotion.- Parameters:
promotionResult- - instance ofPromotionResultModelincludeCouldFirePromotions- include could fire promotions- Returns:
- The total number of items consumed
-
getTotalDiscount
double getTotalDiscount(PromotionResultModel promotionResult)
Get the total value of all discounts in this result. This result will be the same regardless of the applied state of this result, i.e. if not applied this is the discount value that would be applied, if it is applied then it is the value of the discount.- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- The double value for the total discount value
-
getPotentialProductPromotions
java.util.List<PromotionResultModel> getPotentialProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)
Return a list of results for potential promotions that fired and consumed products and have been applied.- Parameters:
promoResult- - instance ofPromotionOrderResultspromotion- - instance ofAbstractPromotionModel- Returns:
- A list of the results of product promotions that fired and applied
-
getPotentialOrderPromotions
java.util.List<PromotionResultModel> getPotentialOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)
Return a list of results for potential promotions that fired and did not consume products and have been applied.- Parameters:
promoResult- - instance ofPromotionOrderResultspromotion- - instance ofAbstractPromotionModel- Returns:
- A list of the results of order promotions that fired and applied
-
getFiredProductPromotions
java.util.List<PromotionResultModel> getFiredProductPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)
Return a list of results for promotions that fired and consumed products.- Parameters:
promoResult- - instance ofPromotionOrderResultspromotion- - instance ofAbstractPromotionModel- Returns:
- A list of the results of product promotions that fired
-
getFiredOrderPromotions
java.util.List<PromotionResultModel> getFiredOrderPromotions(PromotionOrderResults promoResult, AbstractPromotionModel promotion)
Return a list of results for promotions that fired and did not consume products.- Parameters:
promoResult- - instance ofPromotionOrderResultspromotion- - instance ofAbstractPromotionModel- Returns:
- A list of the results of promotions that fired
-
getCouponCodesFromPromotion
java.util.Optional<java.util.Set<java.lang.String>> getCouponCodesFromPromotion(PromotionResultModel promotionResult)
Return give way coupon code for promotion.- Parameters:
promotionResult- - instance ofPromotionResultModel- Returns:
- Optional Set of String containing give way coupon code
-
-