| Line 2... |
Line 2... |
| 2 |
Created on 30-Apr-2012
|
2 |
Created on 30-Apr-2012
|
| 3 |
|
3 |
|
| 4 |
@author: Varun Gupta
|
4 |
@author: Varun Gupta
|
| 5 |
|
5 |
|
| 6 |
When SAccessory, coupon code is applied to cart, containing phone(s) as well as accessories,
|
6 |
When SAccessory, coupon code is applied to cart, containing phone(s) as well as accessories,
|
| 7 |
a discount, equal to 5% of the selling price of phone(s), will be awarded on accessories.
|
7 |
a discount, equal to 5% of the selling price of phone/tablet, will be awarded on accessories.
|
| 8 |
'''
|
8 |
'''
|
| 9 |
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException
|
9 |
from shop2020.thriftpy.model.v1.user.ttypes import PromotionException
|
| 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.clients.CatalogClient import CatalogClient
|
11 |
from shop2020.clients.CatalogClient import CatalogClient
|
| 12 |
from shop2020.thriftpy.model.v1.user.ttypes import Discount
|
12 |
from shop2020.thriftpy.model.v1.user.ttypes import Discount
|
| Line 55... |
Line 55... |
| 55 |
item = catalog_client.getItem(line.itemId)
|
55 |
item = catalog_client.getItem(line.itemId)
|
| 56 |
|
56 |
|
| 57 |
items[line.itemId] = item
|
57 |
items[line.itemId] = item
|
| 58 |
print item.modelName, ', category: ', item.category
|
58 |
print item.modelName, ', category: ', item.category
|
| 59 |
if item.category == 10010 or item.category in category_map[10001]:
|
59 |
if item.category == 10010 or item.category in category_map[10001]:
|
| 60 |
print 'is phone/tablet'
|
60 |
|
| 61 |
available_discount += round(item.sellingPrice * 0.05 * line.quantity)
|
61 |
if available_discount < round(item.sellingPrice * 0.05):
|
| - |
|
62 |
available_discount = round(item.sellingPrice * 0.05)
|
| 62 |
has_phone = True
|
63 |
has_phone = True
|
| 63 |
|
64 |
|
| 64 |
if not has_phone:
|
65 |
if not has_phone:
|
| 65 |
raise PromotionException(115, 'This coupon is valid when a phone/tablet is included in the purchase')
|
66 |
raise PromotionException(115, 'This coupon is valid when a phone/tablet is included in the purchase')
|
| 66 |
|
67 |
|