Subversion Repositories SmartDukaan

Rev

Rev 14397 | Rev 14730 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 14397 Rev 14707
Line 6... Line 6...
6
from dtr.storage.DataService import brand_preferences, user_actions, price_preferences
6
from dtr.storage.DataService import brand_preferences, user_actions, price_preferences
7
from email.mime.multipart import MIMEMultipart
7
from email.mime.multipart import MIMEMultipart
8
import email.encoders
8
import email.encoders
9
import smtplib
9
import smtplib
10
from datetime import datetime
10
from datetime import datetime
-
 
11
from dtr.utils.utils import getCashBack
11
 
12
 
12
mc = MemCache()
13
mc = MemCache("127.0.0.1")
13
con =None
14
con =None
14
DataService.initialize(db_hostname='localhost')
15
DataService.initialize(db_hostname='localhost')
15
 
16
 
16
class __SkuInfo:
17
class __SkuInfo:
17
    
18
    
Line 166... Line 167...
166
    sheet.write(0, 8, "MarketPlace Identifier", heading_xf)
167
    sheet.write(0, 8, "MarketPlace Identifier", heading_xf)
167
    sheet.write(0, 9, "MarketPlace Secondary Identifier", heading_xf)
168
    sheet.write(0, 9, "MarketPlace Secondary Identifier", heading_xf)
168
    sheet.write(0, 10, "Product Name (Marketplace)", heading_xf)
169
    sheet.write(0, 10, "Product Name (Marketplace)", heading_xf)
169
    sheet.write(0, 11, "Url", heading_xf)
170
    sheet.write(0, 11, "Url", heading_xf)
170
    sheet.write(0, 12, "Price", heading_xf)
171
    sheet.write(0, 12, "Price", heading_xf)
-
 
172
    sheet.write(0, 13, "Price After Cashback", heading_xf)
171
    sheet.write(0, 13, "Mrp", heading_xf)
173
    sheet.write(0, 14, "Mrp", heading_xf)
172
    sheet.write(0, 14, "DP", heading_xf)
174
    sheet.write(0, 15, "DP", heading_xf)
173
    sheet.write(0, 15, "Scheme Amount", heading_xf)
175
    sheet.write(0, 16, "Scheme Amount", heading_xf)
174
    sheet.write(0, 16, "Discount Type", heading_xf)
176
    sheet.write(0, 17, "Discount Type", heading_xf)
175
    sheet.write(0, 17, "Min Discount", heading_xf)
177
    sheet.write(0, 18, "Min Discount", heading_xf)
176
    sheet.write(0, 18, "Max Discount", heading_xf)
178
    sheet.write(0, 19, "Max Discount", heading_xf)
177
    sheet.write(0, 19, "Max Nlc", heading_xf)
179
    sheet.write(0, 20, "Max Nlc", heading_xf)
178
    sheet.write(0, 20, "Min Nlc", heading_xf)
180
    sheet.write(0, 21, "Min Nlc", heading_xf)
179
    sheet.write(0, 21, "Max Price", heading_xf)
181
    sheet.write(0, 22, "Max Price", heading_xf)
180
    sheet.write(0, 22, "Rank", heading_xf)
182
    sheet.write(0, 23, "Rank", heading_xf)
181
    sheet.write(0, 23, "Nlc Points", heading_xf)
183
    sheet.write(0, 24, "Nlc Points", heading_xf)
182
    sheet.write(0, 24, "Best Seller Points", heading_xf)
184
    sheet.write(0, 25, "Best Seller Points", heading_xf)
183
    sheet.write(0, 25, "Catalog Best Seller Points", heading_xf)
185
    sheet.write(0, 26, "Catalog Best Seller Points", heading_xf)
184
    sheet.write(0, 26, "Total Points", heading_xf)
186
    sheet.write(0, 27, "Total Points", heading_xf)
185
    sheet.write(0, 27, "Pers Points", heading_xf)
187
    sheet.write(0, 28, "Pers Points", heading_xf)
186
    sheet.write(0, 28, "Show Deals", heading_xf)
188
    sheet.write(0, 29, "Show Deals", heading_xf)
187
    sheet.write(0, 29, "Fav Weight", heading_xf)
189
    sheet.write(0, 30, "Fav Weight", heading_xf)
188
    sheet.write(0, 30, "Brand Weight", heading_xf)
190
    sheet.write(0, 31, "Brand Weight", heading_xf)
189
    sheet.write(0, 31, "Asp Weight", heading_xf)
191
    sheet.write(0, 32, "Asp Weight", heading_xf)
