Subversion Repositories SmartDukaan

Rev

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

Rev 5975 Rev 5997
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
    if 'items' not in args or 'discount' not in args or 'handset_display_name' not in 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)
-
 
12
    if 'discount' not in args or 'handset_display_name' not in args:
12
        raise PromotionException(109, 'Error in rule arguments.')
13
        raise PromotionException(109, 'Error in rule arguments.')
13
        
14
        
14
    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:
15
        if args['usage_limit'] <= get_coupon_usage_count(coupon_code):
16
        if args['usage_limit'] <= get_coupon_usage_count(coupon_code):
16
            raise PromotionException(112, 'This promotion is over.')
17
            raise PromotionException(112, 'This promotion is over.')
Line 31... Line 32...
31
    discounts = []
32
    discounts = []
32
    for line in cart.lines:
33
    for line in cart.lines:
33
        total_selling_price += line.actualPrice * line.quantity
34
        total_selling_price += line.actualPrice * line.quantity
34
        discount_value = 0
35
        discount_value = 0
35
        
36
        
36
        if line.itemId in args['items']:
37
        if line.itemId in itemTuple:
37
            cart_has_specified_item = True
38
            cart_has_specified_item = True
38
            line.discountedPrice = round(line.actualPrice - args['discount'], 4)
39
            line.discountedPrice = round(line.actualPrice - args['discount'], 4)
39
            total_discounted_price += round(line.discountedPrice * line.quantity, 4)
40
            total_discounted_price += round(line.discountedPrice * line.quantity, 4)
40
            discount_value = args['discount']
41
            discount_value = args['discount']
41
        else:
42
        else:
Line 56... Line 57...
56
    cart.totalPrice = round(total_selling_price, 4)
57
    cart.totalPrice = round(total_selling_price, 4)
57
    cart.discountedPrice = total_discounted_price
58
    cart.discountedPrice = total_discounted_price
58
    return cart, discounts
59
    return cart, discounts
59
 
60
 
60
def getDiscountOnItem(item):
61
def getDiscountOnItem(item):
61
    return 100
-
 
62
62
    return None
-
 
63
63
64