| Line 32... |
Line 32... |
| 32 |
f = xlwt.Font()
|
32 |
f = xlwt.Font()
|
| 33 |
f.bold = True
|
33 |
f.bold = True
|
| 34 |
boldStyle.font = f
|
34 |
boldStyle.font = f
|
| 35 |
i = -1
|
35 |
i = -1
|
| 36 |
def generateFlipkartReco():
|
36 |
def generateFlipkartReco():
|
| - |
|
37 |
global i
|
| - |
|
38 |
i = -1
|
| 37 |
curs = getOrdersAfterDate(datetime.now() - timedelta(days=30), 2)
|
39 |
curs = getOrdersAfterDate(datetime.now() - timedelta(days=30), 2)
|
| 38 |
db = client.Dtr
|
40 |
db = client.Dtr
|
| 39 |
rb = open_workbook(XLS_FILENAME)
|
41 |
rb = open_workbook(XLS_FILENAME)
|
| 40 |
wb = copy(rb)
|
42 |
wb = copy(rb)
|
| 41 |
#wb = xlwt.Workbook()
|
43 |
#wb = xlwt.Workbook()
|
| Line 67... |
Line 69... |
| 67 |
#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()))
|
| 68 |
|
70 |
|
| 69 |
for subOrder in order['subOrders']:
|
71 |
for subOrder in order['subOrders']:
|
| 70 |
affs = list(db.flipkartOrderAffiliateInfo.find({"subOrders.productCode":subOrder.get("productCode"), "saleDateInt":saleTime}))
|
72 |
affs = list(db.flipkartOrderAffiliateInfo.find({"subOrders.productCode":subOrder.get("productCode"), "saleDateInt":saleTime}))
|
| 71 |
row += 1
|
73 |
row += 1
|
| 72 |
global i
|
- |
|
| 73 |
i=-1
|
74 |
i=-1
|
| 74 |
worksheet.write(row, inc(), orderId)
|
75 |
worksheet.write(row, inc(), orderId)
|
| 75 |
worksheet.write(row, inc(), row1[1])
|
76 |
worksheet.write(row, inc(), row1[1])
|
| 76 |
worksheet.write(row, inc(), row1[-1])
|
77 |
worksheet.write(row, inc(), row1[-1])
|
| 77 |
worksheet.write(row, inc(), order['merchantOrderId'])
|
78 |
worksheet.write(row, inc(), order['merchantOrderId'])
|
| Line 100... |
Line 101... |
| 100 |
|
101 |
|
| 101 |
matchedList = []
|
102 |
matchedList = []
|
| 102 |
workbook = xlwt.Workbook()
|
103 |
workbook = xlwt.Workbook()
|
| 103 |
worksheet = workbook.add_sheet("Snapdeal Reconciled")
|
104 |
worksheet = workbook.add_sheet("Snapdeal Reconciled")
|
| 104 |
worksheet1 = workbook.add_sheet("Snapdeal Reconciled All")
|
105 |
worksheet1 = workbook.add_sheet("Snapdeal Reconciled All")
|
| - |
|
106 |
worksheet2 = workbook.add_sheet("Snapdeal Orders not reconciled")
|
| - |
|
107 |
affNotReconciledSheet = workbook.add_sheet("Snapdeal Aff not reconciled")
|
| 105 |
setHeaders(worksheet, worksheet1)
|
108 |
setHeaders(worksheet, worksheet1, worksheet2, affNotReconciledSheet)
|
| 106 |
row = 0
|
109 |
row = 0
|
| 107 |
anotherrow = 0
|
110 |
anotherrow = 0
|
| - |
|
111 |
row2 = 0
|
| 108 |
for row1 in curs:
|
112 |
for row1 in curs:
|
| 109 |
orderId = row1[0]
|
113 |
orderId = row1[0]
|
| 110 |
order = db.merchantOrder.find_one({"orderId":orderId})
|
114 |
order = db.merchantOrder.find_one({"orderId":orderId})
|
| 111 |
if order is None:
|
115 |
if order is None:
|
| 112 |
continue
|
116 |
continue
|
| Line 162... |
Line 166... |
| 162 |
worksheet1.write(anotherrow, i, subOrder['cashBackStatus'])
|
166 |
worksheet1.write(anotherrow, i, subOrder['cashBackStatus'])
|
| 163 |
worksheet.write(row, inc(), subOrder['cashBackAmount'])
|
167 |
worksheet.write(row, inc(), subOrder['cashBackAmount'])
|
| 164 |
worksheet1.write(anotherrow, i, subOrder['cashBackAmount'])
|
168 |
worksheet1.write(anotherrow, i, subOrder['cashBackAmount'])
|
| 165 |
|
169 |
|
| 166 |
else:
|
170 |
else:
|
| - |
|
171 |
row2 +=1
|
| 167 |
i=-1
|
172 |
i=-1
|
| 168 |
worksheet1.write(anotherrow, inc(), orderId)
|
173 |
worksheet1.write(anotherrow, inc(), orderId)
|
| - |
|
174 |
worksheet2.write(row2, i, orderId)
|
| 169 |
worksheet1.write(anotherrow, inc(), row1[1])
|
175 |
worksheet1.write(anotherrow, inc(), row1[1])
|
| - |
|
176 |
worksheet2.write(row2, i, row1[1])
|
| 170 |
worksheet1.write(anotherrow, inc(), row1[-1])
|
177 |
worksheet1.write(anotherrow, inc(), row1[-1])
|
| - |
|
178 |
worksheet2.write(row2, i, row1[-1])
|
| 171 |
worksheet1.write(anotherrow, inc(), order['merchantOrderId'])
|
179 |
worksheet1.write(anotherrow, inc(), order['merchantOrderId'])
|
| - |
|
180 |
worksheet2.write(row2, i, order['merchantOrderId'])
|
| 172 |
worksheet1.write(anotherrow, inc(), order['subTagId'])
|
181 |
worksheet1.write(anotherrow, inc(), order['subTagId'])
|
| - |
|
182 |
worksheet2.write(row2, i, order['subTagId'])
|
| 173 |
worksheet1.write(anotherrow, inc(), order['placedOn'])
|
183 |
worksheet1.write(anotherrow, inc(), order['placedOn'])
|
| - |
|
184 |
worksheet2.write(row2, i, order['placedOn'])
|
| 174 |
worksheet1.write(anotherrow, inc(), int(order['paidAmount']))
|
185 |
worksheet1.write(anotherrow, inc(), int(order['paidAmount']))
|
| - |
|
186 |
worksheet2.write(row2, i, int(order['paidAmount']))
|
| 175 |
worksheet1.write(anotherrow, inc(), "")
|
187 |
worksheet1.write(anotherrow, inc(), "")
|
| 176 |
worksheet1.write(anotherrow, inc(), "")
|
188 |
worksheet1.write(anotherrow, inc(), "")
|
| 177 |
worksheet1.write(anotherrow, inc(), "")
|
189 |
worksheet1.write(anotherrow, inc(), "")
|
| 178 |
k = i
|
190 |
k = i
|
| 179 |
anotherrow -= 1
|
191 |
anotherrow -= 1
|
| - |
|
192 |
row2 -= 1
|
| 180 |
for subOrder in order['subOrders']:
|
193 |
for subOrder in order['subOrders']:
|
| 181 |
anotherrow += 1
|
194 |
anotherrow += 1
|
| - |
|
195 |
row2 += 1
|
| 182 |
i = k
|
196 |
i = k
|
| 183 |
worksheet1.write(anotherrow, inc(), subOrder['productTitle'])
|
197 |
worksheet1.write(anotherrow, inc(), subOrder['productTitle'])
|
| - |
|
198 |
worksheet2.write(row2, i-3, subOrder['productTitle'])
|
| 184 |
worksheet1.write(anotherrow, inc(), subOrder['amountPaid'])
|
199 |
worksheet1.write(anotherrow, inc(), subOrder['amountPaid'])
|
| - |
|
200 |
worksheet2.write(row2, i-3, subOrder['amountPaid'])
|
| 185 |
worksheet1.write(anotherrow, inc(), subOrder['quantity'])
|
201 |
worksheet1.write(anotherrow, inc(), subOrder['quantity'])
|
| - |
|
202 |
worksheet2.write(row2, i-3, subOrder['quantity'])
|
| 186 |
worksheet1.write(anotherrow, inc(), subOrder['status'])
|
203 |
worksheet1.write(anotherrow, inc(), subOrder['status'])
|
| - |
|
204 |
worksheet2.write(row2, i-3, subOrder['status'])
|
| 187 |
worksheet1.write(anotherrow, inc(), subOrder['cashBackStatus'])
|
205 |
worksheet1.write(anotherrow, inc(), subOrder['cashBackStatus'])
|
| - |
|
206 |
worksheet2.write(row2, i-3, subOrder['cashBackStatus'])
|
| 188 |
worksheet1.write(anotherrow, inc(), subOrder['cashBackAmount'])
|
207 |
worksheet1.write(anotherrow, inc(), subOrder['cashBackAmount'])
|
| 189 |
|
208 |
worksheet2.write(row2, i-3, subOrder['cashBackAmount'])
|
| 190 |
|
209 |
|
| 191 |
workbook.save(XLS_FILENAME)
|
210 |
workbook.save(XLS_FILENAME)
|
| 192 |
|
211 |
|
| 193 |
def sendmail(email, message, title):
|
212 |
def sendmail(email, message, title):
|
| 194 |
if email == "":
|
213 |
if email == "":
|
| Line 216... |
Line 235... |
| 216 |
email.append('amit.gupta@shop2020.in')
|
235 |
email.append('amit.gupta@shop2020.in')
|
| 217 |
MAILTO = email
|
236 |
MAILTO = email
|
| 218 |
mailServer.login(SENDER, PASSWORD)
|
237 |
mailServer.login(SENDER, PASSWORD)
|
| 219 |
mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())
|
238 |
mailServer.sendmail(PASSWORD, MAILTO, msg.as_string())
|
| 220 |
|
239 |
|
| 221 |
def setHeaders(worksheet, worksheet1):
|
240 |
def setHeaders(worksheet, worksheet1, worksheet2, affNotReconciledSheet):
|
| 222 |
boldStyle = xlwt.XFStyle()
|
241 |
boldStyle = xlwt.XFStyle()
|
| 223 |
f = xlwt.Font()
|
242 |
f = xlwt.Font()
|
| 224 |
f.bold = True
|
243 |
f.bold = True
|
| 225 |
boldStyle.font = f
|
244 |
boldStyle.font = f
|
| 226 |
row = 0
|
245 |
row = 0
|
| Line 258... |
Line 277... |
| 258 |
worksheet1.write(row, inc(), 'Price', boldStyle)
|
277 |
worksheet1.write(row, inc(), 'Price', boldStyle)
|
| 259 |
worksheet1.write(row, inc(), 'Quantity', boldStyle)
|
278 |
worksheet1.write(row, inc(), 'Quantity', boldStyle)
|
| 260 |
worksheet1.write(row, inc(), 'Status', boldStyle)
|
279 |
worksheet1.write(row, inc(), 'Status', boldStyle)
|
| 261 |
worksheet1.write(row, inc(), 'Cashback Status', boldStyle)
|
280 |
worksheet1.write(row, inc(), 'Cashback Status', boldStyle)
|
| 262 |
worksheet1.write(row, inc(), 'CashBack', boldStyle)
|
281 |
worksheet1.write(row, inc(), 'CashBack', boldStyle)
|
| - |
|
282 |
|
| - |
|
283 |
i = -1
|
| - |
|
284 |
worksheet2.write(row, inc(), 'Order Id', boldStyle)
|
| - |
|
285 |
worksheet2.write(row, inc(), 'User Id', boldStyle)
|
| - |
|
286 |
worksheet2.write(row, inc(), 'Username', boldStyle)
|
| - |
|
287 |
worksheet2.write(row, inc(), 'Merchant Order Id', boldStyle)
|
| - |
|
288 |
worksheet2.write(row, inc(), 'SubtagId', boldStyle)
|
| - |
|
289 |
worksheet2.write(row, inc(), 'Sale Date', boldStyle)
|
| - |
|
290 |
worksheet2.write(row, inc(), 'Sale Amount', boldStyle)
|
| - |
|
291 |
worksheet2.write(row, inc(), 'Product Title', boldStyle)
|
| - |
|
292 |
worksheet2.write(row, inc(), 'Price', boldStyle)
|
| - |
|
293 |
worksheet2.write(row, inc(), 'Quantity', boldStyle)
|
| - |
|
294 |
worksheet2.write(row, inc(), 'Status', boldStyle)
|
| - |
|
295 |
worksheet2.write(row, inc(), 'Cashback Status', boldStyle)
|
| - |
|
296 |
worksheet2.write(row, inc(), 'CashBack', boldStyle)
|
| 263 |
|
297 |
|
| - |
|
298 |
i =-1
|
| - |
|
299 |
affNotReconciledSheet.write(row, inc(), 'AdId', boldStyle)
|
| - |
|
300 |
affNotReconciledSheet.write(row, inc(), 'subTagId', boldStyle)
|
| - |
|
301 |
affNotReconciledSheet.write(row, inc(), 'Sale Date', boldStyle)
|
| - |
|
302 |
affNotReconciledSheet.write(row, inc(), 'Sale Amount', boldStyle)
|
| - |
|
303 |
affNotReconciledSheet.write(row, inc(), 'Pay Out', boldStyle)
|
| - |
|
304 |
affNotReconciledSheet.write(row, inc(), 'Status', boldStyle)
|
| - |
|
305 |
db = client.Dtr
|
| - |
|
306 |
for offer in db.snapdealOrderAffiliateInfo.find({"reconciled":{"$exists":False}}):
|
| - |
|
307 |
row += 1
|
| - |
|
308 |
i=-1
|
| - |
|
309 |
affNotReconciledSheet.write(row, inc(), offer.get("adId"))
|
| - |
|
310 |
affNotReconciledSheet.write(row, inc(), offer.get("subTagId"))
|
| - |
|
311 |
affNotReconciledSheet.write(row, inc(), offer.get("saleDate"))
|
| - |
|
312 |
affNotReconciledSheet.write(row, inc(), offer.get("saleAmount"))
|
| - |
|
313 |
affNotReconciledSheet.write(row, inc(), offer.get("payOut"))
|
| - |
|
314 |
affNotReconciledSheet.write(row, inc(), offer.get("conversionStatus"))
|
| 264 |
|
315 |
|
| 265 |
def inc():
|
316 |
def inc():
|
| 266 |
global i
|
317 |
global i
|
| 267 |
i+=1
|
318 |
i+=1
|
| 268 |
return i
|
319 |
return i
|