190
    
192
    
191
    it = 1
193
    it = 1
192
    for x in p:
194
    for x in p:
193
        y = list(get_mongo_connection().Catalog.MasterData.find({'_id':x._id}))
195
        y = list(get_mongo_connection().Catalog.MasterData.find({'_id':x._id}))
194
        sheet.write(it, 0, x._id)
196
        sheet.write(it, 0, x._id)
Line 212... Line 214...
212
        sheet.write(it, 8, y[0]['identifier'])
214
        sheet.write(it, 8, y[0]['identifier'])
213
        sheet.write(it, 9, y[0]['secondaryIdentifier'])
215
        sheet.write(it, 9, y[0]['secondaryIdentifier'])
214
        sheet.write(it, 10, y[0]['source_product_name'])
216
        sheet.write(it, 10, y[0]['source_product_name'])
215
        sheet.write(it, 11, y[0]['url'])
217
        sheet.write(it, 11, y[0]['url'])
216
        sheet.write(it, 12, y[0]['available_price'])
218
        sheet.write(it, 12, y[0]['available_price'])
-
 
219
        cashBack = getCashBack(x._id, x.source_id, x.category_id, mc, 'localhost')
-
 
220
        if not cashBack or cashBack.get('cash_back_status')!=1:
-
 
221
            pass
-
 
222
        else:
-
 
223
            if cashBack['cash_back_type'] ==1:
-
 
224
                y[0]['available_price'] = y[0]['available_price'] - y[0]['available_price'] * float(cashBack['cash_back'])/100
-
 
225
            elif cashBack['cash_back_type'] ==2:
-
 
226
                y[0]['available_price'] = y[0]['available_price'] - float(cashBack['cash_back'])
-
 
227
            else:
-
 
228
                pass
-
 
229
        sheet.write(it, 13, y[0]['available_price'])
217
        sheet.write(it, 13, x.mrp)
230
        sheet.write(it, 14, x.mrp)
218
        sheet.write(it, 14, x.dp)
231
        sheet.write(it, 15, x.dp)
219
        sheet.write(it, 15, x.schemeAmount)
232
        sheet.write(it, 16, x.schemeAmount)
220
        sheet.write(it, 16, x.discountType)
233
        sheet.write(it, 17, x.discountType)
221
        sheet.write(it, 17, x.minDiscount)
234
        sheet.write(it, 18, x.minDiscount)
222
        sheet.write(it, 18, x.maxDiscount)
235
        sheet.write(it, 19, x.maxDiscount)
223
        sheet.write(it, 19, x.maxNlc)
236
        sheet.write(it, 20, x.maxNlc)
224
        sheet.write(it, 20, x.minNlc)
237
        sheet.write(it, 21, x.minNlc)
225
        sheet.write(it, 21, x.maxprice)
238
        sheet.write(it, 22, x.maxprice)
226
        sheet.write(it, 22, x.rank)
239
        sheet.write(it, 23, x.rank)
227
        sheet.write(it, 23, x.nlcPoints)
240
        sheet.write(it, 24, x.nlcPoints)
228
        sheet.write(it, 24, x.bestSellerPoints)
241
        sheet.write(it, 25, x.bestSellerPoints)
229
        sheet.write(it, 25, x.catalogBestSellerPoints)
242
        sheet.write(it, 26, x.catalogBestSellerPoints)
230
        sheet.write(it, 26, x.totalPoints)
243
        sheet.write(it, 27, x.totalPoints)
231
        sheet.write(it, 27, x.persPoints)
244
        sheet.write(it, 28, x.persPoints)
232
        sheet.write(it, 28, x.showDeal)
245
        sheet.write(it, 29, x.showDeal)
233
        sheet.write(it, 29, x.fav_weight)
246
        sheet.write(it, 30, x.fav_weight)
234
        sheet.write(it, 30, x.brand_weight)
247
        sheet.write(it, 31, x.brand_weight)
235
        sheet.write(it, 31, x.asp_weight)
248
        sheet.write(it, 32, x.asp_weight)
236
        it+=1
249
        it+=1
237
    filename = "/tmp/deal-data-user-specific"+str(datetime.now())+".xls" 
250
    filename = "/tmp/deal-data-user-specific"+str(datetime.now())+".xls" 
238
    wbk.save(filename)
251
    wbk.save(filename)
239
    smtpServer = smtplib.SMTP('localhost')
252
    smtpServer = smtplib.SMTP('localhost')
240
    #smtpServer.set_debuglevel(1)
253
    #smtpServer.set_debuglevel(1)