Class OfferProcessingContext
java.lang.Object
com.broadleafcommerce.promotion.offer.service.dto.OfferProcessingContext
- All Implemented Interfaces:
Serializable
This object manages the full list of permutations for a given execution of the offer engine and
provides methods to determine the correct mix of offers for the final result.
- Author:
- Brian Polster (bpolster)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addToListIfPresent
(List<Set<OfferCombinabilityCriteria>> criteriaByTypeList, Map<OfferCombinabilityCriteriaKey, OfferCombinabilityCriteria> permutationMap) Each element in the list represents a single offer type and the unique set ofOfferCombinabilityCriteria
objects.protected void
This method builds all compatible permutations of offers in a tree structure.protected boolean
checkCompatability
(BaseCandidateOffer candidateOffer, BaseCandidateOffer otherCandidateOffer, CompatibleOfferNode node) protected boolean
checkForCombinable
(BaseCandidateOffer candidateOffer, BaseCandidateOffer otherOffer) protected boolean
checkForExplicitExclusions
(BaseCandidateOffer candidateOffer, BaseCandidateOffer otherCandidateOffer) protected boolean
checkForStackable
(BaseCandidateOffer candidateOffer, BaseCandidateOffer otherOffer) protected boolean
checkSegmentCombinable
(BaseCandidateOffer offer, CompatibleOfferNode currentNode) If this is an order offer and the segment is unique with the node path, then this offer can be combined.protected void
protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.CodeResponse
createCodeResponse
(OfferNotAppliedReasonEnum notUsedReason, com.broadleafcommerce.common.extension.TypeFactory offerFactory, org.springframework.context.MessageSource messageSource) void
createPathsForNode
(CompatibleOfferNode currentNode, List<BaseCandidateOffer> theOffers, Set<CompatibleOfferNode> allNodes) filterIncompatibleOffers
(BaseCandidateOffer offer, CompatibleOfferNode node, List<BaseCandidateOffer> otherOffers) Filters the passed in list, removing all incompatible offersfindFirstCompatibleOffer
(BaseCandidateOffer offer, CompatibleOfferNode node, List<BaseCandidateOffer> otherOffers) findFirstIncompatibleOffer
(BaseCandidateOffer offer, CompatibleOfferNode node, List<BaseCandidateOffer> otherOffers) Based on the compatible flag, return the first compatible or incompatible item from the passed in listMethod facilitates unit testing.Builds a list consisting of the sets of OfferCombinabilityCriteria for each offer type.getOrder()
boolean
void
Build unique permutations by offer type where a permutation is grouped by how the permutation can combine with other offer typesprotected void
initializePermutations
(List<? extends BaseCandidateOffer> offers, Map<OfferCombinabilityCriteriaKey, OfferCombinabilityCriteria> permutationMap) boolean
protected boolean
isNotAppliedOffer
(Set<Offer> appliedOffers, Offer offer) void
setBestOfferPermutation
(CombinedTypesOfferPermutation bestOfferPermutation) void
void
updateOfferNotAppliedResponses
(com.broadleafcommerce.common.extension.TypeFactory offerFactory, org.springframework.context.MessageSource messageSource)
-
Constructor Details
-
OfferProcessingContext
-
-
Method Details
-
hasOffers
public boolean hasOffers() -
getCandidateOrderItemOffers
-
getCandidateFulfillmentItemOffers
-
initializePermutations
public void initializePermutations()Build unique permutations by offer type where a permutation is grouped by how the permutation can combine with other offer types- See Also:
-
initializePermutations
protected void initializePermutations(List<? extends BaseCandidateOffer> offers, Map<OfferCombinabilityCriteriaKey, OfferCombinabilityCriteria> permutationMap) -
buildOfferPermutationsForCriteria
This method builds all compatible permutations of offers in a tree structure. Each path of this tree represents a unique offer permutation.- Parameters:
criteria
- OfferCombinabilityCriteria to group offers by
-
createPathsForNode
public void createPathsForNode(CompatibleOfferNode currentNode, List<BaseCandidateOffer> theOffers, Set<CompatibleOfferNode> allNodes) -
filterIncompatibleOffers
public List<BaseCandidateOffer> filterIncompatibleOffers(BaseCandidateOffer offer, CompatibleOfferNode node, List<BaseCandidateOffer> otherOffers) Filters the passed in list, removing all incompatible offers -
findFirstIncompatibleOffer
public BaseCandidateOffer findFirstIncompatibleOffer(BaseCandidateOffer offer, CompatibleOfferNode node, List<BaseCandidateOffer> otherOffers) Based on the compatible flag, return the first compatible or incompatible item from the passed in list -
findFirstCompatibleOffer
public BaseCandidateOffer findFirstCompatibleOffer(BaseCandidateOffer offer, CompatibleOfferNode node, List<BaseCandidateOffer> otherOffers) -
checkCompatability
protected boolean checkCompatability(BaseCandidateOffer candidateOffer, BaseCandidateOffer otherCandidateOffer, CompatibleOfferNode node) -
checkSegmentCombinable
If this is an order offer and the segment is unique with the node path, then this offer can be combined. -
checkForExplicitExclusions
protected boolean checkForExplicitExclusions(BaseCandidateOffer candidateOffer, BaseCandidateOffer otherCandidateOffer) -
checkForStackable
protected boolean checkForStackable(BaseCandidateOffer candidateOffer, BaseCandidateOffer otherOffer) -
checkForCombinable
protected boolean checkForCombinable(BaseCandidateOffer candidateOffer, BaseCandidateOffer otherOffer) -
getCriteriaSetsByType
Builds a list consisting of the sets of OfferCombinabilityCriteria for each offer type. Each index in the list represents a level in the tree of possible offer combinations. The order is important as the permutations will first compute item offers which can impact the overall order subtotal and other offer eligibility. The list will only contain offer types that have relevant offers and they will be in the following order: Item, Order, Voucher, Fulfillment Item, Fulfillment Order- Returns:
-
addToListIfPresent
protected void addToListIfPresent(List<Set<OfferCombinabilityCriteria>> criteriaByTypeList, Map<OfferCombinabilityCriteriaKey, OfferCombinabilityCriteria> permutationMap) Each element in the list represents a single offer type and the unique set ofOfferCombinabilityCriteria
objects. This structure supports the ability to find the best cross-type combination of offers.- Parameters:
criteriaByTypeList
- The list to populatepermutationMap
-
-
getBestOfferPermutation
-
updateBestCombinedTypesPermutation
public void updateBestCombinedTypesPermutation() -
updateOfferNotAppliedResponses
public void updateOfferNotAppliedResponses(@NonNull com.broadleafcommerce.common.extension.TypeFactory offerFactory, @NonNull org.springframework.context.MessageSource messageSource) -
copyBestPermutationCodeResponses
protected void copyBestPermutationCodeResponses() -
isNotAppliedOffer
-
getAppliedFulfillmentGroupOffers
-
getAppliedOrderOffers
-
getAppliedOrderItemOffers
-
getAppliedFulfillmentItemOffers
-
createCodeResponse
protected com.broadleafcommerce.promotion.offer.client.web.context.discounts.CodeResponse createCodeResponse(OfferNotAppliedReasonEnum notUsedReason, @NonNull com.broadleafcommerce.common.extension.TypeFactory offerFactory, @NonNull org.springframework.context.MessageSource messageSource) -
getItemProratedAdjustmentsMap
-
getBestOrderAdjustmentsForTesting
Method facilitates unit testing. This method would not be reliable outside of tests as it does not properly null check the bestOfferPermutation -
getOrderOfferCriteriaMap
-
getItemOfferCriteriaMap
-
getFulfillmentGroupCriteriaMap
public Map<OfferCombinabilityCriteriaKey,OfferCombinabilityCriteria> getFulfillmentGroupCriteriaMap() -
getFulfillmentItemCriteriaMap
public Map<OfferCombinabilityCriteriaKey,OfferCombinabilityCriteria> getFulfillmentItemCriteriaMap() -
getVoucherCriteriaMap
-
getCombinedTypesOfferPermutations
-
setBestOfferPermutation
-
isHasOffers
public boolean isHasOffers() -
getOrder
-