Class DefaultOrderOfferProcessor
- java.lang.Object
-
- com.broadleafcommerce.promotion.offer.service.engine.application.processor.DefaultOrderOfferProcessor
-
- All Implemented Interfaces:
OrderOfferProcessor
public class DefaultOrderOfferProcessor extends Object implements OrderOfferProcessor
- Author:
- Chad Harchar (charchar)
-
-
Constructor Summary
Constructors Constructor Description DefaultOrderOfferProcessor(OrderAndItemOfferHelper helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddVoucherToResult(OfferProcessingContext context, OrderOfferPermutationResult result, CandidateOrderOffer orderOffer)voidapplyOrderAdjustments(OfferProcessingContext context, OrderOfferPermutationResult orderOfferPermutationResult)protected com.broadleafcommerce.promotion.offer.client.web.context.info.VoucherbuildVoucher(Offer voucherOffer)protected Optional<javax.money.MonetaryAmount>computeAdjustmentValue(CandidateOrderOffer orderOffer, OfferProcessingContext context, OrderTotals totals)Calculates the value of the adjustment by first getting the current value of the order and then calculating the value of this adjustment.protected OrderOfferPermutationResultcomputeOfferPermutationValue(OfferProcessingContext context, OffersPermutation<CandidateOrderOffer> offerPermutation, OrderTotals orderTotals)protected booleancouldOfferApplyToOrder(EnhancedOrder order, CandidateOrderOffer orderOffer)protected OrderOfferAdjustmentcreateOrderOfferAdjustment(OfferProcessingContext context, CandidateOrderOffer orderOffer, javax.money.MonetaryAmount amount)voidfindBestOrderOffersForPermutation(OfferProcessingContext context, CombinedTypesOfferPermutation ctop)protected Optional<DiscountTier>findMaxDiscountTier(CandidateOrderOffer offer, javax.money.MonetaryAmount amount)protected javax.money.MonetaryAmountgetEstimatedVoucherValue(EnhancedOrder order, Offer offer)protected OrderAndItemOfferHelpergetHelper()protected voidlogIfDebugOn(String message, Object... formatArgs)Checks ifLog.isDebugEnabled()debug is enabled}, then wraps the message inString.format(String, Object...)with the givenformatArgsand logs it.protected voidlogIfTraceOn(String message, Object... formatArgs)Checks ifLog.isTraceEnabled()trace is enabled}, then wraps the message inString.format(String, Object...)with the givenformatArgsand logs it.
-
-
-
Constructor Detail
-
DefaultOrderOfferProcessor
public DefaultOrderOfferProcessor(OrderAndItemOfferHelper helper)
-
-
Method Detail
-
findBestOrderOffersForPermutation
public void findBestOrderOffersForPermutation(OfferProcessingContext context, CombinedTypesOfferPermutation ctop)
- Specified by:
findBestOrderOffersForPermutationin interfaceOrderOfferProcessor
-
applyOrderAdjustments
public void applyOrderAdjustments(OfferProcessingContext context, OrderOfferPermutationResult orderOfferPermutationResult)
- Specified by:
applyOrderAdjustmentsin interfaceOrderOfferProcessor
-
computeOfferPermutationValue
protected OrderOfferPermutationResult computeOfferPermutationValue(OfferProcessingContext context, OffersPermutation<CandidateOrderOffer> offerPermutation, OrderTotals orderTotals)
-
couldOfferApplyToOrder
protected boolean couldOfferApplyToOrder(EnhancedOrder order, CandidateOrderOffer orderOffer)
-
createOrderOfferAdjustment
protected OrderOfferAdjustment createOrderOfferAdjustment(OfferProcessingContext context, CandidateOrderOffer orderOffer, javax.money.MonetaryAmount amount)
-
addVoucherToResult
protected void addVoucherToResult(OfferProcessingContext context, OrderOfferPermutationResult result, CandidateOrderOffer orderOffer)
- Parameters:
result- theOrderOfferPermutationResultto add theVouchertoorderOffer- thevoucher offerto build theVoucherfrom
-
buildVoucher
protected com.broadleafcommerce.promotion.offer.client.web.context.info.Voucher buildVoucher(Offer voucherOffer)
-
getEstimatedVoucherValue
protected javax.money.MonetaryAmount getEstimatedVoucherValue(EnhancedOrder order, Offer offer)
-
computeAdjustmentValue
protected Optional<javax.money.MonetaryAmount> computeAdjustmentValue(CandidateOrderOffer orderOffer, OfferProcessingContext context, OrderTotals totals)
Calculates the value of the adjustment by first getting the current value of the order and then calculating the value of this adjustment.If this adjustment value is greater than the currentOrderValue (e.g. would make the order go negative then the adjustment value is set to the value of the order).
-
findMaxDiscountTier
protected Optional<DiscountTier> findMaxDiscountTier(CandidateOrderOffer offer, javax.money.MonetaryAmount amount)
-
logIfTraceOn
protected void logIfTraceOn(String message, Object... formatArgs)
Checks ifLog.isTraceEnabled()trace is enabled}, then wraps the message inString.format(String, Object...)with the givenformatArgsand logs it.
-
logIfDebugOn
protected void logIfDebugOn(String message, Object... formatArgs)
Checks ifLog.isDebugEnabled()debug is enabled}, then wraps the message inString.format(String, Object...)with the givenformatArgsand logs it.
-
getHelper
protected OrderAndItemOfferHelper getHelper()
-
-