| Line 154... |
Line 154... |
| 154 |
# if not obj.is_oos:
|
154 |
# if not obj.is_oos:
|
| 155 |
# count+=1
|
155 |
# count+=1
|
| 156 |
# sale = sale+obj.num_orders
|
156 |
# sale = sale+obj.num_orders
|
| 157 |
#avgSalePerDay=0 if count==0 else (float(sale)/count)
|
157 |
#avgSalePerDay=0 if count==0 else (float(sale)/count)
|
| 158 |
totalAvailability, totalReserved = 0,0
|
158 |
totalAvailability, totalReserved = 0,0
|
| - |
|
159 |
if autoDecrementItem.risky:
|
| 159 |
if (not inventoryMap.has_key(autoDecrementItem.item_id)):
|
160 |
if ((not inventoryMap.has_key(autoDecrementItem.item_id)) and autoDecrementItem.risky):
|
| 160 |
markReasonForMpItem(autoDecrementItem,'Inventory info not available',Decision.AUTO_DECREMENT_FAILED)
|
161 |
markReasonForMpItem(autoDecrementItem,'Inventory info not available',Decision.AUTO_DECREMENT_FAILED)
|
| 161 |
continue
|
- |
|
| 162 |
itemInventory=inventoryMap[autoDecrementItem.item_id]
|
- |
|
| 163 |
availableMap = itemInventory.availability
|
- |
|
| 164 |
reserveMap = itemInventory.reserved
|
- |
|
| 165 |
for warehouse,availability in availableMap.iteritems():
|
- |
|
| 166 |
if warehouse==16:
|
- |
|
| 167 |
continue
|
162 |
continue
|
| - |
|
163 |
itemInventory=inventoryMap[autoDecrementItem.item_id]
|
| - |
|
164 |
availableMap = itemInventory.availability
|
| - |
|
165 |
reserveMap = itemInventory.reserved
|
| - |
|
166 |
for warehouse,availability in availableMap.iteritems():
|
| - |
|
167 |
if warehouse==16 or warehouse==1771:
|
| - |
|
168 |
continue
|
| 168 |
totalAvailability = totalAvailability+availability
|
169 |
totalAvailability = totalAvailability+availability
|
| 169 |
for warehouse,reserve in reserveMap.iteritems():
|
170 |
for warehouse,reserve in reserveMap.iteritems():
|
| - |
|
171 |
if warehouse==16 or warehouse==1771:
|
| - |
|
172 |
continue
|
| - |
|
173 |
totalReserved = totalReserved+reserve
|
| - |
|
174 |
if (totalAvailability-totalReserved)<=0:
|
| - |
|
175 |
markReasonForMpItem(autoDecrementItem,'Net availability is 0',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
176 |
continue
|
| - |
|
177 |
#if (avgSalePerDay==0): #exclude
|
| - |
|
178 |
# markReasonForMpItem(autoDecrementItem,'Average sale per day is zero',Decision.AUTO_DECREMENT_FAILED)
|
| 170 |
if warehouse==16:
|
179 |
# continue
|
| - |
|
180 |
avgSalePerDay = (itemSaleMap.get(autoDecrementItem.item_id))[2]
|
| - |
|
181 |
try:
|
| - |
|
182 |
daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
|
| - |
|
183 |
except ZeroDivisionError,e:
|
| - |
|
184 |
lgr.info("Infinite days of stock for item "+str(autoDecrementItem.item_id))
|
| - |
|
185 |
daysOfStock = float("inf")
|
| - |
|
186 |
if daysOfStock<2 and autoDecrementItem.risky:
|
| - |
|
187 |
markReasonForMpItem(autoDecrementItem,'Our stock is not enough',Decision.AUTO_DECREMENT_FAILED)
|
| 171 |
continue
|
188 |
continue
|
| 172 |
totalReserved = totalReserved+reserve
|
- |
|
| 173 |
if (totalAvailability-totalReserved)<=0:
|
- |
|
| 174 |
markReasonForMpItem(autoDecrementItem,'Net availability is 0',Decision.AUTO_DECREMENT_FAILED)
|
- |
|
| 175 |
continue
|
- |
|
| 176 |
#if (avgSalePerDay==0): #exclude
|
- |
|
| 177 |
# markReasonForMpItem(autoDecrementItem,'Average sale per day is zero',Decision.AUTO_DECREMENT_FAILED)
|
- |
|
| 178 |
# continue
|
- |
|
| 179 |
avgSalePerDay = (itemSaleMap.get(autoDecrementItem.item_id))[2]
|
- |
|
| 180 |
try:
|
- |
|
| 181 |
daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
|
- |
|
| 182 |
except ZeroDivisionError,e:
|
- |
|
| 183 |
lgr.info("Infinite days of stock for item "+str(autoDecrementItem.item_id))
|
- |
|
| 184 |
daysOfStock = float("inf")
|
- |
|
| 185 |
if daysOfStock<2 and autoDecrementItem.risky:
|
- |
|
| 186 |
markReasonForMpItem(autoDecrementItem,'Our stock is not enough',Decision.AUTO_DECREMENT_FAILED)
|
- |
|
| 187 |
continue
|
- |
|
| 188 |
|
189 |
|
| 189 |
autoDecrementItem.competitorEnoughStock = True
|
190 |
autoDecrementItem.competitorEnoughStock = True
|
| 190 |
autoDecrementItem.ourEnoughStock = True
|
191 |
autoDecrementItem.ourEnoughStock = True
|
| 191 |
#autoDecrementItem.avgSales = avgSalePerDay
|
192 |
#autoDecrementItem.avgSales = avgSalePerDay
|
| 192 |
autoDecrementItem.decision = Decision.AUTO_DECREMENT_SUCCESS
|
193 |
autoDecrementItem.decision = Decision.AUTO_DECREMENT_SUCCESS
|
| Line 234... |
Line 235... |
| 234 |
mpItem = MarketplaceItems.get_by(itemId=autoIncrementItem.item_id,source=OrderSource.SNAPDEAL)
|
235 |
mpItem = MarketplaceItems.get_by(itemId=autoIncrementItem.item_id,source=OrderSource.SNAPDEAL)
|
| 235 |
if mpItem.maximumSellingPrice is not None and mpItem.maximumSellingPrice > 0:
|
236 |
if mpItem.maximumSellingPrice is not None and mpItem.maximumSellingPrice > 0:
|
| 236 |
if autoIncrementItem.ourSellingPrice+max(10,.01*autoIncrementItem.ourSellingPrice) > mpItem.maximumSellingPrice:
|
237 |
if autoIncrementItem.ourSellingPrice+max(10,.01*autoIncrementItem.ourSellingPrice) > mpItem.maximumSellingPrice:
|
| 237 |
markReasonForMpItem(autoIncrementItem,'Price cannot exceed Maximum Selling Price',Decision.AUTO_INCREMENT_FAILED)
|
238 |
markReasonForMpItem(autoIncrementItem,'Price cannot exceed Maximum Selling Price',Decision.AUTO_INCREMENT_FAILED)
|
| 238 |
continue
|
239 |
continue
|
| - |
|
240 |
avgSalePerDay = (itemSaleMap.get(autoIncrementItem.item_id))[2]
|
| - |
|
241 |
if (avgSalePerDay==0):
|
| - |
|
242 |
markReasonForMpItem(autoIncrementItem,'Average sale per day is zero',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
243 |
continue
|
| 239 |
#oosStatus = inventory_client.getOosStatusesForXDaysForItem(autoIncrementItem.item_id,0,3)
|
244 |
#oosStatus = inventory_client.getOosStatusesForXDaysForItem(autoIncrementItem.item_id,0,3)
|
| 240 |
#count,sale,daysOfStock = 0,0,0
|
245 |
#count,sale,daysOfStock = 0,0,0
|
| 241 |
#for obj in oosStatus:
|
246 |
#for obj in oosStatus:
|
| 242 |
# if not obj.is_oos:
|
247 |
# if not obj.is_oos:
|
| 243 |
# count+=1
|
248 |
# count+=1
|
| 244 |
# sale = sale+obj.num_orders
|
249 |
# sale = sale+obj.num_orders
|
| 245 |
#avgSalePerDay=0 if count==0 else (float(sale)/count)
|
250 |
#avgSalePerDay=0 if count==0 else (float(sale)/count)
|
| 246 |
totalAvailability, totalReserved = 0,0
|
251 |
totalAvailability, totalReserved = 0,0
|
| - |
|
252 |
if autoIncrementItem.risky:
|
| 247 |
if (not inventoryMap.has_key(autoIncrementItem.item_id)):
|
253 |
if ((not inventoryMap.has_key(autoIncrementItem.item_id)) and autoIncrementItem.risky):
|
| 248 |
markReasonForMpItem(autoIncrementItem,'Inventory info not available',Decision.AUTO_INCREMENT_FAILED)
|
254 |
markReasonForMpItem(autoIncrementItem,'Inventory info not available',Decision.AUTO_INCREMENT_FAILED)
|
| 249 |
continue
|
- |
|
| 250 |
itemInventory=inventoryMap[autoIncrementItem.item_id]
|
- |
|
| 251 |
availableMap = itemInventory.availability
|
- |
|
| 252 |
reserveMap = itemInventory.reserved
|
- |
|
| 253 |
for warehouse,availability in availableMap.iteritems():
|
- |
|
| 254 |
if warehouse==16:
|
- |
|
| 255 |
continue
|
255 |
continue
|
| - |
|
256 |
itemInventory=inventoryMap[autoIncrementItem.item_id]
|
| - |
|
257 |
availableMap = itemInventory.availability
|
| - |
|
258 |
reserveMap = itemInventory.reserved
|
| - |
|
259 |
for warehouse,availability in availableMap.iteritems():
|
| - |
|
260 |
if warehouse==16 or warehouse==1771:
|
| - |
|
261 |
continue
|
| 256 |
totalAvailability = totalAvailability+availability
|
262 |
totalAvailability = totalAvailability+availability
|
| 257 |
for warehouse,reserve in reserveMap.iteritems():
|
263 |
for warehouse,reserve in reserveMap.iteritems():
|
| - |
|
264 |
if warehouse==16 or warehouse==1771:
|
| - |
|
265 |
continue
|
| - |
|
266 |
totalReserved = totalReserved+reserve
|
| - |
|
267 |
#if (totalAvailability-totalReserved)<=0:
|
| - |
|
268 |
# markReasonForMpItem(autoIncrementItem,'Our stock is 0',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
269 |
# continue
|
| - |
|
270 |
daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
|
| 258 |
if warehouse==16:
|
271 |
if daysOfStock>5:
|
| - |
|
272 |
markReasonForMpItem(autoIncrementItem,'Our stock is enough',Decision.AUTO_INCREMENT_FAILED)
|
| 259 |
continue
|
273 |
continue
|
| 260 |
totalReserved = totalReserved+reserve
|
- |
|
| 261 |
#if (totalAvailability-totalReserved)<=0:
|
- |
|
| 262 |
# markReasonForMpItem(autoIncrementItem,'Our stock is 0',Decision.AUTO_INCREMENT_FAILED)
|
- |
|
| 263 |
# continue
|
- |
|
| 264 |
avgSalePerDay = (itemSaleMap.get(autoIncrementItem.item_id))[2]
|
- |
|
| 265 |
if (avgSalePerDay==0):
|
- |
|
| 266 |
markReasonForMpItem(autoIncrementItem,'Average sale per day is zero',Decision.AUTO_INCREMENT_FAILED)
|
- |
|
| 267 |
continue
|
- |
|
| 268 |
daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
|
- |
|
| 269 |
if daysOfStock>5:
|
- |
|
| 270 |
markReasonForMpItem(autoIncrementItem,'Our stock is enough',Decision.AUTO_INCREMENT_FAILED)
|
- |
|
| 271 |
continue
|
- |
|
| 272 |
|
274 |
|
| 273 |
autoIncrementItem.ourEnoughStock = False
|
275 |
autoIncrementItem.ourEnoughStock = False
|
| 274 |
#autoIncrementItem.avgSales = avgSalePerDay
|
276 |
#autoIncrementItem.avgSales = avgSalePerDay
|
| 275 |
autoIncrementItem.decision = Decision.AUTO_INCREMENT_SUCCESS
|
277 |
autoIncrementItem.decision = Decision.AUTO_INCREMENT_SUCCESS
|
| 276 |
autoIncrementItem.reason = 'All conditions for auto increment true'
|
278 |
autoIncrementItem.reason = 'All conditions for auto increment true'
|
| Line 298... |
Line 300... |
| 298 |
def getNetAvailability(itemInventory):
|
300 |
def getNetAvailability(itemInventory):
|
| 299 |
totalAvailability, totalReserved = 0,0
|
301 |
totalAvailability, totalReserved = 0,0
|
| 300 |
availableMap = itemInventory.availability
|
302 |
availableMap = itemInventory.availability
|
| 301 |
reserveMap = itemInventory.reserved
|
303 |
reserveMap = itemInventory.reserved
|
| 302 |
for warehouse,availability in availableMap.iteritems():
|
304 |
for warehouse,availability in availableMap.iteritems():
|
| 303 |
if warehouse==16:
|
305 |
if warehouse==16 or warehouse==1771:
|
| 304 |
continue
|
306 |
continue
|
| 305 |
totalAvailability = totalAvailability+availability
|
307 |
totalAvailability = totalAvailability+availability
|
| 306 |
for warehouse,reserve in reserveMap.iteritems():
|
308 |
for warehouse,reserve in reserveMap.iteritems():
|
| 307 |
if warehouse==16:
|
309 |
if warehouse==16 or warehouse==1771:
|
| 308 |
continue
|
310 |
continue
|
| 309 |
totalReserved = totalReserved+reserve
|
311 |
totalReserved = totalReserved+reserve
|
| 310 |
return totalAvailability - totalReserved
|
312 |
return totalAvailability - totalReserved
|
| 311 |
|
313 |
|
| 312 |
def getOosString(oosStatus):
|
314 |
def getOosString(oosStatus):
|
| Line 1989... |
Line 1991... |
| 1989 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
1991 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| 1990 |
print "Successfully sent email"
|
1992 |
print "Successfully sent email"
|
| 1991 |
except:
|
1993 |
except:
|
| 1992 |
print "Error: unable to send email."
|
1994 |
print "Error: unable to send email."
|
| 1993 |
|
1995 |
|
| - |
|
1996 |
def sendAlertForCompetitiveNoInventory(timestamp):
|
| - |
|
1997 |
xstr = lambda s: s or ""
|
| - |
|
1998 |
competitiveNoInv = session.query(MarketPlaceHistory,Item).join((Item,MarketPlaceHistory.item_id==Item.id)).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.COMPETITIVE_NO_INVENTORY).all()
|
| - |
|
1999 |
if len(competitiveNoInv) == 0:
|
| - |
|
2000 |
return
|
| - |
|
2001 |
message="""<html>
|
| - |
|
2002 |
<body>
|
| - |
|
2003 |
<h3 style="color:red;font-weight:bold;">Snapdeal Competitive But No Inventory</h3>
|
| - |
|
2004 |
<table border="1" style="width:100%;">
|
| - |
|
2005 |
<thead>
|
| - |
|
2006 |
<tr><th>Item Id</th>
|
| - |
|
2007 |
<th>Product Name</th>
|
| - |
|
2008 |
<th>SP</th>
|
| - |
|
2009 |
<th>TP</th>
|
| - |
|
2010 |
<th>Lowest Possible SP</th>
|
| - |
|
2011 |
<th>Lowest Possible TP</th>
|
| - |
|
2012 |
<th>Lowest Seller</th>
|
| - |
|
2013 |
<th>Lowest Seller SP</th>
|
| - |
|
2014 |
<th>Margin</th>
|
| - |
|
2015 |
<th>Margin %</th>
|
| - |
|
2016 |
<th>Commission %</th>
|
| - |
|
2017 |
<th>Return Provision %</th>
|
| - |
|
2018 |
<th>Snapdeal Inventory</th>
|
| - |
|
2019 |
<th>Total Inventory</th>
|
| - |
|
2020 |
<th>Sales History</th>
|
| - |
|
2021 |
</tr></thead>
|
| - |
|
2022 |
<tbody>"""
|
| - |
|
2023 |
for item in competitiveNoInv:
|
| - |
|
2024 |
mpHistory = item[0]
|
| - |
|
2025 |
catItem = item[1]
|
| - |
|
2026 |
netInventory=''
|
| - |
|
2027 |
if not inventoryMap.has_key(mpHistory.item_id):
|
| - |
|
2028 |
netInventory='Info Not Available'
|
| - |
|
2029 |
else:
|
| - |
|
2030 |
netInventory = str(getNetAvailability(inventoryMap.get(mpHistory.item_id)))
|
| - |
|
2031 |
mpItem = MarketplaceItems.get_by(itemId=mpHistory.item_id,source=OrderSource.SNAPDEAL)
|
| - |
|
2032 |
message+="""<tr>
|
| - |
|
2033 |
<td style="text-align:center">"""+str(mpHistory.item_id)+"""</td>
|
| - |
|
2034 |
<td style="text-align:center">"""+xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)+"""</td>
|
| - |
|
2035 |
<td style="text-align:center">"""+str(mpHistory.ourSellingPrice)+"""</td>
|
| - |
|
2036 |
<td style="text-align:center">"""+str(mpHistory.ourTp)+"""</td>
|
| - |
|
2037 |
<td style="text-align:center">"""+str(mpHistory.lowestPossibleSp)+"""</td>
|
| - |
|
2038 |
<td style="text-align:center">"""+str(mpHistory.lowestPossibleTp)+"""</td>
|
| - |
|
2039 |
<td style="text-align:center">"""+str(mpHistory.lowestSellerName)+"""</td>
|
| - |
|
2040 |
<td style="text-align:center">"""+str(mpHistory.lowestSellingPrice)+"""</td>
|
| - |
|
2041 |
<td style="text-align:center">"""+str(mpHistory.margin)+"""</td>
|
| - |
|
2042 |
<td style="text-align:center">"""+str(round((mpHistory.margin/mpHistory.ourSellingPrice)*100,1))+" %"+"""</td>
|
| - |
|
2043 |
<td style="text-align:center">"""+str(mpItem.commission)+"""</td>
|
| - |
|
2044 |
<td style="text-align:center">"""+str(mpItem.returnProvision)+" %"+"""</td>
|
| - |
|
2045 |
<td style="text-align:center">"""+str(mpHistory.ourInventory)+"""</td>
|
| - |
|
2046 |
<td style="text-align:center">"""+netInventory+"""</td>
|
| - |
|
2047 |
<td style="text-align:center">"""+getOosString((itemSaleMap.get(mpHistory.item_id))[1])+"""</td>
|
| - |
|
2048 |
</tr>"""
|
| - |
|
2049 |
message+="""</tbody></table></body></html>"""
|
| - |
|
2050 |
print message
|
| - |
|
2051 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
2052 |
mailServer.ehlo()
|
| - |
|
2053 |
mailServer.starttls()
|
| - |
|
2054 |
mailServer.ehlo()
|
| - |
|
2055 |
|
| - |
|
2056 |
#recipients = ['kshitij.sood@saholic.com']
|
| - |
|
2057 |
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']
|
| - |
|
2058 |
msg = MIMEMultipart()
|
| - |
|
2059 |
msg['Subject'] = "Snapdeal Competitive But No Inventory" + ' - ' + str(datetime.now())
|
| - |
|
2060 |
msg['From'] = ""
|
| - |
|
2061 |
msg['To'] = ",".join(recipients)
|
| - |
|
2062 |
msg.preamble = "Snapdeal Competitive But No Inventory" + ' - ' + str(datetime.now())
|
| - |
|
2063 |
html_msg = MIMEText(message, 'html')
|
| - |
|
2064 |
msg.attach(html_msg)
|
| - |
|
2065 |
try:
|
| - |
|
2066 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
2067 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
2068 |
mailServer.sendmail("cafe@nes", recipients, msg.as_string())
|
| - |
|
2069 |
except Exception as e:
|
| - |
|
2070 |
print e
|
| - |
|
2071 |
print "Unable to send Snapdeal Competitive But No Inventory mail.Lets try local SMTP"
|
| - |
|
2072 |
smtpServer = smtplib.SMTP('localhost')
|
| - |
|
2073 |
smtpServer.set_debuglevel(1)
|
| - |
|
2074 |
sender = 'build@shop2020.in'
|
| - |
|
2075 |
try:
|
| - |
|
2076 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| - |
|
2077 |
print "Successfully sent email"
|
| - |
|
2078 |
except:
|
| - |
|
2079 |
print "Error: unable to send email."
|
| - |
|
2080 |
|
| - |
|
2081 |
def sendAlertForInactiveAutoPricing(timestamp):
|
| - |
|
2082 |
xstr = lambda s: s or ""
|
| 1994 |
|
2083 |
inactiveAutoPricing = session.query(MarketPlaceHistory,Item,MarketplaceItems).join((Item,MarketPlaceHistory.item_id==Item.id)).join((MarketplaceItems,MarketPlaceHistory.item_id==MarketplaceItems.itemId)).filter(MarketplaceItems.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(or_(MarketplaceItems.autoDecrement==0,MarketplaceItems.autoIncrement==0)).filter(MarketPlaceHistory.competitiveCategory.in_([CompetitionCategory.BUY_BOX,CompetitionCategory.COMPETITIVE])).all()
|
| - |
|
2084 |
if len(inactiveAutoPricing) == 0:
|
| - |
|
2085 |
return
|
| - |
|
2086 |
message="""<html>
|
| - |
|
2087 |
<body>
|
| - |
|
2088 |
<h3 style="color:red;font-weight:bold;">Snapdeal Competitive But No Inventory</h3>
|
| - |
|
2089 |
<table border="1" style="width:100%;">
|
| - |
|
2090 |
<thead>
|
| - |
|
2091 |
<tr><th>Item Id</th>
|
| - |
|
2092 |
<th>Product Name</th>
|
| - |
|
2093 |
<th>Selling Price</th>
|
| - |
|
2094 |
<th>Competitive Category</th>
|
| - |
|
2095 |
<th>Margin</th>
|
| - |
|
2096 |
<th>Margin %</th>
|
| - |
|
2097 |
<th>Commission %</th>
|
| - |
|
2098 |
<th>Return Provision %</th>
|
| - |
|
2099 |
<th>Snapdeal Inventory</th>
|
| - |
|
2100 |
<th>Total Inventory</th>
|
| - |
|
2101 |
<th>Sales History</th>
|
| - |
|
2102 |
</tr></thead>
|
| - |
|
2103 |
<tbody>"""
|
| - |
|
2104 |
for item in inactiveAutoPricing:
|
| - |
|
2105 |
mpHistory = item[0]
|
| - |
|
2106 |
catItem = item[1]
|
| - |
|
2107 |
mpItem = item[2]
|
| - |
|
2108 |
netInventory=''
|
| - |
|
2109 |
if not inventoryMap.has_key(mpHistory.item_id):
|
| - |
|
2110 |
netInventory='Info Not Available'
|
| - |
|
2111 |
else:
|
| - |
|
2112 |
netInventory = str(getNetAvailability(inventoryMap.get(mpHistory.item_id)))
|
| - |
|
2113 |
message+="""<tr>
|
| - |
|
2114 |
<td style="text-align:center">"""+str(mpHistory.item_id)+"""</td>
|
| - |
|
2115 |
<td style="text-align:center">"""+xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)+"""</td>
|
| - |
|
2116 |
<td style="text-align:center">"""+str(mpHistory.ourSellingPrice)+"""</td>
|
| - |
|
2117 |
<td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(mpHistory.competitiveCategory))+"""</td>
|
| - |
|
2118 |
<td style="text-align:center">"""+str(mpHistory.margin)+"""</td>
|
| - |
|
2119 |
<td style="text-align:center">"""+str(round((mpHistory.margin/mpHistory.ourSellingPrice)*100,1))+" %"+"""</td>
|
| - |
|
2120 |
<td style="text-align:center">"""+str(mpItem.commission)+"""</td>
|
| - |
|
2121 |
<td style="text-align:center">"""+str(mpItem.returnProvision)+" %"+"""</td>
|
| - |
|
2122 |
<td style="text-align:center">"""+str(mpHistory.ourInventory)+"""</td>
|
| - |
|
2123 |
<td style="text-align:center">"""+netInventory+"""</td>
|
| - |
|
2124 |
<td style="text-align:center">"""+getOosString((itemSaleMap.get(mpHistory.item_id))[1])+"""</td>
|
| - |
|
2125 |
</tr>"""
|
| - |
|
2126 |
message+="""</tbody></table></body></html>"""
|
| - |
|
2127 |
print message
|
| - |
|
2128 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
2129 |
mailServer.ehlo()
|
| - |
|
2130 |
mailServer.starttls()
|
| - |
|
2131 |
mailServer.ehlo()
|
| - |
|
2132 |
|
| - |
|
2133 |
#recipients = ['kshitij.sood@saholic.com']
|
| - |
|
2134 |
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']
|
| - |
|
2135 |
msg = MIMEMultipart()
|
| - |
|
2136 |
msg['Subject'] = "Snapdeal Auto Pricing Inactive" + ' - ' + str(datetime.now())
|
| - |
|
2137 |
msg['From'] = ""
|
| - |
|
2138 |
msg['To'] = ",".join(recipients)
|
| - |
|
2139 |
msg.preamble = "Snapdeal Auto Pricing Inactive" + ' - ' + str(datetime.now())
|
| - |
|
2140 |
html_msg = MIMEText(message, 'html')
|
| - |
|
2141 |
msg.attach(html_msg)
|
| - |
|
2142 |
try:
|
| - |
|
2143 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
2144 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
2145 |
mailServer.sendmail("cafe@nes", recipients, msg.as_string())
|
| - |
|
2146 |
except Exception as e:
|
| - |
|
2147 |
print e
|
| - |
|
2148 |
print "Unable to send Snapdeal Auto Pricing Inactive mail.Lets try local SMTP"
|
| - |
|
2149 |
smtpServer = smtplib.SMTP('localhost')
|
| - |
|
2150 |
smtpServer.set_debuglevel(1)
|
| - |
|
2151 |
sender = 'build@shop2020.in'
|
| - |
|
2152 |
try:
|
| - |
|
2153 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| - |
|
2154 |
print "Successfully sent email"
|
| - |
|
2155 |
except:
|
| - |
|
2156 |
print "Error: unable to send email."
|
| 1995 |
|
2157 |
|
| 1996 |
def main():
|
2158 |
def main():
|
| 1997 |
parser = optparse.OptionParser()
|
2159 |
parser = optparse.OptionParser()
|
| 1998 |
parser.add_option("-t", "--type", dest="runType",
|
2160 |
parser.add_option("-t", "--type", dest="runType",
|
| 1999 |
default="FULL", type="string",
|
2161 |
default="FULL", type="string",
|
| Line 2029... |
Line 2191... |
| 2029 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
|
2191 |
writeReport(cantCompete, buyBoxItems, competitive, competitiveNoInventory, exceptionList, negativeMargin, None, None, timestamp, options.runType)
|
| 2030 |
commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp)
|
2192 |
commitPricing(successfulAutoDecrease,successfulAutoIncrease,timestamp)
|
| 2031 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
2193 |
sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
|
| 2032 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
2194 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
| 2033 |
updatePricesOnSnapdeal(successfulAutoDecrease,successfulAutoIncrease)
|
2195 |
updatePricesOnSnapdeal(successfulAutoDecrease,successfulAutoIncrease)
|
| 2034 |
|
2196 |
if options.runType=='FULL':
|
| - |
|
2197 |
sendAlertForCompetitiveNoInventory(timestamp)
|
| - |
|
2198 |
sendAlertForInactiveAutoPricing(timestamp)
|
| 2035 |
if __name__ == '__main__':
|
2199 |
if __name__ == '__main__':
|
| 2036 |
main()
|
2200 |
main()
|
| 2037 |
|
2201 |
|