Subversion Repositories SmartDukaan

Rev

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

Rev 14463 Rev 14473
Line 34... Line 34...
34
    This is to map order statuses of our system to order statuses of snapdeal.
34
    This is to map order statuses of our system to order statuses of snapdeal.
35
    And our statuses will change accordingly.
35
    And our statuses will change accordingly.
36
    
36
    
37
    '''
37
    '''
38
    OrderStatusMap = {
38
    OrderStatusMap = {
39
                      MStore.ORDER_PLACED : ['In Progress','N/A'],
39
                      MStore.ORDER_PLACED : ['In Progress','N/A', 'Pending For Verification'],
40
                      MStore.ORDER_DELIVERED : ['Delivered'],
40
                      MStore.ORDER_DELIVERED : ['Delivered'],
41
                      MStore.ORDER_SHIPPED : ['In Transit'],
41
                      MStore.ORDER_SHIPPED : ['In Transit'],
42
                      MStore.ORDER_CANCELLED : ['Closed For Vendor Reallocation', 'Cancelled', 'Product returned by courier', 'Returned']
42
                      MStore.ORDER_CANCELLED : ['Closed For Vendor Reallocation', 'Cancelled', 'Product returned by courier', 'Returned']
43
                      }
43
                      }
44
    
44
    
Line 124... Line 124...
124
        unitPrice=None
124
        unitPrice=None
125
        offerDiscount = 0
125
        offerDiscount = 0
126
        deliveryCharges = None
126
        deliveryCharges = None
127
        amountPaid = None
127
        amountPaid = None
128
        amount = 0
128
        amount = 0
-
 
129
        sdCash = 0
-
 
130
        unitPrice = 0
129
        for subTr in subTrs:
131
        for subTr in subTrs:
130
            subTrString = str(subTr)
132
            subTrString = str(subTr)
131
            if "Unit Price" in subTrString:
133
            if "Unit Price" in subTrString:
132
                unitPrice = re.findall(r'\d+', subTrString)[0]
134
                unitPrice = int(re.findall(r'\d+', subTrString)[0])
133
            if "Quantity" in subTrString:
135
            if "Quantity" in subTrString:
134
                qty = int(re.findall(r'\d+', subTrString)[0])
136
                qty = int(re.findall(r'\d+', subTrString)[0])
135
            elif "Offer Discount" in subTrString:
137
            elif "Offer Discount" in subTrString:
136
                offerDiscount +=   int(re.findall(r'\d+', subTrString)[0])
138
                offerDiscount +=   int(re.findall(r'\d+', subTrString)[0])
-
 
139
            elif "SD Cash:" in subTrString:
-
 
140
                sdCash =   int(re.findall(r'\d+', subTrString)[0])
137
            elif "Delivery Charges" in subTrString:
141
            elif "Delivery Charges" in subTrString:
138
                deliveryCharges =   re.findall(r'\d+', subTrString)[0]
142
                deliveryCharges =   int(re.findall(r'\d+', subTrString)[0])
139
            elif "Subtotal" in subTrString:
143
            elif "Subtotal" in subTrString:
140
                if int(qty) > 0:
144
                if int(qty) > 0:
141
                    amountPaid =   int(re.findall(r'\d+', subTrString)[0])/qty
145
                    amountPaid =   int(re.findall(r'\d+', subTrString)[0])/qty
142
                else:
146
                else:
143
                    amountPaid =   0
147
                    amountPaid =   0
144
        if qty>0:
148
        if qty>0:
145
            if offerDiscount == 0:
149
            amount = unitPrice - offerDiscount - sdCash
146
                amount = int(unitPrice)
-
 
147
            else:
-
 
148
                amount = int(unitPrice) - offerDiscount
150
            amount = 0 if amount < 0 else amount
149
                
151
                
150
        div1 = subOrderElement.find("div", {"class": "blk lrPad subordrs"})
152
        div1 = subOrderElement.find("div", {"class": "blk lrPad subordrs"})
151
        if div1 is None:
153
        if div1 is None:
152
            raise ParseException("subOrder", "Could not Parse suborders for Snapdeal")
154
            raise ParseException("subOrder", "Could not Parse suborders for Snapdeal")
153
        
155
        
Line 165... Line 167...
165
            subOrder.imgUrl = Mongo.getImgSrc(subOrder.productCode, self.store_id).get('thumbnail')
167
            subOrder.imgUrl = Mongo.getImgSrc(subOrder.productCode, self.store_id).get('thumbnail')
166
            cashbackStatus = Store.CB_NA
168
            cashbackStatus = Store.CB_NA
167
            cashbackAmount = 0
169
            cashbackAmount = 0
168
            percentage = 0
170
            percentage = 0
169
            if amount > 0:
171
            if amount > 0:
170
                cashbackStatus = Store.CB_PENDING
-
 
171
                (cashbackAmount, percentage) = self.getCashbackAmount(subOrder.productCode, amount)
172
                (cashbackAmount, percentage) = self.getCashbackAmount(subOrder.productCode, amount)
172
                if cashbackAmount <= 0:
173
                if cashbackAmount > 0:
173
                    cashbackStatus = Store.CB_NA
174
                    cashbackStatus = Store.CB_NA
174
                    cashbackAmount = 0
-
 
175
            subOrder.cashBackStatus = cashbackStatus
175
            subOrder.cashBackStatus = cashbackStatus
176
            subOrder.cashBackAmount = cashbackAmount
176
            subOrder.cashBackAmount = cashbackAmount
177
            subOrder.cashBackPercentage = percentage
177
            subOrder.cashBackPercentage = percentage
178
            
178
            
179
            
179
            
Line 404... Line 404...
404
    return urllib.urlencode(parameters)
404
    return urllib.urlencode(parameters)
405
 
405
 
406
def main():
406
def main():
407
    #print todict([1,2,"3"])
407
    #print todict([1,2,"3"])
408
    store = getStore(3)
408
    store = getStore(3)
-
 
409
    print store.parseOrderRawHtml(32, "32323", 2, "323243", "https://m.snapdeal.com/orderSummary?code=6d7428243672f72436736707a46ecbd2&order=5328225555")
409
    #store.scrapeStoreOrders()
410
    #store.scrapeStoreOrders()
410
    #store._isSubOrderActive(8, "5970688907")
411
    #store._isSubOrderActive(8, "5970688907")
411
    #store.scrapeAffiliate()
412
    #store.scrapeAffiliate()
412
    store.scrapeStoreOrders()
413
    #store.scrapeStoreOrders()
413
 
414
 
414
 
415
 
415
            
416
            
416
def todict(obj, classkey=None):
417
def todict(obj, classkey=None):
417
    if isinstance(obj, dict):
418
    if isinstance(obj, dict):