| Line 16... |
Line 16... |
| 16 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
16 |
from shop2020.model.v1.catalog.impl.DataService import Item, ItemChangeLog, \
|
| 17 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
17 |
Category, EntityIDGenerator, SimilarItems, ProductNotification, Source, \
|
| 18 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
|
18 |
SourceItemPricing, AuthorizationLog, VoucherItemMapping, CategoryVatMaster, \
|
| 19 |
OOSTracker, EntityTag, ItemInsurerMapping, Insurer, Banner, BannerMap, \
|
19 |
OOSTracker, EntityTag, ItemInsurerMapping, Insurer, Banner, BannerMap, \
|
| 20 |
FreebieItem, BrandInfo, Amazonlisted, StorePricing, ItemVatMaster, \
|
20 |
FreebieItem, BrandInfo, Amazonlisted, StorePricing, ItemVatMaster, \
|
| 21 |
PageViewEvents, CartEvents, EbayItem, BannerUriMapping, Campaign, SnapdealItem
|
21 |
PageViewEvents, CartEvents, EbayItem, BannerUriMapping, Campaign, SnapdealItem, \
|
| - |
|
22 |
SnapdealItemUpdateHistory
|
| 22 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
23 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
| 23 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
24 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
| 24 |
StorePricing as tStorePricing, CatalogServiceException, \
|
25 |
StorePricing as tStorePricing, CatalogServiceException, \
|
| 25 |
BannerType
|
26 |
BannerType
|
| 26 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
27 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
| Line 2059... |
Line 2060... |
| 2059 |
def get_count_for_amazonlisted_items():
|
2060 |
def get_count_for_amazonlisted_items():
|
| 2060 |
return session.query(func.count(Amazonlisted.itemId)).scalar()
|
2061 |
return session.query(func.count(Amazonlisted.itemId)).scalar()
|
| 2061 |
|
2062 |
|
| 2062 |
def add_or_update_snapdeal_item(snapdealitem):
|
2063 |
def add_or_update_snapdeal_item(snapdealitem):
|
| 2063 |
item = SnapdealItem.get_by(item_id=snapdealitem.item_id)
|
2064 |
item = SnapdealItem.get_by(item_id=snapdealitem.item_id)
|
| 2064 |
catalogitem = Item.get_by(id=snapdealitem.item_id)
|
- |
|
| 2065 |
try:
|
2065 |
try:
|
| 2066 |
if item is not None:
|
2066 |
if item is not None:
|
| - |
|
2067 |
itemHistory = SnapdealItemUpdateHistory()
|
| - |
|
2068 |
itemHistory.item_id = snapdealitem.item_id
|
| - |
|
2069 |
itemHistory.exceptionPrice = item.exceptionPrice
|
| - |
|
2070 |
itemHistory.warehouseId = item.warehouseId
|
| - |
|
2071 |
itemHistory.isListedOnSnapdeal = item.isListedOnSnapdeal
|
| - |
|
2072 |
itemHistory.transferPrice = item.transferPrice
|
| - |
|
2073 |
itemHistory.sellingPrice = item.sellingPrice
|
| - |
|
2074 |
itemHistory.courierCost = item.courierCost
|
| - |
|
2075 |
itemHistory.commission = item.commission
|
| - |
|
2076 |
itemHistory.serviceTax = item.serviceTax
|
| - |
|
2077 |
itemHistory.suppressPriceFeed = item.suppressPriceFeed
|
| - |
|
2078 |
itemHistory.suppressInventoryFeed = item.suppressInventoryFeed
|
| - |
|
2079 |
itemHistory.updatedOn = item.updatedOn
|
| - |
|
2080 |
|
| 2067 |
if snapdealitem.exceptionPrice is not None:
|
2081 |
if snapdealitem.exceptionPrice is not None:
|
| 2068 |
item.exceptionPrice = snapdealitem.exceptionPrice
|
2082 |
item.exceptionPrice = snapdealitem.exceptionPrice
|
| 2069 |
if snapdealitem.warehouseId is not None:
|
2083 |
if snapdealitem.warehouseId is not None:
|
| 2070 |
item.warehouseId = snapdealitem.warehouseId
|
2084 |
item.warehouseId = snapdealitem.warehouseId
|
| 2071 |
if snapdealitem.isListedOnSnapdeal is not None:
|
2085 |
if snapdealitem.isListedOnSnapdeal is not None:
|
| 2072 |
catalogitem.isListedOnSnapdeal = snapdealitem.isListedOnSnapdeal
|
2086 |
item.isListedOnSnapdeal = snapdealitem.isListedOnSnapdeal
|
| - |
|
2087 |
if snapdealitem.transferPrice is not None:
|
| - |
|
2088 |
item.transferPrice = snapdealitem.transferPrice
|
| - |
|
2089 |
if snapdealitem.sellingPrice is not None:
|
| - |
|
2090 |
item.sellingPrice = snapdealitem.sellingPrice
|
| - |
|
2091 |
if snapdealitem.courierCost is not None:
|
| - |
|
2092 |
item.courierCost = snapdealitem.courierCost
|
| - |
|
2093 |
if snapdealitem.commission is not None:
|
| - |
|
2094 |
item.commission = snapdealitem.commission
|
| - |
|
2095 |
if snapdealitem.serviceTax is not None:
|
| - |
|
2096 |
item.serviceTax = snapdealitem.serviceTax
|
| - |
|
2097 |
item.suppressPriceFeed =snapdealitem.suppressPriceFeed
|
| - |
|
2098 |
item.suppressInventoryFeed =snapdealitem.suppressInventoryFeed
|
| - |
|
2099 |
item.updatedOn = datetime.datetime.now()
|
| - |
|
2100 |
session.commit()
|
| - |
|
2101 |
return True
|
| 2073 |
else:
|
2102 |
else:
|
| 2074 |
item = SnapdealItem()
|
2103 |
item = SnapdealItem()
|
| 2075 |
if snapdealitem.item_id is not None:
|
2104 |
if snapdealitem.item_id is not None:
|
| 2076 |
item.item_id = snapdealitem.item_id
|
2105 |
item.item_id = snapdealitem.item_id
|
| 2077 |
if snapdealitem.exceptionPrice is not None:
|
2106 |
if snapdealitem.exceptionPrice is not None:
|
| 2078 |
item.exceptionPrice = snapdealitem.exceptionPrice
|
2107 |
item.exceptionPrice = snapdealitem.exceptionPrice
|
| 2079 |
if snapdealitem.warehouseId is not None:
|
2108 |
if snapdealitem.warehouseId is not None:
|
| 2080 |
item.warehouseId = snapdealitem.warehouseId
|
2109 |
item.warehouseId = snapdealitem.warehouseId
|
| 2081 |
if snapdealitem.isListedOnSnapdeal is not None:
|
2110 |
if snapdealitem.isListedOnSnapdeal is not None:
|
| 2082 |
catalogitem.isListedOnSnapdeal = snapdealitem.isListedOnSnapdeal
|
2111 |
item.isListedOnSnapdeal = snapdealitem.isListedOnSnapdeal
|
| - |
|
2112 |
if snapdealitem.transferPrice is not None:
|
| - |
|
2113 |
item.transferPrice = snapdealitem.transferPrice
|
| - |
|
2114 |
if snapdealitem.sellingPrice is not None:
|
| - |
|
2115 |
item.sellingPrice = snapdealitem.sellingPrice
|
| - |
|
2116 |
if snapdealitem.courierCost is not None:
|
| - |
|
2117 |
item.courierCost = snapdealitem.courierCost
|
| - |
|
2118 |
if snapdealitem.commission is not None:
|
| - |
|
2119 |
item.commission = snapdealitem.commission
|
| - |
|
2120 |
if snapdealitem.serviceTax is not None:
|
| - |
|
2121 |
item.serviceTax = snapdealitem.serviceTax
|
| - |
|
2122 |
item.suppressPriceFeed =snapdealitem.suppressPriceFeed
|
| - |
|
2123 |
item.suppressInventoryFeed =snapdealitem.suppressInventoryFeed
|
| - |
|
2124 |
item.updatedOn = datetime.datetime.now()
|
| 2083 |
session.commit()
|
2125 |
session.commit()
|
| - |
|
2126 |
return True
|
| 2084 |
return True
|
2127 |
return False
|
| 2085 |
except:
|
2128 |
except:
|
| 2086 |
return False
|
2129 |
return False
|
| 2087 |
|
2130 |
|
| 2088 |
def get_snapdeal_item(itemid):
|
2131 |
def get_snapdeal_item(itemid):
|
| 2089 |
item = session.query(SnapdealItem,Item).join((Item,SnapdealItem.item_id==Item.id)).filter(SnapdealItem.item_id==itemid).first()
|
2132 |
item = session.query(SnapdealItem,Item).join((Item,SnapdealItem.item_id==Item.id)).filter(SnapdealItem.item_id==itemid).first()
|
| Line 2093... |
Line 2136... |
| 2093 |
def get_all_snapdeal_items():
|
2136 |
def get_all_snapdeal_items():
|
| 2094 |
items = session.query(SnapdealItem,Item).join((Item,SnapdealItem.item_id==Item.id)).all()
|
2137 |
items = session.query(SnapdealItem,Item).join((Item,SnapdealItem.item_id==Item.id)).all()
|
| 2095 |
print items
|
2138 |
print items
|
| 2096 |
return items
|
2139 |
return items
|
| 2097 |
|
2140 |
|
| - |
|
2141 |
def get_snapdeal_items(offset,limit):
|
| - |
|
2142 |
return session.query(SnapdealItem,Item).join((Item,SnapdealItem.item_id==Item.id)).offset(offset).limit(limit).all()
|
| - |
|
2143 |
|
| 2098 |
def update_asin(amazonAsinMap):
|
2144 |
def update_asin(amazonAsinMap):
|
| 2099 |
for item_id,t_item in amazonAsinMap.iteritems():
|
2145 |
for item_id,t_item in amazonAsinMap.iteritems():
|
| 2100 |
item = get_item(item_id)
|
2146 |
item = get_item(item_id)
|
| 2101 |
item.asin=t_item.asin
|
2147 |
item.asin=t_item.asin
|
| 2102 |
item.defaultInventory = t_item.defaultInventory
|
2148 |
item.defaultInventory = t_item.defaultInventory
|
| 2103 |
item.holdInventory = t_item.holdInventory
|
2149 |
item.holdInventory = t_item.holdInventory
|
| 2104 |
item.updatedOn = datetime.datetime.now()
|
2150 |
item.updatedOn = datetime.datetime.now()
|
| 2105 |
session.commit()
|
2151 |
session.commit()
|
| - |
|
2152 |
|
| - |
|
2153 |
def search_snapdeal_items(search_terms,offset,limit):
|
| - |
|
2154 |
query = session.query(SnapdealItem,Item).join((Item,SnapdealItem.item_id==Item.id))
|
| - |
|
2155 |
search_terms = ['%' + search_term + '%' for search_term in search_terms]
|
| - |
|
2156 |
for search_term in search_terms:
|
| - |
|
2157 |
query_clause = []
|
| - |
|
2158 |
query_clause.append(Item.id.like(search_term))
|
| - |
|
2159 |
query_clause.append(Item.brand.like(search_term))
|
| - |
|
2160 |
query_clause.append(Item.model_name.like(search_term))
|
| - |
|
2161 |
query_clause.append(Item.model_number.like(search_term))
|
| - |
|
2162 |
query_clause.append(Item.color.like(search_term))
|
| - |
|
2163 |
query = query.filter(or_(*query_clause))
|
| - |
|
2164 |
|
| - |
|
2165 |
query = query.offset(offset)
|
| - |
|
2166 |
if limit:
|
| - |
|
2167 |
query = query.limit(limit)
|
| - |
|
2168 |
snapdeal_items = query.all()
|
| - |
|
2169 |
return snapdeal_items
|
| - |
|
2170 |
|
| - |
|
2171 |
def get_snapdeal_search_result_count(search_terms):
|
| - |
|
2172 |
query = session.query(SnapdealItem,Item).join((Item,SnapdealItem.item_id==Item.id))
|
| - |
|
2173 |
search_terms = ['%' + search_term + '%' for search_term in search_terms]
|
| - |
|
2174 |
for search_term in search_terms:
|
| - |
|
2175 |
query_clause = []
|
| - |
|
2176 |
query_clause.append(Item.id.like(search_term))
|
| - |
|
2177 |
query_clause.append(Item.brand.like(search_term))
|
| - |
|
2178 |
query_clause.append(Item.model_name.like(search_term))
|
| - |
|
2179 |
query_clause.append(Item.model_number.like(search_term))
|
| - |
|
2180 |
query_clause.append(Item.color.like(search_term))
|
| - |
|
2181 |
query = query.filter(or_(*query_clause))
|
| - |
|
2182 |
return query.count()
|
| - |
|
2183 |
|
| - |
|
2184 |
def get_count_for_snapdeal_items():
|
| - |
|
2185 |
return session.query(func.count(SnapdealItem.item_id)).scalar()
|
| - |
|
2186 |
|
| - |
|
2187 |
|
| - |
|
2188 |
|