| Line 10... |
Line 10... |
| 10 |
statusMap = {1:'Active',2:'EOL',3:'In Process',4:'Exclusive'}
|
10 |
statusMap = {1:'Active',2:'EOL',3:'In Process',4:'Exclusive'}
|
| 11 |
|
11 |
|
| 12 |
class __SkuInfo:
|
12 |
class __SkuInfo:
|
| 13 |
|
13 |
|
| 14 |
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, \
|
| 15 |
maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints,in_stock,maxprice,showDeal, catalogBestSellerPoints):
|
15 |
maxDiscount, discountType, dp, nlcPoints, bestSellerPoints, totalPoints,in_stock,maxprice,showDeal, catalogBestSellerPoints, prepaidDeal):
|
| 16 |
self._id = _id
|
16 |
self._id = _id
|
| 17 |
self.skuBundleId = skuBundleId
|
17 |
self.skuBundleId = skuBundleId
|
| 18 |
self.category_id = category_id
|
18 |
self.category_id = category_id
|
| 19 |
self.mrp = mrp
|
19 |
self.mrp = mrp
|
| 20 |
self.available_price = available_price
|
20 |
self.available_price = available_price
|
| Line 31... |
Line 31... |
| 31 |
self.bestSellerPoints = bestSellerPoints
|
31 |
self.bestSellerPoints = bestSellerPoints
|
| 32 |
self.totalPoints = totalPoints
|
32 |
self.totalPoints = totalPoints
|
| 33 |
self.in_stock = in_stock
|
33 |
self.in_stock = in_stock
|
| 34 |
self.maxprice = maxprice
|
34 |
self.maxprice = maxprice
|
| 35 |
self.showDeal = showDeal
|
35 |
self.showDeal = showDeal
|
| 36 |
self.catalogBestSellerPoints = catalogBestSellerPoints
|
36 |
self.catalogBestSellerPoints = catalogBestSellerPoints
|
| - |
|
37 |
self.prepaidDeal = prepaidDeal
|
| 37 |
|
38 |
|
| 38 |
def get_mongo_connection(host='localhost', port=27017):
|
39 |
def get_mongo_connection(host='localhost', port=27017):
|
| 39 |
global con
|
40 |
global con
|
| 40 |
if con is None:
|
41 |
if con is None:
|
| 41 |
print "Establishing connection %s host and port %d" %(host,port)
|
42 |
print "Establishing connection %s host and port %d" %(host,port)
|
| Line 51... |
Line 52... |
| 51 |
data = get_mongo_connection().Catalog.Deals.find().sort([('totalPoints',pymongo.DESCENDING)])
|
52 |
data = get_mongo_connection().Catalog.Deals.find().sort([('totalPoints',pymongo.DESCENDING)])
|
| 52 |
print data.count()
|
53 |
print data.count()
|
| 53 |
for x in data:
|
54 |
for x in data:
|
| 54 |
s_info = __SkuInfo(x['_id'], x['skuBundleId'], x['category_id'],x['mrp'],x['available_price'],x['source_id'],x['rank'],x['maxNlc'], \
|
55 |
s_info = __SkuInfo(x['_id'], x['skuBundleId'], x['category_id'],x['mrp'],x['available_price'],x['source_id'],x['rank'],x['maxNlc'], \
|
| 55 |
x['minNlc'], x['schemeAmount'],x['minDiscount'],x['maxDiscount'],x['discountType'],x['dp'],x['nlcPoints'],x['bestSellerPoints'], \
|
56 |
x['minNlc'], x['schemeAmount'],x['minDiscount'],x['maxDiscount'],x['discountType'],x['dp'],x['nlcPoints'],x['bestSellerPoints'], \
|
| 56 |
x['totalPoints'],x['in_stock'],x['maxprice'],x['showDeal'],x['catalogBestSellerPoints'])
|
57 |
x['totalPoints'],x['in_stock'],x['maxprice'],x['showDeal'],x['catalogBestSellerPoints'],x['prepaidDeal'])
|
| 57 |
p.append(s_info)
|
58 |
p.append(s_info)
|
| 58 |
|
59 |
|
| 59 |
wbk = xlwt.Workbook()
|
60 |
wbk = xlwt.Workbook()
|
| 60 |
sheet = wbk.add_sheet('Deals')
|
61 |
sheet = wbk.add_sheet('Deals')
|
| 61 |
xstr = lambda s: s or ""
|
62 |
xstr = lambda s: s or ""
|
| Line 90... |
Line 91... |
| 90 |
sheet.write(0, 22, "Rank", heading_xf)
|
91 |
sheet.write(0, 22, "Rank", heading_xf)
|
| 91 |
sheet.write(0, 23, "Nlc Points", heading_xf)
|
92 |
sheet.write(0, 23, "Nlc Points", heading_xf)
|
| 92 |
sheet.write(0, 24, "Best Seller Points", heading_xf)
|
93 |
sheet.write(0, 24, "Best Seller Points", heading_xf)
|
| 93 |
sheet.write(0, 25, "Catalog Best Seller Points", heading_xf)
|
94 |
sheet.write(0, 25, "Catalog Best Seller Points", heading_xf)
|
| 94 |
sheet.write(0, 26, "Total Points", heading_xf)
|
95 |
sheet.write(0, 26, "Total Points", heading_xf)
|
| 95 |
sheet.write(0, 27, "Show Deals", heading_xf)
|
96 |
sheet.write(0, 27, "COD Deal", heading_xf)
|
| - |
|
97 |
sheet.write(0, 28, "Prepaid Deal", heading_xf)
|
| 96 |
|
98 |
|
| 97 |
it = 1
|
99 |
it = 1
|
| 98 |
for x in p:
|
100 |
for x in p:
|
| 99 |
y = list(get_mongo_connection().Catalog.MasterData.find({'_id':x._id}))
|
101 |
y = list(get_mongo_connection().Catalog.MasterData.find({'_id':x._id}))
|
| 100 |
sheet.write(it, 0, x._id)
|
102 |
sheet.write(it, 0, x._id)
|
| Line 130... |
Line 132... |
| 130 |
sheet.write(it, 23, x.nlcPoints)
|
132 |
sheet.write(it, 23, x.nlcPoints)
|
| 131 |
sheet.write(it, 24, x.bestSellerPoints)
|
133 |
sheet.write(it, 24, x.bestSellerPoints)
|
| 132 |
sheet.write(it, 25, x.catalogBestSellerPoints)
|
134 |
sheet.write(it, 25, x.catalogBestSellerPoints)
|
| 133 |
sheet.write(it, 26, x.totalPoints)
|
135 |
sheet.write(it, 26, x.totalPoints)
|
| 134 |
sheet.write(it, 27, x.showDeal)
|
136 |
sheet.write(it, 27, x.showDeal)
|
| - |
|
137 |
sheet.write(it, 28, x.prepaidDeal)
|
| 135 |
it+=1
|
138 |
it+=1
|
| 136 |
filename = "/tmp/deal-data"+str(datetime.now())+".xls"
|
139 |
filename = "/tmp/deal-data"+str(datetime.now())+".xls"
|
| 137 |
wbk.save(filename)
|
140 |
wbk.save(filename)
|
| 138 |
smtpServer = smtplib.SMTP('localhost')
|
141 |
smtpServer = smtplib.SMTP('localhost')
|
| 139 |
#smtpServer.set_debuglevel(1)
|
142 |
#smtpServer.set_debuglevel(1)
|