com.ibm.commerce.couponredemption.commands
Class RedeemCouponCmdImpl

java.lang.Object
  CacheableCommandImpl
      com.ibm.commerce.command.AbstractECTargetableCommand
          com.ibm.commerce.command.ControllerCommandImpl
              com.ibm.commerce.couponredemption.commands.RedeemCouponCmdImpl
All Implemented Interfaces:
AccCommand, ControllerCommand, ECCommand, ECTargetableCommand, Protectable, RedeemCouponCmd

public class RedeemCouponCmdImpl
extends ControllerCommandImpl
implements RedeemCouponCmd

This command is invoked when the user asks to redeem her eCoupons before preparing order and it displays a set of eCoupons that can be applied to this order.

First the temporary and permanent table are cleaned up, which stores the eCoupon discount. Then the eCoupons for this shopper are found out from CouponWalletAccessBean with state as USABLE. The CheckValidityCmd command is called to find the coupons that are not expired and for not expired coupons CheckApplicabilityCmd command is called to find out which eCoupons are applicable for this order. For applicable eCoupons, CalculateDiscountAmtCmd command is called to calculate the discount amount and the view command is redirected to show the applicable coupons and corresponding discounts.

See Also:
Serialized Form

Field Summary
protected java.lang.Integer calculationUsage
The calculation usage code.
protected java.lang.String curCurrency
Currency to be used in calculations.
protected java.lang.Long orderId
The order for which the coupons are to be found out
protected CommandContext processingContext
The command context holder
protected java.lang.Long shopperId
ID of the shopper invoking the command.
protected java.lang.Integer storeId
The store ID.
Fields inherited from class com.ibm.commerce.command.ControllerCommandImpl
requestProperties, responseProperties, retriable, viewReqProperties
Fields inherited from class com.ibm.commerce.command.AbstractECTargetableCommand
commandContext
Fields inherited from interface com.ibm.commerce.couponredemption.commands.RedeemCouponCmd
defaultCommandClassName
Constructor Summary
RedeemCouponCmdImpl()
Constructor for RedeemCouponCmdImpl, calls super.
Method Summary
java.lang.Long getOrderId()
Gets the order ID.
CommandContext getProcessingContext()
Gets the processing context.
java.lang.Long getShopperId()
Gets the shopper ID.
void insertIntoDB(java.lang.Long orderId, java.util.Hashtable couponHashtable)
Inserts the coupon related information in the database.
boolean isReadyToCallExecute()
It always returns true.
void performExecute()
First the temporary and permanent table are cleaned up, which stores the eCoupon discount.
void removeExistingAdjustments(java.lang.Long anOrderId)
Removes the existing adjustments for the orderitems.
void removeOldEntries()
Removes the existing entries from TempOrderCouponMapAccessBean and TempCouponItemMapAccessBean.
void setOrderId(java.lang.Long newOrderId)
Sets the order ID.
void setProcessingContext(CommandContext newProcessingContext)
Sets the processingContext.
void setShopperId(java.lang.Long newShopperId)
Sets the shopper ID.
void validateParameters()
This method extracts and validates the parameters.
Methods inherited from class com.ibm.commerce.command.ControllerCommandImpl
checkPermission, fulfills, getForUserId, getGeneric, getOwner, getRequestProperties, getResolvedRequestProperties, getResourceOwners, getResponseProperties, getRetriable, getViewInputProperties, isGeneric, isRetriable, mergeProperties, setForUserId, setGeneric, setOwner, setRequestProperties, setResponseProperties, setRetriable, setViewInputProperties
Methods inherited from class com.ibm.commerce.command.AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkParameters, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, reset, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.ibm.commerce.command.ControllerCommand
checkPermission, execute, getGeneric, getRequestProperties, getResolvedRequestProperties, getResponseProperties, getRetriable, getViewInputProperties, isGeneric, isRetriable, mergeProperties, setGeneric, setRequestProperties, setRetriable, setViewInputProperties
Methods inherited from interface com.ibm.commerce.command.AccCommand
accessControlCheck, getAccCheck, getForUserId, getResourceOwners, setAccCheck, setForUserId, setOwner
Methods inherited from interface com.ibm.commerce.command.ECCommand
checkIsAllowed, checkResourcePermission, createCommandExecutionEvent, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
Methods inherited from interface com.ibm.commerce.security.Protectable
fulfills, getOwner
Field Detail

