Subversion Repositories SmartDukaan

Rev

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

Rev 14881 Rev 14988
Line 18... Line 18...
18
from xlwt.Workbook import Workbook
18
from xlwt.Workbook import Workbook
19
import MySQLdb
19
import MySQLdb
20
import smtplib
20
import smtplib
21
import time
21
import time
22
import xlwt
22
import xlwt
-
 
23
from dtr.utils.utils import fromTimeStamp
23
#from xlwt import 
24
#from xlwt import 
24
 
25
 
25
client = MongoClient('mongodb://localhost:27017/')
26
client = MongoClient('mongodb://localhost:27017/')
26
 
27
 
27
SENDER = "cnc.center@shop2020.in"
28
SENDER = "cnc.center@shop2020.in"
Line 241... Line 242...
241
        if order is None:
242
        if order is None:
242
            continue
243
            continue
243
        #saleTime = int(time.mktime(datetime.strptime(order['placedOn'], "%b %d, %Y, %I:%M %p").timetuple()))
244
        #saleTime = int(time.mktime(datetime.strptime(order['placedOn'], "%b %d, %Y, %I:%M %p").timetuple()))
244
        aff = list(db.snapdealOrderAffiliateInfo.find({"subTagId":order["subTagId"]}))
245
        aff = list(db.snapdealOrderAffiliateInfo.find({"subTagId":order["subTagId"]}))
245
        anotherrow += 1
246
        anotherrow += 1
-
 
247
        try:
-
 
248
            formattedTimestamp = order['placedOn']
-
 
249
            timestamp1 = int(time.mktime(datetime.strptime(order['placedOn'], "%b %d, %Y, %I:%M %p").timetuple()))
-
 
250
        except:
-
 
251
            timestamp1 = int(time.mktime(row1[-4].timetuple()))
-
 
252
            formattedTimestamp = datetime.strftime(fromTimeStamp(timestamp1), "%b %d, %Y, %I:%M %p")
246
        if len(aff) > 0 and order["subTagId"] not in matchedList and int(order["paidAmount"])==int(aff[0]["saleAmount"]): 
253
        if len(aff) > 0 and order["subTagId"] not in matchedList and int(order["paidAmount"])==int(aff[0]["saleAmount"]): 
247
            matchedList.append(order["subTagId"])
254
            matchedList.append(order["subTagId"])
248
            db.snapdealOrderAffiliateInfo.update({"adId":aff[0].get("adId")}, {"$set":{"reconciled":True, "orderId":orderId}}, multi=True)
255
            db.snapdealOrderAffiliateInfo.update({"adId":aff[0].get("adId")}, {"$set":{"reconciled":True, "orderId":orderId}}, multi=True)
249
            order['reconciled'] = True
256
            order['reconciled'] = True
250
            order['adId'] = aff[0].get("adId")
257
            order['adId'] = aff[0].get("adId")
Line 265... Line 272...
265
            worksheet1.write(anotherrow, i, order['merchantOrderId'])
272
            worksheet1.write(anotherrow, i, order['merchantOrderId'])
266
            worksheet.write(row, inc(), order['subTagId'])
273
            worksheet.write(row, inc(), order['subTagId'])
267
            worksheet1.write(anotherrow, i, order['subTagId'])
274
            worksheet1.write(anotherrow, i, order['subTagId'])
268
            worksheet.write(row, inc(), order['placedOn'])
275
            worksheet.write(row, inc(), order['placedOn'])
269
            worksheet1.write(anotherrow, i, order['placedOn'])
276
            worksheet1.write(anotherrow, i, order['placedOn'])
-
 
277
            worksheet.write(row, inc(), formattedTimestamp)
-
 
278
            worksheet1.write(anotherrow, i, formattedTimestamp)
270
            worksheet.write(row, inc(), int(order['paidAmount']))
279
            worksheet.write(row, inc(), int(order['paidAmount']))
271
            worksheet1.write(anotherrow, i, int(order['paidAmount']))
280
            worksheet1.write(anotherrow, i, int(order['paidAmount']))
272
            worksheet.write(row, inc(), aff[0]['saleDate'])
