Class DefaultFulfillmentGroupOfferProcessor
java.lang.Object
com.broadleafcommerce.promotion.offer.service.engine.application.processor.DefaultFulfillmentGroupOfferProcessor
- All Implemented Interfaces:
FulfillmentGroupOfferProcessor
public class DefaultFulfillmentGroupOfferProcessor
extends Object
implements FulfillmentGroupOfferProcessor
- Author:
- Chad Harchar (charchar), Brian Polster (bpolster)
-
Field Summary
Modifier and TypeFieldDescriptionprotected final OrderAndItemOfferHelper
protected final com.broadleafcommerce.common.extension.TypeFactory
protected static final int
protected final com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService
-
Constructor Summary
ConstructorDescriptionDefaultFulfillmentGroupOfferProcessor
(com.broadleafcommerce.common.extension.TypeFactory offerFactory, com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, OrderAndItemOfferHelper helper) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addAdjustmentToFulfillmentGroup
(CandidateFulfillmentGroup fg, FulfillmentGroupAdjustment adjustment) protected void
addCodeResponseToPermutationResult
(EnhancedOrder order, Offer offer, FulfillmentGroupOfferPermutationResult result, com.broadleafcommerce.promotion.offer.client.web.context.discounts.CodeResponse codeResponse) Adds theCodeResponse
to theFulfillmentGroupOfferPermutationResult
for the provided offer.void
applyFulfillmentGroupAdjustments
(OfferProcessingContext context, Map<String, List<FulfillmentGroupAdjustment>> adjustmentsMap) protected List<CandidateFulfillmentGroup>
protected Optional<javax.money.MonetaryAmount>
calculateAmountRemaining
(OrderOfferAdjustment adjustment) protected DiscountableItemInfo
calculateDiscountableItemTotal
(EnhancedFulfillmentGroup efg, CandidateFulfillmentGroupOffer co, OfferProcessingContext context, CombinedTypesOfferPermutation ctop) protected DiscountableItemInfo
calculateDiscountableItemTotal
(EnhancedFulfillmentGroup efg, OfferProcessingContext context, CombinedTypesOfferPermutation ctop) Deprecated.protected javax.money.MonetaryAmount
calculateFulfillmentGroupItemSubtotal
(EnhancedOrder order, EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop) protected double
calculateFulfillmentItemTotal
(EnhancedFulfillmentLineItem fItem, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop, DiscountableItemInfo discountableItemTotal) void
calculatePotentialSavings
(EnhancedOrder order, List<CandidateFulfillmentGroupOffer> candidateOffers) protected boolean
canOfferBeApplied
(EnhancedOrder order, EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop) Deprecated.protected boolean
canOfferBeApplied
(EnhancedOrder order, EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop, FulfillmentGroupOfferPermutationResult result) protected boolean
checkFulfillmentGroupTotal
(EnhancedOrder order, EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop) protected void
clearStateBetweenPermutations
(EnhancedOrder order, List<CandidateFulfillmentGroupOffer> candidateOffers) protected Optional<javax.money.MonetaryAmount>
computeAdjustmentValue
(javax.money.MonetaryAmount discountableTotal, CandidateFulfillmentGroupOffer fgOffer, CandidateFulfillmentGroup currentGroup, OfferProcessingContext context) Calculates the value of the adjustment .protected javax.money.MonetaryAmount
computeDiscountableTotalForGroup
(EnhancedFulfillmentGroup efg, CandidateFulfillmentGroupOffer offer) protected FulfillmentGroupOfferPermutationResult
computeOfferPermutationValue
(OfferProcessingContext context, OffersPermutation<CandidateFulfillmentGroupOffer> offersPermutation, CombinedTypesOfferPermutation ctop) protected List<CandidateFulfillmentGroupOffer>
convertToFulfillmentGroupOffers
(CombinedTypesOfferPermutation ctop, List<OrderOfferAdjustment> adjustments) protected boolean
couldOfferApplyToGroup
(EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer) protected CandidateFulfillmentGroupOffer
createCandidateFulfillmentGroupOfferForRemaining
(OrderOfferAdjustment adjustment, javax.money.MonetaryAmount amtRemaining) protected FulfillmentGroupAdjustment
createFulfillmentGroupAdjustment
(OfferProcessingContext context, CandidateFulfillmentGroupOffer fulfillmentGroupOffer, CandidateFulfillmentGroup fulfillmentGroup, javax.money.MonetaryAmount amount) protected FulfillmentGroupOfferPermutationResult
determineBestPermutationGivenEqualAdjustmentValues
(AtomicReference<FulfillmentGroupOfferPermutationResult> bestPermutation, FulfillmentGroupOfferPermutationResult result) void
findBestFulfillmentGroupOffersForPermutation
(OfferProcessingContext context, CombinedTypesOfferPermutation ctop) protected @NotNull Function<CandidateFulfillmentGroupOffer,
javax.money.MonetaryAmount> protected @NotNull Function<CandidateFulfillmentGroupOffer,
Long> protected void
protected void
incrementTotalSavingsPerCandidate
(EnhancedOrder order, CandidateFulfillmentGroupOffer offer, List<CandidateFulfillmentGroup> groups) protected boolean
matchingServiceLevel
(EnhancedFulfillmentLineItem item, String offerServiceLevel) protected boolean
shouldIncludeItem
(EnhancedOrder order, EnhancedFulfillmentGroup group, EnhancedFulfillmentLineItem fItem, CandidateFulfillmentGroupOffer groupOffer) sortAndFilter
(List<CandidateFulfillmentGroupOffer> candidateFulfillmentGroupOffers) protected void
void
protected void
Hook for modifying fulfillment offers.
-
Field Details
-
ONE_HUNDRED
protected static final int ONE_HUNDRED- See Also:
-
offerFactory
protected final com.broadleafcommerce.common.extension.TypeFactory offerFactory -
ruleEvaluationService
protected final com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService -
helper
-
-
Constructor Details
-
DefaultFulfillmentGroupOfferProcessor
public DefaultFulfillmentGroupOfferProcessor(com.broadleafcommerce.common.extension.TypeFactory offerFactory, com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, OrderAndItemOfferHelper helper)
-
-
Method Details
-
findBestFulfillmentGroupOffersForPermutation
public void findBestFulfillmentGroupOffersForPermutation(OfferProcessingContext context, CombinedTypesOfferPermutation ctop) - Specified by:
findBestFulfillmentGroupOffersForPermutation
in interfaceFulfillmentGroupOfferProcessor
-
determineBestPermutationGivenEqualAdjustmentValues
protected FulfillmentGroupOfferPermutationResult determineBestPermutationGivenEqualAdjustmentValues(AtomicReference<FulfillmentGroupOfferPermutationResult> bestPermutation, FulfillmentGroupOfferPermutationResult result) -
applyFulfillmentGroupAdjustments
public void applyFulfillmentGroupAdjustments(OfferProcessingContext context, Map<String, List<FulfillmentGroupAdjustment>> adjustmentsMap) - Specified by:
applyFulfillmentGroupAdjustments
in interfaceFulfillmentGroupOfferProcessor
-
computeOfferPermutationValue
protected FulfillmentGroupOfferPermutationResult computeOfferPermutationValue(OfferProcessingContext context, OffersPermutation<CandidateFulfillmentGroupOffer> offersPermutation, CombinedTypesOfferPermutation ctop) -
updatePermutationBeforeRunningFulfillmentOffers
Hook for modifying fulfillment offers. For example, amount off order offers that have theOffer#getApplyRemainderToFulfillment(Boolean)
of true will create a new fulfillment group offer with that remaining amount.- Parameters:
ctop
-fgOffers
-
-
handleOrderWithRemainingTotalOffers
-
calculateAmountRemaining
protected Optional<javax.money.MonetaryAmount> calculateAmountRemaining(OrderOfferAdjustment adjustment) -
convertToFulfillmentGroupOffers
protected List<CandidateFulfillmentGroupOffer> convertToFulfillmentGroupOffers(CombinedTypesOfferPermutation ctop, List<OrderOfferAdjustment> adjustments) -
createCandidateFulfillmentGroupOfferForRemaining
protected CandidateFulfillmentGroupOffer createCandidateFulfillmentGroupOfferForRemaining(OrderOfferAdjustment adjustment, javax.money.MonetaryAmount amtRemaining) -
buildFulfillmentGroupsFromAdjustment
protected List<CandidateFulfillmentGroup> buildFulfillmentGroupsFromAdjustment(OrderOfferAdjustment adjustment) -
computeDiscountableTotalForGroup
protected javax.money.MonetaryAmount computeDiscountableTotalForGroup(EnhancedFulfillmentGroup efg, CandidateFulfillmentGroupOffer offer) -
calculateDiscountableItemTotal
@Deprecated protected DiscountableItemInfo calculateDiscountableItemTotal(EnhancedFulfillmentGroup efg, OfferProcessingContext context, CombinedTypesOfferPermutation ctop) Deprecated. -
calculateDiscountableItemTotal
protected DiscountableItemInfo calculateDiscountableItemTotal(EnhancedFulfillmentGroup efg, CandidateFulfillmentGroupOffer co, OfferProcessingContext context, CombinedTypesOfferPermutation ctop) -
matchingServiceLevel
-
checkFulfillmentGroupTotal
protected boolean checkFulfillmentGroupTotal(EnhancedOrder order, EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop) -
calculateFulfillmentGroupItemSubtotal
protected javax.money.MonetaryAmount calculateFulfillmentGroupItemSubtotal(EnhancedOrder order, EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop) -
calculateFulfillmentItemTotal
protected double calculateFulfillmentItemTotal(EnhancedFulfillmentLineItem fItem, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop, DiscountableItemInfo discountableItemTotal) -
shouldIncludeItem
protected boolean shouldIncludeItem(EnhancedOrder order, EnhancedFulfillmentGroup group, EnhancedFulfillmentLineItem fItem, CandidateFulfillmentGroupOffer groupOffer) -
canOfferBeApplied
protected boolean canOfferBeApplied(EnhancedOrder order, EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop, FulfillmentGroupOfferPermutationResult result) -
canOfferBeApplied
@Deprecated(since="2.0") protected boolean canOfferBeApplied(EnhancedOrder order, EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer, CombinedTypesOfferPermutation ctop) -
couldOfferApplyToGroup
protected boolean couldOfferApplyToGroup(EnhancedFulfillmentGroup group, CandidateFulfillmentGroupOffer groupOffer) -
addAdjustmentToFulfillmentGroup
protected void addAdjustmentToFulfillmentGroup(CandidateFulfillmentGroup fg, FulfillmentGroupAdjustment adjustment) -
createFulfillmentGroupAdjustment
protected FulfillmentGroupAdjustment createFulfillmentGroupAdjustment(OfferProcessingContext context, CandidateFulfillmentGroupOffer fulfillmentGroupOffer, CandidateFulfillmentGroup fulfillmentGroup, javax.money.MonetaryAmount amount) -
computeAdjustmentValue
protected Optional<javax.money.MonetaryAmount> computeAdjustmentValue(javax.money.MonetaryAmount discountableTotal, CandidateFulfillmentGroupOffer fgOffer, CandidateFulfillmentGroup currentGroup, OfferProcessingContext context) Calculates the value of the adjustment .If this adjustment value is greater than the fulfillmentGroup total (e.g. would make the order go negative then the adjustment value is set to the value of the group).
-
clearStateBetweenPermutations
protected void clearStateBetweenPermutations(EnhancedOrder order, List<CandidateFulfillmentGroupOffer> candidateOffers) -
calculatePotentialSavings
public void calculatePotentialSavings(@NonNull EnhancedOrder order, @NonNull List<CandidateFulfillmentGroupOffer> candidateOffers) -
truncateCandidateGroups
-
incrementTotalSavingsPerCandidate
protected void incrementTotalSavingsPerCandidate(EnhancedOrder order, CandidateFulfillmentGroupOffer offer, List<CandidateFulfillmentGroup> groups) -
updateFulfillmentGroupTotal
- Specified by:
updateFulfillmentGroupTotal
in interfaceFulfillmentGroupOfferProcessor
-
sortAndFilter
public List<CandidateFulfillmentGroupOffer> sortAndFilter(List<CandidateFulfillmentGroupOffer> candidateFulfillmentGroupOffers) -
getGetTotalSavings
@NotNull protected @NotNull Function<CandidateFulfillmentGroupOffer,javax.money.MonetaryAmount> getGetTotalSavings() -
getOfferPriority
-
addCodeResponseToPermutationResult
protected void addCodeResponseToPermutationResult(EnhancedOrder order, Offer offer, FulfillmentGroupOfferPermutationResult result, com.broadleafcommerce.promotion.offer.client.web.context.discounts.CodeResponse codeResponse) Adds theCodeResponse
to theFulfillmentGroupOfferPermutationResult
for the provided offer.- Parameters:
order
- provides context information around offers and offer codesoffer
- the offer to add the code responses forresult
- the permutation result to add the code response tocodeResponse
- the code response to be added
-
canOfferBeApplied(EnhancedOrder, EnhancedFulfillmentGroup, CandidateFulfillmentGroupOffer, CombinedTypesOfferPermutation, FulfillmentGroupOfferPermutationResult)