Subversion Repositories SmartDukaan

Rev

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

Rev 3386 Rev 4189
Line 3... Line 3...
3
@author: Varun Gupta
3
@author: Varun Gupta
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,\
8
    get_active_coupons, get_successful_payment_count_for_coupon, get_rule_doc_string, \
9
    get_rule_doc_string
9
    get_item_discount_map
10
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count_by_user
10
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count_by_user
11
from shop2020.model.v1.user.impl import PromotionDataAccessors
11
from shop2020.model.v1.user.impl import PromotionDataAccessors
12
from shop2020.model.v1.user.impl.Converters import to_t_coupon
12
from shop2020.model.v1.user.impl.Converters import to_t_coupon, to_t_item_coupon_discount
13
 
13
 
14
class PromotionServiceHandler:
14
class PromotionServiceHandler:
15
    
15
    
16
    def __init__(self, dbname='user', db_hostname='localhost'):
16
    def __init__(self, dbname='user', db_hostname='localhost'):
17
        initialize(dbname, db_hostname)
17
        initialize(dbname, db_hostname)
Line 121... Line 121...
121
        '''
121
        '''
122
        try:
122
        try:
123
            return get_rule_doc_string(ruleName)
123
            return get_rule_doc_string(ruleName)
124
        finally:
124
        finally:
125
            PromotionDataAccessors.close_session()
125
            PromotionDataAccessors.close_session()
-
 
126
 
-
 
127
    def getItemDiscountMap(self, itemIds):
-
 
128
        '''
-
 
129
        Returns 
-
 
130
        '''
-
 
131
        try:
-
 
132
            return [to_t_item_coupon_discount(item_coupon_discount) for item_coupon_discount in get_item_discount_map(itemIds)]
-
 
133
        finally:
-
 
134
            PromotionDataAccessors.close_session()
126
    
135
        
127
    def isAlive(self):
136
    def isAlive(self):
128
        """
137
        """
129
        For checking weather service is active alive or not. It also checks connectivity with database
138
        For checking weather service is active alive or not. It also checks connectivity with database
130
        """
139
        """
131
        try:
140
        try: