Subversion Repositories SmartDukaan

Rev

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

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