Subversion Repositories SmartDukaan

Rev

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

Rev 3039 Rev 3133
Line 16... Line 16...
16
from shop2020.thriftpy.model.v1.catalog.ttypes import Item as TItem
16
from shop2020.thriftpy.model.v1.catalog.ttypes import Item as TItem
17
from shop2020.thriftpy.logistics.ttypes import LogisticsInfo as TLogisticsInfo,\
17
from shop2020.thriftpy.logistics.ttypes import LogisticsInfo as TLogisticsInfo,\
18
    LogisticsServiceException
18
    LogisticsServiceException
19
 
19
 
20
from shop2020.clients.TransactionClient import TransactionClient
20
from shop2020.clients.TransactionClient import TransactionClient
21
from shop2020.clients.InventoryClient import InventoryClient
21
from shop2020.clients.CatalogClient import CatalogClient
22
from shop2020.clients.LogisticsClient import LogisticsClient
22
from shop2020.clients.LogisticsClient import LogisticsClient
23
from shop2020.model.v1 import user
23
from shop2020.model.v1 import user
24
from shop2020.clients.PromotionClient import PromotionClient
24
from shop2020.clients.PromotionClient import PromotionClient
25
from shop2020.model.v1.user.impl import UserDataAccessors
25
from shop2020.model.v1.user.impl import UserDataAccessors
26
 
26
 
Line 113... Line 113...
113
 
113
 
114
    cart = Cart.get_by(id = cart_id)    
114
    cart = Cart.get_by(id = cart_id)    
115
    if not cart:
115
    if not cart:
116
        raise ShoppingCartException(101, "no cart attached to this id")
116
        raise ShoppingCartException(101, "no cart attached to this id")
117
    retval = ""
117
    retval = ""
118
    inventory_client = InventoryClient().get_client()
118
    inventory_client = CatalogClient().get_client()
119
    item = inventory_client.getItem(item_id)
119
    item = inventory_client.getItem(item_id)
120
    item_shipping_info = inventory_client.isActive(item_id)
120
    item_shipping_info = inventory_client.isActive(item_id)
121
    if not item_shipping_info.isActive:
121
    if not item_shipping_info.isActive:
122
        return inventory_client.getItemStatusDescription(item_id)
122
        return inventory_client.getItemStatusDescription(item_id)
123
    
123
    
Line 271... Line 271...
271
    t_order.created_timestamp = to_java_date(datetime.datetime.now())
271
    t_order.created_timestamp = to_java_date(datetime.datetime.now())
272
    
272
    
273
    return t_order
273
    return t_order
274
        
274
        
275
def create_line_item(item_id, discounted_price):
275
def create_line_item(item_id, discounted_price):
276
    inventory_client = InventoryClient().get_client()
276
    inventory_client = CatalogClient().get_client()
277
    item = inventory_client.getItem(item_id)
277
    item = inventory_client.getItem(item_id)
278
    t_line_item = TLineItem()
278
    t_line_item = TLineItem()
279
    t_line_item.productGroup = item.productGroup
279
    t_line_item.productGroup = item.productGroup
280
    t_line_item.brand = item.brand
280
    t_line_item.brand = item.brand
281
    t_line_item.model_number = item.modelNumber
281
    t_line_item.model_number = item.modelNumber
Line 298... Line 298...
298
    t_line_item.unit_weight = item.weight
298
    t_line_item.unit_weight = item.weight
299
    t_line_item.total_weight = item.weight
299
    t_line_item.total_weight = item.weight
300
    return t_line_item
300
    return t_line_item
301
    
301
    
302
def validate_cart(cartId):
302
def validate_cart(cartId):
303
    inventory_client = InventoryClient().get_client()
303
    inventory_client = CatalogClient().get_client()
304
    logistics_client = LogisticsClient().get_client()
304
    logistics_client = LogisticsClient().get_client()
305
    promotion_client = PromotionClient().get_client()
305
    promotion_client = PromotionClient().get_client()
306
    retval = ""
306
    retval = ""
307
    # No need to validate duplicate items since there are only two ways
307
    # No need to validate duplicate items since there are only two ways
308
    # to add items to a cart and both of them check whether the item being
308
    # to add items to a cart and both of them check whether the item being