| Line 943... |
Line 943... |
| 943 |
|
943 |
|
| 944 |
def getTargetSp(targetTp,mpItem,ourSp):
|
944 |
def getTargetSp(targetTp,mpItem,ourSp):
|
| 945 |
targetSp = float(targetTp+(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100)))/(1-((mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))))
|
945 |
targetSp = float(targetTp+(mpItem.courierCost+mpItem.closingFee)*(1+(mpItem.serviceTax/100)))/(1-((mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))))
|
| 946 |
return round(targetSp,2)
|
946 |
return round(targetSp,2)
|
| 947 |
|
947 |
|
| - |
|
948 |
def getNewLowestPossibleTp(mpItem,nlc,vatRate,proposedSellingPrice):
|
| - |
|
949 |
vat = (proposedSellingPrice/(1+(vatRate/100))-(nlc/(1+(vatRate/100))))*(vatRate/100);
|
| - |
|
950 |
inHouseCost = 15+vat+(mpItem.returnProvision/100)*proposedSellingPrice+mpItem.otherCost;
|
| - |
|
951 |
lowest_possible_tp = nlc+inHouseCost;
|
| - |
|
952 |
return round(lowest_possible_tp,2)
|
| - |
|
953 |
|
| - |
|
954 |
def getNewOurTp(mpItem,proposedSellingPrice):
|
| - |
|
955 |
ourTp = proposedSellingPrice- proposedSellingPrice*(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))-(mpItem.courierCostMarketplace+mpItem.closingFee)*(1+(mpItem.serviceTax/100))
|
| - |
|
956 |
return round(ourTp,2)
|
| - |
|
957 |
|
| - |
|
958 |
def getNewLowestPossibleSp(mpItem,nlc,vatRate):
|
| - |
|
959 |
lowestPossibleSp = (nlc+(mpItem.courierCostMarketplace+mpItem.closingFee)*(1+(mpItem.serviceTax/100))*(1+(vatRate/100))+(15+mpItem.otherCost)*(1+(vatRate)/100))/(1-(mpItem.commission/100+mpItem.emiFee/100)*(1+(mpItem.serviceTax/100))*(1+(vatRate)/100)-(mpItem.returnProvision/100)*(1+(vatRate)/100));
|
| - |
|
960 |
return round(lowestPossibleSp,2)
|
| - |
|
961 |
|
| - |
|
962 |
|
| 948 |
def markAutoFavourite():
|
963 |
def markAutoFavourite():
|
| 949 |
previouslyAutoFav = []
|
964 |
previouslyAutoFav = []
|
| 950 |
nowAutoFav = []
|
965 |
nowAutoFav = []
|
| 951 |
marketplaceItems = session.query(MarketplaceItems).filter(MarketplaceItems.source==OrderSource.FLIPKART).all()
|
966 |
marketplaceItems = session.query(MarketplaceItems).filter(MarketplaceItems.source==OrderSource.FLIPKART).all()
|
| 952 |
fromDate = datetime.now()-timedelta(days = 3, hours=datetime.now().hour, minutes=datetime.now().minute, seconds=datetime.now().second)
|
967 |
fromDate = datetime.now()-timedelta(days = 3, hours=datetime.now().hour, minutes=datetime.now().minute, seconds=datetime.now().second)
|
| Line 1383... |
Line 1398... |
| 1383 |
sheet.write(sheet_iterator,4,catItem.brand)
|
1398 |
sheet.write(sheet_iterator,4,catItem.brand)
|
| 1384 |
sheet.write(sheet_iterator,5,xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color))
|
1399 |
sheet.write(sheet_iterator,5,xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color))
|
| 1385 |
sheet.write(sheet_iterator,6,catItem.weight)
|
1400 |
sheet.write(sheet_iterator,6,catItem.weight)
|
| 1386 |
sheet.write(sheet_iterator,7,mpItem.courierCost)
|
1401 |
sheet.write(sheet_iterator,7,mpItem.courierCost)
|
| 1387 |
sheet.write(sheet_iterator,8,catItem.risky)
|
1402 |
sheet.write(sheet_iterator,8,catItem.risky)
|
| 1388 |
sheet.write(sheet_iterator,9,mpHistory.ourRating)
|
1403 |
sheet.write(sheet_iterator,9,mpHistory.ourRank)
|
| 1389 |
sheet.write(sheet_iterator,10,mpHistory.lowestSellerName)
|
1404 |
sheet.write(sheet_iterator,10,mpHistory.lowestSellerName)
|
| 1390 |
sheet.write(sheet_iterator,11,mpHistory.ourRating)
|
1405 |
sheet.write(sheet_iterator,11,mpHistory.ourRating)
|
| 1391 |
# ourShippingTime= str(flipkartDetails.shippingTimeLowerLimitOur) if flipkartDetails.shippingTimeUpperLimitOur==0\
|
1406 |
# ourShippingTime= str(flipkartDetails.shippingTimeLowerLimitOur) if flipkartDetails.shippingTimeUpperLimitOur==0\
|
| 1392 |
# else str(flipkartDetails.shippingTimeLowerLimitOur)+'-'+str(flipkartDetails.shippingTimeUpperLimitOur)
|
1407 |
# else str(flipkartDetails.shippingTimeLowerLimitOur)+'-'+str(flipkartDetails.shippingTimeUpperLimitOur)
|
| 1393 |
sheet.write(sheet_iterator,12,mpHistory.lowestSellerShippingTime)
|
1408 |
sheet.write(sheet_iterator,12,mpHistory.lowestSellerShippingTime)
|
| Line 2053... |
Line 2068... |
| 2053 |
time.sleep(5)
|
2068 |
time.sleep(5)
|
| 2054 |
print "returning offset******"
|
2069 |
print "returning offset******"
|
| 2055 |
time.sleep(5)
|
2070 |
time.sleep(5)
|
| 2056 |
return endOffset
|
2071 |
return endOffset
|
| 2057 |
|
2072 |
|
| - |
|
2073 |
def sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease):
|
| - |
|
2074 |
if len(successfulAutoDecrease)==0 and len(successfulAutoIncrease)==0 :
|
| - |
|
2075 |
return
|
| - |
|
2076 |
xstr = lambda s: s or ""
|
| - |
|
2077 |
catalog_client = CatalogClient().get_client()
|
| - |
|
2078 |
inventory_client = InventoryClient().get_client()
|
| - |
|
2079 |
message="""<html>
|
| - |
|
2080 |
<body>
|
| - |
|
2081 |
<h3>Auto Decrease Items</h3>
|
| - |
|
2082 |
<table border="1" style="width:100%;">
|
| - |
|
2083 |
<thead>
|
| - |
|
2084 |
<tr><th>Item Id</th>
|
| - |
|
2085 |
<th>Product Name</th>
|
| - |
|
2086 |
<th>Old Price</th>
|
| - |
|
2087 |
<th>New Price</th>
|
| - |
|
2088 |
<th>Old Margin</th>
|
| - |
|
2089 |
<th>New Margin</th>
|
| - |
|
2090 |
<th>Flipkart Inventory</th>
|
| - |
|
2091 |
<th>Sales History</th>
|
| - |
|
2092 |
</tr></thead>
|
| - |
|
2093 |
<tbody>"""
|
| - |
|
2094 |
for item in successfulAutoDecrease:
|
| - |
|
2095 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
2096 |
mpItem = MarketplaceItems.get_by(itemId=item.item_id,source=OrderSource.FLIPKART)
|
| - |
|
2097 |
fkItem = FlipkartItem.get_by(item_id=item.item_id)
|
| - |
|
2098 |
warehouse = inventory_client.getWarehouse(fkItem.warehouseId)
|
| - |
|
2099 |
vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, item.proposedSellingPrice)
|
| - |
|
2100 |
newMargin = round(getNewOurTp(mpItem,item.proposedSellingPrice) - getNewLowestPossibleTp(mpItem,item.ourNlc,vatRate,item.proposedSellingPrice))
|
| - |
|
2101 |
message+="""<tr>
|
| - |
|
2102 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| - |
|
2103 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| - |
|
2104 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
| - |
|
2105 |
<td style="text-align:center">"""+str(math.ceil(item.proposedSellingPrice))+"""</td>
|
| - |
|
2106 |
<td style="text-align:center">"""+str(round(item.margin))+" ("+str(round((item.margin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
| - |
|
2107 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/item.proposedSellingPrice)*100,1))+"%)"+"""</td>
|
| - |
|
2108 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
| - |
|
2109 |
<td style="text-align:center">"""+getOosString((itemSaleMap.get(item.item_id))[1])+"""</td>
|
| - |
|
2110 |
</tr>"""
|
| - |
|
2111 |
message+="""</tbody></table><h3>Auto Increase Items</h3><table border="1" style="width:100%;">
|
| - |
|
2112 |
<thead>
|
| - |
|
2113 |
<tr><th>Item Id</th>
|
| - |
|
2114 |
<th>Product Name</th>
|
| - |
|
2115 |
<th>Old Price</th>
|
| - |
|
2116 |
<th>New Price</th>
|
| - |
|
2117 |
<th>Old Margin</th>
|
| - |
|
2118 |
<th>New Margin</th>
|
| - |
|
2119 |
<th>Flipkart Inventory</th>
|
| - |
|
2120 |
<th>Sales History</th>
|
| - |
|
2121 |
</tr></thead>
|
| - |
|
2122 |
<tbody>"""
|
| - |
|
2123 |
for item in successfulAutoIncrease:
|
| - |
|
2124 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
2125 |
mpItem = MarketplaceItems.get_by(itemId=item.item_id,source=OrderSource.FLIPKART)
|
| - |
|
2126 |
fkItem = FlipkartItem.get_by(item_id=item.item_id)
|
| - |
|
2127 |
warehouse = inventory_client.getWarehouse(fkItem.warehouseId)
|
| - |
|
2128 |
vatRate = catalog_client.getVatPercentageForItem(item.item_id, warehouse.stateId, math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))
|
| - |
|
2129 |
newMargin = round(getNewOurTp(mpItem,item.ourSellingPrice+max(10,.01*item.ourSellingPrice)) - getNewLowestPossibleTp(mpItem,item.ourNlc,vatRate,item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))
|
| - |
|
2130 |
message+="""<tr>
|
| - |
|
2131 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| - |
|
2132 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| - |
|
2133 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
| - |
|
2134 |
<td style="text-align:center">"""+str(math.ceil(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))+"""</td>
|
| - |
|
2135 |
<td style="text-align:center">"""+str(round((item.margin),1))+" ("+str(round((item.margin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
| - |
|
2136 |
<td style="text-align:center">"""+str(newMargin)+" ("+str(round((newMargin/(item.ourSellingPrice+max(10,.01*item.ourSellingPrice)))*100,1))+"%)"+"""</td>
|
| - |
|
2137 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
| - |
|
2138 |
<td style="text-align:center">"""+getOosString((itemSaleMap.get(item.item_id))[1])+"""</td>
|
| - |
|
2139 |
</tr>"""
|
| - |
|
2140 |
message+="""</tbody></table></body></html>"""
|
| - |
|
2141 |
print message
|
| - |
|
2142 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
2143 |
mailServer.ehlo()
|
| - |
|
2144 |
mailServer.starttls()
|
| - |
|
2145 |
mailServer.ehlo()
|
| - |
|
2146 |
|
| - |
|
2147 |
recipients = ['kshitij.sood@saholic.com']
|
| - |
|
2148 |
#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']
|
| - |
|
2149 |
msg = MIMEMultipart()
|
| - |
|
2150 |
msg['Subject'] = "Flipkart Auto Pricing" + ' - ' + str(datetime.now())
|
| - |
|
2151 |
msg['From'] = ""
|
| - |
|
2152 |
msg['To'] = ",".join(recipients)
|
| - |
|
2153 |
msg.preamble = "Flipkart Auto Pricing" + ' - ' + str(datetime.now())
|
| - |
|
2154 |
html_msg = MIMEText(message, 'html')
|
| - |
|
2155 |
msg.attach(html_msg)
|
| - |
|
2156 |
try:
|
| - |
|
2157 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
2158 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
2159 |
mailServer.sendmail("cafe@nes", recipients, msg.as_string())
|
| - |
|
2160 |
except Exception as e:
|
| - |
|
2161 |
print e
|
| - |
|
2162 |
print "Unable to send pricing mail.Lets try with local SMTP."
|
| - |
|
2163 |
smtpServer = smtplib.SMTP('localhost')
|
| - |
|
2164 |
smtpServer.set_debuglevel(1)
|
| - |
|
2165 |
sender = 'support@shop2020.in'
|
| - |
|
2166 |
try:
|
| - |
|
2167 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| - |
|
2168 |
print "Successfully sent email"
|
| - |
|
2169 |
except:
|
| - |
|
2170 |
print "Error: unable to send email."
|
| - |
|
2171 |
|
| - |
|
2172 |
def processLostBuyBoxItems(previousProcessingTimestamp,currentTimestamp):
|
| - |
|
2173 |
previous_buy_box = session.query(MarketPlaceHistory.item_id).filter(MarketPlaceHistory.timestamp==previousProcessingTimestamp).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).filter(or_(MarketPlaceHistory.competitiveCategory==CompetitionCategory.BUY_BOX,MarketPlaceHistory.competitiveCategory==CompetitionCategory.PREF_BUT_NOT_CHEAP)).all()
|
| - |
|
2174 |
cant_compete = session.query(MarketPlaceHistory.item_id).filter(MarketPlaceHistory.timestamp==currentTimestamp).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.CANT_COMPETE).all()
|
| - |
|
2175 |
if previous_buy_box is None:
|
| - |
|
2176 |
print "No item in buy box for last run"
|
| - |
|
2177 |
return
|
| - |
|
2178 |
lost_buy_box = list(set(list(zip(*previous_buy_box)[0]))&set(list(zip(*cant_compete)[0])))
|
| - |
|
2179 |
if len(lost_buy_box)==0:
|
| - |
|
2180 |
return
|
| - |
|
2181 |
xstr = lambda s: s or ""
|
| - |
|
2182 |
message="""<html>
|
| - |
|
2183 |
<body>
|
| - |
|
2184 |
<h3>Lost Buy Box</h3>
|
| - |
|
2185 |
<table border="1" style="width:100%;">
|
| - |
|
2186 |
<thead>
|
| - |
|
2187 |
<tr><th>Item Id</th>
|
| - |
|
2188 |
<th>Product Name</th>
|
| - |
|
2189 |
<th>Current Price</th>
|
| - |
|
2190 |
<th>Current TP</th>
|
| - |
|
2191 |
<th>Current Margin</th>
|
| - |
|
2192 |
<th>Competition TP</th>
|
| - |
|
2193 |
<th>Lowest Possible TP</th>
|
| - |
|
2194 |
<th>NLC</th>
|
| - |
|
2195 |
<th>Target NLC</th>
|
| - |
|
2196 |
<th>Flipkart Inventory</th>
|
| - |
|
2197 |
<th>Total Inventory</th>
|
| - |
|
2198 |
<th>Sales History</th>
|
| - |
|
2199 |
</tr></thead>
|
| - |
|
2200 |
<tbody>"""
|
| - |
|
2201 |
items = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==currentTimestamp).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).filter(MarketPlaceHistory.item_id.in_(lost_buy_box)).all()
|
| - |
|
2202 |
for item in items:
|
| - |
|
2203 |
it = Item.query.filter_by(id=item.item_id).one()
|
| - |
|
2204 |
netInventory=''
|
| - |
|
2205 |
if not inventoryMap.has_key(item.item_id):
|
| - |
|
2206 |
netInventory='Info Not Available'
|
| - |
|
2207 |
else:
|
| - |
|
2208 |
netInventory = str(getNetAvailability(inventoryMap.get(item.item_id)))
|
| - |
|
2209 |
message+="""<tr>
|
| - |
|
2210 |
<td style="text-align:center">"""+str(item.item_id)+"""</td>
|
| - |
|
2211 |
<td style="text-align:center">"""+xstr(it.brand)+" "+xstr(it.model_name)+" "+xstr(it.model_number)+" "+xstr(it.color)+"""</td>
|
| - |
|
2212 |
<td style="text-align:center">"""+str(item.ourSellingPrice)+"""</td>
|
| - |
|
2213 |
<td style="text-align:center">"""+str(item.ourTp)+"""</td>
|
| - |
|
2214 |
<td style="text-align:center">"""+str(round(item.margin))+" ("+str(round((item.margin/item.ourSellingPrice)*100,1))+"%)"+"""</td>
|
| - |
|
2215 |
<td style="text-align:center">"""+str(item.lowestTp)+"""</td>
|
| - |
|
2216 |
<td style="text-align:center">"""+str(item.lowestPossibleTp)+"""</td>
|
| - |
|
2217 |
<td style="text-align:center">"""+str(item.ourNlc)+"""</td>
|
| - |
|
2218 |
<td style="text-align:center">"""+str(item.targetNlc)+"""</td>
|
| - |
|
2219 |
<td style="text-align:center">"""+str(item.ourInventory)+"""</td>
|
| - |
|
2220 |
<td style="text-align:center">"""+netInventory+"""</td>
|
| - |
|
2221 |
<td style="text-align:center">"""+getOosString((itemSaleMap.get(item.item_id))[1])+"""</td>
|
| - |
|
2222 |
</tr>"""
|
| - |
|
2223 |
message+="""</tbody></table></body></html>"""
|
| - |
|
2224 |
print message
|
| - |
|
2225 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
2226 |
mailServer.ehlo()
|
| - |
|
2227 |
mailServer.starttls()
|
| - |
|
2228 |
mailServer.ehlo()
|
| - |
|
2229 |
|
| - |
|
2230 |
recipients = ['kshitij.sood@saholic.com']
|
| - |
|
2231 |
#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']
|
| - |
|
2232 |
msg = MIMEMultipart()
|
| - |
|
2233 |
msg['Subject'] = "Flipkart Lost Buy Box" + ' - ' + str(datetime.now())
|
| - |
|
2234 |
msg['From'] = ""
|
| - |
|
2235 |
msg['To'] = ",".join(recipients)
|
| - |
|
2236 |
msg.preamble = "Flipkart Lost Buy Box" + ' - ' + str(datetime.now())
|
| - |
|
2237 |
html_msg = MIMEText(message, 'html')
|
| - |
|
2238 |
msg.attach(html_msg)
|
| - |
|
2239 |
try:
|
| - |
|
2240 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
2241 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
2242 |
mailServer.sendmail("cafe@nes", recipients, msg.as_string())
|
| - |
|
2243 |
except Exception as e:
|
| - |
|
2244 |
print e
|
| - |
|
2245 |
print "Unable to send lost buy box mail.Lets try local SMTP"
|
| - |
|
2246 |
smtpServer = smtplib.SMTP('localhost')
|
| - |
|
2247 |
smtpServer.set_debuglevel(1)
|
| - |
|
2248 |
sender = 'support@shop2020.in'
|
| - |
|
2249 |
try:
|
| - |
|
2250 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| - |
|
2251 |
print "Successfully sent email"
|
| - |
|
2252 |
except:
|
| - |
|
2253 |
print "Error: unable to send email."
|
| - |
|
2254 |
|
| - |
|
2255 |
def cheapButNotPrefAlert(timestamp):
|
| - |
|
2256 |
cheap_but_not_pref = session.query(MarketPlaceHistory,Item).join(Item,MarketPlaceHistory.item_id==Item.id).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.CHEAP_BUT_NOT_PREF).all()
|
| - |
|
2257 |
if cheap_but_not_pref is None:
|
| - |
|
2258 |
return
|
| - |
|
2259 |
xstr = lambda s: s or ""
|
| - |
|
2260 |
message="""<html>
|
| - |
|
2261 |
<body>
|
| - |
|
2262 |
<h3>Cheap But Not Preferred</h3>
|
| - |
|
2263 |
<table border="1" style="width:100%;">
|
| - |
|
2264 |
<thead>
|
| - |
|
2265 |
<tr><th>Item Id</th>
|
| - |
|
2266 |
<th>Product Name</th>
|
| - |
|
2267 |
<th>Current Price</th>
|
| - |
|
2268 |
<th>Preffered Seller</th>
|
| - |
|
2269 |
<th>Preffered Seller SP</th>
|
| - |
|
2270 |
<th>Flipkart Inventory</th>
|
| - |
|
2271 |
<th>Total Inventory</th>
|
| - |
|
2272 |
<th>Sales History</th>
|
| - |
|
2273 |
</tr></thead>
|
| - |
|
2274 |
<tbody>"""
|
| - |
|
2275 |
for item in cheap_but_not_pref:
|
| - |
|
2276 |
mpHistory = item[0]
|
| - |
|
2277 |
catItem = item[1]
|
| - |
|
2278 |
netInventory=''
|
| - |
|
2279 |
if not inventoryMap.has_key(mpHistory.item_id):
|
| - |
|
2280 |
netInventory='Info Not Available'
|
| - |
|
2281 |
else:
|
| - |
|
2282 |
netInventory = str(getNetAvailability(inventoryMap.get(mpHistory.item_id)))
|
| - |
|
2283 |
if mpHistory.prefferedSellerSellingPrice=='WS Retail':
|
| - |
|
2284 |
style="""background-color:red;\""""
|
| - |
|
2285 |
else:
|
| - |
|
2286 |
style="\""
|
| - |
|
2287 |
message+="""<tr>
|
| - |
|
2288 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.item_id)+"""</td>
|
| - |
|
2289 |
<td style="text-align:center;"""+str(style)+""">"""+xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)+"""</td>
|
| - |
|
2290 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourSellingPrice)+"""</td>
|
| - |
|
2291 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerName)+"""</td>
|
| - |
|
2292 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.prefferedSellerSellingPrice)+"""</td>
|
| - |
|
2293 |
<td style="text-align:center;"""+str(style)+""">"""+str(mpHistory.ourInventory)+"""</td>
|
| - |
|
2294 |
<td style="text-align:center;"""+str(style)+""">"""+netInventory+"""</td>
|
| - |
|
2295 |
<td style="text-align:center;"""+str(style)+""">"""+getOosString((itemSaleMap.get(mpHistory.item_id))[1])+"""</td>
|
| - |
|
2296 |
</tr>"""
|
| - |
|
2297 |
message+="""</tbody></table></body></html>"""
|
| - |
|
2298 |
print message
|
| - |
|
2299 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
2300 |
mailServer.ehlo()
|
| - |
|
2301 |
mailServer.starttls()
|
| - |
|
2302 |
mailServer.ehlo()
|
| - |
|
2303 |
|
| - |
|
2304 |
recipients = ['kshitij.sood@saholic.com']
|
| - |
|
2305 |
#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']
|
| - |
|
2306 |
msg = MIMEMultipart()
|
| - |
|
2307 |
msg['Subject'] = "Flipkart Cheap But Not In BuyBox Items" + ' - ' + str(datetime.now())
|
| - |
|
2308 |
msg['From'] = ""
|
| - |
|
2309 |
msg['To'] = ",".join(recipients)
|
| - |
|
2310 |
msg.preamble = "Flipkart Cheap But Not In BuyBox Items" + ' - ' + str(datetime.now())
|
| - |
|
2311 |
html_msg = MIMEText(message, 'html')
|
| - |
|
2312 |
msg.attach(html_msg)
|
| - |
|
2313 |
try:
|
| - |
|
2314 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
2315 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
2316 |
mailServer.sendmail("cafe@nes", recipients, msg.as_string())
|
| - |
|
2317 |
except Exception as e:
|
| - |
|
2318 |
print e
|
| - |
|
2319 |
print "Unable to send Flipkart Cheap But Not In BuyBox Items mail.Lets try local SMTP"
|
| - |
|
2320 |
smtpServer = smtplib.SMTP('localhost')
|
| - |
|
2321 |
smtpServer.set_debuglevel(1)
|
| - |
|
2322 |
sender = 'support@shop2020.in'
|
| - |
|
2323 |
try:
|
| - |
|
2324 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| - |
|
2325 |
print "Successfully sent email"
|
| - |
|
2326 |
except:
|
| - |
|
2327 |
print "Error: unable to send email."
|
| - |
|
2328 |
|
| - |
|
2329 |
|
| 2058 |
|
2330 |
|
| 2059 |
def main():
|
2331 |
def main():
|
| 2060 |
parser = optparse.OptionParser()
|
2332 |
parser = optparse.OptionParser()
|
| 2061 |
parser.add_option("-t", "--type", dest="runType",
|
2333 |
parser.add_option("-t", "--type", dest="runType",
|
| 2062 |
default="FULL", type="string",
|
2334 |
default="FULL", type="string",
|
| Line 2089... |
Line 2361... |
| 2089 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
2361 |
previousAutoFav, nowAutoFav = markAutoFavourite()
|
| 2090 |
if options.runType =='FULL':
|
2362 |
if options.runType =='FULL':
|
| 2091 |
write_report(previousAutoFav,nowAutoFav,timestamp,options.runType)
|
2363 |
write_report(previousAutoFav,nowAutoFav,timestamp,options.runType)
|
| 2092 |
else:
|
2364 |
else:
|
| 2093 |
write_report(None,None,timestamp,options.runType)
|
2365 |
write_report(None,None,timestamp,options.runType)
|
| - |
|
2366 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
| - |
|
2367 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
| - |
|
2368 |
if options.runType=='FULL':
|
| - |
|
2369 |
cheapButNotPrefAlert(timestamp)
|
| 2094 |
|
2370 |
|
| 2095 |
if __name__ == '__main__':
|
2371 |
if __name__ == '__main__':
|
| 2096 |
main()
|
2372 |
main()
|
| 2097 |
|
2373 |
|