| Line 52... |
Line 52... |
| 52 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
52 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| 53 |
return {}
|
53 |
return {}
|
| 54 |
|
54 |
|
| 55 |
if data['_id'] in ignoreItems:
|
55 |
if data['_id'] in ignoreItems:
|
| 56 |
print "Ignored items returning for %d"%(data['_id'])
|
56 |
print "Ignored items returning for %d"%(data['_id'])
|
| 57 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
57 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 58 |
|
58 |
|
| 59 |
|
59 |
|
| 60 |
if data['dealFlag'] ==1 and data['dealType'] ==1:
|
60 |
if data['dealFlag'] ==1 and data['dealType'] ==1:
|
| 61 |
data['marketPlaceUrl'] = "http://www.amazon.in/dp/%s"%(data['identifier'].strip())
|
61 |
data['marketPlaceUrl'] = "http://www.amazon.in/dp/%s"%(data['identifier'].strip())
|
| 62 |
|
62 |
|
| 63 |
try:
|
63 |
try:
|
| 64 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
64 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| 65 |
print "sku id is already updated",data['_id']
|
65 |
print "sku id is already updated",data['_id']
|
| 66 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
66 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 67 |
except:
|
67 |
except:
|
| 68 |
pass
|
68 |
pass
|
| 69 |
|
69 |
|
| 70 |
|
70 |
|
| 71 |
url = "http://www.amazon.in/gp/aw/ol/%s?o=New&op=1"%(data['identifier'])
|
71 |
url = "http://www.amazon.in/gp/aw/ol/%s?o=New&op=1"%(data['identifier'])
|
| Line 97... |
Line 97... |
| 97 |
else:
|
97 |
else:
|
| 98 |
lowestPrice = data['available_price']
|
98 |
lowestPrice = data['available_price']
|
| 99 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':0,'priceUpdatedOn':to_java_date(now)}}, multi=True)
|
99 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':0,'priceUpdatedOn':to_java_date(now)}}, multi=True)
|
| 100 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':0,'dealType':data['dealType'],'codAvailable':data['codAvailable']}}, multi=True)
|
100 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':0,'dealType':data['dealType'],'codAvailable':data['codAvailable']}}, multi=True)
|
| 101 |
|
101 |
|
| 102 |
return {'_id':data['_id'],'available_price':lowestPrice,'in_stock':inStock,'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
102 |
return {'_id':data['_id'],'available_price':lowestPrice,'in_stock':inStock,'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 103 |
except Exception as e:
|
103 |
except Exception as e:
|
| 104 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
104 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
| 105 |
print e
|
105 |
print e
|
| 106 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
106 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 107 |
|
107 |
|
| 108 |
elif source_id ==4:
|
108 |
elif source_id ==4:
|
| 109 |
|
109 |
|
| 110 |
try:
|
110 |
try:
|
| 111 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
111 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| 112 |
return {}
|
112 |
return {}
|
| 113 |
|
113 |
|
| 114 |
try:
|
114 |
try:
|
| 115 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
115 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| 116 |
print "sku id is already updated",data['_id']
|
116 |
print "sku id is already updated",data['_id']
|
| 117 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':4,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
117 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':4,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 118 |
except:
|
118 |
except:
|
| 119 |
pass
|
119 |
pass
|
| 120 |
|
120 |
|
| 121 |
url = "http://50.116.3.101:8080/mobileapi/dtr-pricing?id=%s"%(data['identifier'])
|
121 |
url = "http://50.116.3.101:8080/mobileapi/dtr-pricing?id=%s"%(data['identifier'])
|
| 122 |
lowestPrice = 0.0
|
122 |
lowestPrice = 0.0
|
| Line 206... |
Line 206... |
| 206 |
else:
|
206 |
else:
|
| 207 |
lowestOfferPrice = data['available_price']
|
207 |
lowestOfferPrice = data['available_price']
|
| 208 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':inStock,'priceUpdatedOn':to_java_date(now),'buyBoxFlag':isBuyBox}}, multi=True)
|
208 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':inStock,'priceUpdatedOn':to_java_date(now),'buyBoxFlag':isBuyBox}}, multi=True)
|
| 209 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':inStock,'codAvailable':data['codAvailable']}}, multi=True)
|
209 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':inStock,'codAvailable':data['codAvailable']}}, multi=True)
|
| 210 |
|
210 |
|
| 211 |
return {'_id':data['_id'],'available_price':lowestOfferPrice,'in_stock':inStock,'source_id':3,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
211 |
return {'_id':data['_id'],'available_price':lowestOfferPrice,'in_stock':inStock,'source_id':3,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 212 |
except Exception as e:
|
212 |
except Exception as e:
|
| 213 |
print traceback.print_exc()
|
213 |
print traceback.print_exc()
|
| 214 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
214 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
| 215 |
print e
|
215 |
print e
|
| 216 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':3,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
216 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':3,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 217 |
|
217 |
|
| 218 |
elif source_id == 2:
|
218 |
elif source_id == 2:
|
| 219 |
try:
|
219 |
try:
|
| 220 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
220 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| 221 |
return {}
|
221 |
return {}
|
| 222 |
|
222 |
|
| 223 |
if data['_id'] in ignoreItems:
|
223 |
if data['_id'] in ignoreItems:
|
| 224 |
print "Ignored items returning for %d"%(data['_id'])
|
224 |
print "Ignored items returning for %d"%(data['_id'])
|
| 225 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
225 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 226 |
|
226 |
|
| 227 |
try:
|
227 |
try:
|
| 228 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
228 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| 229 |
print "sku id is already updated",data['_id']
|
229 |
print "sku id is already updated",data['_id']
|
| 230 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
230 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 231 |
except:
|
231 |
except:
|
| 232 |
pass
|
232 |
pass
|
| 233 |
|
233 |
|
| 234 |
lowestSp = 0
|
234 |
lowestSp = 0
|
| 235 |
inStock = 0
|
235 |
inStock = 0
|
| Line 272... |
Line 272... |
| 272 |
else:
|
272 |
else:
|
| 273 |
lowestSp = data['available_price']
|
273 |
lowestSp = data['available_price']
|
| 274 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':inStock,'priceUpdatedOn':to_java_date(now),'buyBoxFlag':isBuyBox}}, multi=True)
|
274 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':inStock,'priceUpdatedOn':to_java_date(now),'buyBoxFlag':isBuyBox}}, multi=True)
|
| 275 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':inStock,'codAvailable':data['codAvailable']}}, multi=True)
|
275 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':inStock,'codAvailable':data['codAvailable']}}, multi=True)
|
| 276 |
|
276 |
|
| 277 |
return {'_id':data['_id'],'available_price':lowestSp,'in_stock':inStock,'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
277 |
return {'_id':data['_id'],'available_price':lowestSp,'in_stock':inStock,'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 278 |
|
278 |
|
| 279 |
except Exception as e:
|
279 |
except Exception as e:
|
| 280 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
280 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
| 281 |
print e
|
281 |
print e
|
| 282 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
282 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 283 |
|
283 |
|
| 284 |
elif source_id == 5:
|
284 |
elif source_id == 5:
|
| 285 |
try:
|
285 |
try:
|
| 286 |
if data['_id'] in ignoreItems:
|
286 |
if data['_id'] in ignoreItems:
|
| 287 |
print "Ignored items returning for %d"%(data['_id'])
|
287 |
print "Ignored items returning for %d"%(data['_id'])
|
| 288 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
288 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 289 |
|
289 |
|
| 290 |
try:
|
290 |
try:
|
| 291 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
291 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| 292 |
print "sku id is already updated",data['_id']
|
292 |
print "sku id is already updated",data['_id']
|
| 293 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
293 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 294 |
except:
|
294 |
except:
|
| 295 |
pass
|
295 |
pass
|
| 296 |
|
296 |
|
| 297 |
|
297 |
|
| 298 |
url = data['marketPlaceUrl']
|
298 |
url = data['marketPlaceUrl']
|
| Line 314... |
Line 314... |
| 314 |
else:
|
314 |
else:
|
| 315 |
lowestPrice = data['available_price']
|
315 |
lowestPrice = data['available_price']
|
| 316 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':0,'priceUpdatedOn':to_java_date(now)}})
|
316 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':0,'priceUpdatedOn':to_java_date(now)}})
|
| 317 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':0,'dealType':data['dealType'],'rank':data['rank'],'codAvailable':productInfo['isCod']}})
|
317 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':0,'dealType':data['dealType'],'rank':data['rank'],'codAvailable':productInfo['isCod']}})
|
| 318 |
|
318 |
|
| 319 |
return {'_id':data['_id'],'available_price':productInfo['price'],'in_stock':productInfo['inStock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':productInfo['coupon'],'codAvailable':productInfo['isCod']}
|
319 |
return {'_id':data['_id'],'available_price':productInfo['price'],'in_stock':productInfo['inStock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'], 'coupon':productInfo['coupon'],'codAvailable':productInfo['isCod'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 320 |
except Exception as e:
|
320 |
except Exception as e:
|
| 321 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
321 |
print "Exception for _id %d and source %s"%(data['_id'], source_id)
|
| 322 |
print e
|
322 |
print e
|
| 323 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable']}
|
323 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['in_stock'],'source_id':5,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| 324 |
|
324 |
|
| 325 |
else:
|
325 |
else:
|
| 326 |
return {}
|
326 |
return {}
|
| 327 |
|
327 |
|
| 328 |
|
328 |
|
| Line 530... |
Line 530... |
| 530 |
info = returnLatestPrice(item, item['source_id'],False)
|
530 |
info = returnLatestPrice(item, item['source_id'],False)
|
| 531 |
print info
|
531 |
print info
|
| 532 |
|
532 |
|
| 533 |
def main():
|
533 |
def main():
|
| 534 |
print datetime.now()
|
534 |
print datetime.now()
|
| 535 |
print "retuned %s"%(str(getLatestPriceById(271)))
|
535 |
print "retuned %s"%(str(getLatestPriceById(22804)))
|
| 536 |
print datetime.now()
|
536 |
print datetime.now()
|
| 537 |
if __name__=='__main__':
|
537 |
if __name__=='__main__':
|
| 538 |
main()
|
538 |
main()
|
| 539 |
|
539 |
|