| Line 6... |
Line 6... |
| 6 |
import pymongo
|
6 |
import pymongo
|
| 7 |
from dtr.utils.utils import to_java_date
|
7 |
from dtr.utils.utils import to_java_date
|
| 8 |
import optparse
|
8 |
import optparse
|
| 9 |
from dtr.storage.MemCache import MemCache
|
9 |
from dtr.storage.MemCache import MemCache
|
| 10 |
from dtr.utils.utils import getCashBack
|
10 |
from dtr.utils.utils import getCashBack
|
| 11 |
from dtr.utils.utils import getNlcPoints
|
11 |
from dtr.utils.utils import getNlcPoints, DEAL_PRIORITY
|
| 12 |
import traceback
|
12 |
import traceback
|
| 13 |
|
13 |
|
| 14 |
dealsMap = {}
|
14 |
dealsMap = {}
|
| 15 |
con = None
|
15 |
con = None
|
| 16 |
dealsCatalogIds = []
|
16 |
dealsCatalogIds = []
|
| Line 178... |
Line 178... |
| 178 |
print in_stock
|
178 |
print in_stock
|
| 179 |
print available_price
|
179 |
print available_price
|
| 180 |
print dealsMap.get(d_item.id)
|
180 |
print dealsMap.get(d_item.id)
|
| 181 |
print "++++++++++++++++++++++++++"
|
181 |
print "++++++++++++++++++++++++++"
|
| 182 |
if available_price > 0 or available_price is not None:
|
182 |
if available_price > 0 or available_price is not None:
|
| 183 |
netPriceAfterCashBack = getNetPriceForItem(data['_id'], SOURCE_MAP.get('SAHOLIC'), data['category_id'], available_price)
|
183 |
netPriceAfterCashBack = getNetPriceForItem(saholicCatalogId['_id'], SOURCE_MAP.get('SAHOLIC'), saholicCatalogId['category_id'], available_price)
|
| 184 |
get_mongo_connection().Catalog.MasterData.update({'_id':saholicCatalogId['_id']}, {'$set' : {'available_price':available_price,'updatedOn':to_java_date(datetime.now()),'priceUpdatedOn':to_java_date(datetime.now()),'in_stock':in_stock}}, multi=True)
|
184 |
get_mongo_connection().Catalog.MasterData.update({'_id':saholicCatalogId['_id']}, {'$set' : {'available_price':available_price,'updatedOn':to_java_date(datetime.now()),'priceUpdatedOn':to_java_date(datetime.now()),'in_stock':in_stock}}, multi=True)
|
| 185 |
get_mongo_connection().Catalog.Deals.update({'_id':saholicCatalogId['_id']}, {'$set' : {'available_price':available_price , 'in_stock':in_stock,'netPriceAfterCashBack':netPriceAfterCashBack}}, multi=True)
|
185 |
get_mongo_connection().Catalog.Deals.update({'_id':saholicCatalogId['_id']}, {'$set' : {'available_price':available_price , 'in_stock':in_stock,'netPriceAfterCashBack':netPriceAfterCashBack}}, multi=True)
|
| 186 |
else:
|
186 |
else:
|
| 187 |
netPriceAfterCashBack = getNetPriceForItem(data['_id'], SOURCE_MAP.get('SAHOLIC'), data['category_id'], saholicCatalogId['available_price'])
|
187 |
netPriceAfterCashBack = getNetPriceForItem(saholicCatalogId['_id'], SOURCE_MAP.get('SAHOLIC'), saholicCatalogId['category_id'], saholicCatalogId['available_price'])
|
| 188 |
get_mongo_connection().Catalog.MasterData.update({'_id':saholicCatalogId['_id']}, {'$set' : {'updatedOn':to_java_date(datetime.now()),'in_stock':in_stock,'priceUpdatedOn':to_java_date(datetime.now())}}, multi=True)
|
188 |
get_mongo_connection().Catalog.MasterData.update({'_id':saholicCatalogId['_id']}, {'$set' : {'updatedOn':to_java_date(datetime.now()),'in_stock':in_stock,'priceUpdatedOn':to_java_date(datetime.now())}}, multi=True)
|
| 189 |
get_mongo_connection().Catalog.Deals.update({'_id':saholicCatalogId['_id']}, {'$set' : {'in_stock':in_stock,'netPriceAfterCashBack':netPriceAfterCashBack}}, multi=True)
|
189 |
get_mongo_connection().Catalog.Deals.update({'_id':saholicCatalogId['_id']}, {'$set' : {'in_stock':in_stock,'netPriceAfterCashBack':netPriceAfterCashBack}}, multi=True)
|
| 190 |
|
190 |
|
| 191 |
try:
|
191 |
try:
|
| 192 |
recomputeDeal(saholicCatalogId)
|
192 |
recomputeDeal(saholicCatalogId)
|
| Line 242... |
Line 242... |
| 242 |
continue
|
242 |
continue
|
| 243 |
if similarItem.get('netPriceAfterCashBack') < bestPrice:
|
243 |
if similarItem.get('netPriceAfterCashBack') < bestPrice:
|
| 244 |
bestOne = similarItem
|
244 |
bestOne = similarItem
|
| 245 |
bestPrice = similarItem.get('netPriceAfterCashBack')
|
245 |
bestPrice = similarItem.get('netPriceAfterCashBack')
|
| 246 |
bestSellerPoints = similarItem['bestSellerPoints']
|
246 |
bestSellerPoints = similarItem['bestSellerPoints']
|
| 247 |
elif similarItem.get('netPriceAfterCashBack') == bestPrice and bestSellerPoints < similarItem['bestSellerPoints']:
|
247 |
elif similarItem.get('netPriceAfterCashBack') == bestPrice:
|
| - |
|
248 |
|
| - |
|
249 |
try:
|
| - |
|
250 |
if (DEAL_PRIORITY.index(int(similarItem['source_id'])) > DEAL_PRIORITY.index(int(bestOne['source_id']))):
|
| - |
|
251 |
continue
|
| - |
|
252 |
except:
|
| - |
|
253 |
traceback.print_exc()
|
| - |
|
254 |
|
| - |
|
255 |
|
| 248 |
bestOne = similarItem
|
256 |
bestOne = similarItem
|
| 249 |
bestPrice = similarItem.get('netPriceAfterCashBack')
|
257 |
bestPrice = similarItem.get('netPriceAfterCashBack')
|
| 250 |
bestSellerPoints = similarItem['bestSellerPoints']
|
258 |
bestSellerPoints = similarItem['bestSellerPoints']
|
| 251 |
else:
|
259 |
else:
|
| 252 |
pass
|
260 |
pass
|
| Line 261... |
Line 269... |
| 261 |
continue
|
269 |
continue
|
| 262 |
if similarItem.get('netPriceAfterCashBack') < prepaidBestPrice:
|
270 |
if similarItem.get('netPriceAfterCashBack') < prepaidBestPrice:
|
| 263 |
prepaidBestOne = similarItem
|
271 |
prepaidBestOne = similarItem
|
| 264 |
prepaidBestPrice = similarItem.get('netPriceAfterCashBack')
|
272 |
prepaidBestPrice = similarItem.get('netPriceAfterCashBack')
|
| 265 |
prepaidBestSellerPoints = similarItem['bestSellerPoints']
|
273 |
prepaidBestSellerPoints = similarItem['bestSellerPoints']
|
| 266 |
elif similarItem.get('netPriceAfterCashBack') == prepaidBestPrice and prepaidBestSellerPoints < similarItem['bestSellerPoints']:
|
274 |
elif similarItem.get('netPriceAfterCashBack') == prepaidBestPrice:
|
| - |
|
275 |
|
| - |
|
276 |
try:
|
| - |
|
277 |
if (DEAL_PRIORITY.index(int(similarItem['source_id'])) > DEAL_PRIORITY.index(int(bestOne['source_id']))):
|
| - |
|
278 |
continue
|
| - |
|
279 |
except:
|
| - |
|
280 |
traceback.print_exc()
|
| - |
|
281 |
|
| 267 |
prepaidBestOne = similarItem
|
282 |
prepaidBestOne = similarItem
|
| 268 |
prepaidBestPrice = similarItem.get('netPriceAfterCashBack')
|
283 |
prepaidBestPrice = similarItem.get('netPriceAfterCashBack')
|
| 269 |
prepaidBestSellerPoints = similarItem['bestSellerPoints']
|
284 |
prepaidBestSellerPoints = similarItem['bestSellerPoints']
|
| 270 |
else:
|
285 |
else:
|
| 271 |
pass
|
286 |
pass
|