ZenMagick 0.9.1


org.zenmagick.service.ZMCoupons

Class ZMCoupons

ZMObject
|
+--ZMCoupons

public class ZMCoupons
extends ZMObject

Coupons.

Author:
mano
Version:
$Id: ZMCoupons.php 957 2008-03-30 21:03:12Z DerManoMann $

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.

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.

Methods inherited from org.zenmagick.ZMObject
backtrace, create, log, singleton

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.

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.

ZenMagick 0.9.1