Subversion Repositories SmartDukaan

Rev

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

Rev 494 Rev 501
Line 5... Line 5...
5
'''
5
'''
6
from elixir import *
6
from elixir import *
7
from shop2020.model.v1.catalog.impl import DataService
7
from shop2020.model.v1.catalog.impl import DataService
8
from shop2020.model.v1.catalog.impl.DataService import Item, \
8
from shop2020.model.v1.catalog.impl.DataService import Item, \
9
    Warehouse, ItemInventoryHistory, CurrentInventorySnapshot, ItemInfo,\
9
    Warehouse, ItemInventoryHistory, CurrentInventorySnapshot, ItemInfo,\
10
    ItemChangeLog, Price
10
    ItemChangeLog, Price, LatestArrivals, BestDeals, BestSellers
11
from shop2020.thriftpy.model.v1.catalog.ttypes import \
11
from shop2020.thriftpy.model.v1.catalog.ttypes import \
12
    InventoryServiceException, status
12
    InventoryServiceException, status
13
from shop2020.thriftpy.model.v1.catalog.ttypes import Item as TItem
13
from shop2020.thriftpy.model.v1.catalog.ttypes import Item as TItem
14
 
14
 
15
from shop2020.thriftpy.model.v1.catalog.ttypes import Warehouse as TWarehouse
15
from shop2020.thriftpy.model.v1.catalog.ttypes import Warehouse as TWarehouse
16
import datetime
16
import datetime
17
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
17
from shop2020.utils.Utils import log_entry, to_py_date, to_java_date
-
 
18
from sqlalchemy import desc, asc
18
 
19
 
19
 
20
 
20
def initialize():
21
def initialize():
21
    DataService.initialize()
22
    DataService.initialize()
22
    
23
    
Line 400... Line 401...
400
    
401
    
401
    if not item:
402
    if not item:
402
        raise InventoryServiceException(101, "bad item")
403
        raise InventoryServiceException(101, "bad item")
403
    
404
    
404
    warehouses = item.currentInventory.warehouse
405
    warehouses = item.currentInventory.warehouse
405
    return warehouses
-
 
406
406
    return warehouses
-
 
407
 
-
 
408
def get_best_sellers():
-
 
409
    sellers = BestSellers.query.all()
-
 
410
    
-
 
411
    t_sellers = []
-
 
412
    for seller in sellers:
-
 
413
        t_sellers.append(seller.item_id)
-
 
414
    return t_sellers   
-
 
415
    
-
 
416
def get_best_deals():
-
 
417
    deals = BestDeals.query.all()
-
 
418
    
-
 
419
    #query = BestDeals.query.all()
-
 
420
    #deals = query.order_by(asc(BestDeals.priority)).all()
-
 
421
    
-
 
422
    
-
 
423
    t_deals = []
-
 
424
    for deal in deals:
-
 
425
        t_deals.append(deal.item_id)
-
 
426
    return t_deals   
-
 
427
    
-
 
428
def get_latest_arrivals():
-
 
429
    arrivals = LatestArrivals.query.all()
-
 
430
    
-
 
431
    t_arrivals = []
-
 
432
    for arrival in arrivals:
-
 
433
        t_arrivals.append(arrival.item_id)
-
 
434
    return t_arrivals    
-
 
435