Subversion Repositories SmartDukaan

Rev

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

Rev 6018 Rev 6026
Line 6... Line 6...
6
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException, Discount
6
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException, Discount
7
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count, get_coupon_usage_count_by_user
7
from shop2020.model.v1.user.impl.PromotionRuleDataUtilities import get_coupon_usage_count, get_coupon_usage_count_by_user
8
from shop2020.clients.UserClient import UserClient
8
from shop2020.clients.UserClient import UserClient
9
 
9
 
10
def execute(cart, coupon_code, args):
10
def execute(cart, coupon_code, args):
11
    itemTuple = (6737,6830,7769,2091,2527,3882,6829,7243,5834,7227,2629,5839,3358,4643,7298,2215,2481,4630,5731,1493,1502,2073,2621,5840,5841,5842,4961,7509,7510,7511,7335,7508,5,6,7,8,9,2094,2274,2280,6823,7517,7565,7332,2026,2074,2020,2021,1584,2058,1595,3361,4627,2039,7295,4645,7126,7503,4646,4859,2082,2083,3880,7297,7548,4647)
11
    itemTuple = (2091,2527,3882,6829,7243,5834,7227,2629,5839,3358,4643,7298,2215,2481,4630,5731,1493,1502,2073,2621,5840,5841,5842,4961,7509,7510,7511,7335,7508,5,6,7,8,9,2094,2274,2280,6823,7517,7565,7332,2026,2074,2020,2021,1584,2058,1595,3361,4627,2039,7295,4645,7126,7503,4646,4859,2082,2083,3880,7297,7548,4647)
12
    if 'discount' not in args or 'handset_display_name' not in args:
12
    if 'discount' not in args or 'handset_display_name' not in args:
13
        raise PromotionException(109, 'Error in rule arguments.')
13
        raise PromotionException(109, 'Error in rule arguments.')
14
        
14
        
15
    if 'usage_limit' in args and args['usage_limit'] is not None:
15
    if 'usage_limit' in args and args['usage_limit'] is not None:
16
        if args['usage_limit'] <= get_coupon_usage_count(coupon_code):
16
        if args['usage_limit'] <= get_coupon_usage_count(coupon_code):
Line 34... Line 34...
34
        total_selling_price += line.actualPrice * line.quantity
34
        total_selling_price += line.actualPrice * line.quantity
35
        discount_value = 0
35
        discount_value = 0
36
        
36
        
37
        if line.itemId in itemTuple:
37
        if line.itemId in itemTuple:
38
            discount = args['discount']
38
            discount = args['discount']
39
            if line.itemId in (6830, 6737, 7769):
-
 
40
                discount = 500
-
 
41
            cart_has_specified_item = True
39
            cart_has_specified_item = True
42
            line.discountedPrice = round(line.actualPrice - discount, 4)
40
            line.discountedPrice = round(line.actualPrice - discount, 4)
43
            total_discounted_price += round(line.discountedPrice * line.quantity, 4)
41
            total_discounted_price += round(line.discountedPrice * line.quantity, 4)
44
            discount_value = discount
42
            discount_value = discount
45
        else:
43
        else: