Class ItemOfferProcessorImpl
java.lang.Object
org.broadleafcommerce.core.offer.service.processor.AbstractBaseProcessor
org.broadleafcommerce.core.offer.service.processor.OrderOfferProcessorImpl
org.broadleafcommerce.core.offer.service.processor.ItemOfferProcessorImpl
- All Implemented Interfaces:
BaseProcessor,ItemOfferMarkTargets,ItemOfferProcessor,OrderOfferProcessor
@Service("blItemOfferProcessor")
public class ItemOfferProcessorImpl
extends OrderOfferProcessorImpl
implements ItemOfferProcessor, ItemOfferMarkTargets
Filter and apply order item offers.
- Author:
- jfischer
-
Field Summary
FieldsFields inherited from class org.broadleafcommerce.core.offer.service.processor.OrderOfferProcessorImpl
entityService, offerDao, offerServiceUtilities, orderItemDao, promotableItemFactoryFields inherited from class org.broadleafcommerce.core.offer.service.processor.AbstractBaseProcessor
extensionManager, offerTimeZoneProcessor, promotableOfferUtility -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyAdjustments(PromotableOrder order, PromotableCandidateItemOffer itemOffer) The itemOffer has been qualified and prior methods added PromotionDiscount objects onto the ItemPriceDetail.voidapplyAllItemOffers(List<PromotableCandidateItemOffer> itemOffers, PromotableOrder order) Private method that takes a list of sorted CandidateItemOffers and determines if each offer can be applied based on the restrictions (stackable and/or combinable) on that offer.voidapplyAndCompareOrderAndItemOffers(PromotableOrder order, List<PromotableCandidateOrderOffer> qualifiedOrderOffers, List<PromotableCandidateItemOffer> qualifiedItemOffers) protected voidapplyItemOffer(PromotableOrder order, PromotableCandidateItemOffer itemOffer) protected BooleanapplyItemOfferExtension(PromotableOrder order, PromotableCandidateItemOffer itemOffer) Call out to extension managers.protected voidapplyItemQualifiersAndTargets(PromotableCandidateItemOffer itemOffer, PromotableOrder order) protected List<List<PromotableCandidateItemOffer>>This method could be overridden to potentially run all permutations of offers.protected List<PromotableOrderItemPriceDetail>protected BigDecimalcalculatePercent(org.broadleafcommerce.common.money.Money itemSubTotal, org.broadleafcommerce.common.money.Money itemSavings) protected voidcalculatePotentialSavings(List<PromotableCandidateItemOffer> itemOffers, PromotableOrder order) This method determines the potential savings for each item offer as if it was the only item offer being applied.protected org.broadleafcommerce.common.money.MoneycalculatePotentialSavingsForOrderItem(PromotableCandidateItemOffer itemOffer, PromotableOrderItem item, int quantity) Provide an opportunity to for modules to override the potentialSavingsCalculationprotected BigDecimalcalculateWeightedPercent(PromotionDiscount discount, PromotableOrderItem item, org.broadleafcommerce.common.money.Money itemSavings) protected voidSome promotions can only apply to the retail price.convertToIdList(List<PromotableCandidateItemOffer> offerList) protected PromotableCandidateItemOffercreateCandidateItemOffer(List<PromotableCandidateItemOffer> qualifiedItemOffers, Offer offer, PromotableOrder promotableOrder) Create a candidate item offer based on the offer in question and a specific order itemprotected List<PromotableCandidateItemOffer>determineBestPermutation(List<PromotableCandidateItemOffer> itemOffers, PromotableOrder order) voidfilterItemLevelOffer(PromotableOrder order, List<PromotableCandidateItemOffer> qualifiedItemOffers, Offer offer) Review an item level offer against the list of discountable items from the order.voidfilterOffers(PromotableOrder order, List<Offer> filteredOffers, List<PromotableCandidateOrderOffer> qualifiedOrderOffers, List<PromotableCandidateItemOffer> qualifiedItemOffers) protected List<PromotableCandidateItemOffer>getPermutationByComparator(List<PromotableCandidateItemOffer> offers, Comparator instance) protected booleanprotected booleanisPercentOffOffer(Offer offer) protected booleanprotected booleanmarkQualifiers(PromotableCandidateItemOffer itemOffer, PromotableOrder order) Loop through ItemCriteria and mark qualifiers required to give the promotion to 1 or more targets.protected voidmarkQualifiersAndTargets(PromotableOrder order, PromotableCandidateItemOffer itemOffer) protected booleanmarkRelatedQualifiersAndTargets(PromotableCandidateItemOffer itemOffer, PromotableOrder order) When theOffer.getRequiresRelatedTargetAndQualifiers()flag is set to true, we must make sure that we identify qualifiers and targets together, as they must be related to each other based on theOrderItem.getParentOrderItem()/OrderItem.getChildOrderItems()attributes.protected booleanmarkTargets(PromotableCandidateItemOffer itemOffer, PromotableOrder order, OrderItem relatedQualifier) booleanmarkTargets(PromotableCandidateItemOffer itemOffer, PromotableOrder order, OrderItem relatedQualifier, boolean checkOnly) Loop through ItemCriteria and mark targets that can get this promotion to give the promotion to 1 or more targets.protected voidmergePriceDetails(PromotableOrder order) Checks to see if any priceDetails need to be combined and if so, combines them.protected booleanprotected booleanorderMeetsQualifyingSubtotalRequirements(PromotableOrder order, PromotableCandidateItemOffer itemOffer) protected booleanorderMeetsSubtotalRequirements(PromotableOrder order, PromotableCandidateItemOffer itemOffer) protected booleanorderMeetsTargetSubtotalRequirements(PromotableOrder order, PromotableCandidateItemOffer itemOffer) protected voidremoveDuplicatePermutations(List<List<PromotableCandidateItemOffer>> permutations) protected voidremoveTotalitarianAndNonCombinableOffers(List<PromotableCandidateItemOffer> offers, List<List<PromotableCandidateItemOffer>> listOfOfferLists) protected voidprotected booleanuseCalculatePercent(Offer offer) protected booleanusePercentOffValue(Offer offer) Methods inherited from class org.broadleafcommerce.core.offer.service.processor.OrderOfferProcessorImpl
applyAllOrderOffers, applyOrderOffer, buildItemPriceDetailKey, buildPromFulfillmentAdjMap, buildPromotableDetailsMap, buildPromotableFulfillmentGroupMap, buildPromotableOrderAdjustmentsMap, buildPromotableQualifiersMap, compareAndAdjustOrderAndItemOffers, couldOfferApplyToOrder, couldOfferApplyToOrder, couldOfferApplyToOrder, couldOfferApplyToOrder, createCandidateOrderOffer, fgContainsFutureCreditAdjustment, filterOrderLevelOffer, getOfferServiceUtilities, getPromotableItemFactory, orderMeetsQualifyingSubtotalRequirements, orderMeetsSubtotalRequirements, processMatchingDetails, removeTrailingNotCombinableOrderOffers, setOfferDao, setOfferServiceUtilities, setOrderItemDao, setPromotableItemFactory, syncFulfillmentPrice, synchronizeAdjustmentsAndPrices, synchronizeFulfillmentGroupAdjustments, synchronizeFulfillmentGroups, synchronizeItemPriceDetails, synchronizeItemQualifiers, synchronizeOrderAdjustments, synchronizeOrderItems, updateAdjustmentIfChangesDetectedMethods inherited from class org.broadleafcommerce.core.offer.service.processor.AbstractBaseProcessor
addChildOrderItemsToCandidates, checkForItemRequirements, clearAllNonFinalizedQuantities, couldOfferApplyToCustomer, couldOfferApplyToOrderItems, couldOfferApplyToRequestDTO, couldOfferApplyToTimePeriod, couldOrderItemMeetOfferRequirement, dateToCalendar, executeExpression, filterOffers, finalizeQuantities, findQualifyingItemForPriceData, getOfferTimeZoneProcessor, hasPositiveValue, isEmpty, meetsItemQualifierSubtotal, removeInvalidCustomerOffers, removeInvalidRequestOffers, removeOutOfDateOffers, removeTimePeriodOffers, setOfferTimeZoneProcessor, splitDetailsIfNecessary, usePriceBeforeAdjustmentsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.broadleafcommerce.core.offer.service.processor.BaseProcessor
filterOffersMethods inherited from interface org.broadleafcommerce.core.offer.service.processor.OrderOfferProcessor
applyAllOrderOffers, couldOfferApplyToOrder, executeExpression, filterOrderLevelOffer, getPromotableItemFactory, removeTrailingNotCombinableOrderOffers, setOfferDao, setOrderItemDao, setPromotableItemFactory, synchronizeAdjustmentsAndPrices
-
Field Details
-
LOG
protected static final org.apache.commons.logging.Log LOG
-
-
Constructor Details
-
ItemOfferProcessorImpl
-
-
Method Details
-
filterItemLevelOffer
public void filterItemLevelOffer(PromotableOrder order, List<PromotableCandidateItemOffer> qualifiedItemOffers, Offer offer) Description copied from interface:ItemOfferProcessorReview an item level offer against the list of discountable items from the order. If the offer applies, add it to the qualifiedItemOffers list.- Specified by:
filterItemLevelOfferin interfaceItemOfferProcessor- Parameters:
order- the BLC orderqualifiedItemOffers- the container list for any qualified offersoffer- the offer in question
-
createCandidateItemOffer
protected PromotableCandidateItemOffer createCandidateItemOffer(List<PromotableCandidateItemOffer> qualifiedItemOffers, Offer offer, PromotableOrder promotableOrder) Create a candidate item offer based on the offer in question and a specific order item- Parameters:
qualifiedItemOffers- the container list for candidate item offersoffer- the offer in question- Returns:
- the candidate item offer
-
applyAllItemOffers
public void applyAllItemOffers(List<PromotableCandidateItemOffer> itemOffers, PromotableOrder order) Description copied from interface:ItemOfferProcessorPrivate method that takes a list of sorted CandidateItemOffers and determines if each offer can be applied based on the restrictions (stackable and/or combinable) on that offer. OrderItemAdjustments are create on the OrderItem for each applied CandidateItemOffer. An offer with stackable equals false cannot be applied to an OrderItem that already contains an OrderItemAdjustment. An offer with combinable equals false cannot be applied to an OrderItem if that OrderItem already contains an OrderItemAdjustment, unless the offer is the same offer as the OrderItemAdjustment offer.- Specified by:
applyAllItemOffersin interfaceItemOfferProcessor- Parameters:
itemOffers- a sorted list of CandidateItemOffer
-
orderMeetsQualifyingSubtotalRequirements
protected boolean orderMeetsQualifyingSubtotalRequirements(PromotableOrder order, PromotableCandidateItemOffer itemOffer) -
orderMeetsTargetSubtotalRequirements
protected boolean orderMeetsTargetSubtotalRequirements(PromotableOrder order, PromotableCandidateItemOffer itemOffer) -
orderMeetsSubtotalRequirements
protected boolean orderMeetsSubtotalRequirements(PromotableOrder order, PromotableCandidateItemOffer itemOffer) -
isTotalitarianOfferAppliedToAnyItem
-
applyAdjustments
The itemOffer has been qualified and prior methods added PromotionDiscount objects onto the ItemPriceDetail. This code will convert the PromotionDiscounts into Adjustments- Parameters:
order-itemOffer-
-
applyItemOfferExtension
protected Boolean applyItemOfferExtension(PromotableOrder order, PromotableCandidateItemOffer itemOffer) Call out to extension managers. Returns true if the core processing should still be performed for the passed in offer.- Parameters:
order-itemOffer-- Returns:
-
applyItemOffer
-
chooseSaleOrRetailAdjustments
Some promotions can only apply to the retail price. This method determines whether retailPrice only promotions should be used instead of those that can apply to the sale price as well.- Parameters:
order-
-
mergePriceDetails
Checks to see if any priceDetails need to be combined and if so, combines them.- Parameters:
order-
-
applyItemQualifiersAndTargets
protected void applyItemQualifiersAndTargets(PromotableCandidateItemOffer itemOffer, PromotableOrder order) -
buildPriceDetailListFromOrderItems
protected List<PromotableOrderItemPriceDetail> buildPriceDetailListFromOrderItems(List<PromotableOrderItem> items) -
markQualifiers
Loop through ItemCriteria and mark qualifiers required to give the promotion to 1 or more targets.- Parameters:
itemOffer-order-- Returns:
-
markTargets
protected boolean markTargets(PromotableCandidateItemOffer itemOffer, PromotableOrder order, OrderItem relatedQualifier) -
markTargets
public boolean markTargets(PromotableCandidateItemOffer itemOffer, PromotableOrder order, OrderItem relatedQualifier, boolean checkOnly) Loop through ItemCriteria and mark targets that can get this promotion to give the promotion to 1 or more targets.- Specified by:
markTargetsin interfaceItemOfferMarkTargets- Parameters:
itemOffer-order-- Returns:
-
markRelatedQualifiersAndTargets
protected boolean markRelatedQualifiersAndTargets(PromotableCandidateItemOffer itemOffer, PromotableOrder order) When theOffer.getRequiresRelatedTargetAndQualifiers()flag is set to true, we must make sure that we identify qualifiers and targets together, as they must be related to each other based on theOrderItem.getParentOrderItem()/OrderItem.getChildOrderItems()attributes.- Parameters:
itemOffer-order-- Returns:
- whether or not a suitable qualifier/target pair was found and marked
-
filterOffers
public void filterOffers(PromotableOrder order, List<Offer> filteredOffers, List<PromotableCandidateOrderOffer> qualifiedOrderOffers, List<PromotableCandidateItemOffer> qualifiedItemOffers) - Specified by:
filterOffersin interfaceItemOfferProcessor
-
calculatePotentialSavingsForOrderItem
protected org.broadleafcommerce.common.money.Money calculatePotentialSavingsForOrderItem(PromotableCandidateItemOffer itemOffer, PromotableOrderItem item, int quantity) Provide an opportunity to for modules to override the potentialSavingsCalculation- Parameters:
itemOffer-item-quantity-- Returns:
-
calculatePotentialSavings
protected void calculatePotentialSavings(List<PromotableCandidateItemOffer> itemOffers, PromotableOrder order) This method determines the potential savings for each item offer as if it was the only item offer being applied.- Parameters:
itemOffers-order-
-
calculatePercent
protected BigDecimal calculatePercent(org.broadleafcommerce.common.money.Money itemSubTotal, org.broadleafcommerce.common.money.Money itemSavings) -
calculateWeightedPercent
protected BigDecimal calculateWeightedPercent(PromotionDiscount discount, PromotableOrderItem item, org.broadleafcommerce.common.money.Money itemSavings) -
useCalculatePercent
-
isPercentOffOffer
-
usePercentOffValue
-
hasQualifierAndQualifierRestricted
-
markQualifiersAndTargets
protected void markQualifiersAndTargets(PromotableOrder order, PromotableCandidateItemOffer itemOffer) -
offerListStartsWithNonCombinable
-
buildItemOfferPermutations
protected List<List<PromotableCandidateItemOffer>> buildItemOfferPermutations(List<PromotableCandidateItemOffer> offers) This method could be overridden to potentially run all permutations of offers. A reasonable alternative is to have a permutation with nonCombinable offers and another with combinable offers.- Parameters:
offers-- Returns:
-
removeTotalitarianAndNonCombinableOffers
protected void removeTotalitarianAndNonCombinableOffers(List<PromotableCandidateItemOffer> offers, List<List<PromotableCandidateItemOffer>> listOfOfferLists) -
getPermutationByComparator
protected List<PromotableCandidateItemOffer> getPermutationByComparator(List<PromotableCandidateItemOffer> offers, Comparator instance) -
restPriceDetails
-
determineBestPermutation
protected List<PromotableCandidateItemOffer> determineBestPermutation(List<PromotableCandidateItemOffer> itemOffers, PromotableOrder order) -
removeDuplicatePermutations
-
convertToIdList
-
applyAndCompareOrderAndItemOffers
public void applyAndCompareOrderAndItemOffers(PromotableOrder order, List<PromotableCandidateOrderOffer> qualifiedOrderOffers, List<PromotableCandidateItemOffer> qualifiedItemOffers) - Specified by:
applyAndCompareOrderAndItemOffersin interfaceItemOfferProcessor
-