| Line 66... |
Line 66... |
| 66 |
|
66 |
|
| 67 |
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']}
|
67 |
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']}
|
| 68 |
except:
|
68 |
except:
|
| 69 |
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']}
|
69 |
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']}
|
| 70 |
|
70 |
|
| - |
|
71 |
elif source_id ==4:
|
| - |
|
72 |
try:
|
| - |
|
73 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| - |
|
74 |
return {}
|
| - |
|
75 |
|
| - |
|
76 |
try:
|
| - |
|
77 |
if data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| - |
|
78 |
print "sku id is already updated",data['_id']
|
| - |
|
79 |
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']}
|
| - |
|
80 |
except:
|
| - |
|
81 |
pass
|
| - |
|
82 |
|
| - |
|
83 |
url = "http://109.74.200.220:8080/mobileapi/dtr-pricing?id=%s"%(data['identifier'])
|
| - |
|
84 |
lowestPrice = 0.0
|
| - |
|
85 |
instock = 0
|
| - |
|
86 |
req = urllib2.Request(url,headers=headers)
|
| - |
|
87 |
response = urllib2.urlopen(req)
|
| - |
|
88 |
response.close()
|
| - |
|
89 |
json_input = response.read()
|
| - |
|
90 |
priceInfo = json.loads(json_input)
|
| - |
|
91 |
lowestPrice = priceInfo['response']['sellingPrice']
|
| - |
|
92 |
if lowestPrice > 0:
|
| - |
|
93 |
instock = 1
|
| - |
|
94 |
if instock == 1:
|
| - |
|
95 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'available_price':lowestPrice,'updatedOn':to_java_date(now),'priceUpdatedOn':to_java_date(now),'in_stock':inStock}}, multi=True)
|
| - |
|
96 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'available_price':lowestPrice , 'in_stock':inStock}}, multi=True)
|
| - |
|
97 |
else:
|
| - |
|
98 |
lowestPrice = data['available_price']
|
| - |
|
99 |
get_mongo_connection().Catalog.MasterData.update({'_id':data['_id']}, {'$set' : {'updatedOn':to_java_date(now),'in_stock':inStock,'priceUpdatedOn':to_java_date(now)}}, multi=True)
|
| - |
|
100 |
get_mongo_connection().Catalog.Deals.update({'_id':data['_id']}, {'$set' : {'in_stock':inStock}}, multi=True)
|
| - |
|
101 |
|
| - |
|
102 |
try:
|
| - |
|
103 |
recomputeDeal(data['skuBundleId'])
|
| - |
|
104 |
except:
|
| - |
|
105 |
print "Unable to compute deal for ",data['skuBundleId']
|
| - |
|
106 |
|
| - |
|
107 |
return {'_id':data['_id'],'available_price':lowestPrice,'in_stock':inStock,'source_id':4,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail']}
|
| - |
|
108 |
except:
|
| - |
|
109 |
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']}
|
| - |
|
110 |
|
| - |
|
111 |
|
| - |
|
112 |
|
| - |
|
113 |
|
| - |
|
114 |
|
| - |
|
115 |
|
| 71 |
elif source_id ==3:
|
116 |
elif source_id ==3:
|
| 72 |
try:
|
117 |
try:
|
| 73 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
118 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| 74 |
return {}
|
119 |
return {}
|
| 75 |
|
120 |
|