Class DefaultPromotionsService
java.lang.Object
de.hybris.platform.servicelayer.internal.service.AbstractService
de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
de.hybris.platform.promotions.impl.AbstractPromotionsService
de.hybris.platform.promotions.impl.DefaultPromotionsService
- All Implemented Interfaces:
PromotionsService,Serializable,org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.beans.factory.InitializingBean
public class DefaultPromotionsService
extends AbstractPromotionsService
implements PromotionsService
DefaultPromotionsService.
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final StringFields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManagerFields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanautoApplyApplies(PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, AbstractPromotionModel promotion) protected voidbuildPromotionResultDataUniqueKey(PromotionResultModel promotionResult, StringBuilder builder) Build a unique identifier for a PromotionResult.protected StringbuildQueryForDistinctProductPromotionQuery(ProductModel product, Map<String, Object> args) protected voidvoidcleanupCart(CartModel cart) Delete the the stored promotion results for a Cart.protected voiddeleteStoredPromotionResults(AbstractOrderModel order, boolean undoActions) Delete the the stored promotion results for an AbstractOrder.protected List<PromotionResultModel>evaluatePromotion(PromotionEvaluationContext promoContext, AbstractPromotionModel promotion) protected <T extends AbstractPromotionModel>
List<T>filterPromotionsByRestrictions(List<T> allPromotions, ProductModel product, Date date) Filter a list of promotions by their restrictionsfindOrderAndProductPromotionsSortByPriority(Collection<PromotionGroupModel> promotionGroups, Collection<ProductModel> products, Date date) Find all promotions that can be evaluated on the list of product specified.protected voidfixupVouchersReapplyVouchers(AbstractOrderModel order, List<VoucherModel> vouchers) Method to fixup the vouchers applied to the order.protected List<VoucherModel>Method to fixup the vouchers applied to the order.List<? extends AbstractPromotionModel>getAbstractProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product) Get the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.List<? extends AbstractPromotionModel>getAbstractProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, Date date) Get the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.protected ProductModelgetBaseProduct(ProductModel product) Return the base product for the product specified.protected List<ProductModel>getBaseProducts(ProductModel product) This is a recursive variant of the method above.protected voidgetBaseProducts(ProductModel product, List<ProductModel> result) Internal recursive method to get all base products of a given product.protected Collection<ProductModel>Get the list of products and base products in the order.protected CalculationServiceprotected StringgetDataUniqueKey(PromotionResultModel result) Generates a string identifier that can be used to establish if 2 PromotionResults are the same.Lookup the default promotion group created by the promotions extension.protected FlexibleSearchServiceprotected LegacyModeCheckergetOrderPromotions(Collection<PromotionGroupModel> promotionGroups) Get the ordered list ofOrderPromotioninstances.getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions) Get the ordered list ofOrderPromotioninstances.getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product) Get the ordered list ofOrderPromotioninstances.getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product, Date date) Get the ordered list ofOrderPromotioninstances.getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, Date date) Get the ordered list ofOrderPromotioninstances.getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product) Get the ordered list ofOrderPromotioninstances.getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product, Date date) Get the ordered list ofOrderPromotioninstances.getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, Date date) Get the ordered list ofOrderPromotioninstances.getProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product) Get the ordered list ofProductPromotioninstances that are related to theProductModelspecified.getProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, Date date) Get the ordered list ofProductPromotioninstances that are related to theProductModelspecified.getPromotionDescription(AbstractPromotionModel promotion) Get the description of given promotion.getPromotionGroup(String identifier) Lookup a promotion group with the given identifier.protected final StringgetPromotionResultDataUniqueKey(PromotionResultModel promotionResult) Generate a string identifier that can be used to establish if 2 PromotionResults are the same.Get the promotion results for the specified order.getPromotionResults(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date) Get the promotion results for the specified order.protected List<PromotionResultModel>Get the list of promotion results for the specified order.protected doubleprotected PromotionsManagergetRestrictions(AbstractPromotionModel promotion) Get the collection ofAbstractPromotionRestrictionModelinstances.protected JaloSessionprotected doublegetTotalDiscount(PromotionResultModel result) Gets the total value of all discounts in the result.protected booleanisDiscountAbsolute(DiscountModel discount) protected booleanprotected booleanprotected booleanprotected booleankeepApplied(PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, AbstractPromotionModel promotion, boolean autoApply) protected voidrefreshOrder(AbstractOrderModel order) protected voidsaveIfModified(AbstractOrderModel order) voidsetCalculationService(CalculationService calculationService) voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService) voidsetLegacyModeChecker(LegacyModeChecker legacyModeChecker) protected Comparator<PromotionResultModel>returns a comparator that sorts promotionresults by their promotion's priorityvoidtransferPromotionsToOrder(AbstractOrderModel source, OrderModel target, boolean onlyTransferAppliedPromotions) Transfer the promotions applied to a cart to a new order.protected doubleupdateForActivePromotions(AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date, List<String> promotionResultsToKeepApplied, List<PromotionResultModel> results, double newTotalAppliedDiscount, List<AbstractPromotionModel> activePromotions) updatePromotions(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order) Update the promotions on the specifiedAbstractOrderobject.updatePromotions(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date) Update the promotions on the specifiedAbstractOrderModelobject.protected PromotionOrderResultsupdatePromotionsInternal(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date) protected PromotionOrderResultsupdatePromotionsNotThreadSafe(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date) protected booleanMethods inherited from class de.hybris.platform.promotions.impl.AbstractPromotionsService
getCart, getOrder, getOrder, getProduct, getPromotion, getPromotion, getPromotion, getPromotionGroup, getResult, getSessionContext, refreshModifiedModelsAfterMethods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManagerMethods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
Field Details
-
PROMOTION_RESULTS_QUERY
-
ORDER_PROMOTIONS_QUERY
- See Also:
-
PRODUCT_PROMOTIONS_QUERY
- See Also:
-
PRODUCT_PROMTIONS_QUERY_UNION
- See Also:
-
PROMOTION_GROUP_QUERY
-
PRODUCT_PROMOTIONS_QUERY_DESC
- See Also:
-
SORTED_ORDER_AND_PRODUCT_PROMOTIONS_QUERY_START
- See Also:
-
SORTED_ORDER_AND_PRODUCT_PROMOTIONS_QUERY_PRODUCTS_PART
- See Also:
-
SORTED_ORDER_AND_PRODUCT_PROMOTIONS_QUERY_CATEGORIES_PART
- See Also:
-
SORTED_ORDER_AND_PRODUCT_PROMOTIONS_QUERY_UNION_ALL_PART
- See Also:
-
SORTED_ORDER_AND_PRODUCT_PROMOTIONS_QUERY_ORDER_PART
- See Also:
-
-
Constructor Details
-
DefaultPromotionsService
public DefaultPromotionsService()
-
-
Method Details
-
getPromotionsManager
-
getSession
-
cleanupCart
Description copied from interface:PromotionsServiceDelete the the stored promotion results for a Cart.- Specified by:
cleanupCartin interfacePromotionsService- Parameters:
cart- TheCartto delete the results for
-
deleteStoredPromotionResults
Delete the the stored promotion results for an AbstractOrder.- Parameters:
order- The order to delete the results forundoActions- Undo the actions before deleting the promotion results
-
getPromotionResultsInternal
Get the list of promotion results for the specified order.- Parameters:
order- The order to get the promotion results for- Returns:
- The promotion results
-
usingPolyglotPersistence
protected boolean usingPolyglotPersistence() -
sortByPromotionPriority
returns a comparator that sorts promotionresults by their promotion's priority -
getDefaultPromotionGroup
Description copied from interface:PromotionsServiceLookup the default promotion group created by the promotions extension.- Specified by:
getDefaultPromotionGroupin interfacePromotionsService- Returns:
- the default promotion group
-
getOrderPromotions
public List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups) Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluate- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, Date date) Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluatedate- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product) Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product to pass to restrictions- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product, Date date) Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product to pass to restrictionsdate- The date to check for promotions, typically the current date- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions) Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateevaluateRestrictions- Flag, pass false to ignore any restrictions specified on the promotions, pass true to observe the restrictions.- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, Date date) Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- 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 date- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product) Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- 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 true- Returns:
- The list of
OrderPromotion
-
getOrderPromotions
public List<OrderPromotionModel> getOrderPromotions(Collection<PromotionGroupModel> promotionGroups, boolean evaluateRestrictions, ProductModel product, Date date) Description copied from interface:PromotionsServiceGet the ordered list ofOrderPromotioninstances.- Specified by:
getOrderPromotionsin interfacePromotionsService- Parameters:
promotionGroups- 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 date- Returns:
- The list of
OrderPromotion
-
filterPromotionsByRestrictions
protected <T extends AbstractPromotionModel> List<T> filterPromotionsByRestrictions(List<T> allPromotions, ProductModel product, Date date) Filter a list of promotions by their restrictions- Parameters:
allPromotions- The promotions list to filterproduct- Optional product to pass when evaluating restrictionsdate- The restriction date- Returns:
- The filtered list of promotions
-
getProductPromotions
public List<ProductPromotionModel> getProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product) Description copied from interface:PromotionsServiceGet the ordered list ofProductPromotioninstances that are related to theProductModelspecified.- Specified by:
getProductPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related to- Returns:
- The list of
ProductPromotionrelated to theProductModelspecified
-
getProductPromotions
public List<ProductPromotionModel> getProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, Date date) Description copied from interface:PromotionsServiceGet the ordered list ofProductPromotioninstances that are related to theProductModelspecified.- Specified by:
getProductPromotionsin interfacePromotionsService- Parameters:
promotionGroups- 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 date- Returns:
- The list of
ProductPromotionrelated to theProductModelspecified
-
buildQueryForDistinctProductPromotionQuery
protected String buildQueryForDistinctProductPromotionQuery(ProductModel product, Map<String, Object> args) -
getAbstractProductPromotions
public List<? extends AbstractPromotionModel> getAbstractProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product) Description copied from interface:PromotionsServiceGet the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.- Specified by:
getAbstractProductPromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateproduct- The product that the promotions are related to- Returns:
- The list of
AbstractPromotionModelrelated to theProductModelspecified
-
getAbstractProductPromotions
public List<? extends AbstractPromotionModel> getAbstractProductPromotions(Collection<PromotionGroupModel> promotionGroups, ProductModel product, boolean evaluateRestrictions, Date date) Description copied from interface:PromotionsServiceGet the ordered list ofAbstractPromotionModelinstances that are related to theProductModelspecified.- Specified by:
getAbstractProductPromotionsin interfacePromotionsService- Parameters:
promotionGroups- 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 date- Returns:
- The list of
AbstractPromotionModelrelated to theProductModelspecified
-
getPromotionGroup
Lookup a promotion group with the given identifier.- Specified by:
getPromotionGroupin interfacePromotionsService- Parameters:
identifier- identifier of the promotion group to look for- Returns:
- the promotion group or null if no group with the given identifier is found
-
getPromotionResults
Description copied from interface:PromotionsServiceGet the promotion results for the specified order. These are the promotion results stored in the database for the specified order as generated by the last call toPromotionsService.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.- Specified by:
getPromotionResultsin interfacePromotionsService- Parameters:
order- The order to get the promotion results for- Returns:
- The promotion results
-
isPromotionResultValid
-
isPromotionResultFired
-
isPromotionResultApplied
-
getPromotionResultTotalDiscount
-
getDataUniqueKey
Generates a string identifier that can be used to establish if 2 PromotionResults are the same. The identifier should be based on the data for the PromotionResult, e.g. the promotion that created it, the number and type of products consumed, the actions created.- Parameters:
promotionResult-- Returns:
- a string that identifies this promotion result
-
getPromotionResultDataUniqueKey
Generate a string identifier that can be used to establish if 2 PromotionResults are the same. The identifier should be based on the data for the PromotionResult, e.g. the promotion that created it, the number and type of products consumed, the actions created. This method is final, but calls thebuildPromotionResultDataUniqueKey(de.hybris.platform.promotions.model.PromotionResultModel, java.lang.StringBuilder)method to allow subclasses to affect the way the identifier is built.- Parameters:
promotionResult- The promotion result- Returns:
- a string that identifies this promotion result
-
buildPromotionResultDataUniqueKey
protected void buildPromotionResultDataUniqueKey(PromotionResultModel promotionResult, StringBuilder builder) Build a unique identifier for a PromotionResult. This method is called fromgetPromotionResultDataUniqueKey(de.hybris.platform.promotions.model.PromotionResultModel). This method may be overridden by a subclass to customize how the identifier is built.- Parameters:
promotionResult- The promotion resultbuilder- A StringBuilder used to build up the identifier
-
getTotalDiscount
Gets the total value of all discounts in the 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.- Returns:
- The double value for the total discount value
-
getPromotionResults
public PromotionOrderResults getPromotionResults(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date) Description copied from interface:PromotionsServiceGet the promotion results for the specified order. These are the promotion results stored in the database for the specified order as generated by the last call toPromotionsService.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 callingPromotionsService.updatePromotions(java.util.Collection<de.hybris.platform.promotions.model.PromotionGroupModel>, de.hybris.platform.core.model.order.AbstractOrderModel).- Specified by:
getPromotionResultsin interfacePromotionsService- Parameters:
promotionGroups- 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.- Returns:
- The promotion results
-
transferPromotionsToOrder
public void transferPromotionsToOrder(AbstractOrderModel source, OrderModel target, boolean onlyTransferAppliedPromotions) Description copied from interface:PromotionsServiceTransfer the promotions applied to a cart to a new order. This is used when an order is created from a cart.- Specified by:
transferPromotionsToOrderin interfacePromotionsService- Parameters:
source- 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 transfered
-
updatePromotions
public PromotionOrderResults updatePromotions(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order) Description copied from interface:PromotionsServiceUpdate the promotions on the specifiedAbstractOrderobject. 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 samePromotionOrderResultscan be obtained later by callingPromotionsService.getPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel).- Specified by:
updatePromotionsin interfacePromotionsService- Parameters:
promotionGroups- The promotion groups to evaluateorder- The order object to update with the results of the promotions- Returns:
- The promotion results
-
updatePromotions
public PromotionOrderResults updatePromotions(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date) Description copied from interface:PromotionsServiceUpdate the promotions on the specifiedAbstractOrderModelobject. The resulting promotions can be retrieved later by callingPromotionsService.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 callingAbstractOrder.recalculate()on theAbstractOrderModel. Where thePromotionsManager.AutoApplyModeis set toPromotionsManager.AutoApplyMode.KEEP_APPLIEDthe state of any previously appliedPromotionResultis 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 samePromotionOrderResultscan be obtained later by callingPromotionsService.getPromotionResults(de.hybris.platform.core.model.order.AbstractOrderModel). After this method is called, please call getModelService().refresh(order) or getModelService().save(order).- Specified by:
updatePromotionsin interfacePromotionsService- Parameters:
promotionGroups- 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.- Returns:
- The promotion results
-
updatePromotionsInternal
protected PromotionOrderResults updatePromotionsInternal(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date) -
updatePromotionsNotThreadSafe
protected PromotionOrderResults updatePromotionsNotThreadSafe(Collection<PromotionGroupModel> promotionGroups, AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date) -
getBaseProductsForOrder
Get the list of products and base products in the order. If the product is a variant then the base product is selected.- Parameters:
order- the order- Returns:
- the list of products from the order
-
getBaseProduct
Return the base product for the product specified. Returns the current product if the product is not an instance of VariantProduct and the result of VariantProductModel.getBaseProduct() if it is.- Parameters:
product- The product to get the base product for- Returns:
- the base product for the product specified
-
getBaseProducts
This is a recursive variant of the method above. -
getBaseProducts
Internal recursive method to get all base products of a given product.- Parameters:
product-result-
-
findOrderAndProductPromotionsSortByPriority
public List<AbstractPromotionModel> findOrderAndProductPromotionsSortByPriority(Collection<PromotionGroupModel> promotionGroups, Collection<ProductModel> products, Date date) Find all promotions that can be evaluated on the list of product specified. This includes all OrderPromotions and any ProductPromotions that are related to the any of the products passed- Parameters:
promotionGroups- The promotion groups to evaluateproducts- The list of products to find associated promotions fordate- The date to test against promotions- Returns:
- The list of promotions
-
updateForActivePromotions
protected double updateForActivePromotions(AbstractOrderModel order, boolean evaluateRestrictions, PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, Date date, List<String> promotionResultsToKeepApplied, List<PromotionResultModel> results, double newTotalAppliedDiscount, List<AbstractPromotionModel> activePromotions) -
fixupVouchersRemoveVouchers
Method to fixup the vouchers applied to the order. This method is called before promotions have been calculates. It identifies any voucher discounts that are applied to the order, and removes them.- Parameters:
order- the order to fixup
-
fixupVouchersReapplyVouchers
Method to fixup the vouchers applied to the order. This method is called after promotions have been applied. It takes a list of voucher that were removed from the order. This method reapplies the voucher's discount to the order. The voucher calculates its discount based on the subtotal and does not take into account other discounts. This method then recalculates the discount that should be applied for each voucher and adds a new global discount for this.- Parameters:
order- the order to fixupvouchers- the vouchers to reapply
-
isDiscountAbsolute
-
evaluatePromotion
protected List<PromotionResultModel> evaluatePromotion(PromotionEvaluationContext promoContext, AbstractPromotionModel promotion) -
autoApplyApplies
protected boolean autoApplyApplies(PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, AbstractPromotionModel promotion) -
keepApplied
protected boolean keepApplied(PromotionsManager.AutoApplyMode productPromotionMode, PromotionsManager.AutoApplyMode orderPromotionMode, AbstractPromotionModel promotion, boolean autoApply) -
refreshOrder
-
saveIfModified
-
checkLegacyMode
protected void checkLegacyMode() -
getRestrictions
public Collection<AbstractPromotionRestrictionModel> getRestrictions(AbstractPromotionModel promotion) Description copied from interface:PromotionsServiceGet the collection ofAbstractPromotionRestrictionModelinstances.- Specified by:
getRestrictionsin interfacePromotionsService- Parameters:
promotion- the promotion which restrictions should be returned- Returns:
- A collection of
AbstractPromotionRestrictionModelinstances attached to this promotion.
-
getPromotionDescription
Description copied from interface:PromotionsServiceGet the description of given promotion.- Specified by:
getPromotionDescriptionin interfacePromotionsService- Parameters:
promotion- the promotion to get the description for- Returns:
- String representing promotion description
-
setFlexibleSearchService
-
getFlexibleSearchService
-
setCalculationService
-
getCalculationService
-
getLegacyModeChecker
-
setLegacyModeChecker
-