281
            worksheet.write(row, inc(), aff[0]['saleDate'])
273
            worksheet1.write(anotherrow, i, aff[0]['saleDate'])
282
            worksheet1.write(anotherrow, i, aff[0]['saleDate'])
274
            worksheet.write(row, inc(), aff[0]['saleAmount'])
283
            worksheet.write(row, inc(), aff[0]['saleAmount'])
Line 306... Line 315...
306
            worksheet1.write(anotherrow, inc(), row1[-3])
315
            worksheet1.write(anotherrow, inc(), row1[-3])
307
            worksheet1.write(anotherrow, inc(), order['merchantOrderId'])
316
            worksheet1.write(anotherrow, inc(), order['merchantOrderId'])
308
            worksheet1.write(anotherrow, inc(), order['subTagId'])
317
            worksheet1.write(anotherrow, inc(), order['subTagId'])
309
            worksheet1.write(anotherrow, inc(), order['placedOn'])
318
            worksheet1.write(anotherrow, inc(), order['placedOn'])
310
            worksheet1.write(anotherrow, inc(), int(order['paidAmount']))
319
            worksheet1.write(anotherrow, inc(), int(order['paidAmount']))
311
            try:
-
 
312
                timestamp1 = int(time.mktime(datetime.strptime(order['placedOn'], "%b %d, %Y, %I:%M %p").timetuple()))
-
 
313
            except:
-
 
314
                timestamp1 = row1[-4]
-
 
315
                
320
                
316
            notReconciled[orderId] = (anotherrow, i, int(order['paidAmount']), timestamp1, order["subTagId"]) 
321
            notReconciled[orderId] = (anotherrow, i, int(order['paidAmount']), timestamp1, order["subTagId"]) 
317
            inc()
322
            inc()
318
            inc()
323
            inc()
319
            inc()
324
            inc()
Line 367... Line 372...
367
                worksheet2.write(row2, inc(), row1[-2])
372
                worksheet2.write(row2, inc(), row1[-2])
368
                worksheet2.write(row2, inc(), row1[-3])
373
                worksheet2.write(row2, inc(), row1[-3])
369
                worksheet2.write(row2, inc(), order['merchantOrderId'])
374
                worksheet2.write(row2, inc(), order['merchantOrderId'])
370
                worksheet2.write(row2, inc(), order['subTagId'])
375
                worksheet2.write(row2, inc(), order['subTagId'])
371
                worksheet2.write(row2, inc(), order['placedOn'])
376
                worksheet2.write(row2, inc(), order['placedOn'])
-
 
377
                worksheet2.write(row2, inc(), formattedTimestamp)
372
                worksheet2.write(row2, inc(), int(order['paidAmount']))
378
                worksheet2.write(row2, inc(), int(order['paidAmount']))
373
                row2 -=1
379
                row2 -=1
374
                k=i
380
                k=i
375
                for subOrder in order['subOrders']:
381
                for subOrder in order['subOrders']:
376
                    i = k
382
                    i = k
Line 441... Line 447...
441
    worksheet.write(row, inc(), 'Version Code', boldStyle)
447
    worksheet.write(row, inc(), 'Version Code', boldStyle)
442
    worksheet.write(row, inc(), 'Device', boldStyle)
448
    worksheet.write(row, inc(), 'Device', boldStyle)
443
    worksheet.write(row, inc(), 'Merchant Order Id', boldStyle)
449
    worksheet.write(row, inc(), 'Merchant Order Id', boldStyle)
444
    worksheet.write(row, inc(), 'SubtagId', boldStyle)
450
    worksheet.write(row, inc(), 'SubtagId', boldStyle)
445
    worksheet.write(row, inc(), 'Sale Date', boldStyle)
451
    worksheet.write(row, inc(), 'Sale Date', boldStyle)
-
 
452
    worksheet.write(row, inc(), 'Dtr Sale Date', boldStyle)
446
    worksheet.write(row, inc(), 'Sale Amount', boldStyle)
453
    worksheet.write(row, inc(), 'Sale Amount', boldStyle)
