|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.elasticpath.domain.impl.AbstractEpDomainImpl
com.elasticpath.domain.impl.AbstractPersistenceImpl
com.elasticpath.domain.impl.AbstractValueObjectImpl
com.elasticpath.domain.rules.impl.PromotionRuleDelegateImpl
public class PromotionRuleDelegateImpl
This interface provides helper methods that can be invoked from Drools code to make queries on the system. The intent of this interface/implementation is to move as much logic as possible out of the rule code so that the drools code is as simple as possible.
| Field Summary | |
|---|---|
static long |
serialVersionUID
Serial version id. |
| Constructor Summary | |
|---|---|
PromotionRuleDelegateImpl()
The default constructor. |
|
| Method Summary | |
|---|---|
void |
applyCartSkuDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
java.lang.String skuCode,
java.lang.String amount,
int maxItems,
java.lang.String exceptionStr)
Apply a discount amount to a product in the cart. |
void |
applyCartSkuDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
java.lang.String skuCode,
java.lang.String percent,
int maxItems,
java.lang.String exceptionStr)
Apply a discount amount to a product in the cart. |
void |
applyCatalogProductDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
Product product,
java.util.Currency currency,
java.lang.String amount,
java.lang.String exceptionStr)
Reduces the price of a product by the specified amount. |
void |
applyCatalogSkuDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
Product product,
java.lang.String skuCode,
java.util.Currency currency,
java.lang.String amount)
Reduces the price of a sku by the specified amount. |
void |
applyCatalogSkuDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
Product product,
java.lang.String skuCode,
java.util.Currency currency,
java.lang.String percent)
Reduces the price of a sku by the specified amount. |
void |
applyNFreeSkus(ShoppingCart shoppingCart,
long ruleId,
java.lang.String skuCode,
int numSkus)
Add N items of a product to the cart at a zero price. |
void |
applyNthProductDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
long productId,
java.lang.String percent,
int nthItem,
java.lang.String exceptionStr)
Apply a percentage discount to the Nth item of a given product in the cart. |
void |
applyOrderCategoryDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
long categoryId,
java.lang.String amount,
int maxItems,
java.lang.String exceptionStr)
Apply a discount amount to all items in a particular category in the cart. |
void |
applyOrderCategoryDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
long categoryId,
java.lang.String percent,
int maxItems,
java.lang.String exceptionStr)
Apply a percentage discount to all items in a particular category in the cart. |
void |
applyOrderDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
java.lang.String amount)
Reduces the subtotal of the shopping cart by the specified amount. |
void |
applyOrderDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
java.lang.String percent)
Reduces the subtotal of the shopping cart by the specified percent. |
void |
applyProductDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
long productId,
java.lang.String amount,
int maxItems,
java.lang.String exceptionStr)
Apply a discount amount to a product in the cart. |
void |
applyProductDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
long productId,
java.lang.String percent,
int maxItems,
java.lang.String exceptionStr)
Apply a percentage discount to a product in the cart. |
void |
applyProductDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
Product product,
java.util.Currency currency,
java.lang.String percent,
java.lang.String exceptionStr)
Reduces the price of a product by the specified percent. |
void |
applyShippingDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
java.lang.String amount,
long shippingMethodId)
Reduces the shipping cost of the shopping cart by the specified amount. |
void |
applyShippingDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
java.lang.String percent,
long shippingMethodId)
Reduces the shipping cost of the shopping cart by the specified percent. |
boolean |
cartContainsItemsOfCategory(ShoppingCart shoppingCart,
long categoryId,
int numItems,
java.lang.String exceptionStr)
Checks if the shopping cart contains the specified quantity of items of the given product. |
boolean |
cartContainsProduct(ShoppingCart shoppingCart,
long productId,
int quantity,
java.lang.String exceptionStr)
Checks if the shopping cart contains the specified quantity of items of the given product. |
boolean |
cartContainsSku(ShoppingCart shoppingCart,
java.lang.String skuCode,
int quantity)
Checks if the shopping cart contains the specified quantity of items with the specified sku code. |
boolean |
cartCurrencyMatches(ShoppingCart shoppingCart,
java.lang.String currencyCode)
Checks if the currency of a shopping cart matches the specified currency code. |
boolean |
cartHasPromoCode(ShoppingCart shoppingCart,
java.lang.String promoCode)
Checks if the shopping cart has the specified promo code entered by the user. |
boolean |
cartSubtotalExceeds(ShoppingCart shoppingCart,
java.lang.String amount,
java.lang.String exceptionStr)
Checks if the shopping cart subtotal exceeds the specified amount. |
boolean |
catalogBrandIs(Product product,
boolean isBrand,
java.lang.String brandCode,
java.lang.String exceptionStr)
Returns true if the given product is/is not of the specified brand. |
boolean |
catalogProductInCategory(Product product,
boolean isIn,
long categoryUid,
java.lang.String exceptionStr)
Checks if the given product is in the category with the specified categoryID. |
boolean |
catalogProductIs(Product product,
boolean isProduct,
long productUid,
java.lang.String exceptionStr)
Returns true if the given product is/is not the product with the specified Id. |
boolean |
checkDateRange(java.lang.String startDateString,
java.lang.String endDateString)
Checks that the current date is between the specified dates. |
boolean |
customerInGroup(ShoppingCart shoppingCart,
long customerGroup)
Checks if the customer is in the specified customer group. |
boolean |
isExistingCustomer(ShoppingCart shoppingCart)
Checks if the customer already has an account in the system. |
boolean |
isFirstTimeBuyer(ShoppingCart shoppingCart)
Checks if the customer is a first time buyer. |
void |
setOrderService(OrderService orderService)
Set the OrderService. |
void |
setProductSkuService(ProductSkuService productSkuService)
Set the ProductSkuService. |
| Methods inherited from class com.elasticpath.domain.impl.AbstractPersistenceImpl |
|---|
executeBeforePersistAction, getUidPk, isPersistent, setDefaultValues, setUidPk |
| Methods inherited from class com.elasticpath.domain.impl.AbstractEpDomainImpl |
|---|
getElasticPath, setElasticPath |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.elasticpath.domain.Persistence |
|---|
executeBeforePersistAction, getUidPk, isPersistent, setDefaultValues, setUidPk |
| Methods inherited from interface com.elasticpath.domain.EpDomain |
|---|
getElasticPath, setElasticPath |
| Field Detail |
|---|
public static final long serialVersionUID
| Constructor Detail |
|---|
public PromotionRuleDelegateImpl()
| Method Detail |
|---|
public void applyCartSkuDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
java.lang.String skuCode,
java.lang.String amount,
int maxItems,
java.lang.String exceptionStr)
applyCartSkuDiscountAmount in interface PromotionRuleDelegateshoppingCart - the shopping cart to have a discountedruleId - the id of the rule executing this actionskuCode - the sku code of the sku to be discountedamount - the amount of the discountmaxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public void applyCartSkuDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
java.lang.String skuCode,
java.lang.String percent,
int maxItems,
java.lang.String exceptionStr)
applyCartSkuDiscountPercent in interface PromotionRuleDelegateshoppingCart - the shopping cart to have a discountedruleId - the id of the rule executing this actionskuCode - the sku code of the sku to be discountedpercent - the percentage of the promotion X 100 (e.g. 50 means 50% off).maxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public void applyCatalogProductDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
Product product,
java.util.Currency currency,
java.lang.String amount,
java.lang.String exceptionStr)
applyCatalogProductDiscountAmount in interface PromotionRuleDelegateshoppingCart - the customer's shopping cartruleId - the id of the rule executing this actionproduct - the product to be discountedcurrency - the Currency of the price to be reducedamount - the percentage of the promotion X 100 (e.g. 50 means 50% off).exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public void applyCatalogSkuDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
Product product,
java.lang.String skuCode,
java.util.Currency currency,
java.lang.String amount)
applyCatalogSkuDiscountAmount in interface PromotionRuleDelegateshoppingCart - the customer's shopping cartruleId - the id of the rule executing this actionproduct - the product containing the SKU to be discountedskuCode - the SKU code for the sku to be discountedcurrency - the Currency of the price to be reducedamount - the percentage of the promotion X 100 (e.g. 50 means 50% off).
public void applyCatalogSkuDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
Product product,
java.lang.String skuCode,
java.util.Currency currency,
java.lang.String percent)
applyCatalogSkuDiscountPercent in interface PromotionRuleDelegateshoppingCart - the customer's shopping cartruleId - the id of the rule executing this actionproduct - the product containing the SKU to be discountedskuCode - the SKU code for the sku to be discountedcurrency - the Currency of the price to be reducedpercent - the percentage of the promotion X 100 (e.g. 50 means 50% off).
public void applyNFreeSkus(ShoppingCart shoppingCart,
long ruleId,
java.lang.String skuCode,
int numSkus)
applyNFreeSkus in interface PromotionRuleDelegateshoppingCart - the shopping cart to have products discountedruleId - the id of the rule executing this actionskuCode - the sku code of the sku to be added to the cartnumSkus - the number of items to give for free
public void applyNthProductDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
long productId,
java.lang.String percent,
int nthItem,
java.lang.String exceptionStr)
applyNthProductDiscountPercent in interface PromotionRuleDelegateshoppingCart - the shopping cart to have products discountedruleId - the id of the rule executing this actionproductId - the id of the product to be discountedpercent - the percentage of the promotion X 100 (e.g. 50 means 50% off, 100 means free).nthItem - the number of items that must be present before one is discountedexceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public void applyOrderCategoryDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
long categoryId,
java.lang.String amount,
int maxItems,
java.lang.String exceptionStr)
applyOrderCategoryDiscountAmount in interface PromotionRuleDelegateshoppingCart - the shopping cart to have items in a category discountedruleId - the id of the rule executing this actioncategoryId - the id of the category that the promotion applies toamount - the amount by which the price is to be reducedmaxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public void applyOrderCategoryDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
long categoryId,
java.lang.String percent,
int maxItems,
java.lang.String exceptionStr)
applyOrderCategoryDiscountPercent in interface PromotionRuleDelegateshoppingCart - the shopping cart to have items in a category discountedruleId - the id of the rule executing this actioncategoryId - the id of the category that the promotion applies topercent - the percentage of the promotion X 100 (e.g. 50 means 50% off).maxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public void applyOrderDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
java.lang.String amount)
applyOrderDiscountAmount in interface PromotionRuleDelegateshoppingCart - the shopping cart that the discount is to be applied toruleId - the id of the rule executing this actionamount - the amount by which to reduce the subtotal
public void applyOrderDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
java.lang.String percent)
applyOrderDiscountPercent in interface PromotionRuleDelegateshoppingCart - the shopping cart that the discount is to be applied toruleId - the id of the rule executing this actionpercent - the percent by which to reduce the subtotal
public void applyProductDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
long productId,
java.lang.String amount,
int maxItems,
java.lang.String exceptionStr)
applyProductDiscountAmount in interface PromotionRuleDelegateshoppingCart - the shopping cart to have a discountedruleId - the id of the rule executing this actionproductId - the id of the product to be discountedamount - the amount of the discountmaxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public void applyProductDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
long productId,
java.lang.String percent,
int maxItems,
java.lang.String exceptionStr)
applyProductDiscountPercent in interface PromotionRuleDelegateshoppingCart - the shopping cart to have a discountedruleId - the id of the rule executing this actionproductId - the id of the product to be discountedpercent - the percentage of the promotion X 100 (e.g. 50 means 50% off, 100 means free).maxItems - the maximum number of items to apply the promotion to. Set to zero for unlimited.exceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public void applyProductDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
Product product,
java.util.Currency currency,
java.lang.String percent,
java.lang.String exceptionStr)
applyProductDiscountPercent in interface PromotionRuleDelegateshoppingCart - the customer's shopping cartruleId - the id of the rule executing this actionproduct - the product to be discountedcurrency - the Currency of the price to be reducedpercent - the amount that the price should be reducedexceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public void applyShippingDiscountAmount(ShoppingCart shoppingCart,
long ruleId,
java.lang.String amount,
long shippingMethodId)
applyShippingDiscountAmount in interface PromotionRuleDelegateshoppingCart - the shopping cart that the shipping discount is to be applied toruleId - the id of the rule executing this actionamount - the amount by which to reduce the shipping costshippingMethodId - the shipping method that this discount applies to
public void applyShippingDiscountPercent(ShoppingCart shoppingCart,
long ruleId,
java.lang.String percent,
long shippingMethodId)
applyShippingDiscountPercent in interface PromotionRuleDelegateshoppingCart - the shopping cart that the shipping discount is to be applied toruleId - the id of the rule executing this actionpercent - the percent by which to reduce the shipping cost (String value from 1 to 100)shippingMethodId - the shipping method that this discount applies to
public boolean cartContainsItemsOfCategory(ShoppingCart shoppingCart,
long categoryId,
int numItems,
java.lang.String exceptionStr)
cartContainsItemsOfCategory in interface PromotionRuleDelegateshoppingCart - the shopping cart to checkcategoryId - the category id that must be in the cartnumItems - the minimum quantity of items of the category that must be presentexceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
quantity items with productId in the cart
public boolean cartContainsProduct(ShoppingCart shoppingCart,
long productId,
int quantity,
java.lang.String exceptionStr)
cartContainsProduct in interface PromotionRuleDelegateshoppingCart - the shopping cart to checkproductId - the sku code that must be in the cartquantity - the minimum quantity of the product that must be presentexceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
quantity items with productId in the cart
public boolean cartContainsSku(ShoppingCart shoppingCart,
java.lang.String skuCode,
int quantity)
cartContainsSku in interface PromotionRuleDelegateshoppingCart - the shopping cart to checkskuCode - the sku code that must be in the cartquantity - the quantity of the sku that must be present
quantity items with skuCode in the cart
public boolean cartCurrencyMatches(ShoppingCart shoppingCart,
java.lang.String currencyCode)
cartCurrencyMatches in interface PromotionRuleDelegateshoppingCart - The shopping cart to checkcurrencyCode - The currency code, e.g. CAD
public boolean cartHasPromoCode(ShoppingCart shoppingCart,
java.lang.String promoCode)
cartHasPromoCode in interface PromotionRuleDelegateshoppingCart - the shopping cart to check for the promo codepromoCode - the promo code to check for.
public boolean cartSubtotalExceeds(ShoppingCart shoppingCart,
java.lang.String amount,
java.lang.String exceptionStr)
cartSubtotalExceeds in interface PromotionRuleDelegateshoppingCart - the shopping cart to checkamount - the amount the shopping cart must exceedexceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public boolean catalogBrandIs(Product product,
boolean isBrand,
java.lang.String brandCode,
java.lang.String exceptionStr)
catalogBrandIs in interface PromotionRuleDelegateproduct - the product whose condition is to be checkedisBrand - set to true to check that the brand is the one with the specified Id, or false to check that it is not the brand with the
specified id.brandCode - the code of the brand to check forexceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public boolean catalogProductInCategory(Product product,
boolean isIn,
long categoryUid,
java.lang.String exceptionStr)
catalogProductInCategory in interface PromotionRuleDelegateproduct - the productisIn - set to true to specify that the product is in the category, false to require that it isn't in the categorycategoryUid - the id of the category to check if the product is in itexceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public boolean catalogProductIs(Product product,
boolean isProduct,
long productUid,
java.lang.String exceptionStr)
catalogProductIs in interface PromotionRuleDelegateproduct - the product whose condition is to be checkedisProduct - set to true to check that the product is the one with the specified Id, or false to check that it is not the product with the
specified id.productUid - the id of the product to check forexceptionStr - exceptions to this rule element; to be used to populate the PromotionRuleExceptions.
public boolean checkDateRange(java.lang.String startDateString,
java.lang.String endDateString)
checkDateRange in interface PromotionRuleDelegatestartDateString - the start date represented as a long (milliseconds) in a string. 0 means no start date restriction on the date range.endDateString - the end date represented as a long (milliseconds) in a string. 0 means no end date. Longs are not supported by Drools so
the dates are passed as strings.
public boolean customerInGroup(ShoppingCart shoppingCart,
long customerGroup)
customerInGroup in interface PromotionRuleDelegateshoppingCart - the shopping cart containing a reference to the customercustomerGroup - the customer group that the customer must belong to
public boolean isExistingCustomer(ShoppingCart shoppingCart)
isExistingCustomer in interface PromotionRuleDelegateshoppingCart - the shopping cart containing a reference to the customer
public boolean isFirstTimeBuyer(ShoppingCart shoppingCart)
isFirstTimeBuyer in interface PromotionRuleDelegateshoppingCart - the shopping cart containing a reference to the customer
public void setOrderService(OrderService orderService)
OrderService. This method should only be used by unit test code.
orderService - the OrderServicepublic void setProductSkuService(ProductSkuService productSkuService)
ProductSkuService. This method should only be used by unit test code.
productSkuService - the ProductSkuService
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||