ZenMagick 0.9.6


org.zenmagick.service.ZMCoupons

Class ZMCoupons

ZMObject
|
+--ZMCoupons

public class ZMCoupons
extends ZMObject

Coupons.

Author:
DerManoMann
Version:
$Id: ZMCoupons.php 2149 2009-04-13 22:59:14Z dermanomann $

Field Summary
final mixed

BALANCE_ADD

final mixed

BALANCE_SET

final mixed

TYPPE_FIXED

final mixed

TYPPE_GV

final mixed

TYPPE_PERCENT

final mixed

TYPPE_SHIPPING

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMCoupons()

Create new instance.

Method Summary
ZMCoupon

createCoupon(mixed couponCode, float amount, string type, int accountId)

Create a new coupon.

string

createCouponCode(string salt, int length)

Create a new coupon code.

void

createCouponTracker(ZMCoupon coupon, ZMAccount account, ZMGVReceiver gvreceiver)

Create a new coupon tracker record.

void

creditCoupon(int couponId, int accountId)

Credit coupon for account.

void

finalizeCoupon(int couponId, int accountId, string remoteIp)

Finalize a coupon.

ZMCoupon

getCouponForCode(string code, int languageId)

Coupon lookup for the given code.

ZMCoupon

getCouponForId(int id, int languageId)

Coupon lookup for the given id.

ZMCouponQueue

getCouponQueueEntryForId(int queueId)

Get a coupon queue entry.

ZMCouponRestrictions

getRestrictionsForCouponId(mixed couponId, int id)

Load coupon restrictions for the given coupon id.

float

getVoucherBalanceForAccountId(int accountId)

Get the coupon/voucher balance for the given account.

static void

instance()

Get instance.

boolean

isCouponRedeemable(string couponId)

Check if a given coupon code can be redeemed.

void

redeemCoupon(int couponId, int accountId, string remoteIp)

Redeem a coupon.

void

setVoucherBalanceForAccountId(int accountId, float amount)

Update the coupon/coucher balance for the given account id.

protected void

updateVoucherBalanceForAccountId(int accountId, float amount, string mode)

Update the coupon/coucher balance for the given account id.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

BALANCE_ADD

public final mixed BALANCE_ADD = 'balance_add'

BALANCE_SET

public final mixed BALANCE_SET = 'balance_set'

TYPPE_FIXED

public final mixed TYPPE_FIXED = 'F'

TYPPE_GV

public final mixed TYPPE_GV = 'G'

TYPPE_PERCENT

public final mixed TYPPE_PERCENT = 'P'

TYPPE_SHIPPING

public final mixed TYPPE_SHIPPING = 'S'

Constructor Detail

ZMCoupons

public ZMCoupons()

Create new instance. /


Method Detail

createCoupon

public ZMCoupon createCoupon(mixed couponCode, float amount, string type, int accountId)

Create a new coupon.

Parameters:
accountId - The account id.
amount - The new amount.
type - The coupon type.
Returns:
A ZMCoupon instance or null.

createCouponCode

public string createCouponCode(string salt, int length)

Create a new coupon code.

Parameters:
salt - The salt to be used to generate the unique code.
length - The coupon code length; default is 0 to use the setting couponCodeLength.
Returns:
A new unique coupon code.

createCouponTracker

public void createCouponTracker(ZMCoupon coupon, ZMAccount account, ZMGVReceiver gvreceiver)

Create a new coupon tracker record.

Parameters:
coupon - The coupon.
account - The sender account.
gvreceiver - The receiver.

creditCoupon

public void creditCoupon(int couponId, int accountId)

Credit coupon for account.

Parameters:
couponId - The coupon id.
accountId - The redeeming account id.

finalizeCoupon

public void finalizeCoupon(int couponId, int accountId, string remoteIp)

Finalize a coupon.

Parameters:
couponId - The coupon id.
accountId - The redeeming account id.
remoteIp - The redeeming IP addres; default is an empty string.

getCouponForCode

public ZMCoupon getCouponForCode(string code, int languageId)

Coupon lookup for the given code.

Parameters:
code - The coupons code.
languageId - The languageId; default is null for session language.
Returns:
A ZMCoupon instance or null.

getCouponForId

public ZMCoupon getCouponForId(int id, int languageId)

Coupon lookup for the given id.

Parameters:
id - The coupon id.
languageId - The languageId; default is null for session language.
Returns:
A ZMCoupon instance or null.

getCouponQueueEntryForId

public ZMCouponQueue getCouponQueueEntryForId(int queueId)

Get a coupon queue entry.

Parameters:
queueId - The coupon queue id.
Returns:
A queue entry or null.

getRestrictionsForCouponId

public ZMCouponRestrictions getRestrictionsForCouponId(mixed couponId, int id)

Load coupon restrictions for the given coupon id.

Parameters:
id - The coupon id.
Returns:
The restrictions.

getVoucherBalanceForAccountId

public float getVoucherBalanceForAccountId(int accountId)

Get the coupon/voucher balance for the given account.

Parameters:
accountId - The account id.
Returns:
The available balance or 0.

instance

public static void instance()

Get instance. /


isCouponRedeemable

public boolean isCouponRedeemable(string couponId)

Check if a given coupon code can be redeemed.

Parameters:
couponId - The coupon id to verify.
Returns:
true if the coupon can be redeemed, false if not.

redeemCoupon

public void redeemCoupon(int couponId, int accountId, string remoteIp)

Redeem a coupon.

This will call finalizeCoupon(...) and creditCoupon(...).

Parameters:
couponId - The coupon id.
accountId - The redeeming account id.
remoteIp - The redeeming IP addres; default is an empty string.

setVoucherBalanceForAccountId

public void setVoucherBalanceForAccountId(int accountId, float amount)

Update the coupon/coucher balance for the given account id.

Parameters:
accountId - The account id.
amount - The new amount.

updateVoucherBalanceForAccountId

protected void updateVoucherBalanceForAccountId(int accountId, float amount, string mode)

Update the coupon/coucher balance for the given account id.

Parameters:
accountId - The account id.
amount - The new amount.
mode - Optional update mode; either BALANCE_SET or BALANCE_ADD.

ZenMagick 0.9.6