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