| Line 2... |
Line 2... |
| 2 |
import xlwt
|
2 |
import xlwt
|
| 3 |
from datetime import datetime
|
3 |
from datetime import datetime
|
| 4 |
from email.mime.multipart import MIMEMultipart
|
4 |
from email.mime.multipart import MIMEMultipart
|
| 5 |
import email.encoders
|
5 |
import email.encoders
|
| 6 |
import smtplib
|
6 |
import smtplib
|
| 7 |
from dtr.utils.utils import getCashBack
|
- |
|
| 8 |
from dtr.storage.MemCache import MemCache
|
- |
|
| 9 |
|
- |
|
| 10 |
|
7 |
|
| 11 |
con = None
|
8 |
con = None
|
| 12 |
|
9 |
|
| 13 |
statusMap = {1:'Active',2:'EOL',3:'In Process',4:'Exclusive'}
|
10 |
statusMap = {1:'Active',2:'EOL',3:'In Process',4:'Exclusive'}
|
| 14 |
mc = MemCache("127.0.0.1")
|
- |
|
| 15 |
|
11 |
|
| 16 |
class __SkuInfo:
|
12 |
class __SkuInfo:
|
| 17 |
|
13 |
|
| 18 |
def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
|
14 |
def __init__(self, _id, skuBundleId, category_id, mrp, available_price, source_id, rank, maxNlc, minNlc, schemeAmount, minDiscount, \
|
| 19 |
maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints,in_stock,maxprice,showDeal, catalogBestSellerPoints):
|
15 |
maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints,in_stock,maxprice,showDeal, catalogBestSellerPoints):
|
| Line 80... |
Line 76... |
| 80 |
sheet.write(0, 8, "MarketPlace Identifier", heading_xf)
|
76 |
sheet.write(0, 8, "MarketPlace Identifier", heading_xf)
|
| 81 |
sheet.write(0, 9, "MarketPlace Secondary Identifier", heading_xf)
|
77 |
sheet.write(0, 9, "MarketPlace Secondary Identifier", heading_xf)
|
| 82 |
sheet.write(0, 10, "Product Name (Marketplace)", heading_xf)
|
78 |
sheet.write(0, 10, "Product Name (Marketplace)", heading_xf)
|
| 83 |
sheet.write(0, 11, "Url", heading_xf)
|
79 |
sheet.write(0, 11, "Url", heading_xf)
|
| 84 |
sheet.write(0, 12, "Price", heading_xf)
|
80 |
sheet.write(0, 12, "Price", heading_xf)
|
| 85 |
sheet.write(0, 13, "After Cashback", heading_xf)
|
- |
|
| 86 |
sheet.write(0, 14, "Mrp", heading_xf)
|
81 |
sheet.write(0, 13, "Mrp", heading_xf)
|
| 87 |
sheet.write(0, 15, "DP", heading_xf)
|
82 |
sheet.write(0, 14, "DP", heading_xf)
|
| 88 |
sheet.write(0, 16, "Scheme Amount", heading_xf)
|
83 |
sheet.write(0, 15, "Scheme Amount", heading_xf)
|
| 89 |
sheet.write(0, 17, "Discount Type", heading_xf)
|
84 |
sheet.write(0, 16, "Discount Type", heading_xf)
|
| 90 |
sheet.write(0, 18, "Min Discount", heading_xf)
|
85 |
sheet.write(0, 17, "Min Discount", heading_xf)
|
| 91 |
sheet.write(0, 19, "Max Discount", heading_xf)
|
86 |
sheet.write(0, 18, "Max Discount", heading_xf)
|
| 92 |
sheet.write(0, 20, "Max Nlc", heading_xf)
|
87 |
sheet.write(0, 19, "Max Nlc", heading_xf)
|
| 93 |
sheet.write(0, 21, "Min Nlc", heading_xf)
|
88 |
sheet.write(0, 20, "Min Nlc", heading_xf)
|
| 94 |
sheet.write(0, 22, "Max Price", heading_xf)
|
89 |
sheet.write(0, 21, "Max Price", heading_xf)
|
| 95 |
sheet.write(0, 23, "Rank", heading_xf)
|
90 |
sheet.write(0, 22, "Rank", heading_xf)
|
| 96 |
sheet.write(0, 24, "Nlc Points", heading_xf)
|
91 |
sheet.write(0, 23, "Nlc Points", heading_xf)
|
| 97 |
sheet.write(0, 25, "Best Seller Points", heading_xf)
|
92 |
sheet.write(0, 24, "Best Seller Points", heading_xf)
|
| 98 |
sheet.write(0, 26, "Catalog Best Seller Points", heading_xf)
|
93 |
sheet.write(0, 25, "Catalog Best Seller Points", heading_xf)
|
| 99 |
sheet.write(0, 27, "Total Points", heading_xf)
|
94 |
sheet.write(0, 26, "Total Points", heading_xf)
|
| 100 |
sheet.write(0, 28, "Show Deals", heading_xf)
|
95 |
sheet.write(0, 27, "Show Deals", heading_xf)
|
| 101 |
|
96 |
|
| 102 |
it = 1
|
97 |
it = 1
|
| 103 |
for x in p:
|
98 |
for x in p:
|
| 104 |
y = list(get_mongo_connection().Catalog.MasterData.find({'_id':x._id}))
|
99 |
y = list(get_mongo_connection().Catalog.MasterData.find({'_id':x._id}))
|
| 105 |
sheet.write(it, 0, x._id)
|
100 |
sheet.write(it, 0, x._id)
|
| Line 120... |
Line 115... |
| 120 |
sheet.write(it, 8, y[0]['identifier'])
|
115 |
sheet.write(it, 8, y[0]['identifier'])
|
| 121 |
sheet.write(it, 9, y[0]['secondaryIdentifier'])
|
116 |
sheet.write(it, 9, y[0]['secondaryIdentifier'])
|
| 122 |
sheet.write(it, 10, y[0]['source_product_name'])
|
117 |
sheet.write(it, 10, y[0]['source_product_name'])
|
| 123 |
sheet.write(it, 11, y[0]['url'])
|
118 |
sheet.write(it, 11, y[0]['url'])
|
| 124 |
sheet.write(it, 12, y[0]['available_price'])
|
119 |
sheet.write(it, 12, y[0]['available_price'])
|
| 125 |
cashBack = getCashBack(x._id, x.source_id, x.category_id, mc, 'localhost')
|
- |
|
| 126 |
if not cashBack or cashBack.get('cash_back_status')!=1:
|
- |
|
| 127 |
pass
|
- |
|
| 128 |
else:
|
- |
|
| 129 |
if cashBack['cash_back_type'] ==1:
|
- |
|
| 130 |
y[0]['available_price'] = y[0]['available_price'] - y[0]['available_price'] * float(cashBack['cash_back'])/100
|
- |
|
| 131 |
elif cashBack['cash_back_type'] ==2:
|
- |
|
| 132 |
y[0]['available_price'] = y[0]['available_price'] - float(cashBack['cash_back'])
|
- |
|
| 133 |
else:
|
- |
|
| 134 |
pass
|
- |
|
| 135 |
sheet.write(it, 13, y[0]['available_price'])
|
- |
|
| 136 |
sheet.write(it, 14, x.mrp)
|
120 |
sheet.write(it, 13, x.mrp)
|
| 137 |
sheet.write(it, 15, x.dp)
|
121 |
sheet.write(it, 14, x.dp)
|
| 138 |
sheet.write(it, 16, x.schemeAmount)
|
122 |
sheet.write(it, 15, x.schemeAmount)
|
| 139 |
sheet.write(it, 17, x.discountType)
|
123 |
sheet.write(it, 16, x.discountType)
|
| 140 |
sheet.write(it, 18, x.minDiscount)
|
124 |
sheet.write(it, 17, x.minDiscount)
|
| 141 |
sheet.write(it, 19, x.maxDiscount)
|
125 |
sheet.write(it, 18, x.maxDiscount)
|
| 142 |
sheet.write(it, 20, x.maxNlc)
|
126 |
sheet.write(it, 19, x.maxNlc)
|
| 143 |
sheet.write(it, 21, x.minNlc)
|
127 |
sheet.write(it, 20, x.minNlc)
|
| 144 |
sheet.write(it, 22, x.maxprice)
|
128 |
sheet.write(it, 21, x.maxprice)
|
| 145 |
sheet.write(it, 23, x.rank)
|
129 |
sheet.write(it, 22, x.rank)
|
| 146 |
sheet.write(it, 24, x.nlcPoints)
|
130 |
sheet.write(it, 23, x.nlcPoints)
|
| 147 |
sheet.write(it, 25, x.bestSellerPoints)
|
131 |
sheet.write(it, 24, x.bestSellerPoints)
|
| 148 |
sheet.write(it, 26, x.catalogBestSellerPoints)
|
132 |
sheet.write(it, 25, x.catalogBestSellerPoints)
|
| 149 |
sheet.write(it, 27, x.totalPoints)
|
133 |
sheet.write(it, 26, x.totalPoints)
|
| 150 |
sheet.write(it, 28, x.showDeal)
|
134 |
sheet.write(it, 27, x.showDeal)
|
| 151 |
it+=1
|
135 |
it+=1
|
| 152 |
filename = "/tmp/deal-data"+str(datetime.now())+".xls"
|
136 |
filename = "/tmp/deal-data"+str(datetime.now())+".xls"
|
| 153 |
wbk.save(filename)
|
137 |
wbk.save(filename)
|
| 154 |
smtpServer = smtplib.SMTP('localhost')
|
138 |
smtpServer = smtplib.SMTP('localhost')
|
| 155 |
#smtpServer.set_debuglevel(1)
|
139 |
#smtpServer.set_debuglevel(1)
|