Subversion Repositories SmartDukaan

Rev

Rev 16398 | Rev 16450 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 16398 Rev 16406
Line 17... Line 17...
17
con = None
17
con = None
18
 
18
 
19
DataService.initialize(db_hostname="localhost")
19
DataService.initialize(db_hostname="localhost")
20
mc = MemCache("127.0.0.1")
20
mc = MemCache("127.0.0.1")
21
 
21
 
22
SOURCE_MAP = {1:'AMAZON',2:'FLIPKART',3:'SNAPDEAL',4:'SAHOLIC',5:"SHOPCLUES.COM"}
22
SOURCE_MAP = {1:'AMAZON',2:'FLIPKART',3:'SNAPDEAL',4:'SAHOLIC',5:"SHOPCLUES.COM",6:"PAYTM.COM"}
23
 
23
 
24
COLLECTION_MAP = {
24
COLLECTION_MAP = {
25
                  'ExceptionalNlc':'skuBundleId',
25
                  'ExceptionalNlc':'skuBundleId',
26
                  'SkuDealerPrices':'skuBundleId',
26
                  'SkuDealerPrices':'skuBundleId',
27
                  'SkuDiscountInfo':'skuBundleId',
27
                  'SkuDiscountInfo':'skuBundleId',
Line 617... Line 617...
617
                return cashBack.get(category_id)
617
                return cashBack.get(category_id)
618
    else:
618
    else:
619
        return {}
619
        return {}
620
 
620
 
621
def getDealRank(identifier, source_id, userId):
621
def getDealRank(identifier, source_id, userId):
622
    if source_id in (1,2,4,5):
622
    if source_id in (1,2,4,5,6):
623
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'identifier':identifier.strip(), 'source_id':source_id}))
623
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'identifier':identifier.strip(), 'source_id':source_id}))
624
    elif source_id == 3:
624
    elif source_id == 3:
625
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'secondaryIdentifier':identifier.strip(), 'source_id':source_id}))
625
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'secondaryIdentifier':identifier.strip(), 'source_id':source_id}))
626
    else:
626
    else:
627
        return {'rank':0, 'description':'Source not valid','maxNlc':None, 'minNlc':None,'status':None,'dp':None}
627
        return {'rank':0, 'description':'Source not valid','maxNlc':None, 'minNlc':None,'status':None,'dp':None}
Line 666... Line 666...
666
 
666
 
667
def getCashBackDetails(identifier, source_id):
667
def getCashBackDetails(identifier, source_id):
668
    if not bool(mc.get("category_cash_back")):
668
    if not bool(mc.get("category_cash_back")):
669
        populateCashBack()
669
        populateCashBack()
670
    
670
    
671
    if source_id in (1,2,4,5):
671
    if source_id in (1,2,4,5,6):
672
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'identifier':identifier.strip(), 'source_id':source_id}))
672
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'identifier':identifier.strip(), 'source_id':source_id}))
673
    elif source_id == 3:
673
    elif source_id == 3:
674
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'secondaryIdentifier':identifier.strip(), 'source_id':source_id}))
674
        skuData = list(get_mongo_connection().Catalog.MasterData.find({'secondaryIdentifier':identifier.strip(), 'source_id':source_id}))
675
    else:
675
    else:
676
        return {}
676
        return {}
Line 692... Line 692...
692
    else:
692
    else:
693
        return {}
693
        return {}
694
    
694
    
695
def getImgSrc(identifier, source_id):
695
def getImgSrc(identifier, source_id):
696
    skuData = None
696
    skuData = None
697
    if source_id in (1,2,4,5):
697
    if source_id in (1,2,4,5,6):
698
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'identifier':identifier.strip(), 'source_id':source_id})
698
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'identifier':identifier.strip(), 'source_id':source_id})
699
    elif source_id == 3:
699
    elif source_id == 3:
700
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'secondaryIdentifier':identifier.strip(), 'source_id':source_id})
700
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'secondaryIdentifier':identifier.strip(), 'source_id':source_id})
701
    if skuData is None:
701
    if skuData is None:
702
        return {}
702
        return {}
