| Line 140... |
Line 140... |
| 140 |
markReasonForMpItem(autoDecrementItem,'Proposed SP greater than or equal to current SP',Decision.AUTO_DECREMENT_FAILED)
|
140 |
markReasonForMpItem(autoDecrementItem,'Proposed SP greater than or equal to current SP',Decision.AUTO_DECREMENT_FAILED)
|
| 141 |
continue
|
141 |
continue
|
| 142 |
if autoDecrementItem.proposedSellingPrice < autoDecrementItem.lowestPossibleSp:
|
142 |
if autoDecrementItem.proposedSellingPrice < autoDecrementItem.lowestPossibleSp:
|
| 143 |
markReasonForMpItem(autoDecrementItem,'Proposed SP less than lowest possible SP',Decision.AUTO_DECREMENT_FAILED)
|
143 |
markReasonForMpItem(autoDecrementItem,'Proposed SP less than lowest possible SP',Decision.AUTO_DECREMENT_FAILED)
|
| 144 |
continue
|
144 |
continue
|
| 145 |
totalAvailability, totalReserved = 0,0
|
- |
|
| 146 |
if (not inventoryMap.has_key(autoDecrementItem.item_id)):
|
- |
|
| 147 |
markReasonForMpItem(autoDecrementItem,'Inventory info not available',Decision.AUTO_DECREMENT_FAILED)
|
- |
|
| 148 |
continue
|
- |
|
| 149 |
itemInventory=inventoryMap[autoDecrementItem.item_id]
|
- |
|
| 150 |
availableMap = itemInventory.availability
|
- |
|
| 151 |
reserveMap = itemInventory.reserved
|
- |
|
| 152 |
for warehouse,availability in availableMap.iteritems():
|
- |
|
| 153 |
if warehouse==16:
|
- |
|
| 154 |
continue
|
- |
|
| 155 |
totalAvailability = totalAvailability+availability
|
- |
|
| 156 |
for warehouse,reserve in reserveMap.iteritems():
|
- |
|
| 157 |
if warehouse==16:
|
- |
|
| 158 |
continue
|
- |
|
| 159 |
totalReserved = totalReserved+reserve
|
- |
|
| 160 |
if (totalAvailability-totalReserved)<=0:
|
- |
|
| 161 |
markReasonForMpItem(autoDecrementItem,'Net availability is 0',Decision.AUTO_DECREMENT_FAILED)
|
- |
|
| 162 |
continue
|
- |
|
| 163 |
avgSalePerDay = (itemSaleMap.get(autoDecrementItem.item_id))[2]
|
- |
|
| 164 |
try:
|
- |
|
| 165 |
daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
|
- |
|
| 166 |
except ZeroDivisionError,e:
|
- |
|
| 167 |
daysOfStock = float("inf")
|
- |
|
| 168 |
if daysOfStock<2 and autoDecrementItem.risky:
|
- |
|
| 169 |
markReasonForMpItem(autoDecrementItem,'Our stock is not enough',Decision.AUTO_DECREMENT_FAILED)
|
- |
|
| 170 |
continue
|
- |
|
| 171 |
|
- |
|
| 172 |
if autoDecrementItem.competitiveCategory == CompetitionCategory.PREF_BUT_NOT_CHEAP:
|
145 |
if autoDecrementItem.competitiveCategory == CompetitionCategory.PREF_BUT_NOT_CHEAP:
|
| 173 |
avgSaleLastTwoDay = (itemSaleMap.get(autoDecrementItem.item_id))[6]
|
146 |
avgSaleLastTwoDay = (itemSaleMap.get(autoDecrementItem.item_id))[6]
|
| 174 |
if avgSaleLastTwoDay >= 3:
|
147 |
if avgSaleLastTwoDay >= .5:
|
| 175 |
markReasonForMpItem(autoDecrementItem,'Last two day avg sale is greater than 2',Decision.AUTO_DECREMENT_FAILED)
|
148 |
markReasonForMpItem(autoDecrementItem,'Last two day avg sale is greater than 2',Decision.AUTO_DECREMENT_FAILED)
|
| 176 |
continue
|
149 |
continue
|
| - |
|
150 |
totalAvailability, totalReserved = 0,0
|
| - |
|
151 |
if autoDecrementItem.risky:
|
| - |
|
152 |
if (not inventoryMap.has_key(autoDecrementItem.item_id)):
|
| - |
|
153 |
markReasonForMpItem(autoDecrementItem,'Inventory info not available',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
154 |
continue
|
| - |
|
155 |
itemInventory=inventoryMap[autoDecrementItem.item_id]
|
| - |
|
156 |
availableMap = itemInventory.availability
|
| - |
|
157 |
reserveMap = itemInventory.reserved
|
| - |
|
158 |
for warehouse,availability in availableMap.iteritems():
|
| - |
|
159 |
if warehouse==16 or warehouse==1771:
|
| - |
|
160 |
continue
|
| - |
|
161 |
totalAvailability = totalAvailability+availability
|
| - |
|
162 |
for warehouse,reserve in reserveMap.iteritems():
|
| - |
|
163 |
if warehouse==16 or warehouse==1771:
|
| - |
|
164 |
continue
|
| - |
|
165 |
totalReserved = totalReserved+reserve
|
| - |
|
166 |
if (totalAvailability-totalReserved)<=0:
|
| - |
|
167 |
markReasonForMpItem(autoDecrementItem,'Net availability is 0',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
168 |
continue
|
| - |
|
169 |
avgSalePerDay = (itemSaleMap.get(autoDecrementItem.item_id))[2]
|
| - |
|
170 |
try:
|
| - |
|
171 |
daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
|
| - |
|
172 |
except ZeroDivisionError,e:
|
| - |
|
173 |
daysOfStock = float("inf")
|
| - |
|
174 |
if daysOfStock<2 and autoDecrementItem.risky:
|
| - |
|
175 |
markReasonForMpItem(autoDecrementItem,'Our stock is not enough',Decision.AUTO_DECREMENT_FAILED)
|
| - |
|
176 |
continue
|
| 177 |
|
177 |
|
| 178 |
autoDecrementItem.ourEnoughStock = True
|
178 |
autoDecrementItem.ourEnoughStock = True
|
| 179 |
autoDecrementItem.decision = Decision.AUTO_DECREMENT_SUCCESS
|
179 |
autoDecrementItem.decision = Decision.AUTO_DECREMENT_SUCCESS
|
| 180 |
autoDecrementItem.reason = 'All conditions for auto decrement true'
|
180 |
autoDecrementItem.reason = 'All conditions for auto decrement true'
|
| 181 |
successfulAutoDecrease.append(autoDecrementItem)
|
181 |
successfulAutoDecrease.append(autoDecrementItem)
|
| Line 219... |
Line 219... |
| 219 |
# if not obj.is_oos:
|
219 |
# if not obj.is_oos:
|
| 220 |
# count+=1
|
220 |
# count+=1
|
| 221 |
# sale = sale+obj.num_orders
|
221 |
# sale = sale+obj.num_orders
|
| 222 |
#avgSalePerDay=0 if count==0 else (float(sale)/count)
|
222 |
#avgSalePerDay=0 if count==0 else (float(sale)/count)
|
| 223 |
totalAvailability, totalReserved = 0,0
|
223 |
totalAvailability, totalReserved = 0,0
|
| - |
|
224 |
if autoIncrementItem.risky:
|
| 224 |
if (not inventoryMap.has_key(autoIncrementItem.item_id)):
|
225 |
if (not inventoryMap.has_key(autoIncrementItem.item_id)):
|
| 225 |
markReasonForMpItem(autoIncrementItem,'Inventory info not available',Decision.AUTO_INCREMENT_FAILED)
|
226 |
markReasonForMpItem(autoIncrementItem,'Inventory info not available',Decision.AUTO_INCREMENT_FAILED)
|
| 226 |
continue
|
- |
|
| 227 |
itemInventory=inventoryMap[autoIncrementItem.item_id]
|
- |
|
| 228 |
availableMap = itemInventory.availability
|
- |
|
| 229 |
reserveMap = itemInventory.reserved
|
- |
|
| 230 |
for warehouse,availability in availableMap.iteritems():
|
- |
|
| 231 |
if warehouse==16:
|
- |
|
| 232 |
continue
|
227 |
continue
|
| - |
|
228 |
itemInventory=inventoryMap[autoIncrementItem.item_id]
|
| - |
|
229 |
availableMap = itemInventory.availability
|
| - |
|
230 |
reserveMap = itemInventory.reserved
|
| - |
|
231 |
for warehouse,availability in availableMap.iteritems():
|
| - |
|
232 |
if warehouse==16 or warehouse==1771:
|
| - |
|
233 |
continue
|
| 233 |
totalAvailability = totalAvailability+availability
|
234 |
totalAvailability = totalAvailability+availability
|
| 234 |
for warehouse,reserve in reserveMap.iteritems():
|
235 |
for warehouse,reserve in reserveMap.iteritems():
|
| - |
|
236 |
if warehouse==16 or warehouse==1771:
|
| - |
|
237 |
continue
|
| - |
|
238 |
totalReserved = totalReserved+reserve
|
| - |
|
239 |
#if (totalAvailability-totalReserved)<=0:
|
| - |
|
240 |
# markReasonForMpItem(autoIncrementItem,'Our stock is 0',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
241 |
# continue
|
| - |
|
242 |
avgSalePerDay = (itemSaleMap.get(autoIncrementItem.item_id))[2]
|
| - |
|
243 |
if (avgSalePerDay==0):
|
| - |
|
244 |
markReasonForMpItem(autoIncrementItem,'Average sale per day is zero',Decision.AUTO_INCREMENT_FAILED)
|
| - |
|
245 |
continue
|
| - |
|
246 |
daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
|
| 235 |
if warehouse==16:
|
247 |
if daysOfStock>5:
|
| - |
|
248 |
markReasonForMpItem(autoIncrementItem,'Our stock is enough',Decision.AUTO_INCREMENT_FAILED)
|
| 236 |
continue
|
249 |
continue
|
| 237 |
totalReserved = totalReserved+reserve
|
- |
|
| 238 |
#if (totalAvailability-totalReserved)<=0:
|
- |
|
| 239 |
# markReasonForMpItem(autoIncrementItem,'Our stock is 0',Decision.AUTO_INCREMENT_FAILED)
|
- |
|
| 240 |
# continue
|
- |
|
| 241 |
avgSalePerDay = (itemSaleMap.get(autoIncrementItem.item_id))[2]
|
- |
|
| 242 |
if (avgSalePerDay==0):
|
- |
|
| 243 |
markReasonForMpItem(autoIncrementItem,'Average sale per day is zero',Decision.AUTO_INCREMENT_FAILED)
|
- |
|
| 244 |
continue
|
- |
|
| 245 |
daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
|
- |
|
| 246 |
if daysOfStock>5:
|
- |
|
| 247 |
markReasonForMpItem(autoIncrementItem,'Our stock is enough',Decision.AUTO_INCREMENT_FAILED)
|
- |
|
| 248 |
continue
|
- |
|
| 249 |
|
250 |
|
| 250 |
autoIncrementItem.ourEnoughStock = False
|
251 |
autoIncrementItem.ourEnoughStock = False
|
| 251 |
autoIncrementItem.decision = Decision.AUTO_INCREMENT_SUCCESS
|
252 |
autoIncrementItem.decision = Decision.AUTO_INCREMENT_SUCCESS
|
| 252 |
autoIncrementItem.reason = 'All conditions for auto increment true'
|
253 |
autoIncrementItem.reason = 'All conditions for auto increment true'
|
| 253 |
successfulAutoIncrease.append(autoIncrementItem)
|
254 |
successfulAutoIncrease.append(autoIncrementItem)
|
| Line 767... |
Line 768... |
| 767 |
flipkartDetails.shippingTimeLowerLimitLowestSeller = flipkartDetails.shippingTimeLowerLimitOur
|
768 |
flipkartDetails.shippingTimeLowerLimitLowestSeller = flipkartDetails.shippingTimeLowerLimitOur
|
| 768 |
flipkartDetails.shippingTimeUpperLimitLowestSeller = flipkartDetails.shippingTimeUpperLimitOur
|
769 |
flipkartDetails.shippingTimeUpperLimitLowestSeller = flipkartDetails.shippingTimeUpperLimitOur
|
| 769 |
flipkartDetails.lowestSellerName = 'Saholic'
|
770 |
flipkartDetails.lowestSellerName = 'Saholic'
|
| 770 |
flipkartDetails.lowestSellerCode = flipkartDetails.ourCode
|
771 |
flipkartDetails.lowestSellerCode = flipkartDetails.ourCode
|
| 771 |
flipkartDetails.lowestSellerBuyTrend = flipkartDetails.ourBuyTrend
|
772 |
flipkartDetails.lowestSellerBuyTrend = flipkartDetails.ourBuyTrend
|
| - |
|
773 |
flipkartDetails.rank=1
|
| - |
|
774 |
flipkartDetails.ourBuyTrend ='NPrefCheap'
|
| 772 |
|
775 |
|
| 773 |
return flipkartDetails
|
776 |
return flipkartDetails
|
| 774 |
|
777 |
|
| 775 |
def calculateAverageSale(oosStatus):
|
778 |
def calculateAverageSale(oosStatus):
|
| 776 |
count,sale = 0,0
|
779 |
count,sale = 0,0
|
| Line 791... |
Line 794... |
| 791 |
def getNetAvailability(itemInventory):
|
794 |
def getNetAvailability(itemInventory):
|
| 792 |
totalAvailability, totalReserved = 0,0
|
795 |
totalAvailability, totalReserved = 0,0
|
| 793 |
availableMap = itemInventory.availability
|
796 |
availableMap = itemInventory.availability
|
| 794 |
reserveMap = itemInventory.reserved
|
797 |
reserveMap = itemInventory.reserved
|
| 795 |
for warehouse,availability in availableMap.iteritems():
|
798 |
for warehouse,availability in availableMap.iteritems():
|
| 796 |
if warehouse==16:
|
799 |
if warehouse==16 or warehouse==1771:
|
| 797 |
continue
|
800 |
continue
|
| 798 |
totalAvailability = totalAvailability+availability
|
801 |
totalAvailability = totalAvailability+availability
|
| 799 |
for warehouse,reserve in reserveMap.iteritems():
|
802 |
for warehouse,reserve in reserveMap.iteritems():
|
| 800 |
if warehouse==16:
|
803 |
if warehouse==16 or warehouse==1771:
|
| 801 |
continue
|
804 |
continue
|
| 802 |
totalReserved = totalReserved+reserve
|
805 |
totalReserved = totalReserved+reserve
|
| 803 |
return totalAvailability - totalReserved
|
806 |
return totalAvailability - totalReserved
|
| 804 |
|
807 |
|
| 805 |
def getOosString(oosStatus):
|
808 |
def getOosString(oosStatus):
|
| Line 833... |
Line 836... |
| 833 |
spm = val.sourcePercentage
|
836 |
spm = val.sourcePercentage
|
| 834 |
flipkartDetails = val.flipkartDetails
|
837 |
flipkartDetails = val.flipkartDetails
|
| 835 |
if (flipkartDetails is None or flipkartDetails.totalAvailableSeller==0):
|
838 |
if (flipkartDetails is None or flipkartDetails.totalAvailableSeller==0):
|
| 836 |
exceptionItems.append(val)
|
839 |
exceptionItems.append(val)
|
| 837 |
continue
|
840 |
continue
|
| - |
|
841 |
if ((flipkartDetails.rank=='' or flipkartDetails.rank==0) and val.ourFlipkartInventory!=0):
|
| - |
|
842 |
exceptionItems.append(val)
|
| - |
|
843 |
continue
|
| 838 |
|
844 |
|
| 839 |
mpItem = MarketplaceItems.get_by(itemId=val.item_id,source=OrderSource.FLIPKART)
|
845 |
mpItem = MarketplaceItems.get_by(itemId=val.item_id,source=OrderSource.FLIPKART)
|
| 840 |
if flipkartDetails.rank==0:
|
846 |
if flipkartDetails.rank==0:
|
| 841 |
flipkartDetails.ourSp = mpItem.currentSp
|
847 |
flipkartDetails.ourSp = mpItem.currentSp
|
| 842 |
ourSp = mpItem.currentSp
|
848 |
ourSp = mpItem.currentSp
|
| Line 2635... |
Line 2641... |
| 2635 |
try:
|
2641 |
try:
|
| 2636 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
2642 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| 2637 |
print "Successfully sent email"
|
2643 |
print "Successfully sent email"
|
| 2638 |
except:
|
2644 |
except:
|
| 2639 |
print "Error: unable to send email."
|
2645 |
print "Error: unable to send email."
|
| - |
|
2646 |
|
| - |
|
2647 |
def sendAlertForCompetitiveNoInventory(timestamp):
|
| - |
|
2648 |
xstr = lambda s: s or ""
|
| - |
|
2649 |
competitiveNoInv = session.query(MarketPlaceHistory,Item).join((Item,MarketPlaceHistory.item_id==Item.id)).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).filter(MarketPlaceHistory.competitiveCategory==CompetitionCategory.COMPETITIVE_NO_INVENTORY).all()
|
| - |
|
2650 |
if len(competitiveNoInv) == 0:
|
| - |
|
2651 |
return
|
| - |
|
2652 |
message="""<html>
|
| - |
|
2653 |
<body>
|
| - |
|
2654 |
<h3 style="color:red;font-weight:bold;">Flipkart Competitive But No Inventory</h3>
|
| - |
|
2655 |
<table border="1" style="width:100%;">
|
| - |
|
2656 |
<thead>
|
| - |
|
2657 |
<tr><th>Item Id</th>
|
| - |
|
2658 |
<th>Product Name</th>
|
| - |
|
2659 |
<th>SP</th>
|
| - |
|
2660 |
<th>TP</th>
|
| - |
|
2661 |
<th>Lowest Possible SP</th>
|
| - |
|
2662 |
<th>Lowest Possible TP</th>
|
| - |
|
2663 |
<th>Lowest Seller</th>
|
| - |
|
2664 |
<th>Lowest Seller SP</th>
|
| - |
|
2665 |
<th>Margin</th>
|
| - |
|
2666 |
<th>Margin %</th>
|
| - |
|
2667 |
<th>Commission %</th>
|
| - |
|
2668 |
<th>Return Provision %</th>
|
| - |
|
2669 |
<th>Flipkart Inventory</th>
|
| - |
|
2670 |
<th>Total Inventory</th>
|
| - |
|
2671 |
<th>Sales History</th>
|
| - |
|
2672 |
</tr></thead>
|
| - |
|
2673 |
<tbody>"""
|
| - |
|
2674 |
for item in competitiveNoInv:
|
| - |
|
2675 |
mpHistory = item[0]
|
| - |
|
2676 |
catItem = item[1]
|
| - |
|
2677 |
netInventory=''
|
| - |
|
2678 |
if not inventoryMap.has_key(mpHistory.item_id):
|
| - |
|
2679 |
netInventory='Info Not Available'
|
| - |
|
2680 |
else:
|
| - |
|
2681 |
netInventory = str(getNetAvailability(inventoryMap.get(mpHistory.item_id)))
|
| - |
|
2682 |
mpItem = MarketplaceItems.get_by(itemId=mpHistory.item_id,source=OrderSource.FLIPKART)
|
| - |
|
2683 |
message+="""<tr>
|
| - |
|
2684 |
<td style="text-align:center">"""+str(mpHistory.item_id)+"""</td>
|
| - |
|
2685 |
<td style="text-align:center">"""+xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)+"""</td>
|
| - |
|
2686 |
<td style="text-align:center">"""+str(mpHistory.ourSellingPrice)+"""</td>
|
| - |
|
2687 |
<td style="text-align:center">"""+str(mpHistory.ourTp)+"""</td>
|
| - |
|
2688 |
<td style="text-align:center">"""+str(mpHistory.lowestPossibleSp)+"""</td>
|
| - |
|
2689 |
<td style="text-align:center">"""+str(mpHistory.lowestPossibleTp)+"""</td>
|
| - |
|
2690 |
<td style="text-align:center">"""+str(mpHistory.lowestSellerName)+"""</td>
|
| - |
|
2691 |
<td style="text-align:center">"""+str(mpHistory.lowestSellingPrice)+"""</td>
|
| - |
|
2692 |
<td style="text-align:center">"""+str(mpHistory.margin)+"""</td>
|
| - |
|
2693 |
<td style="text-align:center">"""+str(round((mpHistory.margin/mpHistory.ourSellingPrice)*100,1))+" %"+"""</td>
|
| - |
|
2694 |
<td style="text-align:center">"""+str(mpItem.commission)+"""</td>
|
| - |
|
2695 |
<td style="text-align:center">"""+str(mpItem.returnProvision)+" %"+"""</td>
|
| - |
|
2696 |
<td style="text-align:center">"""+str(mpHistory.ourInventory)+"""</td>
|
| - |
|
2697 |
<td style="text-align:center">"""+netInventory+"""</td>
|
| - |
|
2698 |
<td style="text-align:center">"""+getOosString((itemSaleMap.get(mpHistory.item_id))[1])+"""</td>
|
| - |
|
2699 |
</tr>"""
|
| - |
|
2700 |
message+="""</tbody></table></body></html>"""
|
| - |
|
2701 |
print message
|
| - |
|
2702 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
2703 |
mailServer.ehlo()
|
| - |
|
2704 |
mailServer.starttls()
|
| - |
|
2705 |
mailServer.ehlo()
|
| - |
|
2706 |
|
| - |
|
2707 |
#recipients = ['kshitij.sood@saholic.com']
|
| - |
|
2708 |
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']
|
| - |
|
2709 |
msg = MIMEMultipart()
|
| - |
|
2710 |
msg['Subject'] = "Flipkart Competitive But No Inventory" + ' - ' + str(datetime.now())
|
| - |
|
2711 |
msg['From'] = ""
|
| - |
|
2712 |
msg['To'] = ",".join(recipients)
|
| - |
|
2713 |
msg.preamble = "Flipkart Competitive But No Inventory" + ' - ' + str(datetime.now())
|
| - |
|
2714 |
html_msg = MIMEText(message, 'html')
|
| - |
|
2715 |
msg.attach(html_msg)
|
| - |
|
2716 |
try:
|
| - |
|
2717 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
2718 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
2719 |
mailServer.sendmail("cafe@nes", recipients, msg.as_string())
|
| - |
|
2720 |
except Exception as e:
|
| - |
|
2721 |
print e
|
| - |
|
2722 |
print "Unable to send Flipkart Competitive But No Inventory mail.Lets try local SMTP"
|
| - |
|
2723 |
smtpServer = smtplib.SMTP('localhost')
|
| - |
|
2724 |
smtpServer.set_debuglevel(1)
|
| - |
|
2725 |
sender = 'build@shop2020.in'
|
| - |
|
2726 |
try:
|
| - |
|
2727 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| - |
|
2728 |
print "Successfully sent email"
|
| - |
|
2729 |
except:
|
| - |
|
2730 |
print "Error: unable to send email."
|
| - |
|
2731 |
|
| - |
|
2732 |
def sendAlertForInactiveAutoPricing(timestamp):
|
| - |
|
2733 |
xstr = lambda s: s or ""
|
| 2640 |
|
2734 |
inactiveAutoPricing = session.query(MarketPlaceHistory,Item,MarketplaceItems).join((Item,MarketPlaceHistory.item_id==Item.id)).join((MarketplaceItems,MarketPlaceHistory.item_id==MarketplaceItems.itemId)).filter(MarketplaceItems.source==OrderSource.FLIPKART).filter(MarketPlaceHistory.timestamp==timestamp).filter(MarketPlaceHistory.source==OrderSource.FLIPKART).filter(or_(MarketplaceItems.autoDecrement==0,MarketplaceItems.autoIncrement==0)).filter(MarketPlaceHistory.competitiveCategory.in_([CompetitionCategory.BUY_BOX,CompetitionCategory.COMPETITIVE,CompetitionCategory.PREF_BUT_NOT_CHEAP])).all()
|
| - |
|
2735 |
if len(inactiveAutoPricing) == 0:
|
| - |
|
2736 |
return
|
| - |
|
2737 |
message="""<html>
|
| - |
|
2738 |
<body>
|
| - |
|
2739 |
<h3 style="color:red;font-weight:bold;">Flipkart Competitive But No Inventory</h3>
|
| - |
|
2740 |
<table border="1" style="width:100%;">
|
| - |
|
2741 |
<thead>
|
| - |
|
2742 |
<tr><th>Item Id</th>
|
| - |
|
2743 |
<th>Product Name</th>
|
| - |
|
2744 |
<th>Selling Price</th>
|
| - |
|
2745 |
<th>Competitive Category</th>
|
| - |
|
2746 |
<th>Margin</th>
|
| - |
|
2747 |
<th>Margin %</th>
|
| - |
|
2748 |
<th>Commission %</th>
|
| - |
|
2749 |
<th>Return Provision %</th>
|
| - |
|
2750 |
<th>Flipkart Inventory</th>
|
| - |
|
2751 |
<th>Total Inventory</th>
|
| - |
|
2752 |
<th>Sales History</th>
|
| - |
|
2753 |
</tr></thead>
|
| - |
|
2754 |
<tbody>"""
|
| - |
|
2755 |
for item in inactiveAutoPricing:
|
| - |
|
2756 |
mpHistory = item[0]
|
| - |
|
2757 |
catItem = item[1]
|
| - |
|
2758 |
mpItem = item[2]
|
| - |
|
2759 |
netInventory=''
|
| - |
|
2760 |
if not inventoryMap.has_key(mpHistory.item_id):
|
| - |
|
2761 |
netInventory='Info Not Available'
|
| - |
|
2762 |
else:
|
| - |
|
2763 |
netInventory = str(getNetAvailability(inventoryMap.get(mpHistory.item_id)))
|
| - |
|
2764 |
mpItem = MarketplaceItems.get_by(itemId=mpHistory.item_id,source=OrderSource.FLIPKART)
|
| - |
|
2765 |
message+="""<tr>
|
| - |
|
2766 |
<td style="text-align:center">"""+str(mpHistory.item_id)+"""</td>
|
| - |
|
2767 |
<td style="text-align:center">"""+xstr(catItem.brand)+" "+xstr(catItem.model_name)+" "+xstr(catItem.model_number)+" "+xstr(catItem.color)+"""</td>
|
| - |
|
2768 |
<td style="text-align:center">"""+str(mpHistory.ourSellingPrice)+"""</td>
|
| - |
|
2769 |
<td style="text-align:center">"""+str(CompetitionCategory._VALUES_TO_NAMES.get(mpHistory.competitiveCategory))+"""</td>
|
| - |
|
2770 |
<td style="text-align:center">"""+str(mpHistory.margin)+"""</td>
|
| - |
|
2771 |
<td style="text-align:center">"""+str(round((mpHistory.margin/mpHistory.ourSellingPrice)*100,1))+" %"+"""</td>
|
| - |
|
2772 |
<td style="text-align:center">"""+str(mpItem.commission)+"""</td>
|
| - |
|
2773 |
<td style="text-align:center">"""+str(mpItem.returnProvision)+" %"+"""</td>
|
| - |
|
2774 |
<td style="text-align:center">"""+str(mpHistory.ourInventory)+"""</td>
|
| - |
|
2775 |
<td style="text-align:center">"""+netInventory+"""</td>
|
| - |
|
2776 |
<td style="text-align:center">"""+getOosString((itemSaleMap.get(mpHistory.item_id))[1])+"""</td>
|
| - |
|
2777 |
</tr>"""
|
| - |
|
2778 |
message+="""</tbody></table></body></html>"""
|
| - |
|
2779 |
print message
|
| - |
|
2780 |
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
|
| - |
|
2781 |
mailServer.ehlo()
|
| - |
|
2782 |
mailServer.starttls()
|
| - |
|
2783 |
mailServer.ehlo()
|
| - |
|
2784 |
|
| - |
|
2785 |
#recipients = ['kshitij.sood@saholic.com']
|
| - |
|
2786 |
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']
|
| - |
|
2787 |
msg = MIMEMultipart()
|
| - |
|
2788 |
msg['Subject'] = "Flipkart Auto Pricing Inactive" + ' - ' + str(datetime.now())
|
| - |
|
2789 |
msg['From'] = ""
|
| - |
|
2790 |
msg['To'] = ",".join(recipients)
|
| - |
|
2791 |
msg.preamble = "Flipkart Auto Pricing Inactive" + ' - ' + str(datetime.now())
|
| - |
|
2792 |
html_msg = MIMEText(message, 'html')
|
| - |
|
2793 |
msg.attach(html_msg)
|
| - |
|
2794 |
try:
|
| - |
|
2795 |
mailServer.login("build@shop2020.in", "cafe@nes")
|
| - |
|
2796 |
#mailServer.sendmail("cafe@nes", ['kshitij.sood@saholic.com'], msg.as_string())
|
| - |
|
2797 |
mailServer.sendmail("cafe@nes", recipients, msg.as_string())
|
| - |
|
2798 |
except Exception as e:
|
| - |
|
2799 |
print e
|
| - |
|
2800 |
print "Unable to send Flipkart Auto Pricing Inactive mail.Lets try local SMTP"
|
| - |
|
2801 |
smtpServer = smtplib.SMTP('localhost')
|
| - |
|
2802 |
smtpServer.set_debuglevel(1)
|
| - |
|
2803 |
sender = 'build@shop2020.in'
|
| - |
|
2804 |
try:
|
| - |
|
2805 |
smtpServer.sendmail(sender, recipients, msg.as_string())
|
| - |
|
2806 |
print "Successfully sent email"
|
| - |
|
2807 |
except:
|
| - |
|
2808 |
print "Error: unable to send email."
|
| - |
|
2809 |
|
| - |
|
2810 |
|
| 2641 |
|
2811 |
|
| 2642 |
|
2812 |
|
| 2643 |
|
2813 |
|
| 2644 |
def main():
|
2814 |
def main():
|
| 2645 |
parser = optparse.OptionParser()
|
2815 |
parser = optparse.OptionParser()
|
| Line 2683... |
Line 2853... |
| 2683 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
2853 |
processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
|
| 2684 |
if options.runType=='FULL':
|
2854 |
if options.runType=='FULL':
|
| 2685 |
cheapButNotPrefAlert(timestamp)
|
2855 |
cheapButNotPrefAlert(timestamp)
|
| 2686 |
sendPricingMismatch(timestamp)
|
2856 |
sendPricingMismatch(timestamp)
|
| 2687 |
sendAlertForNegativeMargins(timestamp)
|
2857 |
sendAlertForNegativeMargins(timestamp)
|
| - |
|
2858 |
sendAlertForCompetitiveNoInventory(timestamp)
|
| - |
|
2859 |
sendAlertForInactiveAutoPricing(timestamp)
|
| 2688 |
|
2860 |
|
| 2689 |
if __name__ == '__main__':
|
2861 |
if __name__ == '__main__':
|
| 2690 |
main()
|
2862 |
main()
|
| 2691 |
|
2863 |
|