Subversion Repositories SmartDukaan

Rev

Rev 3937 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3937 Rev 5331
Line 13... Line 13...
13
from shop2020.thriftpy.model.v1.user.ttypes import Discount
13
from shop2020.thriftpy.model.v1.user.ttypes import Discount
14
 
14
 
15
def execute(cart, coupon_code, args):
15
def execute(cart, coupon_code, args):
16
    
16
    
17
    user_client = UserClient().get_client()
17
    user_client = UserClient().get_client()
18
    user = user_client.getUserById(cart.userId)
18
    user = user_client.getUserByCartId(cart.id)
19
    
19
    
20
    if not user.email.lower().strip() in ('pankaj.jain@shop2020.in', 'pankaj.kankar@shop2020.in', 'rajveer.singh@shop2020.in', \
20
    if not user.email.lower().strip() in ('pankaj.jain@shop2020.in', 'pankaj.kankar@shop2020.in', 'rajveer.singh@shop2020.in', \
21
                          'chandranshu.s@shop2020.in', 'vikas.malik@shop2020.in', 'varun.gupta@shop2020.in', \
21
                          'chandranshu.s@shop2020.in', 'vikas.malik@shop2020.in', 'varun.gupta@shop2020.in', \
22
                          'mandeep.dhir@shop2020.in', 'vrinda.k@shop2020.in', 'smriti.r@shop2020.in', \
22
                          'mandeep.dhir@shop2020.in', 'vrinda.k@shop2020.in', 'smriti.r@shop2020.in', \
23
                          'tarita.kulkani@shop2020.in', 'manmohan.singh@shop2020.in', 'anand.sinha@shop2020.in', \
23
                          'tarita.kulkani@shop2020.in', 'manmohan.singh@shop2020.in', 'anand.sinha@shop2020.in', \
24
                          'parmod.kumar@shop2020.in', 'satya.mahapatra@shop2020.in', 'abhishek.mathur@shop2020.in', \
24
                          'parmod.kumar@shop2020.in', 'satya.mahapatra@shop2020.in', 'abhishek.mathur@shop2020.in', \
25
                          'chaitnaya.vats@shop2020.in', 'j.p.gupta@shop2020.in', 'zaffar.kar@shop2020.in'):
25
                          'chaitnaya.vats@shop2020.in', 'j.p.gupta@shop2020.in', 'zaffar.kar@shop2020.in'):
26
        raise PromotionException(111, 'You are not allowed to use this coupon')
26
        raise PromotionException(111, 'You are not allowed to use this coupon')
27
    
27
    
28
    #Allow only first 1000 users to use the coupon
28
    #Allow only first 1000 users to use the coupon
29
    count_coupon_usage = get_coupon_usage_count_by_user(coupon_code, cart.userId)
29
    count_coupon_usage = get_coupon_usage_count_by_user(coupon_code, user.id)
30
    
30
    
31
    if count_coupon_usage > 0:
31
    if count_coupon_usage > 0:
32
        raise PromotionException(112, 'You have already used the voucher.')
32
        raise PromotionException(112, 'You have already used the voucher.')
33
    
33
    
34
    discounts = []
34
    discounts = []