Interface PromotionActionService
-
- All Known Implementing Classes:
DefaultPromotionActionService
public interface PromotionActionServiceEncapsulates logic for taking actions to apply promotions.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcreateDiscountValue(DiscountRAO discountRao, java.lang.String code, AbstractOrderEntryModel orderEntry)Creates aDiscountValuefrom the givendiscountRaoand adds it to the givenorderEntry.voidcreateDiscountValue(DiscountRAO discountRao, java.lang.String code, AbstractOrderModel order)Creates aDiscountValuefrom the givendiscountRaoand adds it to the givenorder.PromotionResultModelcreatePromotionResult(AbstractRuleActionRAO action)Creates aPromotionResultModelobject for the givenAbstractRuleActionRAO.AbstractOrderModelgetOrder(AbstractRuleActionRAO action)Returns the order for the givenaction.AbstractOrderEntryModelgetOrderEntry(AbstractRuleActionRAO action)Looks up theAbstractOrderEntryModelbased on the given AbstractRuleActionRAO.AbstractRuleEngineRuleModelgetRule(AbstractRuleActionRAO action)Returns the rule for the givenaction.voidrecalculateFiredPromotionMessage(PromotionResultModel promoResult)Recalculates promotion fired message and stores it in providedPromotionResultModel.voidrecalculateTotals(AbstractOrderModel order)Recalculates totals for the givenorder.java.util.List<ItemModel>removeDiscountValue(java.lang.String code, AbstractOrderModel order)Removes theDiscountValuewith the given code from the givenorderand its order entries.
-
-
-
Method Detail
-
recalculateFiredPromotionMessage
void recalculateFiredPromotionMessage(PromotionResultModel promoResult)
Recalculates promotion fired message and stores it in providedPromotionResultModel. This method should be used for potential promotion only to update computed values displayed in the message- Parameters:
promoResult- a promotion result that holds fired promotion message which needs to be updated
-
createPromotionResult
PromotionResultModel createPromotionResult(AbstractRuleActionRAO action)
Creates aPromotionResultModelobject for the givenAbstractRuleActionRAO.- Parameters:
action- the action rao to use for the promotion result creation- Returns:
- the newly created (not persisted!)
PromotionResultModel.
-
createDiscountValue
void createDiscountValue(DiscountRAO discountRao, java.lang.String code, AbstractOrderModel order)
Creates aDiscountValuefrom the givendiscountRaoand adds it to the givenorder. Note: The order is not saved!- Parameters:
discountRao- the discountRao to take the values fromcode- the code for the new DiscountValue (e.g. UUID from the respectiveAbstractPromotionActionModelthat creates this discount)order- the order to apply the discount value to
-
removeDiscountValue
java.util.List<ItemModel> removeDiscountValue(java.lang.String code, AbstractOrderModel order)
Removes theDiscountValuewith the given code from the givenorderand its order entries. Returns the list of all modified items (order, order entries). Note: The returned items are not saved!- Parameters:
code- the code for the DiscountValue to be removedorder- the order to remove the discount value from- Returns:
- all items (order, order entries) that have been modified and need saving
-
createDiscountValue
void createDiscountValue(DiscountRAO discountRao, java.lang.String code, AbstractOrderEntryModel orderEntry)
Creates aDiscountValuefrom the givendiscountRaoand adds it to the givenorderEntry. Note: The orderEntry is not saved!- Parameters:
discountRao- the discountRao to take the values fromcode- the code for the new DiscountValue (e.g. UUID from the respectiveAbstractPromotionActionModelthat creates this discount)orderEntry- the orderEntry to apply the discount value to
-
getOrderEntry
AbstractOrderEntryModel getOrderEntry(AbstractRuleActionRAO action)
Looks up theAbstractOrderEntryModelbased on the given AbstractRuleActionRAO.- Parameters:
action- the action to use for the look-up- Returns:
- the AbstractOrderEntryModel
-
getOrder
AbstractOrderModel getOrder(AbstractRuleActionRAO action)
Returns the order for the givenaction.- Parameters:
action- the orderRao- Returns:
- the order or null if no order is found
-
getRule
AbstractRuleEngineRuleModel getRule(AbstractRuleActionRAO action)
Returns the rule for the givenaction.- Parameters:
action- the action rao- Returns:
- the rule or null if no rule is found
-
recalculateTotals
void recalculateTotals(AbstractOrderModel order)
Recalculates totals for the givenorder.- Parameters:
order- the order to recalculate its totals
-
-