Line 1250... Line 1250...
1250
def getItemObjForStaticDeals(item):
1250
def getItemObjForStaticDeals(item):
1251
    return {'marketPlaceUrl':item.get('marketPlaceUrl'),'available_price':item.get('available_price'),'source_product_name':item.get('source_product_name'),'thumbnail':item.get('thumbnail'),'source_id':int(item.get('source_id'))}
1251
    return {'marketPlaceUrl':item.get('marketPlaceUrl'),'available_price':item.get('available_price'),'source_product_name':item.get('source_product_name'),'thumbnail':item.get('thumbnail'),'source_id':int(item.get('source_id'))}
1252
 
1252
 
1253
def getItemByMerchantIdentifier(identifier, source_id):
1253
def getItemByMerchantIdentifier(identifier, source_id):
1254
    skuData = None
1254
    skuData = None
1255
    if source_id in (1,2,4,5):
1255
    if source_id in (1,2,4,5,6):
1256
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'identifier':identifier.strip(), 'source_id':source_id})
1256
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'identifier':identifier.strip(), 'source_id':source_id})
1257
    elif source_id == 3:
1257
    elif source_id == 3:
1258
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'secondaryIdentifier':identifier.strip(), 'source_id':source_id})
1258
        skuData = get_mongo_connection().Catalog.MasterData.find_one({'secondaryIdentifier':identifier.strip(), 'source_id':source_id})
1259
    if skuData is None:
1259
    if skuData is None:
1260
        return {}
1260
        return {}
Line 1262... Line 1262...
1262
        return skuData
1262
        return skuData
1263
    
1263
    
1264
def getDealsForNotification(skuBundleIds):
1264
def getDealsForNotification(skuBundleIds):
1265
    bundles= [int(skuBundleId) for skuBundleId in skuBundleIds.split(',')]
1265
    bundles= [int(skuBundleId) for skuBundleId in skuBundleIds.split(',')]
1266
    print bundles
1266
    print bundles
-
 
1267
    dealsList = []
1267
    dealsListMap = []
1268
    dealsListMap = []
-
 
1269
    for bundleId in bundles:
1268
    outer_query = []
1270
        outer_query = []
1269
    outer_query.append({ "$or": [ { "showDeal": 1} , { "prepaidDeal": 1 } ] })
1271
        outer_query.append({ "$or": [ { "showDeal": 1} , { "prepaidDeal": 1 } ] })
1270
    outer_query.append({'skuBundleId':{"$in":bundles}})
1272
        outer_query.append({'skuBundleId':bundleId})
1271
    print outer_query
-
 
1272
    deals = get_mongo_connection().Catalog.Deals.find({"$and":outer_query})
1273
        deals = get_mongo_connection().Catalog.Deals.find({"$and":outer_query})
-
 
1274
        for deal in deals:
-
 
1275
            dealsList.append(deal)
1273
    sortedMap = {}
1276
    sortedMap = {}
1274
    rankMap = {}
1277
    rankMap = {}
1275
    rank = 0
1278
    rank = 0
1276
    for sorted_deal in deals:
1279
    for sorted_deal in dealsList:
1277
        if sortedMap.get(sorted_deal['skuBundleId']) is None:
1280
        if sortedMap.get(sorted_deal['skuBundleId']) is None:
1278
            sortedMap[sorted_deal['skuBundleId']] = {rank:[sorted_deal]}
1281
            sortedMap[sorted_deal['skuBundleId']] = {rank:[sorted_deal]}
1279
            rankMap[rank] = (sortedMap[sorted_deal['skuBundleId']].values())[0]
1282
            rankMap[rank] = (sortedMap[sorted_deal['skuBundleId']].values())[0]
1280
            rank = rank +1
1283
            rank = rank +1
1281
        else:
1284
        else:
Line 1327... Line 1330...
1327
        if orders is None:
1330
        if orders is None:
1328
            return {}
1331
            return {}
1329
        return orders
1332
        return orders
1330
    
1333
    
1331
def main():
1334
def main():
1332
    print getItem(1)
1335
    print getDealsForNotification("1,2,34,5")
1333
    
1336
    
1334
    
1337
    
1335
    
1338
    
1336
if __name__=='__main__':
1339
if __name__=='__main__':
1337
    main()
1340
    main()