|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.softslate.commerce.businessobjects.core.BaseBusinessObject
com.softslate.commerce.businessobjects.core.BaseBusinessProcessor
com.softslate.commerce.businessobjects.order.BasicCartDiscountProcessor
public class BasicCartDiscountProcessor
Processes business logic having to do with discounts in a user's cart.
BasicCartDiscountProcessor is the default implementation of the
CartDiscountProcessor interface for the application.
InventoryProcessor| Field Summary | |
|---|---|
(package private) static org.apache.commons.logging.Log |
log
|
| Constructor Summary | |
|---|---|
BasicCartDiscountProcessor()
|
|
| Method Summary | |
|---|---|
void |
addOrderItemToSkuDiscount(Discount ad,
OrderItem oi)
|
void |
addSkuDiscount(java.util.Collection skuDiscountsToApply,
Discount discount,
OrderItem oi)
|
java.util.Map |
calculateDiscount(Discount discount,
java.lang.Double totalToDiscount,
java.lang.Integer quantity)
Calculated the value of a discount as applied to the current user's cart. |
java.util.Map |
defineDiscountSettings(Product product,
java.util.Collection attributeSKUCollection,
java.util.Collection storeDiscounts)
Inspects a Product and returns a Map of useful variables related to the state of the product's discounts. |
java.lang.Double |
excludeGiftCertificateProducts(Discount discount,
java.lang.Double totalToDiscount,
java.lang.Integer quantity)
When computing a global discount, exclude the value of any gift certificates that are being purchased if called for by the setting 'excludeGiftCertificatesFromDiscounts'. |
java.util.Collection |
getDiscountsBySkuIDs(java.util.Collection skuIDs)
Returns a Collection of
Discount objects
associated with the given Collection of
SKU ids. |
java.util.Collection |
getGlobalDiscounts()
Returns a Collection of global
Discount objects
that are not associated with a particular SKU. |
java.lang.Double |
getPreviousOrderTotal()
Looks up the total of all of the orders the current user has previously placed. |
java.util.Collection |
getSkuIDs(OrderItem oi,
java.util.Collection matchingSkus)
|
java.lang.Integer |
getTimesUsedByCustomer(Discount discount)
Looks up the number of times the current user has used a given Discount. |
boolean |
isCartItemsOk(Discount discount)
Checks that the current user's cart contains the required items to use a given Discount
based on its settings. |
boolean |
isCouponOk(Discount discount)
Checks that a given Discount either is
not a coupon, or is a coupon whose code the current user has already
entered in the session. |
boolean |
isDiscountOk(Discount discount,
java.lang.Double previousOrderTotal)
Checks that a given discount is applicable. |
boolean |
isDiscountOkIfItemInCart(Discount discount,
java.lang.Double previousOrderTotal,
java.lang.String productCode)
Checks if a given discount would be applicable, if the given product code were in the user's cart. |
boolean |
isItemWouldAllowDiscount(Discount discount,
java.lang.String productCode)
Checks whether the given productCode is among the products that are required to be in the user's cart for the Discount to apply,
based on its settings. |
boolean |
isShippingMethodOk(Discount discount)
Checks that the current user's cart contains the required shipping method to use a given Discount based on
its settings. |
boolean |
isStartedAndNotExpired(Discount discount)
Checks that the current time is not before a given Discount's start
date or after its expiration date. |
boolean |
isTimesUsedOk(Discount discount)
Checks that a given Discount has not
been used more than the maximum number of times it's allowed to be used. |
boolean |
isUserQualified(Discount discount,
java.lang.Double previousOrderTotal)
Checks that the current user is qualified to use a given Discount based on
its settings. |
java.util.Collection |
loadGiftCertificates()
Returns a Collection of gift certificate
Discount objects
matching the list of coupon/gift certificate codes that the current user
has entered. |
java.util.Collection |
loadShippingDiscounts()
Returns a Collection of shipping discounts -
Discount objects
matching the list of coupon codes that the current user has entered. |
java.util.Map |
processAddItems(java.util.Collection newOrderItems)
Processes discounts upon adding an item or items to the user's cart. |
java.util.Map |
processAfterTaxes(java.util.Map parameters)
Processes discounts after shipping and taxes have been calculated. |
java.util.Map |
processCouponCode(java.util.Map parameters)
Processes discounts as a user enters a coupon code. |
java.util.Map |
processCustomerLogin(java.util.Map parameters)
Processes discounts as a customer logs in. |
java.util.Map |
processCustomerLogout(java.util.Map parameters)
Processes discounts as a customer logs out. |
java.util.Map |
processDiscounts(java.util.Collection newOrderItems)
Processes discount for the current user and his or her cart. |
java.util.Map |
processGiftCertificates()
Queries for and applies the gift certs applicable for the user/order. |
java.util.Map |
processGlobalDiscounts()
Processes global discounts, which are not associated with specific SKUs. |
java.util.Map |
processOnCheckout(java.util.Map parameters)
Processes discounts during checkout, as taxes and shipping are processed. |
java.util.Map |
processOrderComplete(java.util.Map parameters)
Processes discounts as a user's order is completed. |
java.util.Map |
processRemoveDiscounts()
Removes all the discounts in the current user's cart. |
java.util.Map |
processShippingDiscounts()
Queries for and inserts the shipping discounts applicable for the user/order. |
java.util.Collection |
processShippingDiscountsOnShippingOptions(java.util.Collection shippingOptions)
Applies shipping discounts to each of the shipping options in the incoming Collection. |
java.util.Map |
processSkuDiscounts(java.util.Collection orderItems)
Processes discounts associated with specific SKUs in the current user's cart. |
java.util.Map |
processTimesUsed()
|
java.util.Map |
processTimesUsed(int addOrSubtract)
|
void |
updateGiftCertOrderAndDeliveryTotals(java.lang.Double discountTotal)
Subtracts a gift certificate total from the current user's order's total (rather than its subtotal as is the case for other types of discounts). |
void |
updateOrderAndDeliveryTotals(java.lang.Double discountTotal)
Subtracts a discount total from the current user's order. |
| Methods inherited from class com.softslate.commerce.businessobjects.core.BaseBusinessProcessor |
|---|
formatDateTime, formatPrice, getAppComponents, getAppSettings, getAttributeIDs, getBusinessObjectFactory, getDaoFactory, getProductIDs, getSettings, getUser, initialize, loadMatchingSkus, parseDateTime, parseResponseData, prepareRequestData, sendHTTPPost, sendHTTPPost, setAppComponents, setAppSettings, setBusinessObjectFactory, setDaoFactory, setSettings, setUser, updateOrderTotals, updateOrderTotals, utils |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static org.apache.commons.logging.Log log
| Constructor Detail |
|---|
public BasicCartDiscountProcessor()
| Method Detail |
|---|
public java.util.Map processAddItems(java.util.Collection newOrderItems)
throws java.lang.Exception
CartDiscountProcessorprocessDiscounts(Collection)
processAddItems in interface CartDiscountProcessornewOrderItems - The collection of OrderItem objects being added
to the cart.
Map containing results of the processing. The
default implementation returns null.
java.lang.Exception
public java.util.Map processCouponCode(java.util.Map parameters)
throws java.lang.Exception
CartDiscountProcessorprocessDiscounts(Collection)
processCouponCode in interface CartDiscountProcessorparameters - A Map with any parameters needed for the
processing. The default implementation does not use this
argument.
Map containing results of the processing. The
default implementation returns null.
java.lang.Exception
public java.util.Map processOnCheckout(java.util.Map parameters)
throws java.lang.Exception
CartDiscountProcessorprocessDiscounts(Collection)
processOnCheckout in interface CartDiscountProcessorparameters - A Map with any parameters needed for the
processing. The default implementation does not use this
argument.
Map containing results of the processing. The
default implementation returns null.
java.lang.Exception
public java.util.Map processAfterTaxes(java.util.Map parameters)
throws java.lang.Exception
CartDiscountProcessorprocessDiscounts(Collection)
processAfterTaxes in interface CartDiscountProcessorparameters - A Map with any parameters needed for the
processing. The default implementation does not use this
argument.
Map containing results of the processing. The
default implementation returns null.
java.lang.Exception
public java.util.Map processCustomerLogin(java.util.Map parameters)
throws java.lang.Exception
CartDiscountProcessorprocessDiscounts(Collection)
processCustomerLogin in interface CartDiscountProcessorparameters - A Map with any parameters needed for the
processing. The default implementation does not use this
argument.
Map containing results of the processing. The
default implementation returns null.
java.lang.Exception
public java.util.Map processCustomerLogout(java.util.Map parameters)
throws java.lang.Exception
CartDiscountProcessorprocessDiscounts(Collection)
processCustomerLogout in interface CartDiscountProcessorparameters - A Map with any parameters needed for the
processing. The default implementation does not use this
argument.
Map containing results of the processing. The
default implementation returns null.
java.lang.Exception
public java.util.Map processOrderComplete(java.util.Map parameters)
throws java.lang.Exception
CartDiscountProcessorprocessDiscounts(Collection)
processOrderComplete in interface CartDiscountProcessorparameters - A Map with any parameters needed for the
processing. The default implementation does not use this
argument.
Map containing results of the processing. The
default implementation returns null.
java.lang.Exception
public java.util.Map processDiscounts(java.util.Collection newOrderItems)
throws java.lang.Exception
newOrderItems - The Collection of OrderItems in the
user's cart.
Map containing results of the processing. This
implementation returns null.
java.lang.Exception
public java.util.Map processRemoveDiscounts()
throws java.lang.Exception
CartDiscountProcessorBasicCartProcessor.processRemoveItem(OrderItem)
processRemoveDiscounts in interface CartDiscountProcessorMap containing results of the processing. The
default implementation returns null.
java.lang.Exception
public java.util.Map processSkuDiscounts(java.util.Collection orderItems)
throws java.lang.Exception
orderItems - The Collection of OrderItems in the
user's cart.
Map containing results of the processing. This
implementation returns null.
java.lang.Exception
public java.util.Map processGlobalDiscounts()
throws java.lang.Exception
Map containing results of the processing. This
implementation returns null.
java.lang.Exception
public java.util.Map processShippingDiscounts()
throws java.lang.Exception
java.lang.Exception
public java.util.Collection processShippingDiscountsOnShippingOptions(java.util.Collection shippingOptions)
throws java.lang.Exception
CartDiscountProcessor
processShippingDiscountsOnShippingOptions in interface CartDiscountProcessorjava.lang.Exception
public java.util.Map processGiftCertificates()
throws java.lang.Exception
java.lang.Exception
public java.util.Map processTimesUsed()
throws java.lang.Exception
java.lang.Exception
public java.util.Map processTimesUsed(int addOrSubtract)
throws java.lang.Exception
java.lang.Exception
public java.util.Collection getSkuIDs(OrderItem oi,
java.util.Collection matchingSkus)
public java.util.Collection getDiscountsBySkuIDs(java.util.Collection skuIDs)
throws java.lang.Exception
Collection of
Discount objects
associated with the given Collection of
SKU ids. Used
during SKU discount processing.
skuIDs - A Collection of
SKU
ids.
Collection of
Discount
objects
java.lang.Exception
public java.util.Collection getGlobalDiscounts()
throws java.lang.Exception
Collection of global
Discount objects
that are not associated with a particular SKU. Used during
global discount processing.
Collection of
Discount
objects
java.lang.Exception
public java.util.Collection loadShippingDiscounts()
throws java.lang.Exception
Collection of shipping discounts -
Discount objects
matching the list of coupon codes that the current user has entered. Used
during discount processing.
Collection of
Discount
objects
java.lang.Exception
public java.util.Collection loadGiftCertificates()
throws java.lang.Exception
Collection of gift certificate
Discount objects
matching the list of coupon/gift certificate codes that the current user
has entered. Used during discount processing.
Collection of
Discount
objects
java.lang.Exception
public boolean isDiscountOk(Discount discount,
java.lang.Double previousOrderTotal)
throws java.lang.Exception
This method calls the following methods in turn:
isStartedAndNotExpired(Discount)isCouponOk(Discount)isUserQualified(Discount, Double)isCartItemsOk(Discount)isTimesUsedOk(Discount)
isDiscountOk in interface CartDiscountProcessordiscount - The discount whose applicability is being checked.previousOrderTotal - The previous order total of the current user, or null. Some
discount are only applicable if the user has previously placed
orders totaling a certain amount.
java.lang.Exception
public boolean isDiscountOkIfItemInCart(Discount discount,
java.lang.Double previousOrderTotal,
java.lang.String productCode)
throws java.lang.Exception
This method calls the following methods in turn:
isStartedAndNotExpired(Discount)isCouponOk(Discount)isUserQualified(Discount, Double)isTimesUsedOk(Discount)
isDiscountOkIfItemInCart in interface CartDiscountProcessordiscount - The discount whose applicability is being checked.previousOrderTotal - The previous order total of the current user, or null. Some
discount are only applicable if the user has previously placed
orders totaling a certain amount.
java.lang.Exception
public boolean isStartedAndNotExpired(Discount discount)
throws java.lang.Exception
Discount's start
date or after its expiration date.
discount - The Discount to check.
Discount
's start date or after its expiration date.
java.lang.Exception
public boolean isTimesUsedOk(Discount discount)
throws java.lang.Exception
Discount has not
been used more than the maximum number of times it's allowed to be used.
discount - The Discount to check.
Discount has not been used more than
the maximum number of times it's allowed to be used.
java.lang.Exception
public boolean isCouponOk(Discount discount)
throws java.lang.Exception
Discount either is
not a coupon, or is a coupon whose code the current user has already
entered in the session.
discount - The Discount to check.
Discount either is not a coupon, or is
a coupon whose code the current user has already entered in the
session.
java.lang.ExceptionUser.getEnteredCouponCodes()
public boolean isUserQualified(Discount discount,
java.lang.Double previousOrderTotal)
throws java.lang.Exception
Discount based on
its settings.
discount - The Discount to check.previousOrderTotal - The previous order total of the current user, or null. Some
discounts are only applicable if the user has previously
placed orders totalling a certain amount.
Discount.
java.lang.Exception
public boolean isCartItemsOk(Discount discount)
throws java.lang.Exception
Discount
based on its settings.
discount - The Discount to check.
Discount.
java.lang.Exception
public boolean isShippingMethodOk(Discount discount)
throws java.lang.Exception
Discount based on
its settings.
discount - The Discount to check.
Discount.
java.lang.Exception
public boolean isItemWouldAllowDiscount(Discount discount,
java.lang.String productCode)
throws java.lang.Exception
Discount to apply,
based on its settings.
discount - The Discount to check.
Discount.
java.lang.Exception
public java.lang.Double getPreviousOrderTotal()
throws java.lang.Exception
java.lang.Exception
public java.lang.Integer getTimesUsedByCustomer(Discount discount)
throws java.lang.Exception
Discount.
discount - The Discount to check.
Integer representing the number of times the
current user has used the Discount.
java.lang.Exception
public java.util.Map calculateDiscount(Discount discount,
java.lang.Double totalToDiscount,
java.lang.Integer quantity)
discount - The Discount to be applied.totalToDiscount - The total that the discount is to be applied against.
Discounts are not allowed to be more than the amount they are
being applied against.quantity - The total number of items in the user's cart, or the quantity
of an DiscountRange
that corresponds to the total number of items in the user's
cart (in the case of global discounts), or the quantity of an
OrderItem correponding to a SKU
associated with the discount (in the case of SKU
discounts).
Map with information about the discount, and a key
named "discountTotal", holding the calculated value of the
discount.
public java.lang.Double excludeGiftCertificateProducts(Discount discount,
java.lang.Double totalToDiscount,
java.lang.Integer quantity)
discount - totalToDiscount - quantity -
public void updateOrderAndDeliveryTotals(java.lang.Double discountTotal)
discountTotal - The discount total to subtract.public void updateGiftCertOrderAndDeliveryTotals(java.lang.Double discountTotal)
discountTotal - The discount total to subtract.
public void addSkuDiscount(java.util.Collection skuDiscountsToApply,
Discount discount,
OrderItem oi)
public void addOrderItemToSkuDiscount(Discount ad,
OrderItem oi)
public java.util.Map defineDiscountSettings(Product product,
java.util.Collection attributeSKUCollection,
java.util.Collection storeDiscounts)
throws java.lang.Exception
CartDiscountProcessor
defineDiscountSettings in interface CartDiscountProcessorattributeSKUCollection - An optional Collection of attribute-only SKUs used to define
the inventory settings that are returned.storeDiscounts - An optional Collection of global, store discounts, used to
determine if "promotions" for the product exist, ie, discounts
that would be applied if the product were added to the cart.
java.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||