Subversion Repositories SmartDukaan

Rev

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

Rev 4494 Rev 5469
Line 4... Line 4...
4
'''
4
'''
5
 
5
 
6
from shop2020.model.v1.user.impl.PromotionDataAccessors import initialize, create_promotion,\
6
from shop2020.model.v1.user.impl.PromotionDataAccessors import initialize, create_promotion,\
7
    generate_coupons_for_promotion, apply_coupon, track_coupon_usage, is_alive,\
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, \
8
    get_active_coupons, get_successful_payment_count_for_coupon, get_rule_doc_string, \
9
    get_item_discount_map, get_discounts_for_entity
9
    get_item_discount_map, get_discounts_for_entity, add_voucher, assign_voucher,\
-
 
10
    mark_voucher_as_redeemed
10
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count_by_user
11
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count_by_user
11
from shop2020.model.v1.user.impl import PromotionDataAccessors
12
from shop2020.model.v1.user.impl import PromotionDataAccessors
12
from shop2020.model.v1.user.impl.Converters import to_t_coupon, to_t_item_coupon_discount
13
from shop2020.model.v1.user.impl.Converters import to_t_coupon, to_t_item_coupon_discount,\
-
 
14
    to_t_voucher
13
 
15
 
14
class PromotionServiceHandler:
16
class PromotionServiceHandler:
15
    
17
    
16
    def __init__(self, dbname='user', db_hostname='localhost'):
18
    def __init__(self, dbname='user', db_hostname='localhost'):
17
        initialize(dbname, db_hostname)
19
        initialize(dbname, db_hostname)
Line 142... Line 144...
142
        '''
144
        '''
143
        try:
145
        try:
144
            return get_discounts_for_entity(entityId)
146
            return get_discounts_for_entity(entityId)
145
        finally:
147
        finally:
146
            PromotionDataAccessors.close_session()
148
            PromotionDataAccessors.close_session()
-
 
149
 
-
 
150
    def addVoucher(self, voucher):
-
 
151
        """
-
 
152
        Parameters:
-
 
153
         - voucher
-
 
154
        """
-
 
155
        try:
-
 
156
            return add_voucher(voucher)
-
 
157
        finally:
-
 
158
            PromotionDataAccessors.close_session()
-
 
159
 
-
 
160
    def assignVoucher(self, userId, userEmail, voucherType, amount):
-
 
161
        """
-
 
162
        Parameters:
-
 
163
         - userId
-
 
164
         - voucherType
-
 
165
         - amount
-
 
166
        """
-
 
167
        try:
-
 
168
            return to_t_voucher(assign_voucher(userId, userEmail, voucherType, amount))
-
 
169
        finally:
-
 
170
            PromotionDataAccessors.close_session()
-
 
171
 
-
 
172
    def markVoucherAsRedeemed(self, voucherCode, redeemedOn):
-
 
173
        """
-
 
174
        Parameters:
-
 
175
         - voucherCode
-
 
176
         - redeemedOn
-
 
177
        """
-
 
178
        try:
-
 
179
            return mark_voucher_as_redeemed(voucherCode, redeemedOn)
-
 
180
        finally:
-
 
181
            PromotionDataAccessors.close_session()
147
    
182
        
148
    def isAlive(self):
183
    def isAlive(self):
149
        """
184
        """
150
        For checking weather service is active alive or not. It also checks connectivity with database
185
        For checking weather service is active alive or not. It also checks connectivity with database
151
        """
186
        """
152
        try:
187
        try: