| Line 1412... |
Line 1412... |
| 1412 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
1412 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| 1413 |
mailServer.ehlo()
|
1413 |
mailServer.ehlo()
|
| 1414 |
mailServer.starttls()
|
1414 |
mailServer.starttls()
|
| 1415 |
mailServer.ehlo()
|
1415 |
mailServer.ehlo()
|
| 1416 |
|
1416 |
|
| 1417 |
# Create the container (outer) email message.
|
1417 |
#recipients = ['kshitij.sood@saholic.com']
|
| 1418 |
recipients = ['rajneesh.arora@saholic.com','rajveer.singh@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']
|
1418 |
recipients = ['rajneesh.arora@saholic.com','rajveer.singh@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']
|
| 1419 |
msg = MIMEMultipart()
|
1419 |
msg = MIMEMultipart()
|
| 1420 |
msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
1420 |
msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
|
| 1421 |
msg['From'] = ""
|
1421 |
msg['From'] = ""
|
| 1422 |
msg['To'] = ",".join(recipients)
|
1422 |
msg['To'] = ",".join(recipients)
|
| Line 1502... |
Line 1502... |
| 1502 |
if (markUpdatedItem.sellingPrice!=snapdealItem.sellingPrice or markUpdatedItem.suppressPriceFeed!=snapdealItem.suppressPriceFeed or markUpdatedItem.isListedOnSource!=snapdealItem.isListedOnSnapdeal):
|
1502 |
if (markUpdatedItem.sellingPrice!=snapdealItem.sellingPrice or markUpdatedItem.suppressPriceFeed!=snapdealItem.suppressPriceFeed or markUpdatedItem.isListedOnSource!=snapdealItem.isListedOnSnapdeal):
|
| 1503 |
markUpdatedItem.lastUpdatedOn = snapdealItem.updatedOn
|
1503 |
markUpdatedItem.lastUpdatedOn = snapdealItem.updatedOn
|
| 1504 |
markUpdatedItem.sellingPrice = snapdealItem.sellingPrice
|
1504 |
markUpdatedItem.sellingPrice = snapdealItem.sellingPrice
|
| 1505 |
markUpdatedItem.suppressPriceFeed = snapdealItem.suppressPriceFeed
|
1505 |
markUpdatedItem.suppressPriceFeed = snapdealItem.suppressPriceFeed
|
| 1506 |
markUpdatedItem.isListedOnSource = snapdealItem.isListedOnSnapdeal
|
1506 |
markUpdatedItem.isListedOnSource = snapdealItem.isListedOnSnapdeal
|
| - |
|
1507 |
|
| - |
|
1508 |
def processLostBuyBoxItems(previousProcessingTimestamp,currentTimestamp):
|
| - |
|
1509 |
previous_buy_box = session.query(MarketPlaceHistory.item_id).filter(MarketPlaceHistory.timestamp==previousProcessingTimestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.BUY_BOX).all()
|
| - |
|
1510 |
cant_compete = session.query(MarketPlaceHistory.item_id).filter(MarketPlaceHistory.timestamp==currentTimestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).all()
|
| - |
|
1511 |
lost_buy_box = list(list(zip(*previous_buy_box)[0])&list(zip(*cant_compete)[0]))
|
| - |
|
1512 |
if len(lost_buy_box)==0:
|
| - |
|
1513 |
return
|
| - |
|
1514 |
xstr = lambda s: s or ""
|
| - |
|
1515 |
message="""<html>
|
| - |
|
1516 |
<body>
|
| - |
|
1517 |
<h3>Lost Buy Box</h3>
|
| - |
|
1518 |
<table border="1" style="width:100%;">
|
| - |
|
1519 |
<thead>
|
| - |
|
1520 |
<tr><th>Item Id</th>
|
| - |
|
1521 |
<th>Product Name</th>
|
| - |
|
1522 |
<th>Current Price</th>
|
| - |
|
1523 |
<th>Current TP</th>
|
| - |
|
1524 |
<th>Current Margin</th>
|
| - |
|
1525 |
<th>Competition TP</th>
|
| - |
|
1526 |
<th>Lowest Possible TP</th>
|
| - |
|
1527 |
<th>NLC</th>
|
| - |
|
1528 |
<th>Target NLC</th>
|
| - |
|
1529 |
<th>Snapdeal Inventory</th>
|
| - |
|
1530 |
<th>Total Inventory</th>
|
| - |
|
1531 |
<th>Sales History</th>
|
| - |
|
1532 |
</tr></thead>
|
| - |
|
1533 |
<tbody>"""
|
| - |
|
1534 |
items = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==currentTimestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.item_id.in_(lost_buy_box)).all()
|
| - |
|
1535 |
for item in items:
|
| - |
|
1536 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
1537 |
netInventory=''
|
| - |
|
1538 |
if not inventoryMap.has_key(item.item_id):
|
| - |
|
1539 |
netInventory='Info Not Available'
|
| - |
|
1540 |
else:
|
| - |
|
1541 |
netInventory = str(getNetAvailability(inventoryMap.get(item.item_id)))
|
| - |
|
1542 |
message+="""<tr>
|
| - |
|
1543 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| - |
|
1544 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| - |
|
1545 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
| - |
|
1546 |
<td style="text-align:center">"""+str(item.ourTp)+"""</td>
|
| - |
|
1547 |
<td style="text-align:center">"""+str(round(item.margin))+" ("+str(round((item.margin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
| - |
|
1548 |
<td style="text-align:center">"""+str(item.lowestTp)+"""</td>
|
| - |
|
1549 |
<td style="text-align:center">"""+str(item.lowestPossibleTp)+"""</td>
|
| - |
|
1550 |
<td style="text-align:center">"""+str(item.ourNlc)+"""</td>
|
| - |
|
1551 |
<td style="text-align:center">"""+str(item.targetNlc)+"""</td>
|
| - |
|
1552 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
| - |
|
1553 |
<td style="text-align:center">"""+netInventory+"""</td>
|
| - |
|
1554 |
<td style="text-align:center">"""+getOosString((itemSaleMap.get(item.item_id))[1])+"""</td>
|
| - |
|
1555 |
</tr>"""
|
| - |
|
1556 |
message+="""</tbody></table></body></html>"""
|
| - |
|
1557 |
print message
|
| - |
|
1558 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
1559 |
mailServer.ehlo()
|
| - |
|
1560 |
mailServer.starttls()
|
| - |
|
1561 |
mailServer.ehlo()
|
| - |
|
1562 |
|
| - |
|
1563 |
recipients = ['kshitij.sood@saholic.com']
|
| 1507 |
|
1564 |
#recipients = ['rajneesh.arora@saholic.com','rajveer.singh@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']
|
| - |
|
1565 |
msg = MIMEMultipart()
|
| - |
|
1566 |
msg['Subject'] = "Snapdeal Lost Buy Box" + ' - ' + str(datetime.now())
|
| - |
|
1567 |
msg['From'] = ""
|
| - |
|
1568 |
msg['To'] = ",".join(recipients)
|
| - |
|
1569 |
msg.preamble = "Snapdeal Lost Buy Box" + ' - ' + str(datetime.now())
|
| - |
|
1570 |
html_msg = MIMEText(message, 'html')
|
| - |
|
1571 |
msg.attach(html_msg)
|
| - |
|
1572 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
1573 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
1574 |
mailServer.sendmail("cafe@nes", recipients, msg.as_string())
|
| - |
|
1575 |
|
| 1508 |
|
1576 |
|
| 1509 |
|
1577 |
|
| 1510 |
def getOtherTp(snapdealDetails,val,spm):
|
1578 |
def getOtherTp(snapdealDetails,val,spm):
|
| 1511 |
if val.parent_category==10011:
|
1579 |
if val.parent_category==10011:
|
| 1512 |
commissionPercentage = spm.competitorCommissionAccessory
|
1580 |
commissionPercentage = spm.competitorCommissionAccessory
|
| Line 1579... |
Line 1647... |
| 1579 |
sys.exit(1)
|
1647 |
sys.exit(1)
|
| 1580 |
itemInfo,spm= populateStuff(options.runType)
|
1648 |
itemInfo,spm= populateStuff(options.runType)
|
| 1581 |
cantCompete, buyBoxItems, competitive, \
|
1649 |
cantCompete, buyBoxItems, competitive, \
|
| 1582 |
competitiveNoInventory, exceptionList, negativeMargin = decideCategory(itemInfo,spm)
|
1650 |
competitiveNoInventory, exceptionList, negativeMargin = decideCategory(itemInfo,spm)
|
| 1583 |
timestamp = datetime.now()
|
1651 |
timestamp = datetime.now()
|
| - |
|
1652 |
previousProcessingTimestamp = session.query(func.max(MarketPlaceHistory.timestamp)).filter(MarketPlaceHistory.source==7).one()
|
| 1584 |
exceptionItems = commitExceptionList(exceptionList,timestamp)
|
1653 |
exceptionItems = commitExceptionList(exceptionList,timestamp)
|
| 1585 |
cantComepeteItems = commitCantCompete(cantCompete,timestamp)
|
1654 |
cantComepeteItems = commitCantCompete(cantCompete,timestamp)
|
| 1586 |
buyBoxList = commitBuyBox(buyBoxItems,timestamp)
|
1655 |
buyBoxList = commitBuyBox(buyBoxItems,timestamp)
|
| 1587 |
competitiveItems = commitCompetitive(competitive,timestamp)
|
1656 |
competitiveItems = commitCompetitive(competitive,timestamp)
|
| 1588 |
competitiveNoInventoryItems = commitCompetitiveNoInventory(competitiveNoInventory,timestamp)
|
1657 |
competitiveNoInventoryItems = commitCompetitiveNoInventory(competitiveNoInventory,timestamp)
|
| Line 1595... |
Line 1664... |
| 1595 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
|
1664 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, previousAutoFav, nowAutoFav,timestamp, options.runType)
|
| 1596 |
else:
|
1665 |
else:
|
| 1597 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
|
1666 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
|
| 1598 |
commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp)
|
1667 |
commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp)
|
| 1599 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
1668 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
| - |
|
1669 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
| 1600 |
|
1670 |
|
| 1601 |
if __name__ == '__main__':
|
1671 |
if __name__ == '__main__':
|
| 1602 |
main()
|
1672 |
main()
|
| 1603 |
|
1673 |
|