Subversion Repositories SmartDukaan

Rev

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

Rev 9426 Rev 9451
Line 63... Line 63...
63
    url="http://www.snapdeal.com/json/gvbps?supc=%s&catId=91"%(supc_code)
63
    url="http://www.snapdeal.com/json/gvbps?supc=%s&catId=91"%(supc_code)
64
    print url
64
    print url
65
    time.sleep(2)
65
    time.sleep(2)
66
    req = urllib2.Request(url)
66
    req = urllib2.Request(url)
67
    response = urllib2.urlopen(req)
67
    response = urllib2.urlopen(req)
68
    print response
-
 
69
    json_input = response.read()
68
    json_input = response.read()
70
    vendorInfo = json.loads(json_input)
69
    vendorInfo = json.loads(json_input)
71
    rank ,otherInventory ,ourInventory, offerPrice, ourSp,iterator = 0, 0, 0, 0, 0, 0
70
    rank ,otherInventory ,ourInventory, offerPrice, ourSp,iterator = 0, 0, 0, 0, 0, 0
72
    secondLowestSellerName=''
71
    secondLowestSellerName=''
73
    secondLowestSellerSp=0
72
    secondLowestSellerSp=0
Line 173... Line 172...
173
    
172
    
174
    buyBoxItems = []
173
    buyBoxItems = []
175
    competitive = []
174
    competitive = []
176
    competitiveNoInventory = []
175
    competitiveNoInventory = []
177
    exceptionItems = []
176
    exceptionItems = []
-
 
177
    negativeMargin = []
178
    
178
    
179
    wbk = xlwt.Workbook()
179
    wbk = xlwt.Workbook()
180
    sheet = wbk.add_sheet('Can\'t Compete')
180
    sheet = wbk.add_sheet('Can\'t Compete')
181
 
181
 
182
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
182
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
Line 238... Line 238...
238
        for x in range (0,slab):
238
        for x in range (0,slab):
239
            courierCost = courierCost + 35
239
            courierCost = courierCost + 35
240
        
240
        
241
        courierCost = courierCost * 1.1236
241
        courierCost = courierCost * 1.1236
242
        
242
        
-
 
243
        if one_line.parent_category ==10011:
-
 
244
            lowestTp = (supc_data.lowestSp*(1-.0803))-courierCost
-
 
245
        else:
-
 
246
            lowestTp = supc_data.lowestSp*0.9497-courierCost
-
 
247
        
-
 
248
        lowest_possible_tp = one_line.our_nlc/0.988+15+6
-
 
249
        
-
 
250
        if (supc_data.ourSp*0.9597-courierCost < lowest_possible_tp):
-
 
251
            temp=[]
-
 
252
            temp.append(supc_data)
-
 
253
            temp.append(one_line)
-
 
254
            negativeMargin.append(temp)
-
 
255
            i+=1
-
 
256
            continue
-
 
257
        
243
        if supc_data.rank==1:
258
        if supc_data.rank==1:
244
            temp = []
259
            temp = []
245
            temp.append(supc_data)
260
            temp.append(supc_data)
246
            temp.append(one_line)
261
            temp.append(one_line)
247
            buyBoxItems.append(temp)
262
            buyBoxItems.append(temp)
248
            i+=1
263
            i+=1
249
            continue
264
            continue
250
        
265
        
251
        if one_line.parent_category ==10011:
-
 
252
            lowestTp = (supc_data.lowestSp*(1-.0803))-courierCost
-
 
253
        else:
-
 
254
            lowestTp = supc_data.lowestSp*0.9497-courierCost
-
 
255
        
-
 
256
        lowest_possible_tp = one_line.our_nlc/0.988+15+6
-
 
257
        
266
        
258
        if (lowestTp > lowest_possible_tp and supc_data.ourInventory!=0):
267
        if (lowestTp > lowest_possible_tp and supc_data.ourInventory!=0):
259
            temp=[]
268
            temp=[]
260
            temp.append(supc_data)
269
            temp.append(supc_data)
261
            temp.append(one_line)
270
            temp.append(one_line)
Line 269... Line 278...
269
            temp.append(one_line)
278
            temp.append(one_line)
270
            competitiveNoInventory.append(temp)
279
            competitiveNoInventory.append(temp)
271
            i+=1
280
            i+=1
272
            continue
281
            continue
273
        
282
        
-
 
283
        
274
        sheet.write(sheet_iterator, 0, one_line.item_id)
284
        sheet.write(sheet_iterator, 0, one_line.item_id)
275
        sheet.write(sheet_iterator, 1, one_line.category_name)
285
        sheet.write(sheet_iterator, 1, one_line.category_name)
276
        sheet.write(sheet_iterator, 2, one_line.product_group)
286
        sheet.write(sheet_iterator, 2, one_line.product_group)
277
        sheet.write(sheet_iterator, 3, supc)
287
        sheet.write(sheet_iterator, 3, supc)
278
        sheet.write(sheet_iterator, 4, one_line.brand)
288
        sheet.write(sheet_iterator, 4, one_line.brand)
Line 340... Line 350...
340
        
350
        
