| Line 17... |
Line 17... |
| 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, ProductFeedSubmit, MarketplaceItems, MarketPlaceItemPrice
|
22 |
SnapdealItemUpdateHistory, ProductFeedSubmit, MarketplaceItems, MarketPlaceItemPrice, \
|
| - |
|
23 |
SourcePercentageMaster, SourceItemPercentage
|
| 23 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
24 |
from shop2020.thriftpy.model.v1.catalog.ttypes import status, ItemShippingInfo, \
|
| 24 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
25 |
ItemType, PremiumType, FreebieItem as t_FreebieItem, \
|
| 25 |
StorePricing as tStorePricing, CatalogServiceException, \
|
26 |
StorePricing as tStorePricing, CatalogServiceException, \
|
| 26 |
BannerType, InsurerType
|
27 |
BannerType, InsurerType
|
| 27 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
28 |
from shop2020.thriftpy.model.v1.inventory.ttypes import \
|
| Line 2085... |
Line 2086... |
| 2085 |
def get_count_for_amazonlisted_items():
|
2086 |
def get_count_for_amazonlisted_items():
|
| 2086 |
return session.query(func.count(Amazonlisted.itemId)).scalar()
|
2087 |
return session.query(func.count(Amazonlisted.itemId)).scalar()
|
| 2087 |
|
2088 |
|
| 2088 |
def add_or_update_snapdeal_item(snapdealitem):
|
2089 |
def add_or_update_snapdeal_item(snapdealitem):
|
| 2089 |
item = SnapdealItem.get_by(item_id=snapdealitem.item_id)
|
2090 |
item = SnapdealItem.get_by(item_id=snapdealitem.item_id)
|
| - |
|
2091 |
if not __validateSnapdealObject(snapdealitem):
|
| - |
|
2092 |
print "Bad object"
|
| - |
|
2093 |
return False
|
| 2090 |
try:
|
2094 |
try:
|
| 2091 |
if item is not None:
|
2095 |
if item is not None:
|
| 2092 |
itemHistory = SnapdealItemUpdateHistory()
|
2096 |
itemHistory = SnapdealItemUpdateHistory()
|
| 2093 |
itemHistory.item_id = snapdealitem.item_id
|
2097 |
itemHistory.item_id = snapdealitem.item_id
|
| 2094 |
itemHistory.exceptionPrice = item.exceptionPrice
|
2098 |
itemHistory.exceptionPrice = item.exceptionPrice
|
| Line 2103... |
Line 2107... |
| 2103 |
itemHistory.suppressInventoryFeed = item.suppressInventoryFeed
|
2107 |
itemHistory.suppressInventoryFeed = item.suppressInventoryFeed
|
| 2104 |
itemHistory.updatedOn = item.updatedOn
|
2108 |
itemHistory.updatedOn = item.updatedOn
|
| 2105 |
itemHistory.maxNlc = item.maxNlc
|
2109 |
itemHistory.maxNlc = item.maxNlc
|
| 2106 |
itemHistory.skuAtSnapdeal = item.skuAtSnapdeal
|
2110 |
itemHistory.skuAtSnapdeal = item.skuAtSnapdeal
|
| 2107 |
itemHistory.supc = item.supc
|
2111 |
itemHistory.supc = item.supc
|
| - |
|
2112 |
itemHistory.priceUpdatedBy = item.priceUpdatedBy
|
| 2108 |
|
2113 |
|
| - |
|
2114 |
if (item.sellingPrice!=snapdealitem.sellingPrice):
|
| - |
|
2115 |
item.priceUpdatedBy = snapdealitem.updatedBy
|
| - |
|
2116 |
|
| 2109 |
if snapdealitem.exceptionPrice is not None:
|
2117 |
if snapdealitem.exceptionPrice is not None:
|
| 2110 |
item.exceptionPrice = snapdealitem.exceptionPrice
|
2118 |
item.exceptionPrice = snapdealitem.exceptionPrice
|
| 2111 |
if snapdealitem.warehouseId is not None:
|
2119 |
if snapdealitem.warehouseId is not None:
|
| 2112 |
item.warehouseId = snapdealitem.warehouseId
|
2120 |
item.warehouseId = snapdealitem.warehouseId
|
| 2113 |
if snapdealitem.isListedOnSnapdeal is not None:
|
2121 |
if snapdealitem.isListedOnSnapdeal is not None:
|
| Line 2127... |
Line 2135... |
| 2127 |
if snapdealitem.maxNlc is not None:
|
2135 |
if snapdealitem.maxNlc is not None:
|
| 2128 |
item.maxNlc = snapdealitem.maxNlc
|
2136 |
item.maxNlc = snapdealitem.maxNlc
|
| 2129 |
item.skuAtSnapdeal = snapdealitem.skuAtSnapdeal
|
2137 |
item.skuAtSnapdeal = snapdealitem.skuAtSnapdeal
|
| 2130 |
item.updatedOn = datetime.datetime.now()
|
2138 |
item.updatedOn = datetime.datetime.now()
|
| 2131 |
item.supc = snapdealitem.supc
|
2139 |
item.supc = snapdealitem.supc
|
| 2132 |
session.commit()
|
2140 |
__markStatusForMarketplaceItems(snapdealitem,item)
|
| 2133 |
return True
|
2141 |
return update_marketplace_attributes_for_item(snapdealitem.marketplaceItems)
|
| 2134 |
else:
|
2142 |
else:
|
| 2135 |
item = SnapdealItem()
|
2143 |
item = SnapdealItem()
|
| 2136 |
if snapdealitem.item_id is not None:
|
2144 |
if snapdealitem.item_id is not None:
|
| 2137 |
item.item_id = snapdealitem.item_id
|
2145 |
item.item_id = snapdealitem.item_id
|
| 2138 |
if snapdealitem.exceptionPrice is not None:
|
2146 |
if snapdealitem.exceptionPrice is not None:
|
| Line 2154... |
Line 2162... |
| 2154 |
item.suppressPriceFeed =snapdealitem.suppressPriceFeed
|
2162 |
item.suppressPriceFeed =snapdealitem.suppressPriceFeed
|
| 2155 |
item.suppressInventoryFeed =snapdealitem.suppressInventoryFeed
|
2163 |
item.suppressInventoryFeed =snapdealitem.suppressInventoryFeed
|
| 2156 |
item.maxNlc = snapdealitem.maxNlc
|
2164 |
item.maxNlc = snapdealitem.maxNlc
|
| 2157 |
item.skuAtSnapdeal = snapdealitem.skuAtSnapdeal
|
2165 |
item.skuAtSnapdeal = snapdealitem.skuAtSnapdeal
|
| 2158 |
item.supc = snapdealitem.supc
|
2166 |
item.supc = snapdealitem.supc
|
| 2159 |
item.updatedOn = datetime.datetime.now()
|
2167 |
item.updatedOn = datetime.datetime.now()
|
| 2160 |
session.commit()
|
2168 |
item.priceUpdatedBy = snapdealitem.updatedBy
|
| 2161 |
return True
|
2169 |
__markStatusForMarketplaceItems(snapdealitem,item)
|
| - |
|
2170 |
return update_marketplace_attributes_for_item(snapdealitem.marketplaceItems)
|
| 2162 |
return False
|
2171 |
except Exception as ex:
|
| - |
|
2172 |
print "Unable to addOrupdate snapdealItem"
|
| 2163 |
except:
|
2173 |
print ex
|
| 2164 |
return False
|
2174 |
return False
|
| 2165 |
|
2175 |
|
| 2166 |
def get_snapdeal_item(itemid):
|
2176 |
def get_snapdeal_item(itemid):
|
| 2167 |
item = session.query(SnapdealItem,Item).join((Item,SnapdealItem.item_id==Item.id)).filter(SnapdealItem.item_id==itemid).first()
|
2177 |
item = session.query(SnapdealItem,Item).join((Item,SnapdealItem.item_id==Item.id)).filter(SnapdealItem.item_id==itemid).first()
|
| 2168 |
return item
|
2178 |
return item
|
| Line 2277... |
Line 2287... |
| 2277 |
marketplaceItem = get_marketplace_details_for_item(t_marketplaceItem.itemId,t_marketplaceItem.source)
|
2287 |
marketplaceItem = get_marketplace_details_for_item(t_marketplaceItem.itemId,t_marketplaceItem.source)
|
| 2278 |
if marketplaceItem is None:
|
2288 |
if marketplaceItem is None:
|
| 2279 |
marketplaceItem = MarketplaceItems()
|
2289 |
marketplaceItem = MarketplaceItems()
|
| 2280 |
marketplaceItem.itemId = t_marketplaceItem.itemId
|
2290 |
marketplaceItem.itemId = t_marketplaceItem.itemId
|
| 2281 |
marketplaceItem.source = t_marketplaceItem.source
|
2291 |
marketplaceItem.source = t_marketplaceItem.source
|
| 2282 |
marketplaceItem.emiFee =0.0
|
2292 |
marketplaceItem.emiFee = t_marketplaceItem.emiFee
|
| 2283 |
marketplaceItem.closingFee = 0.0
|
2293 |
marketplaceItem.closingFee = t_marketplaceItem.closingFee
|
| 2284 |
marketplaceItem.returnProvision = 0.5
|
2294 |
marketplaceItem.returnProvision = t_marketplaceItem.returnProvision
|
| 2285 |
marketplaceItem.commission = 3.59
|
2295 |
marketplaceItem.commission = t_marketplaceItem.commission
|
| 2286 |
marketplaceItem.vat = t_marketplaceItem.vat
|
2296 |
marketplaceItem.vat = t_marketplaceItem.vat
|
| 2287 |
marketplaceItem.packagingCost = 15.0
|
2297 |
marketplaceItem.packagingCost = 15.0
|
| 2288 |
marketplaceItem.serviceTax = 12.36
|
2298 |
marketplaceItem.serviceTax = t_marketplaceItem.serviceTax
|
| 2289 |
marketplaceItem.courierCost = t_marketplaceItem.courierCost
|
2299 |
marketplaceItem.courierCost = t_marketplaceItem.courierCost
|
| 2290 |
marketplaceItem.otherCost = t_marketplaceItem.otherCost
|
2300 |
marketplaceItem.otherCost = t_marketplaceItem.otherCost
|
| 2291 |
marketplaceItem.autoIncrement = t_marketplaceItem.autoIncrement
|
2301 |
marketplaceItem.autoIncrement = t_marketplaceItem.autoIncrement
|
| 2292 |
marketplaceItem.autoDecrement = t_marketplaceItem.autoDecrement
|
2302 |
marketplaceItem.autoDecrement = t_marketplaceItem.autoDecrement
|
| 2293 |
marketplaceItem.manualFavourite = t_marketplaceItem.manualFavourite
|
2303 |
marketplaceItem.manualFavourite = t_marketplaceItem.manualFavourite
|
| Line 2303... |
Line 2313... |
| 2303 |
marketplaceItem.manualFavourite = t_marketplaceItem.manualFavourite
|
2313 |
marketplaceItem.manualFavourite = t_marketplaceItem.manualFavourite
|
| 2304 |
marketplaceItem.currentSp = t_marketplaceItem.currentSp
|
2314 |
marketplaceItem.currentSp = t_marketplaceItem.currentSp
|
| 2305 |
marketplaceItem.currentTp = t_marketplaceItem.currentTp
|
2315 |
marketplaceItem.currentTp = t_marketplaceItem.currentTp
|
| 2306 |
marketplaceItem.minimumPossibleSp = t_marketplaceItem.minimumPossibleSp
|
2316 |
marketplaceItem.minimumPossibleSp = t_marketplaceItem.minimumPossibleSp
|
| 2307 |
marketplaceItem.minimumPossibleTp = t_marketplaceItem.minimumPossibleTp
|
2317 |
marketplaceItem.minimumPossibleTp = t_marketplaceItem.minimumPossibleTp
|
| - |
|
2318 |
marketplaceItem.emiFee = t_marketplaceItem.emiFee
|
| - |
|
2319 |
marketplaceItem.closingFee = t_marketplaceItem.closingFee
|
| - |
|
2320 |
marketplaceItem.returnProvision = t_marketplaceItem.returnProvision
|
| - |
|
2321 |
marketplaceItem.commission = t_marketplaceItem.commission
|
| - |
|
2322 |
marketplaceItem.vat = t_marketplaceItem.vat
|
| - |
|
2323 |
marketplaceItem.serviceTax = t_marketplaceItem.serviceTax
|
| 2308 |
session.commit()
|
2324 |
session.commit()
|
| 2309 |
return True
|
2325 |
return True
|
| 2310 |
except Exception as ex:
|
2326 |
except Exception as ex:
|
| - |
|
2327 |
print "Unable to addOrupdate MarketplaceItem"
|
| 2311 |
print ex
|
2328 |
print ex
|
| 2312 |
return False
|
2329 |
return False
|
| - |
|
2330 |
|
| - |
|
2331 |
def __markStatusForMarketplaceItems(snapdealItem,item):
|
| - |
|
2332 |
try:
|
| - |
|
2333 |
marketplaceItem = snapdealItem.marketplaceItems
|
| - |
|
2334 |
markUpdatedItem = MarketPlaceItemPrice.query.filter(MarketPlaceItemPrice.item_id==snapdealItem.item_id).filter(MarketPlaceItemPrice.source==marketplaceItem.source).first()
|
| - |
|
2335 |
if markUpdatedItem is None:
|
| - |
|
2336 |
marketPlaceItemPrice = MarketPlaceItemPrice()
|
| - |
|
2337 |
marketPlaceItemPrice.item_id = snapdealItem.item_id
|
| - |
|
2338 |
marketPlaceItemPrice.source = marketplaceItem.source
|
| - |
|
2339 |
marketPlaceItemPrice.lastUpdatedOn = item.updatedOn
|
| - |
|
2340 |
marketPlaceItemPrice.sellingPrice = item.sellingPrice
|
| - |
|
2341 |
marketPlaceItemPrice.suppressPriceFeed = item.suppressPriceFeed
|
| - |
|
2342 |
marketPlaceItemPrice.isListedOnSource = item.isListedOnSnapdeal
|
| - |
|
2343 |
else:
|
| - |
|
2344 |
if (markUpdatedItem.sellingPrice!=snapdealItem.sellingPrice or markUpdatedItem.suppressPriceFeed!=item.suppressPriceFeed or markUpdatedItem.isListedOnSource!=item.isListedOnSnapdeal):
|
| - |
|
2345 |
markUpdatedItem.lastUpdatedOn = item.updatedOn
|
| - |
|
2346 |
markUpdatedItem.sellingPrice = snapdealItem.sellingPrice
|
| - |
|
2347 |
markUpdatedItem.suppressPriceFeed = item.suppressPriceFeed
|
| - |
|
2348 |
markUpdatedItem.isListedOnSource = item.isListedOnSnapdeal
|
| - |
|
2349 |
return True
|
| - |
|
2350 |
except Exception as e:
|
| - |
|
2351 |
print e
|
| - |
|
2352 |
return False
|
| - |
|
2353 |
|
| - |
|
2354 |
def get_costing_for_marketplace(source_id,itemId):
|
| - |
|
2355 |
sip = SourceItemPercentage.get_by(source=source_id,item_id=itemId)
|
| - |
|
2356 |
if sip is None:
|
| - |
|
2357 |
spm = SourcePercentageMaster.get_by(source=source_id)
|
| - |
|
2358 |
return spm
|
| - |
|
2359 |
else:
|
| - |
|
2360 |
return sip
|
| 2313 |
|
2361 |
|
| - |
|
2362 |
def __validateSnapdealObject(snapdealItem):
|
| - |
|
2363 |
if len(snapdealItem.supc)==0 or snapdealItem.supc is None or len(snapdealItem.skuAtSnapdeal)==0 or snapdealItem.skuAtSnapdeal is None or snapdealItem.sellingPrice==0 or snapdealItem.maxNlc==0:
|
| - |
|
2364 |
return False
|
| - |
|
2365 |
else:
|
| - |
|
2366 |
return True
|
| - |
|
2367 |
|
| - |
|
2368 |
|
| 2314 |
def get_all_marketplace_items_for_priceupdate(source):
|
2369 |
def get_all_marketplace_items_for_priceupdate(source):
|
| 2315 |
marketPlaceItemsPrices = MarketPlaceItemPrice.query.filter(MarketPlaceItemPrice.source == source).filter(MarketPlaceItemPrice.lastUpdatedOn > MarketPlaceItemPrice.lastUpdatedOnMarketplace).all()
|
2370 |
marketPlaceItemsPrices = MarketPlaceItemPrice.query.filter(MarketPlaceItemPrice.source == source).filter(MarketPlaceItemPrice.lastUpdatedOn > MarketPlaceItemPrice.lastUpdatedOnMarketplace).all()
|
| 2316 |
print marketPlaceItemsPrices
|
2371 |
print marketPlaceItemsPrices
|
| 2317 |
return marketPlaceItemsPrices
|
2372 |
return marketPlaceItemsPrices
|
| 2318 |
|
2373 |
|