Subversion Repositories SmartDukaan

Rev

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

Rev 14480 Rev 14487
Line 65... Line 65...
65
            continue
65
            continue
66
        print order["subTagId"]
66
        print order["subTagId"]
67
        print order
67
        print order
68
        saleTime = int(time.mktime(datetime.strptime(order['placedOn'], "%d %B, %Y %I:%M %p").replace(hour=0, minute=0, second=0, microsecond=0).timetuple()))
68
        saleTime = int(time.mktime(datetime.strptime(order['placedOn'], "%d %B, %Y %I:%M %p").replace(hour=0, minute=0, second=0, microsecond=0).timetuple()))
69
        #saleTime1 = int(time.mktime((datetime.strptime(order['placedOn'], "%b %d, %Y %I:%M %p") + timedelta(seconds=-60)).timetuple()))
69
        #saleTime1 = int(time.mktime((datetime.strptime(order['placedOn'], "%b %d, %Y %I:%M %p") + timedelta(seconds=-60)).timetuple()))
70
        affs = list(db.flipkartOrderAffiliateInfo.find({"subTagId":order["subTagId"], "saleDateInt":saleTime}))
-
 
71
        
70
        
72
        for subOrder in order['subOrders']: 
71
        for subOrder in order['subOrders']: 
-
 
72
            affs = list(db.flipkartOrderAffiliateInfo.find({"subOrders.productCode":subOrder.getProductCode("productCode"), "saleDateInt":saleTime}))
73
            row += 1
73
            row += 1
74
            global i
74
            global i
75
            i=-1
75
            i=-1
76
            worksheet.write(row, inc(), orderId)
76
            worksheet.write(row, inc(), orderId)
77
            worksheet.write(row, inc(), row1[1])
77
            worksheet.write(row, inc(), row1[1])
Line 85... Line 85...
85
            worksheet.write(row, inc(), subOrder['cashBackStatus'])
85
            worksheet.write(row, inc(), subOrder['cashBackStatus'])
86
            worksheet.write(row, inc(), subOrder['cashBackAmount'])
86
            worksheet.write(row, inc(), subOrder['cashBackAmount'])
87
            worksheet.write(row, inc(), subOrder['placedOn'])
87
            worksheet.write(row, inc(), subOrder['placedOn'])
88
            worksheet.write(row, inc(), order['subTagId'])
88
            worksheet.write(row, inc(), order['subTagId'])
89
            for aff in affs:
89
            for aff in affs:
90
                if aff['productCode']== subOrder['productCode']:
90
                if aff['subTagId']== subOrder['subTagId']:
91
                    worksheet.write(row, inc(), aff['category'])
91
                    worksheet.write(row, inc(), aff['category'])
92
                    worksheet.write(row, inc(), aff['payOut'])
92
                    worksheet.write(row, inc(), aff['payOut'])
93
                    worksheet.write(row, inc(), aff['saleAmount'])
93
                    worksheet.write(row, inc(), aff['saleAmount'])
94
                    worksheet.write(row, inc(), aff['saleDate'])
94
                    worksheet.write(row, inc(), aff['saleDate'])
95
                    break
95
                    break
Line 98... Line 98...
98
        wb.save(XLS_FILENAME)
98
        wb.save(XLS_FILENAME)
99
def generateSnapDealReco():
99
def generateSnapDealReco():
100
    curs = getOrdersAfterDate(datetime.now() - timedelta(days=30), 3)
100
    curs = getOrdersAfterDate(datetime.now() - timedelta(days=30), 3)
101
    db = client.Dtr
101
    db = client.Dtr
102
    
102
    
-
 
103
    matchedList = []
103
    workbook = xlwt.Workbook()
104
    workbook = xlwt.Workbook()
104
    worksheet = workbook.add_sheet("Snapdeal")
105
    worksheet = workbook.add_sheet("Snapdeal")
105
    column = 0
106
    column = 0
106
    row = 0
107
    row = 0
107
    global i
108
    global i
Line 130... Line 131...
130
        if order is None:
131
        if order is None:
131
            continue
132
            continue
132
        print order["subTagId"]
133
        print order["subTagId"]
133
        saleTime = int(time.mktime(datetime.strptime(order['placedOn'], "%b %d, %Y, %I:%M %p").timetuple()))
134
        saleTime = int(time.mktime(datetime.strptime(order['placedOn'], "%b %d, %Y, %I:%M %p").timetuple()))
134
        aff = list(db.snapdealOrderAffiliateInfo.find({"subTagId":order["subTagId"]}))
135
        aff = list(db.snapdealOrderAffiliateInfo.find({"subTagId":order["subTagId"]}))
-
 
136
        gotCashBack = False
-
 
137
        #if len(aff) and aff[0]['saleTime']- saleTime < 90 and aff[0]['saleTime'] - saleTime >= 0:
-
 
138
        if order["subTagId"] not in matchedList: 
-
 
139
            gotCashBack = True
135
 
140
                
136
        for subOrder in order['subOrders']:
141
        for subOrder in order['subOrders']:
137
            i=-1 
142
            i=-1 
138
            row += 1
143
            row += 1
139
            worksheet.write(row, inc(), orderId)
144
            worksheet.write(row, inc(), orderId)
140
            worksheet.write(row, inc(), row1[1])
145
            worksheet.write(row, inc(), row1[1])
Line 147... Line 152...
147
            worksheet.write(row, inc(), subOrder['detailedStatus'])
152
            worksheet.write(row, inc(), subOrder['detailedStatus'])
148
            worksheet.write(row, inc(), subOrder['cashBackStatus'])
153
            worksheet.write(row, inc(), subOrder['cashBackStatus'])
149
            worksheet.write(row, inc(), subOrder['cashBackAmount'])
154
            worksheet.write(row, inc(), subOrder['cashBackAmount'])
150
            worksheet.write(row, inc(), subOrder['placedOn'])
155
            worksheet.write(row, inc(), subOrder['placedOn'])
151
            worksheet.write(row, inc(), order['subTagId'])
156
            worksheet.write(row, inc(), order['subTagId'])
152
            
157
            if gotCashBack:
153
            if len(aff) and aff[0]['saleTime']- saleTime < 90 and aff[0]['saleTime'] - saleTime >= 0:
-
 
154
                print saleTime -aff[0]['saleTime'] 
158
                print saleTime -aff[0]['saleTime'] 
155
                worksheet.write(row, inc(), aff[0]['adId'])
159
                worksheet.write(row, inc(), aff[0]['adId'])
156
                worksheet.write(row, inc(), aff[0]['payOut'])
160
                worksheet.write(row, inc(), aff[0]['payOut'])
157
                worksheet.write(row, inc(), aff[0]['saleAmount'])
161
                worksheet.write(row, inc(), aff[0]['saleAmount'])
158
                worksheet.write(row, inc(), aff[0]['saleDate'])
162
                worksheet.write(row, inc(), aff[0]['saleDate'])