|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.konakart.bl.BaseMgr
com.konakart.bl.PromotionMgr
public class PromotionMgr
Promotions Manager
| Nested Class Summary | |
|---|---|
protected class |
PromotionMgr.StaticData
Used to store the static data of this manager |
| Field Summary | |
|---|---|
static int |
ALL
Constant for Promotion Rule |
static int |
COUPON_DOESNT_EXIST
Coupon doesn't exist |
static int |
COUPON_EXISTS_ACTIVE
Coupon exists and is active |
static int |
COUPON_EXISTS_INACTIVE
Coupon exists but is no longer active |
static int |
EXCLUDE
Constant for Promotion Rule |
protected static int |
GIFT_CERTIFICATE_RELATION_TYPE
Constant for Promotion To Product Relation |
static int |
INCLUDE
Constant for Promotion Rule |
protected static org.apache.commons.logging.Log |
log
the log |
protected static java.lang.String |
mutex
|
protected static int |
PROMOTION_RELATION_TYPE
Constant for Promotion To Product Relation |
protected static java.util.Map<java.lang.String,PromotionMgr.StaticData> |
staticDataHM
Hash Map that contains the static data |
| Fields inherited from class com.konakart.bl.BaseMgr |
|---|
templateBaseDir |
| Constructor Summary | |
|---|---|
PromotionMgr(KKEngIf eng)
Constructor |
|
| Method Summary | |
|---|---|
protected void |
applyDiscount(ProductIf prod,
PromotionResultIf promResult,
PromotionOptionsIf options)
Apply the promotion discount to a product |
protected int |
checkCategory(Promotion prm,
ProductIf prod)
We check to see whether the product category is a category that can use the promotion. |
protected int |
checkCoupon(Promotion prm,
Order order)
If the promotion requires a coupon, we try and find one or more active coupons for the promotion that have a coupon code equal to the one in the order. |
protected int |
checkCoupon(Promotion prm,
java.lang.String[] coupons)
If the promotion requires a coupon, we try and find one or more active coupons for the promotion that have a coupon code equal to one of the ones the array. |
int |
checkCoupon(java.lang.String couponCode)
This method is used to verify whether a coupon code actually exists and if it does, whether the coupon is still active. |
protected int |
checkCustomer(Promotion prm,
int customerId)
We check to see whether the customer submitting the order is a customer that can use the promotion. |
protected int |
checkCustomerGroup(Promotion prm,
int customerId)
We check to see whether the group of the customer submitting the order is a group that can use the promotion. |
protected int |
checkCustomerUse(Promotion prm,
int customerId)
If the promotion has the maxUse attribute set to a positive value, then we check to see whether the customer can still use the promotion or whether he has already used it the maximum number of times allowed. |
protected int |
checkExpression(Promotion prm,
int customerId)
We check to see whether the expression evaluates to TRUE |
protected int |
checkManufacturer(Promotion prm,
ProductIf prod)
We check to see whether the product manufacturer is a manufacturer that can use the promotion. |
protected int |
checkProduct(Promotion prm,
OrderProductIf orderProd)
We check to see whether the product is a product that can use the promotion. |
protected boolean |
checkPromotion(Promotion prm)
Checks the validity of the promotion object. |
Promotion[] |
getAllPromotions()
Returns an array of all active promotions |
protected int |
getCustomerId(java.lang.String sessionId,
int customerId)
If the sessionId is null, we check the customerId to ensure that it is negative. |
protected OrderProduct[] |
getOrderProductsFromProduct(ProductIf prod)
Creates OrderProducts from a product so that we can reuse the checkProduct() method. |
protected int |
getPromotionIdForGiftCertificate(int productId,
int productOptionId,
int productOptionValueId)
Protected method for common code to get the promotion id of a promotion connected to a gift certificate. |
int |
getPromotionIdForGiftCertificate(OrderProductIf op)
Get the promotion id for an order product object containing a gift certificate. |
protected PromotionResultIf[] |
getPromotionResultArray(PromotionResultIf[] currentArray,
PromotionResult newResult)
Utility method to add a PromotionResult object on to the end of an array |
Promotion[] |
getPromotions(java.lang.String orderTotalCode,
Order order)
We return all active promotions for the orderTotalCode passed in as a parameter. |
protected Promotion[] |
getPromotionsPerOrderTotalCode(java.lang.String orderTotalCode)
The promotions related to the orderTotalCode passed in as a parameter, are fetched from the database. |
ProductIf[] |
getPromotionsPerProducts(java.lang.String sessionId,
int customerId,
ProductIf[] products,
PromotionIf[] promotions,
java.lang.String[] couponCodes,
PromotionOptionsIf options)
This method is used to calculate a discount on individual products so that the discount can be displayed without having to add the product to the cart. The method receives an array of products and returns an array of products with attached PromotionResult objects that contain the results of one or more of the promotions passed in as a parameter. |
int |
insertCoupon(CouponIf coupon,
int promotionId)
Insert a coupon and associate it with the promotion referenced by promotionId. |
protected void |
processPrice(ProductIf prod,
PromotionOptionsIf options)
We apply the discount to a product, taking into consideration the rules to decide which promotion discount to select |
void |
refreshConfigs()
Refresh the configuration of the Promotion manager |
protected void |
setCouponCriteriaWithStandardAttributes(org.apache.torque.util.Criteria c)
Set the criteria object with all of the attributes for a coupon |
protected void |
setPromotionCriteriaWithStandardAttributes(org.apache.torque.util.Criteria c)
Set the criteria object with all of the attributes for a promotion |
void |
updatePromotionUsage(Order order)
If the order has any associated coupons we iterate through the coupons and increment the timesUsed attribute. |
protected void |
validateCoupon(CouponIf coupon)
Used to validate a coupon before inserting |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static org.apache.commons.logging.Log log
protected static java.lang.String mutex
protected static java.util.Map<java.lang.String,PromotionMgr.StaticData> staticDataHM
public static final int ALL
public static final int EXCLUDE
public static final int INCLUDE
protected static final int PROMOTION_RELATION_TYPE
protected static final int GIFT_CERTIFICATE_RELATION_TYPE
public static final int COUPON_DOESNT_EXIST
public static final int COUPON_EXISTS_ACTIVE
public static final int COUPON_EXISTS_INACTIVE
| Constructor Detail |
|---|
public PromotionMgr(KKEngIf eng)
throws java.lang.Exception
eng -
java.lang.Exception| Method Detail |
|---|
public Promotion[] getPromotions(java.lang.String orderTotalCode,
Order order)
throws java.lang.Exception
getPromotions in interface PromotionMgrIforderTotalCode - order -
java.lang.Exception
public Promotion[] getAllPromotions()
throws java.lang.Exception
getAllPromotions in interface PromotionMgrIfjava.lang.Exceptionprotected boolean checkPromotion(Promotion prm)
prm -
protected int checkCustomer(Promotion prm,
int customerId)
throws com.workingdogs.village.DataSetException,
org.apache.torque.TorqueException
prm - customerId -
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
protected int checkCustomerUse(Promotion prm,
int customerId)
throws com.workingdogs.village.DataSetException,
org.apache.torque.TorqueException
prm - customerId -
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
protected int checkCustomerGroup(Promotion prm,
int customerId)
throws java.lang.Exception
prm - customerId -
java.lang.Exception
protected int checkManufacturer(Promotion prm,
ProductIf prod)
throws com.workingdogs.village.DataSetException,
org.apache.torque.TorqueException
prm - prod -
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
protected int checkProduct(Promotion prm,
OrderProductIf orderProd)
throws com.workingdogs.village.DataSetException,
org.apache.torque.TorqueException
prm - orderProd -
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
protected int checkCategory(Promotion prm,
ProductIf prod)
throws java.lang.Exception
prm - prod -
java.lang.Exception
protected int checkCoupon(Promotion prm,
Order order)
throws com.workingdogs.village.DataSetException,
org.apache.torque.TorqueException
prm - order -
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
protected int checkCoupon(Promotion prm,
java.lang.String[] coupons)
throws com.workingdogs.village.DataSetException,
org.apache.torque.TorqueException
prm - coupons -
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
protected int checkExpression(Promotion prm,
int customerId)
throws java.lang.Exception
prm - customerId -
java.lang.Exception
protected Promotion[] getPromotionsPerOrderTotalCode(java.lang.String orderTotalCode)
throws com.workingdogs.village.DataSetException,
org.apache.torque.TorqueException
orderTotalCode -
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
public void updatePromotionUsage(Order order)
throws org.apache.torque.TorqueException,
com.workingdogs.village.DataSetException
updatePromotionUsage in interface PromotionMgrIforder -
org.apache.torque.TorqueException
com.workingdogs.village.DataSetExceptionprotected void setPromotionCriteriaWithStandardAttributes(org.apache.torque.util.Criteria c)
c - protected void setCouponCriteriaWithStandardAttributes(org.apache.torque.util.Criteria c)
c -
public int getPromotionIdForGiftCertificate(OrderProductIf op)
throws KKException,
org.apache.torque.TorqueException,
com.workingdogs.village.DataSetException
getPromotionIdForGiftCertificate in interface PromotionMgrIfop -
KKException
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
protected int getPromotionIdForGiftCertificate(int productId,
int productOptionId,
int productOptionValueId)
throws org.apache.torque.TorqueException,
com.workingdogs.village.DataSetException
productId - productOptionId - productOptionValueId -
org.apache.torque.TorqueException
com.workingdogs.village.DataSetException
public int insertCoupon(CouponIf coupon,
int promotionId)
throws java.lang.Exception
insertCoupon in interface PromotionMgrIfcoupon - promotionId -
java.lang.Exception
protected void validateCoupon(CouponIf coupon)
throws KKException
coupon -
KKException
public int checkCoupon(java.lang.String couponCode)
throws com.workingdogs.village.DataSetException,
org.apache.torque.TorqueException
checkCoupon in interface PromotionMgrIfcouponCode - The coupon code
com.workingdogs.village.DataSetException
org.apache.torque.TorqueException
public ProductIf[] getPromotionsPerProducts(java.lang.String sessionId,
int customerId,
ProductIf[] products,
PromotionIf[] promotions,
java.lang.String[] couponCodes,
PromotionOptionsIf options)
throws java.lang.Exception
getPromotionsPerProducts in interface PromotionMgrIfsessionId - Only used if the customer is logged in. Otherwise set to null.customerId - If the sessionId is set to null then the customerId should contain the id of the
temporary user which is a negative number. The temporary user id can be used for
evaluating expression rules.products - An array of products to be processedpromotions - The promotions which will be applied to the products if all rules are matched.couponCodes - Coupon codes to use. If none of the promotions require coupons, it should be set
to nulloptions - An object containing information to configure the calculation for applying one or
more promotion results to the product price.
java.lang.Exception
protected void processPrice(ProductIf prod,
PromotionOptionsIf options)
prod - options -
protected void applyDiscount(ProductIf prod,
PromotionResultIf promResult,
PromotionOptionsIf options)
prod - promResult - options -
protected PromotionResultIf[] getPromotionResultArray(PromotionResultIf[] currentArray,
PromotionResult newResult)
currentArray - newResult -
protected OrderProduct[] getOrderProductsFromProduct(ProductIf prod)
throws java.lang.Exception
prod -
java.lang.Exception
protected int getCustomerId(java.lang.String sessionId,
int customerId)
throws java.lang.Exception
sessionId - customerId -
java.lang.Exception
public void refreshConfigs()
throws java.lang.Exception
PromotionMgrIf
refreshConfigs in interface PromotionMgrIfjava.lang.Exception
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||