Subversion Repositories SmartDukaan

Rev

Rev 5469 | Rev 6301 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5469 Rev 6250
Line 1... Line 1...
1
'''
1
'''
2
Created on: May 24, 2011
2
Created on: May 24, 2011
3
@author: Varun Gupta
3
@author: Varun Gupta
4
'''
4
'''
5
 
5
 
6
from shop2020.model.v1.user.impl.PromotionDataAccessors import initialize, create_promotion,\
-
 
7
    generate_coupons_for_promotion, apply_coupon, track_coupon_usage, is_alive,\
-
 
8
    get_active_coupons, get_successful_payment_count_for_coupon, get_rule_doc_string, \
-
 
9
    get_item_discount_map, get_discounts_for_entity, add_voucher, assign_voucher,\
-
 
10
    mark_voucher_as_redeemed
-
 
11
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count_by_user
-
 
12
from shop2020.model.v1.user.impl import PromotionDataAccessors
6
from shop2020.model.v1.user.impl import PromotionDataAccessors
13
from shop2020.model.v1.user.impl.Converters import to_t_coupon, to_t_item_coupon_discount,\
7
from shop2020.model.v1.user.impl.Converters import to_t_coupon, \
-
 
8
    to_t_item_coupon_discount, to_t_voucher
-
 
9
from shop2020.model.v1.user.impl.PromotionDataAccessors import initialize, \
-
 
10
    create_promotion, generate_coupons_for_promotion, apply_coupon, \
-
 
11
    track_coupon_usage, is_alive, get_active_coupons, \
-
 
12
    get_successful_payment_count_for_coupon, get_rule_doc_string, \
-
 
13
    get_item_discount_map, get_discounts_for_entity, add_voucher, assign_voucher, \
-
 
14
    mark_voucher_as_redeemed, create_coupon
-
 
15
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import \
14
    to_t_voucher
16
    get_coupon_usage_count_by_user
15
 
17
 
16
class PromotionServiceHandler:
18
class PromotionServiceHandler:
17
    
19
    
18
    def __init__(self, dbname='user', db_hostname='localhost'):
20
    def __init__(self, dbname='user', db_hostname='localhost'):
19
        initialize(dbname, db_hostname)
21
        initialize(dbname, db_hostname)
Line 56... Line 58...
56
        try:
58
        try:
57
            generate_coupons_for_promotion(promotionId, couponCode)
59
            generate_coupons_for_promotion(promotionId, couponCode)
58
        finally:
60
        finally:
59
            PromotionDataAccessors.close_session()
61
            PromotionDataAccessors.close_session()
60
    
62
    
-
 
63
    def createCoupon(self, promotionId, endOn, email, amount, usage):
-
 
64
        '''
-
 
65
        Parameters:
-
 
66
        - promotionId
-
 
67
        - couponCode
-
 
68
        '''
-
 
69
        try:
-
 
70
            return create_coupon(promotionId, endOn, email, amount, usage)
-
 
71
        finally:
-
 
72
            PromotionDataAccessors.close_session()
-
 
73
    
61
    def applyCoupon(self, couponCode, cartId):
74
    def applyCoupon(self, couponCode, cartId):
62
        '''
75
        '''
63
        Parameters:
76
        Parameters:
64
        - couponCode
77
        - couponCode
65
        - cartId
78
        - cartId