| Line 2290... |
Line 2290... |
| 2290 |
pfSt = mpHistory.prefferedSellerShippingTime.split('-')
|
2290 |
pfSt = mpHistory.prefferedSellerShippingTime.split('-')
|
| 2291 |
if mpHistory.prefferedSellerName=='WS Retail' and mpHistory.ourRating > mpHistory.prefferedSellerRating and int(ourSt[0])<=int(pfSt[0]):
|
2291 |
if mpHistory.prefferedSellerName=='WS Retail' and mpHistory.ourRating > mpHistory.prefferedSellerRating and int(ourSt[0])<=int(pfSt[0]):
|
| 2292 |
style="""background-color:red;\""""
|
2292 |
style="""background-color:red;\""""
|
| 2293 |
else:
|
2293 |
else:
|
| 2294 |
style="\""
|
2294 |
style="\""
|
| 2295 |
message+="""<tr>
|
2295 |
message+="""<tr>
|
| 2296 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.item_id)+"""</td>
|
2296 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.item_id)+"""</td>
|
| 2297 |
<td style="text-align:center;"""+str(style)+""">"""+xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)+"""</td>
|
2297 |
<td style="text-align:center;"""+str(style)+""">"""+xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)+"""</td>
|
| 2298 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourSellingPrice)+"""</td>
|
2298 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourSellingPrice)+"""</td>
|
| 2299 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourRating)+"""</td>
|
2299 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourRating)+"""</td>
|
| 2300 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourShippingTime)+"""</td>
|
2300 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourShippingTime)+"""</td>
|
| 2301 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerName)+"""</td>
|
2301 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerName)+"""</td>
|
| 2302 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerSellingPrice)+"""</td>
|
2302 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerSellingPrice)+"""</td>
|
| 2303 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerRating)+"""</td>
|
2303 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerRating)+"""</td>
|
| 2304 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerShippingTime)+"""</td>
|
2304 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerShippingTime)+"""</td>
|
| 2305 |
<td style="text-align:center;"""+str(style)+""">"""+str(round(((mpHistory.prefferedSellerSellingPrice-mpHistory.ourSellingPrice)/mpHistory.ourSellingPrice)*100))+"%"+"""</td>
|
2305 |
<td style="text-align:center;"""+str(style)+""">"""+str(round(((mpHistory.prefferedSellerSellingPrice-mpHistory.ourSellingPrice)/mpHistory.ourSellingPrice)*100))+"%"+"""</td>
|
| 2306 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourInventory)+"""</td>
|
2306 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourInventory)+"""</td>
|
| 2307 |
<td style="text-align:center;"""+str(style)+""">"""+netInventory+"""</td>
|
2307 |
<td style="text-align:center;"""+str(style)+""">"""+netInventory+"""</td>
|
| 2308 |
<td style="text-align:center;"""+str(style)+""">"""+getOosString((itemSaleMap.get(mpHistory.item_id))[1])+"""</td>
|
2308 |
<td style="text-align:center;"""+str(style)+""">"""+getOosString((itemSaleMap.get(mpHistory.item_id))[1])+"""</td>
|
| 2309 |
</tr>"""
|
2309 |
</tr>"""
|
| 2310 |
message+="""</tbody></table></body></html>"""
|
2310 |
message+="""</tbody></table></body></html>"""
|
| 2311 |
print message
|
2311 |
print message
|
| 2312 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
2312 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| 2313 |
mailServer.ehlo()
|
2313 |
mailServer.ehlo()
|
| 2314 |
mailServer.starttls()
|
2314 |
mailServer.starttls()
|
| Line 2336... |
Line 2336... |
| 2336 |
try:
|
2336 |
try:
|
| 2337 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
2337 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| 2338 |
print "Successfully sent email"
|
2338 |
print "Successfully sent email"
|
| 2339 |
except:
|
2339 |
except:
|
| 2340 |
print "Error: unable to send email."
|
2340 |
print "Error: unable to send email."
|
| - |
|
2341 |
|
| - |
|
2342 |
def sendPricingMismatch(timestamp):
|
| - |
|
2343 |
xstr = lambda s: s or ""
|
| - |
|
2344 |
message="""<html>
|
| - |
|
2345 |
<body>
|
| - |
|
2346 |
<h3>Flipkart Pricing Mismatch</h3>
|
| - |
|
2347 |
<table border="1" style="width:100%;">
|
| - |
|
2348 |
<thead>
|
| - |
|
2349 |
<tr><th>Item Id</th>
|
| - |
|
2350 |
<th>Product Name</th>
|
| - |
|
2351 |
<th>Our System Price</th>
|
| - |
|
2352 |
<th>Flipkart Price</th>
|
| - |
|
2353 |
<th>Flipkart Inventory</th>
|
| - |
|
2354 |
<th>Total Inventory</th>
|
| - |
|
2355 |
<th>Sales History</th>
|
| - |
|
2356 |
</tr></thead>
|
| - |
|
2357 |
<tbody>"""
|
| - |
|
2358 |
flipkartPricing = {}
|
| - |
|
2359 |
saholicPricing = {}
|
| - |
|
2360 |
mpHistoryItems = session.query(MarketPlaceHistory,Item).join((Item,MarketPlaceHistory.item_id==Item.id)).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).all()
|
| - |
|
2361 |
for val in mpHistoryItems:
|
| - |
|
2362 |
temp = []
|
| - |
|
2363 |
temp.append(val[0].ourSellingPrice)
|
| - |
|
2364 |
temp.append(xstr(val[1].brand)+" "+xstr(val[1].model_name)+" "+xstr(val[1].model_number)+" "+xstr(val[1].color))
|
| - |
|
2365 |
temp.append(val.ourInventory)
|
| - |
|
2366 |
flipkartPricing[val[0].item_id] = temp
|
| - |
|
2367 |
mpHistoryItems[:] = []
|
| - |
|
2368 |
mpItems = session.query(MarketplaceItems).filter(MarketplaceItems.source==OrderSource.FLIPKART).all()
|
| - |
|
2369 |
for val in mpItems:
|
| - |
|
2370 |
saholicPricing[val.itemId] = val.currentSp
|
| - |
|
2371 |
mpItems[:] = []
|
| - |
|
2372 |
mismatches = []
|
| - |
|
2373 |
for k,v in flipkartPricing.iteritems():
|
| - |
|
2374 |
flipkartSellingPrice = v[0]
|
| - |
|
2375 |
ourSellingPrice = saholicPricing.get(k)
|
| - |
|
2376 |
if ourSellingPrice!=flipkartSellingPrice:
|
| - |
|
2377 |
mismatches.append(k)
|
| - |
|
2378 |
print "mismatches are ",mismatches
|
| - |
|
2379 |
for item in mismatches:
|
| - |
|
2380 |
netInventory=''
|
| - |
|
2381 |
if not inventoryMap.has_key(item):
|
| - |
|
2382 |
netInventory='Info Not Available'
|
| - |
|
2383 |
else:
|
| - |
|
2384 |
netInventory = str(getNetAvailability(inventoryMap.get(item)))
|
| - |
|
2385 |
message+="""<tr>
|
| - |
|
2386 |
<td style="text-align:center;>"""+str(item)+"""</td>
|
| - |
|
2387 |
<td style="text-align:center;>"""+str(flipkartPricing.get(item)[1])+"""</td>
|
| - |
|
2388 |
<td style="text-align:center;>"""+str(saholicPricing.get(item))+"""</td>
|
| - |
|
2389 |
<td style="text-align:center;>"""+str(flipkartPricing.get(item)[0])+"""</td>
|
| - |
|
2390 |
<td style="text-align:center;>"""+str(flipkartPricing.get(item)[2])+"""</td>
|
| - |
|
2391 |
<td style="text-align:center;>"""+netInventory+"""</td>
|
| - |
|
2392 |
<td style="text-align:center;>"""+getOosString((itemSaleMap.get(item))[1])+"""</td>
|
| - |
|
2393 |
</tr>"""
|
| - |
|
2394 |
message+="""</tbody></table></body></html>"""
|
| - |
|
2395 |
print message
|
| - |
|
2396 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
2397 |
mailServer.ehlo()
|
| - |
|
2398 |
mailServer.starttls()
|
| - |
|
2399 |
mailServer.ehlo()
|
| - |
|
2400 |
|
| - |
|
2401 |
recipients = ['kshitij.sood@saholic.com']
|
| 2341 |
|
2402 |
#recipients = ['rajneesh.arora@saholic.com','anikendra.das@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
|
| - |
|
2403 |
msg = MIMEMultipart()
|
| - |
|
2404 |
msg['Subject'] = "Flipkart Price Mismatch" + ' - ' + str(datetime.now())
|
| - |
|
2405 |
msg['From'] = ""
|
| - |
|
2406 |
msg['To'] = ",".join(recipients)
|
| - |
|
2407 |
msg.preamble = "Flipkart Price Mismatch" + ' - ' + str(datetime.now())
|
| - |
|
2408 |
html_msg = MIMEText(message, 'html')
|
| - |
|
2409 |
msg.attach(html_msg)
|
| - |
|
2410 |
try:
|
| - |
|
2411 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
2412 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
2413 |
mailServer.sendmail("cafe@nes", recipients, msg.as_string())
|
| - |
|
2414 |
except Exception as e:
|
| - |
|
2415 |
print e
|
| - |
|
2416 |
print "Unable to send Flipkart Price Mismatch mail.Lets try local SMTP"
|
| - |
|
2417 |
smtpServer = smtplib.SMTP('localhost')
|
| - |
|
2418 |
smtpServer.set_debuglevel(1)
|
| - |
|
2419 |
sender = 'support@shop2020.in'
|
| - |
|
2420 |
try:
|
| - |
|
2421 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| - |
|
2422 |
print "Successfully sent email"
|
| - |
|
2423 |
except:
|
| - |
|
2424 |
print "Error: unable to send email."
|
| 2342 |
|
2425 |
|
| 2343 |
|
2426 |
|
| 2344 |
def main():
|
2427 |
def main():
|
| 2345 |
parser = optparse.OptionParser()
|
2428 |
parser = optparse.OptionParser()
|
| 2346 |
parser.add_option("-t", "--type", dest="runType",
|
2429 |
parser.add_option("-t", "--type", dest="runType",
|
| Line 2379... |
Line 2462... |
| 2379 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
2462 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
| 2380 |
if previousProcessingTimestamp[0] is not None:
|
2463 |
if previousProcessingTimestamp[0] is not None:
|
| 2381 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
2464 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
| 2382 |
if options.runType=='FULL':
|
2465 |
if options.runType=='FULL':
|
| 2383 |
cheapButNotPrefAlert(timestamp)
|
2466 |
cheapButNotPrefAlert(timestamp)
|
| - |
|
2467 |
sendPricingMismatch(timestamp)
|
| 2384 |
|
2468 |
|
| 2385 |
if __name__ == '__main__':
|
2469 |
if __name__ == '__main__':
|
| 2386 |
main()
|
2470 |
main()
|
| 2387 |
|
2471 |
|