341
    createSheetForBuyBoxItems(buyBoxItems,wbk)
351
    createSheetForBuyBoxItems(buyBoxItems,wbk)
342
    createSheetForCometitiveItems(competitive,wbk)
352
    createSheetForCometitiveItems(competitive,wbk)
343
    createSheetForCometitiveItemsNoInventory(competitiveNoInventory,wbk)
353
    createSheetForCometitiveItemsNoInventory(competitiveNoInventory,wbk)
344
    exception_sheet(exceptionItems,wbk)
354
    exception_sheet(exceptionItems,wbk)
-
 
355
    createSheetForNegativeMargin(negativeMargin,wbk)
345
    wbk.save(filename)
356
    wbk.save(filename)
346
    
357
    
347
    EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@shop2020.in"], " " , "", [get_attachment_part(filename)], ["kshitij.sood@shop2020.in"], [])
358
    EmailAttachmentSender.mail("build@shop2020.in", "cafe@nes", ["kshitij.sood@shop2020.in"], " " , "", [get_attachment_part(filename)], ["kshitij.sood@shop2020.in"], [])
348
 
359
 
349
    
360
    
Line 686... Line 697...
686
        else:
697
        else:
687
            sheet.write(sheet_iterator, 28, "LOW")
698
            sheet.write(sheet_iterator, 28, "LOW")
688
        i= i+1
699
        i= i+1
689
        sheet_iterator+=1
700
        sheet_iterator+=1
690
    
701
    
-
 
702
def createSheetForNegativeMargin(negativeMargin,wbk):
-
 
703
    sheet = wbk.add_sheet('Negative Margin')
-
 
704
 
-
 
705
    heading_xf = xlwt.easyxf('font: bold on; align: wrap off, vert centre, horiz center')
-
 
706
    
-
 
707
    excel_integer_format = '0'
-
 
708
    integer_style = xlwt.XFStyle()
-
 
709
    integer_style.num_format_str = excel_integer_format
-
 
710
    
-
 
711
    sheet.write(0, 0, "Item ID", heading_xf)
-
 
712
    sheet.write(0, 1, "Category", heading_xf)
-
 
713
    sheet.write(0, 2, "Product Group.", heading_xf)
-
 
714
    sheet.write(0, 3, "SUPC", heading_xf)
-
 
715
    sheet.write(0, 4, "Brand", heading_xf)
-
 
716
    sheet.write(0, 5, "Model Name", heading_xf)
-
 
717
    sheet.write(0, 6, "Model Number", heading_xf)
-
 
718
    sheet.write(0, 7, "Color", heading_xf)
-
 
719
    sheet.write(0, 8, "Weight", heading_xf)
-
 
720
    sheet.write(0, 9, "Courier Cost", heading_xf)
-
 
721
    sheet.write(0, 10, "Risky", heading_xf)
-
 
722
    sheet.write(0, 11, "Our SP", heading_xf)
-
 
723
    sheet.write(0, 13, "Our TP", heading_xf)
-
 
724
    sheet.write(0, 12, "Our Offer Price", heading_xf)
-
 
725
    sheet.write(0, 14, "Our Rank", heading_xf)
-
 
726
    sheet.write(0, 15, "Lowest Seller", heading_xf)
-
 
727
    sheet.write(0, 16, "Lowest SP", heading_xf)
-
 
728
    sheet.write(0, 17, "Lowest TP", heading_xf)
-
 
729
    sheet.write(0, 18, "Lowest Offer Price", heading_xf)
-
 
730
    sheet.write(0, 19, "Inventory of Top Vendors", heading_xf)
-
 
731
    sheet.write(0, 20, "Our Snapdeal Inventory", heading_xf)
-
 
732
    sheet.write(0, 21, "Our NLC", heading_xf)
-
 
733
    sheet.write(0, 22, "Lowest Possible TP", heading_xf)
-
 
734
    sheet.write(0, 23, "Lowest Possible SP", heading_xf)
-
 
735
    sheet.write(0, 24, "Competition Basis ", heading_xf)
-
 
736
    sheet.write(0, 25, "Can Compete", heading_xf)
-
 
737
    sheet.write(0, 26, "Target TP", heading_xf)
-
 
738
    sheet.write(0, 27, "Target SP", heading_xf)  
-
 
739
    sheet.write(0, 28, "Sales Potential", heading_xf)
691
    
740
    
-
 
741
    i, sheet_iterator=1,1
-
 
742
    for data in negativeMargin:
-
 
743
        supc_data =data[0]
-
 
744
        one_line = data[1]
-
 
745
        
-
 
746
        courierCost = 45
-
 
747
        
-
 
748
        if one_line.weight:
-
 
749
            slab = int(((one_line.weight+0.05) - .001)/.5)
-
 
750
        for x in range (0,slab):
-
 
751
            courierCost = courierCost + 35
-
 
752
        
-
 
753
        courierCost = courierCost * 1.1236
-
 
754
        
-
 
755
        
-
 
756
        sheet.write(sheet_iterator, 0, one_line.item_id)
-
 
757
        sheet.write(sheet_iterator, 1, one_line.category_name)
-
 
758
        sheet.write(sheet_iterator, 2, one_line.product_group)
