| Line 38... |
Line 38... |
| 38 |
return {}
|
38 |
return {}
|
| 39 |
|
39 |
|
| 40 |
try:
|
40 |
try:
|
| 41 |
if data['updatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
41 |
if data['updatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| 42 |
print "sku id is already updated",data['_id']
|
42 |
print "sku id is already updated",data['_id']
|
| 43 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['inStock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail']}
|
43 |
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']}
|
| 44 |
except:
|
44 |
except:
|
| 45 |
pass
|
45 |
pass
|
| 46 |
|
46 |
|
| 47 |
|
47 |
|
| 48 |
url = "http://www.amazon.in/gp/offer-listing/%s/ref=olp_sort_ps"%(data['identifier'])
|
48 |
url = "http://www.amazon.in/gp/offer-listing/%s/ref=olp_sort_ps"%(data['identifier'])
|
| Line 63... |
Line 63... |
| 63 |
except:
|
63 |
except:
|
| 64 |
print "Unable to compute deal for ",data['skuBundleId']
|
64 |
print "Unable to compute deal for ",data['skuBundleId']
|
| 65 |
|
65 |
|
| 66 |
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']}
|
66 |
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 |
except:
|
67 |
except:
|
| 68 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['inStock'],'source_id':1,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail']}
|
68 |
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 |
|
69 |
|
| 70 |
elif source_id ==3:
|
70 |
elif source_id ==3:
|
| 71 |
try:
|
71 |
try:
|
| 72 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
72 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| 73 |
return {}
|
73 |
return {}
|
| 74 |
|
74 |
|
| 75 |
try:
|
75 |
try:
|
| 76 |
if data['updatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
76 |
if data['updatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| 77 |
print "sku id is already updated",data['_id']
|
77 |
print "sku id is already updated",data['_id']
|
| 78 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['inStock'],'source_id':3,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail']}
|
78 |
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']}
|
| 79 |
|
79 |
|
| 80 |
except Exception as e:
|
80 |
except Exception as e:
|
| - |
|
81 |
print "Exception snapdeal"
|
| 81 |
print e
|
82 |
print e
|
| 82 |
pass
|
83 |
pass
|
| 83 |
|
84 |
|
| 84 |
|
85 |
|
| 85 |
url="http://www.snapdeal.com/acors/json/gvbps?supc=%s&catId=175&sort=sellingPrice"%(data['identifier'])
|
86 |
url="http://www.snapdeal.com/acors/json/gvbps?supc=%s&catId=175&sort=sellingPrice"%(data['identifier'])
|
| Line 111... |
Line 112... |
| 111 |
except:
|
112 |
except:
|
| 112 |
print "Unable to compute deal for ",data['skuBundleId']
|
113 |
print "Unable to compute deal for ",data['skuBundleId']
|
| 113 |
|
114 |
|
| 114 |
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']}
|
115 |
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']}
|
| 115 |
except:
|
116 |
except:
|
| 116 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['inStock'],'source_id':3,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail']}
|
117 |
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']}
|
| 117 |
|
118 |
|
| 118 |
elif source_id == 2:
|
119 |
elif source_id == 2:
|
| 119 |
try:
|
120 |
try:
|
| 120 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
121 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| 121 |
return {}
|
122 |
return {}
|
| 122 |
|
123 |
|
| 123 |
try:
|
124 |
try:
|
| 124 |
if data['updatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
125 |
if data['updatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| 125 |
print "sku id is already updated",data['_id']
|
126 |
print "sku id is already updated",data['_id']
|
| 126 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['inStock'],'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail']}
|
127 |
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']}
|
| 127 |
except:
|
128 |
except:
|
| 128 |
pass
|
129 |
pass
|
| 129 |
|
130 |
|
| 130 |
|
131 |
|
| 131 |
url = "http://www.flipkart.com/ps/%s"%(data['identifier'])
|
132 |
url = "http://www.flipkart.com/ps/%s"%(data['identifier'])
|
| Line 155... |
Line 156... |
| 155 |
except:
|
156 |
except:
|
| 156 |
print "Unable to compute deal for ",data['skuBundleId']
|
157 |
print "Unable to compute deal for ",data['skuBundleId']
|
| 157 |
|
158 |
|
| 158 |
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']}
|
159 |
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']}
|
| 159 |
except:
|
160 |
except:
|
| 160 |
return {'_id':data['_id'],'available_price':data['available_price'],'in_stock':data['inStock'],'source_id':2,'source_product_name':data['source_product_name'],'marketPlaceUrl':data['marketPlaceUrl'],'thumbnail':data['thumbnail']}
|
161 |
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']}
|
| 161 |
else:
|
162 |
else:
|
| 162 |
return {}
|
163 |
return {}
|
| 163 |
|
164 |
|
| 164 |
|
165 |
|
| 165 |
def recomputeDeal(skuBundleId):
|
166 |
def recomputeDeal(skuBundleId):
|
| Line 204... |
Line 205... |
| 204 |
item = list(get_mongo_connection().Catalog.MasterData.find({'_id':id}))
|
205 |
item = list(get_mongo_connection().Catalog.MasterData.find({'_id':id}))
|
| 205 |
return returnLatestPrice(item[0], item[0]['source_id'])
|
206 |
return returnLatestPrice(item[0], item[0]['source_id'])
|
| 206 |
|
207 |
|
| 207 |
|
208 |
|
| 208 |
def main():
|
209 |
def main():
|
| 209 |
print getLatestPriceById(7)
|
210 |
print getLatestPriceById(148)
|
| 210 |
|
211 |
|
| 211 |
if __name__=='__main__':
|
212 |
if __name__=='__main__':
|
| 212 |
main()
|
213 |
main()
|
| 213 |
|
214 |
|