Subversion Repositories SmartDukaan

Rev

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

Rev 13912 Rev 13973
Line 17... Line 17...
17
now = datetime.now()
17
now = datetime.now()
18
 
18
 
19
class __SkuInfo:
19
class __SkuInfo:
20
    
20
    
21
    def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
21
    def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
22
                 maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints, status, in_stock, maxprice, showDeal):
22
                 maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints, status, in_stock, maxprice):
23
        self._id = _id
23
        self._id = _id
24
        self.skuBundleId = skuBundleId
24
        self.skuBundleId = skuBundleId
25
        self.category_id = category_id
25
        self.category_id = category_id
26
        self.mrp = mrp
26
        self.mrp = mrp
27
        self.available_price = available_price
27
        self.available_price = available_price
Line 38... Line 38...
38
        self.bestSellerPoints = bestSellerPoints
38
        self.bestSellerPoints = bestSellerPoints
39
        self.totalPoints = totalPoints
39
        self.totalPoints = totalPoints
40
        self.status = status
40
        self.status = status
41
        self.in_stock = in_stock
41
        self.in_stock = in_stock
42
        self.maxprice = maxprice
42
        self.maxprice = maxprice
43
        self.showDeal = showDeal 
-
 
44
 
43
 
45
 
44
 
46
def get_mongo_connection(host='localhost', port=27017):
45
def get_mongo_connection(host='localhost', port=27017):
47
    global con
46
    global con
48
    if con is None:
47
    if con is None:
Line 68... Line 67...
68
        #topSkus = collection.find( {'_id':664})
67
        #topSkus = collection.find( {'_id':664})
69
        for sku in topSkus:
68
        for sku in topSkus:
70
            """Fix this """
69
            """Fix this """
71
            #TODO Compute deal flags else where.
70
            #TODO Compute deal flags else where.
72
            info = __SkuInfo(sku['_id'], sku['skuBundleId'], sku['category_id'], sku['mrp'], sku['available_price'], sku['source_id'], sku['rank'], None, None, 0.0, None, \
71
            info = __SkuInfo(sku['_id'], sku['skuBundleId'], sku['category_id'], sku['mrp'], sku['available_price'], sku['source_id'], sku['rank'], None, None, 0.0, None, \
73
                             None, None, None, None, None, None, sku['status'], sku['in_stock'],None,0)
72
                             None, None, None, None, None, None, sku['status'], sku['in_stock'],None)
74
            exceptionalNlc = list(get_mongo_connection().Catalog.ExceptionalNlc.find( {"$and" : [ {'sku':info._id}, {'overrideNlc':1} ]} ))
73
            exceptionalNlc = list(get_mongo_connection().Catalog.ExceptionalNlc.find( {"$and" : [ {'sku':info._id}, {'overrideNlc':1} ]} ))
75
            if len(exceptionalNlc) > 0:
74
            if len(exceptionalNlc) > 0:
76
                """Exceptional nlc found, no need to calculate max and min R-nlc"""
75
                """Exceptional nlc found, no need to calculate max and min R-nlc"""
77
                info.maxNlc = exceptionalNlc[0]['maxNlc']
76
                info.maxNlc = exceptionalNlc[0]['maxNlc']
78
                info.minNlc = exceptionalNlc[0]['minNlc']
77
                info.minNlc = exceptionalNlc[0]['minNlc']
Line 229... Line 228...
229
        bestPrice = float("inf")
228
        bestPrice = float("inf")
230
        bestOne = None
229
        bestOne = None
231
        bestSellerPoints = 0
230
        bestSellerPoints = 0
232
        toUpdate = []
231
        toUpdate = []
233
        for similarItem in similarItems:
232
        for similarItem in similarItems:
234
            if similarItem['in_stock'] == 0:
233
            if similarItem['in_stock'] == 0 or similarItem['maxprice'] is None or similarItem['maxprice'] < similarItem['available_price']:
235
                get_mongo_connection().Catalog.Deals.update({ '_id' : similarItem['_id'] }, {'$set':{'showDeal':0 }})
234
                get_mongo_connection().Catalog.Deals.update({ '_id' : similarItem['_id'] }, {'$set':{'showDeal':0 }})
236
                continue
235
                continue
237
            if similarItem['available_price'] < bestPrice:
236
            if similarItem['available_price'] < bestPrice:
238
                bestOne = similarItem
237
                bestOne = similarItem
239
                bestPrice = similarItem['available_price']
238
                bestPrice = similarItem['available_price']