-
 
759
        sheet.write(sheet_iterator, 3, supc_data.supc)
-
 
760
        sheet.write(sheet_iterator, 4, one_line.brand)
-
 
761
        sheet.write(sheet_iterator, 5, one_line.model_name)
-
 
762
        sheet.write(sheet_iterator, 6, one_line.model_number)
-
 
763
        sheet.write(sheet_iterator, 7, one_line.color)
-
 
764
        sheet.write(sheet_iterator, 8, one_line.weight)
-
 
765
        sheet.write(sheet_iterator, 9, round(courierCost))
-
 
766
        sheet.write(sheet_iterator, 10, one_line.risky)
-
 
767
        sheet.write(sheet_iterator, 11, supc_data.ourSp)
-
 
768
        sheet.write(sheet_iterator, 13, '-')
-
 
769
        sheet.write(sheet_iterator, 12, supc_data.ourOfferPrice)
-
 
770
        sheet.write(sheet_iterator, 14, supc_data.rank)
-
 
771
        sheet.write(sheet_iterator, 15, supc_data.lowestSellerName)
-
 
772
        sheet.write(sheet_iterator, 16, supc_data.lowestSp)
-
 
773
        if one_line.parent_category ==10011:
-
 
774
            lowestTp = (supc_data.lowestSp*(1-.0803))-courierCost
-
 
775
        else:
-
 
776
            lowestTp = supc_data.lowestSp*0.9497-courierCost
-
 
777
        sheet.write(sheet_iterator, 17, round(lowestTp))
-
 
778
        sheet.write(sheet_iterator, 18, supc_data.lowestOfferPrice)
-
 
779
        sheet.write(sheet_iterator, 19, supc_data.otherInventory)
-
 
780
        sheet.write(sheet_iterator, 20, supc_data.ourInventory)
-
 
781
        sheet.write(sheet_iterator, 21, one_line.our_nlc)
-
 
782
        if supc_data.rank==1:
-
 
783
            i+=1
-
 
784
            sheet_iterator+=1
-
 
785
            continue
-
 
786
        lowest_possible_tp = one_line.our_nlc/0.988+15+6
-
 
787
        lowest_possible_sp = (lowest_possible_tp+courierCost)/0.9597
-
 
788
        sheet.write(sheet_iterator, 22, round(lowest_possible_tp))
-
 
789
        sheet.write(sheet_iterator, 23, round(lowest_possible_sp))
-
 
790
        competitionBasis ='TP'
-
 
791
        if (supc_data.lowestOfferPrice == supc_data.lowestSp):
-
 
792
            competitionBasis ='SP'
-
 
793
            sheet.write(sheet_iterator, 24, 'SP')
-
 
794
        else:
-
 
795
            sheet.write(sheet_iterator, 24, 'TP')
-
 
796
        proposed_tp = 0
-
 
797
        if lowestTp > lowest_possible_tp:
-
 
798
            sheet.write(sheet_iterator, 25, "Yes")
-
 
799
            if competitionBasis=='SP':
-
 
800
                proposed_sp = max(supc_data.lowestSp - max((10, supc_data.lowestSp*0.001)), lowest_possible_sp)
-
 
801
                proposed_tp = proposed_sp*.9597-courierCost
-
 
802
                sheet.write(sheet_iterator, 26, round(proposed_tp))
-
 
803
                sheet.write(sheet_iterator, 27, round(proposed_sp))
-
 
804
            else:
-
 
805
                proposed_tp  = max(lowestTp - max((10, lowestTp*0.001)), lowest_possible_tp)
-
 
806
                sheet.write(sheet_iterator, 26, round(proposed_tp))
-
 
807
                sheet.write(sheet_iterator, 27, round((proposed_tp+courierCost)/0.9597))
-
 
808
        else:
-
 
809
            sheet.write(sheet_iterator, 25, "No")
-
 
810
        
-
 
811
        if (supc_data.lowestOfferPrice - one_line.our_nlc) < 0:
-
 
812
            sheet.write(sheet_iterator, 28, "HIGH")
-
 
813
        elif (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice >=0 and (supc_data.lowestOfferPrice - one_line.our_nlc)/supc_data.lowestOfferPrice <= .02:
-
 
814
            sheet.write(sheet_iterator, 28, "MEDIUM")
-
 
815
        else:
-
 
816
            sheet.write(sheet_iterator, 28, "LOW")
-
 
817
        i= i+1
-
 
818
        sheet_iterator+=1
-
 
819
       
692
 
820
 
693
def main():
821
def main():
694
    parser = optparse.OptionParser()
822
    parser = optparse.OptionParser()
695
    parser.add_option("-f", "--file", dest="filename",
823
    parser.add_option("-f", "--file", dest="filename",
696
                   default="ItemList.xls", type="string",
824
                   default="ItemList.xls", type="string",
Line 702... Line 830...
702
    filename = options.filename
830
    filename = options.filename
703
    read_data(filename)
831
    read_data(filename)
704
 
832
 
705
if __name__ == '__main__':
833
if __name__ == '__main__':
706
    main()
834
    main()
707
 
835