447
    worksheet.write(row, inc(), 'Aff Sale Date', boldStyle)
454
    worksheet.write(row, inc(), 'Aff Sale Date', boldStyle)
448
    worksheet.write(row, inc(), 'Aff Sale Amt', boldStyle)
455
    worksheet.write(row, inc(), 'Aff Sale Amt', boldStyle)
449
    worksheet.write(row, inc(), 'Aff PayOut', boldStyle)
456
    worksheet.write(row, inc(), 'Aff PayOut', boldStyle)
450
    worksheet.write(row, inc(), 'IP', boldStyle)
457
    worksheet.write(row, inc(), 'IP', boldStyle)
Line 462... Line 469...
462
    worksheet1.write(row, inc(), 'Version Code', boldStyle)
469
    worksheet1.write(row, inc(), 'Version Code', boldStyle)
463
    worksheet1.write(row, inc(), 'Device', boldStyle)
470
    worksheet1.write(row, inc(), 'Device', boldStyle)
464
    worksheet1.write(row, inc(), 'Merchant Order Id', boldStyle)
471
    worksheet1.write(row, inc(), 'Merchant Order Id', boldStyle)
465
    worksheet1.write(row, inc(), 'SubtagId', boldStyle)
472
    worksheet1.write(row, inc(), 'SubtagId', boldStyle)
466
    worksheet1.write(row, inc(), 'Sale Date', boldStyle)
473
    worksheet1.write(row, inc(), 'Sale Date', boldStyle)
-
 
474
    worksheet1.write(row, inc(), 'Dtr Sale Date', boldStyle)
467
    worksheet1.write(row, inc(), 'Sale Amount', boldStyle)
475
    worksheet1.write(row, inc(), 'Sale Amount', boldStyle)
468
    worksheet1.write(row, inc(), 'Aff Sale Date', boldStyle)
476
    worksheet1.write(row, inc(), 'Aff Sale Date', boldStyle)
469
    worksheet1.write(row, inc(), 'Aff Sale Amt', boldStyle)
477
    worksheet1.write(row, inc(), 'Aff Sale Amt', boldStyle)
470
    worksheet1.write(row, inc(), 'Aff PayOut', boldStyle)
478
    worksheet1.write(row, inc(), 'Aff PayOut', boldStyle)
471
    worksheet1.write(row, inc(), 'IP', boldStyle)
479
    worksheet1.write(row, inc(), 'IP', boldStyle)
Line 483... Line 491...
483
    worksheet2.write(row, inc(), 'Version Code', boldStyle)
491
    worksheet2.write(row, inc(), 'Version Code', boldStyle)
484
    worksheet2.write(row, inc(), 'Device', boldStyle)
492
    worksheet2.write(row, inc(), 'Device', boldStyle)
485
    worksheet2.write(row, inc(), 'Merchant Order Id', boldStyle)
493
    worksheet2.write(row, inc(), 'Merchant Order Id', boldStyle)
486
    worksheet2.write(row, inc(), 'SubtagId', boldStyle)
494
    worksheet2.write(row, inc(), 'SubtagId', boldStyle)
487
    worksheet2.write(row, inc(), 'Sale Date', boldStyle)
495
    worksheet2.write(row, inc(), 'Sale Date', boldStyle)
-
 
496
    worksheet2.write(row, inc(), 'Dtr Sale Date', boldStyle)
488
    worksheet2.write(row, inc(), 'Sale Amount', boldStyle)
497
    worksheet2.write(row, inc(), 'Sale Amount', boldStyle)
489
    worksheet2.write(row, inc(), 'Product Title', boldStyle)
498
    worksheet2.write(row, inc(), 'Product Title', boldStyle)
490
    worksheet2.write(row, inc(), 'Price', boldStyle)
499
    worksheet2.write(row, inc(), 'Price', boldStyle)
491
    worksheet2.write(row, inc(), 'Quantity', boldStyle)
500
    worksheet2.write(row, inc(), 'Quantity', boldStyle)
492
    worksheet2.write(row, inc(), 'Status', boldStyle)
501
    worksheet2.write(row, inc(), 'Status', boldStyle)