| Line 53... |
Line 53... |
| 53 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
53 |
if data['identifier'] is None or len(data['identifier'].strip())==0:
|
| 54 |
return {}
|
54 |
return {}
|
| 55 |
|
55 |
|
| 56 |
if data.get('ignorePricing') ==1:
|
56 |
if data.get('ignorePricing') ==1:
|
| 57 |
if data['dealFlag'] ==1 and data['dealType'] ==1:
|
57 |
if data['dealFlag'] ==1 and data['dealType'] ==1:
|
| 58 |
data['marketPlaceUrl'] = "http://www.amazon.in/dp/%s"%(data['identifier'].strip())
|
58 |
data['marketPlaceUrl'] = data['dealUrl'].strip()
|
| 59 |
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']}
|
59 |
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']}
|
| 60 |
|
60 |
|
| 61 |
|
61 |
|
| 62 |
if data['dealFlag'] ==1 and data['dealType'] ==1:
|
62 |
if data['dealFlag'] ==1 and data['dealType'] ==1:
|
| 63 |
data['marketPlaceUrl'] = "http://www.amazon.in/dp/%s"%(data['identifier'].strip())
|
63 |
data['marketPlaceUrl'] = data['dealUrl'].strip()
|
| 64 |
|
64 |
|
| 65 |
try:
|
65 |
try:
|
| 66 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
66 |
if ignoreLastUpdated and data['priceUpdatedOn'] > to_java_date(now - timedelta(minutes=5)):
|
| 67 |
print "sku id is already updated",data['_id']
|
67 |
print "sku id is already updated",data['_id']
|
| 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'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
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'],'coupon':data['coupon'], 'codAvailable':data['codAvailable'], 'tagline': data['tagline'], 'offer': data['offer']}
|
| Line 73... |
Line 73... |
| 73 |
url = "http://www.amazon.in/gp/aw/ol/%s?o=New&op=1"%(data['identifier'])
|
73 |
url = "http://www.amazon.in/gp/aw/ol/%s?o=New&op=1"%(data['identifier'])
|
| 74 |
lowestPrice = 0.0
|
74 |
lowestPrice = 0.0
|
| 75 |
try:
|
75 |
try:
|
| 76 |
if data['dealFlag'] ==1 and data['dealType'] ==1:
|
76 |
if data['dealFlag'] ==1 and data['dealType'] ==1:
|
| 77 |
print "Inside deal"
|
77 |
print "Inside deal"
|
| 78 |
deal_url = "http://www.amazon.in/dp/%s"%(data['identifier'].strip())
|
78 |
deal_url = data['marketPlaceUrl']
|
| 79 |
print deal_url
|
79 |
print deal_url
|
| 80 |
dealScraperAmazon = AmazonDealScraper.AmazonScraper(True)
|
80 |
dealScraperAmazon = AmazonDealScraper.AmazonScraper(True)
|
| 81 |
lowestPrice = dealScraperAmazon.read(deal_url)
|
81 |
lowestPrice = dealScraperAmazon.read(deal_url)
|
| 82 |
print lowestPrice
|
82 |
print lowestPrice
|
| 83 |
if lowestPrice == 0:
|
83 |
if lowestPrice == 0:
|
| Line 511... |
Line 511... |
| 511 |
itemIds = list(get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId,'source_id' : source_id}))
|
511 |
itemIds = list(get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId,'source_id' : source_id}))
|
| 512 |
item = None
|
512 |
item = None
|
| 513 |
for item in itemIds:
|
513 |
for item in itemIds:
|
| 514 |
item['dealFlag'] = 0
|
514 |
item['dealFlag'] = 0
|
| 515 |
item['dealType'] = 0
|
515 |
item['dealType'] = 0
|
| - |
|
516 |
item['dealUrl'] = ""
|
| 516 |
if item['source_id'] ==5 and item['rank'] == 0:
|
517 |
if item['source_id'] ==5 and item['rank'] == 0:
|
| 517 |
continue
|
518 |
continue
|
| 518 |
if item['source_id'] ==3:
|
519 |
if item['source_id'] ==3:
|
| 519 |
item['marketPlaceUrl'] = item['marketPlaceUrl']+'?supc='+item.get('identifier')
|
520 |
item['marketPlaceUrl'] = item['marketPlaceUrl']+'?supc='+item.get('identifier')
|
| 520 |
manualDeals = list(get_mongo_connection().Catalog.ManualDeals.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())},'source_id':source_id, 'sku':item['_id']}))
|
521 |
manualDeals = list(get_mongo_connection().Catalog.ManualDeals.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())},'source_id':source_id, 'sku':item['_id']}))
|
| 521 |
if len(manualDeals) > 0:
|
522 |
if len(manualDeals) > 0:
|
| 522 |
item['dealFlag'] = 1
|
523 |
item['dealFlag'] = 1
|
| 523 |
item['dealType'] =manualDeals[0]['dealType']
|
524 |
item['dealType'] =manualDeals[0]['dealType']
|
| - |
|
525 |
item['dealUrl'] = manualDeals[0]['dealUrl']
|
| 524 |
info = returnLatestPrice(item, source_id)
|
526 |
info = returnLatestPrice(item, source_id)
|
| 525 |
print info
|
527 |
print info
|
| 526 |
try:
|
528 |
try:
|
| 527 |
cashBack = getCashBack(item['_id'], item['source_id'], item['category_id'], mc, 'localhost')
|
529 |
cashBack = getCashBack(item['_id'], item['source_id'], item['category_id'], mc, 'localhost')
|
| 528 |
print "CashBack is ",cashBack
|
530 |
print "CashBack is ",cashBack
|
| Line 555... |
Line 557... |
| 555 |
|
557 |
|
| 556 |
def getLatestPriceById(id):
|
558 |
def getLatestPriceById(id):
|
| 557 |
item = list(get_mongo_connection().Catalog.MasterData.find({'_id':id}))
|
559 |
item = list(get_mongo_connection().Catalog.MasterData.find({'_id':id}))
|
| 558 |
item[0]['dealFlag'] = 0
|
560 |
item[0]['dealFlag'] = 0
|
| 559 |
item[0]['dealType'] = 0
|
561 |
item[0]['dealType'] = 0
|
| - |
|
562 |
item[0]['dealUrl'] = ""
|
| - |
|
563 |
|
| 560 |
manualDeals = list(get_mongo_connection().Catalog.ManualDeals.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())},'source_id':item[0]['source_id'], 'sku':item[0]['_id']}))
|
564 |
manualDeals = list(get_mongo_connection().Catalog.ManualDeals.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())},'source_id':item[0]['source_id'], 'sku':item[0]['_id']}))
|
| 561 |
if len(manualDeals) > 0:
|
565 |
if len(manualDeals) > 0:
|
| 562 |
item[0]['dealFlag'] = 1
|
566 |
item[0]['dealFlag'] = 1
|
| 563 |
item[0]['dealType'] =manualDeals[0]['dealType']
|
567 |
item[0]['dealType'] =manualDeals[0]['dealType']
|
| - |
|
568 |
item[0]['dealUrl'] = manualDeals[0]['dealUrl']
|
| 564 |
|
569 |
|
| 565 |
info = returnLatestPrice(item[0], item[0]['source_id'])
|
570 |
info = returnLatestPrice(item[0], item[0]['source_id'])
|
| 566 |
print info
|
571 |
print info
|
| 567 |
try:
|
572 |
try:
|
| 568 |
cashBack = getCashBack(item[0]['_id'], item[0]['source_id'], item[0]['category_id'], mc, 'localhost')
|
573 |
cashBack = getCashBack(item[0]['_id'], item[0]['source_id'], item[0]['category_id'], mc, 'localhost')
|
| Line 595... |
Line 600... |
| 595 |
itemIds = list(get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId,'priceUpdatedOn':{'$lte':to_java_date(datetime.now() - timedelta(minutes=2))},'source_id':{"$in":SOURCE_MAP.values()}}))
|
600 |
itemIds = list(get_mongo_connection().Catalog.MasterData.find({'skuBundleId':skuBundleId,'priceUpdatedOn':{'$lte':to_java_date(datetime.now() - timedelta(minutes=2))},'source_id':{"$in":SOURCE_MAP.values()}}))
|
| 596 |
for item in itemIds:
|
601 |
for item in itemIds:
|
| 597 |
print item['_id']
|
602 |
print item['_id']
|
| 598 |
item['dealFlag'] = 0
|
603 |
item['dealFlag'] = 0
|
| 599 |
item['dealType'] = 0
|
604 |
item['dealType'] = 0
|
| - |
|
605 |
item['dealUrl'] = ""
|
| 600 |
manualDeals = list(get_mongo_connection().Catalog.ManualDeals.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())},'source_id':item['source_id'], 'sku':item['_id']}))
|
606 |
manualDeals = list(get_mongo_connection().Catalog.ManualDeals.find({'startDate':{'$lte':to_java_date(datetime.now())},'endDate':{'$gte':to_java_date(datetime.now())},'source_id':item['source_id'], 'sku':item['_id']}))
|
| 601 |
if len(manualDeals) > 0:
|
607 |
if len(manualDeals) > 0:
|
| 602 |
item['dealFlag'] = 1
|
608 |
item['dealFlag'] = 1
|
| 603 |
item['dealType'] =manualDeals[0]['dealType']
|
609 |
item['dealType'] =manualDeals[0]['dealType']
|
| - |
|
610 |
item['dealUrl'] = manualDeals[0]['dealUrl']
|
| 604 |
info = returnLatestPrice(item, item['source_id'],False)
|
611 |
info = returnLatestPrice(item, item['source_id'],False)
|
| 605 |
print info
|
612 |
print info
|
| 606 |
|
613 |
|
| 607 |
def main():
|
614 |
def main():
|
| 608 |
print datetime.now()
|
615 |
print datetime.now()
|