orderId

protected java.lang.Long orderId
The order for which the coupons are to be found out

shopperId

protected java.lang.Long shopperId
ID of the shopper invoking the command.

processingContext

protected CommandContext processingContext
The command context holder

calculationUsage

protected java.lang.Integer calculationUsage
The calculation usage code.

curCurrency

protected java.lang.String curCurrency
Currency to be used in calculations.

storeId

protected java.lang.Integer storeId
The store ID.
Constructor Detail

RedeemCouponCmdImpl

public RedeemCouponCmdImpl()
Constructor for RedeemCouponCmdImpl, calls super.
Method Detail

getOrderId

public java.lang.Long getOrderId()
Gets the order ID.
Returns:
the order ID.

getProcessingContext

public CommandContext getProcessingContext()
Gets the processing context.
Returns:
the command context.

getShopperId

public java.lang.Long getShopperId()
Gets the shopper ID.
Returns:
the shopper ID.

insertIntoDB

public void insertIntoDB(java.lang.Long orderId,
                         java.util.Hashtable couponHashtable)
                  throws ECSystemException
Inserts the coupon related information in the database. First create the OrderCouponMapAccessBean for each coupon used for this order. Then, create the CouponItemMapAccessBean for each item for coupon, with the discount amount information.
Parameters:
orderId - The order for which the coupons are being applied.
Throws:
com.ibm.commerce.exception.ECException.
ECSystemException

isReadyToCallExecute

public boolean isReadyToCallExecute()
It always returns true.
Overrides:
isReadyToCallExecute in class AbstractECTargetableCommand
Returns:
true if we can execute the command false if we canot execute the command

performExecute

public void performExecute()
                    throws ECException

First the temporary and permanent table are cleaned up, which stores the eCoupon discount. Then the eCoupons for this shopper are found out from CouponWalletAccessBean with state as USABLE. The CheckValidityCmd command is called to find the coupons that are not expired and for not expired coupons CheckApplicabilityCmd command is called to find out which eCoupons are applicable for this order. For applicable eCoupons, CalculateDiscountAmtCmd command is called to calculate the discount amount and the view command is redirected to show the applicable coupons and corresponding discounts.

Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
com.ibm.commerce.exception.ECException.
ECException

removeExistingAdjustments

public void removeExistingAdjustments(java.lang.Long anOrderId)
                               throws ECSystemException
Removes the existing adjustments for the orderitems.
Parameters:
anOrderId - The order for which the adjustments are to be removed.
Throws:
com.ibm.commerce.exception.ECException.
ECSystemException

removeOldEntries

public void removeOldEntries()
                      throws ECSystemException
Removes the existing entries from TempOrderCouponMapAccessBean and TempCouponItemMapAccessBean.
Throws:
com.ibm.commerce.exception.ECException.
ECSystemException

setOrderId

public void setOrderId(java.lang.Long newOrderId)
Sets the order ID.
Parameters:
newOrderId - the order ID.

setProcessingContext

public void setProcessingContext(CommandContext newProcessingContext)
Sets the processingContext.
Parameters:
newProcessingContext - the command context.

setShopperId

public void setShopperId(java.lang.Long newShopperId)
Sets the shopper ID.
Parameters:
newShopperId - the shopper ID.

validateParameters

public void validateParameters()
                        throws ECException
This method extracts and validates the parameters.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECTargetableCommand
Throws:
com.ibm.commerce.exception.ECException.
ECException

Feedback