Class PromotionOrderResults
- java.lang.Object
-
- de.hybris.platform.promotions.result.PromotionOrderResults
-
public class PromotionOrderResults extends java.lang.ObjectAn object representing the results of evaluating promotions on an AbstractOrder. This object holds details of each promotion that fired, and the OrderEntry objects that it fired on, and details of all other OrderEntry objects, indicating if they could be part of a potential promotion. APromotionResultobject represents the state of any promotion that fired or potentially fired.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPromotionOrderResults.PromotionResultProductsprotected static classPromotionOrderResults.PromotionResultStatus
-
Constructor Summary
Constructors Constructor Description PromotionOrderResults(SessionContext ctx, AbstractOrder order, java.util.List<PromotionResult> promotionResults, double changeFromLastResults)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.util.List<WrappedOrderEntry>cleanWrappedEntryList(SessionContext ctx, java.util.List<WrappedOrderEntry> wrappedEntries)protected static java.util.Collection<WrappedOrderEntry>findAllMatchingEntries(SessionContext ctx, java.util.List<WrappedOrderEntry> wrappedEntries, java.util.Collection<PromotionOrderEntryConsumed> consumedEntries)java.util.List<PromotionResult>getAllOrderPromotions()Return a list of results for promotions that did not consume products.java.util.List<PromotionResult>getAllProductPromotions()Return a list of results for promotions that consumed products.java.util.List<PromotionResult>getAllResults()Returns allPromotionResultobjects.java.util.List<PromotionResult>getAppliedOrderPromotions()Return a list of results for promotions that fired and did not consume products and have been applied.java.util.List<PromotionResult>getAppliedProductPromotions()Return a list of results for promotions that fired and consumed products and have been applied.protected static longgetConsumedQuantityForEntry(SessionContext ctx, PromotionResult result, AbstractOrderEntry orderEntry)java.util.List<WrappedOrderEntry>getEntriesNotInFiredPromotions()Return a list of WrappedOrderEntry objects that were not part of any any promotion that fired.java.util.List<WrappedOrderEntry>getEntriesNotInPromotions()Return a list of WrappedOrderEntry objects that were not part of any any promotion that fired or could fire.java.util.List<WrappedOrderEntry>getEntriesWithPotentialPromotions()Return a list of WrappedOrderEntry objects that were part of any any promotion that could fire.java.util.List<PromotionResult>getFiredOrderPromotions()Return a list of results for promotions that fired and did not consume products.java.util.List<PromotionResult>getFiredProductPromotions()Return a list of results for promotions that fired and consumed products.protected static longgetMaxConsumedQuantityForEntry(SessionContext ctx, java.util.List<PromotionResult> promotionResults, AbstractOrderEntry orderEntry)java.util.List<PromotionResult>getPotentialOrderPromotions()Return a list of results for promotions that fired and did not consume products and have been applied.java.util.List<PromotionResult>getPotentialProductPromotions()Return a list of results for promotions that fired and consumed products and have been applied.protected java.util.List<PromotionResult>getPromotionResults(PromotionOrderResults.PromotionResultStatus statusFlag, PromotionOrderResults.PromotionResultProducts productsFlag)Return a list of results for promotions that meet the specified criteria.doublegetTotalChangeFromLastResults()Return the total change since the last evaluation of results.voidinvalidateCache()Invalidate all cached data held in this PromotionOrderResults instance.protected static voidremoveConsumedEntries(SessionContext ctx, java.util.List<WrappedOrderEntry> wrappedEntries, java.util.Collection<PromotionOrderEntryConsumed> consumedEntries)protected static java.util.List<WrappedOrderEntry>wrapEntries(SessionContext ctx, AbstractOrder order)
-
-
-
Constructor Detail
-
PromotionOrderResults
public PromotionOrderResults(SessionContext ctx, AbstractOrder order, java.util.List<PromotionResult> promotionResults, double changeFromLastResults)
Constructor.- Parameters:
ctx- The hybris contextorder- The orderpromotionResults- The promotion resultschangeFromLastResults- The change from last results
-
-
Method Detail
-
invalidateCache
public void invalidateCache()
Invalidate all cached data held in this PromotionOrderResults instance. This method should be called if any of the PromotionResults are applied or unapplied.
-
getTotalChangeFromLastResults
public double getTotalChangeFromLastResults()
Return the total change since the last evaluation of results.- Returns:
- A double representing the calculation newTotalValueOfDiscounts - oldTotalValueOfDiscounts
-
getAllResults
public java.util.List<PromotionResult> getAllResults()
Returns allPromotionResultobjects. This list will include all promotions that either fired or identified themselves as potentially firing.- Returns:
- The list of promotion results
-
getAllProductPromotions
public java.util.List<PromotionResult> getAllProductPromotions()
Return a list of results for promotions that consumed products. This list will include all promotions that consumed products regardless of their firing status.- Returns:
- The list of promotion results
-
getFiredProductPromotions
public java.util.List<PromotionResult> getFiredProductPromotions()
Return a list of results for promotions that fired and consumed products.- Returns:
- A list of the results of product promotions that fired
-
getAppliedProductPromotions
public java.util.List<PromotionResult> getAppliedProductPromotions()
Return a list of results for promotions that fired and consumed products and have been applied.- Returns:
- A list of the results of product promotions that fired and applied
-
getPotentialProductPromotions
public java.util.List<PromotionResult> getPotentialProductPromotions()
Return a list of results for promotions that fired and consumed products and have been applied.- Returns:
- A list of the results of product promotions that fired and applied
-
getAllOrderPromotions
public java.util.List<PromotionResult> getAllOrderPromotions()
Return a list of results for promotions that did not consume products. This list will include all promotions that did not consume products regardless of their firing status- Returns:
- The list of promotion results
-
getFiredOrderPromotions
public java.util.List<PromotionResult> getFiredOrderPromotions()
Return a list of results for promotions that fired and did not consume products.- Returns:
- A list of the results of promotions that fired
-
getAppliedOrderPromotions
public java.util.List<PromotionResult> getAppliedOrderPromotions()
Return a list of results for promotions that fired and did not consume products and have been applied.- Returns:
- A list of the results of promotions that fired and applied
-
getPotentialOrderPromotions
public java.util.List<PromotionResult> getPotentialOrderPromotions()
Return a list of results for promotions that fired and did not consume products and have been applied.- Returns:
- A list of the results of order promotions that fired and applied
-
getPromotionResults
protected java.util.List<PromotionResult> getPromotionResults(PromotionOrderResults.PromotionResultStatus statusFlag, PromotionOrderResults.PromotionResultProducts productsFlag)
Return a list of results for promotions that meet the specified criteria.- Parameters:
statusFlag- status criteriaproductsFlag- consumed products criteria- Returns:
- a list of promotion results
-
getEntriesNotInPromotions
public java.util.List<WrappedOrderEntry> getEntriesNotInPromotions()
Return a list of WrappedOrderEntry objects that were not part of any any promotion that fired or could fire.- Returns:
- a list of WrappedOrderEntry objects
-
getEntriesWithPotentialPromotions
public java.util.List<WrappedOrderEntry> getEntriesWithPotentialPromotions()
Return a list of WrappedOrderEntry objects that were part of any any promotion that could fire.- Returns:
- a list of WrappedOrderEntry objects
-
getEntriesNotInFiredPromotions
public java.util.List<WrappedOrderEntry> getEntriesNotInFiredPromotions()
Return a list of WrappedOrderEntry objects that were not part of any any promotion that fired. The WrappedOrderEntry holds the promotions that could fire for the specified products. Note that the results returned from this method are the same as those from combining the results from methodsgetEntriesWithPotentialPromotions()andgetEntriesNotInPromotions()but the WrappedOrderEntry objects may be consolidated together. In general it is preferable to callgetEntriesWithPotentialPromotions()andgetEntriesNotInPromotions()that than calling this method directly.- Returns:
- a list of WrappedOrderEntry objects
-
getMaxConsumedQuantityForEntry
protected static long getMaxConsumedQuantityForEntry(SessionContext ctx, java.util.List<PromotionResult> promotionResults, AbstractOrderEntry orderEntry)
-
getConsumedQuantityForEntry
protected static long getConsumedQuantityForEntry(SessionContext ctx, PromotionResult result, AbstractOrderEntry orderEntry)
-
findAllMatchingEntries
protected static java.util.Collection<WrappedOrderEntry> findAllMatchingEntries(SessionContext ctx, java.util.List<WrappedOrderEntry> wrappedEntries, java.util.Collection<PromotionOrderEntryConsumed> consumedEntries)
-
wrapEntries
protected static java.util.List<WrappedOrderEntry> wrapEntries(SessionContext ctx, AbstractOrder order)
-
removeConsumedEntries
protected static void removeConsumedEntries(SessionContext ctx, java.util.List<WrappedOrderEntry> wrappedEntries, java.util.Collection<PromotionOrderEntryConsumed> consumedEntries)
-
cleanWrappedEntryList
protected static java.util.List<WrappedOrderEntry> cleanWrappedEntryList(SessionContext ctx, java.util.List<WrappedOrderEntry> wrappedEntries)
-
-