Subversion Repositories SmartDukaan

Rev

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

Rev 11167 Rev 11753
Line 134... Line 134...
134
    for autoDecrementItem in autoDecrementItems:
134
    for autoDecrementItem in autoDecrementItems:
135
        #mpHistory = MarketPlaceHistory.get_by(source=OrderSource.SNAPDEAL,item_id=autoDecrementItem.itemId,timestamp=time)
135
        #mpHistory = MarketPlaceHistory.get_by(source=OrderSource.SNAPDEAL,item_id=autoDecrementItem.itemId,timestamp=time)
136
        if not autoDecrementItem.competitiveCategory == CompetitionCategory.COMPETITIVE:
136
        if not autoDecrementItem.competitiveCategory == CompetitionCategory.COMPETITIVE:
137
            markReasonForMpItem(autoDecrementItem,'Category is '+CompetitionCategory._VALUES_TO_NAMES.get(autoDecrementItem.competitiveCategory),Decision.AUTO_DECREMENT_FAILED)
137
            markReasonForMpItem(autoDecrementItem,'Category is '+CompetitionCategory._VALUES_TO_NAMES.get(autoDecrementItem.competitiveCategory),Decision.AUTO_DECREMENT_FAILED)
138
            continue
138
            continue
139
        if not autoDecrementItem.risky:
139
#        if not autoDecrementItem.risky:
140
            markReasonForMpItem(autoDecrementItem,'Item is not risky',Decision.AUTO_DECREMENT_FAILED)
140
#            markReasonForMpItem(autoDecrementItem,'Item is not risky',Decision.AUTO_DECREMENT_FAILED)
141
            continue
141
#            continue
142
        if math.ceil(autoDecrementItem.proposedSellingPrice) >= autoDecrementItem.ourSellingPrice:
142
        if math.ceil(autoDecrementItem.proposedSellingPrice) >= autoDecrementItem.ourSellingPrice:
143
            markReasonForMpItem(autoDecrementItem,'Proposed SP greater than or equal to current SP',Decision.AUTO_DECREMENT_FAILED)
143
            markReasonForMpItem(autoDecrementItem,'Proposed SP greater than or equal to current SP',Decision.AUTO_DECREMENT_FAILED)
144
            continue
144
            continue
145
        if autoDecrementItem.proposedSellingPrice < autoDecrementItem.lowestPossibleSp:
145
        if autoDecrementItem.proposedSellingPrice < autoDecrementItem.lowestPossibleSp:
146
            markReasonForMpItem(autoDecrementItem,'Proposed SP less than lowest possible SP',Decision.AUTO_DECREMENT_FAILED)
146
            markReasonForMpItem(autoDecrementItem,'Proposed SP less than lowest possible SP',Decision.AUTO_DECREMENT_FAILED)
Line 180... Line 180...
180
        try:
180
        try:
181
            daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
181
            daysOfStock = (float(totalAvailability-totalReserved))/avgSalePerDay
182
        except ZeroDivisionError,e:
182
        except ZeroDivisionError,e:
183
            lgr.info("Infinite days of stock for item "+str(autoDecrementItem.item_id))
183
            lgr.info("Infinite days of stock for item "+str(autoDecrementItem.item_id))
184
            daysOfStock = float("inf")
184
            daysOfStock = float("inf")
185
        if daysOfStock<2:
185
        if daysOfStock<2 and autoDecrementItem.risky:
186
            markReasonForMpItem(autoDecrementItem,'Our stock is not enough',Decision.AUTO_DECREMENT_FAILED)
186
            markReasonForMpItem(autoDecrementItem,'Our stock is not enough',Decision.AUTO_DECREMENT_FAILED)
187
            continue
187
            continue
188
 
188
 
189
        autoDecrementItem.competitorEnoughStock = True
189
        autoDecrementItem.competitorEnoughStock = True
190
        autoDecrementItem.ourEnoughStock = True
190
        autoDecrementItem.ourEnoughStock = True
Line 1203... Line 1203...
1203
        smtpServer = smtplib.SMTP('localhost')
1203
        smtpServer = smtplib.SMTP('localhost')
1204
        smtpServer.set_debuglevel(1)
1204
        smtpServer.set_debuglevel(1)
1205
        sender = 'support@shop2020.in'
1205
        sender = 'support@shop2020.in'
1206
        #recipients = ['kshitij.sood@saholic.com']
1206
        #recipients = ['kshitij.sood@saholic.com']
1207
        msg = MIMEMultipart()
1207
        msg = MIMEMultipart()
1208
        msg['Subject'] = "Snapdeal Auto Pricing" + ' - ' + str(datetime.now())
1208
        msg['Subject'] = "Snapdeal Auto Pricing " +runType+" " + str(timestamp)
1209
        msg['From'] = sender
1209
        msg['From'] = sender
1210
        recipients = ['rajneesh.arora@saholic.com','anikendra.das@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
1210
        recipients = ['rajneesh.arora@saholic.com','anikendra.das@saholic.com','vikram.raghav@saholic.com','kshitij.sood@saholic.com','khushal.bhatia@saholic.com','chaitnaya.vats@saholic.com','chandan.kumar@saholic.com','manoj.kumar@saholic.com','yukti.jain@saholic.com','ankush.dhingra@saholic.com','manoj.pal@saholic.com']
1211
        msg['To'] = ",".join(recipients)
1211
        msg['To'] = ",".join(recipients)
1212
        fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
1212
        fileMsg = email.mime.base.MIMEBase('application','vnd.ms-excel')
1213
        fileMsg.set_payload(file(filename).read())
1213
        fileMsg.set_payload(file(filename).read())
Line 1623... Line 1623...
1623
    if syncPrice=='false':
1623
    if syncPrice=='false':
1624
        return
1624
        return
1625
    url = 'http://support.shop2020.in:8080/Support/reports'
1625
    url = 'http://support.shop2020.in:8080/Support/reports'
1626
    br = getBrowserObject()
1626
    br = getBrowserObject()
1627
    br.open(url)
1627
    br.open(url)
1628
    br.open(url)
-
 
1629
    br.select_form(nr=0)
1628
    br.select_form(nr=0)
1630
    br.form['username'] = "manoj"
1629
    br.form['username'] = "manoj"
1631
    br.form['password'] = "man0j"
1630
    br.form['password'] = "man0j"
1632
    br.submit()
1631
    br.submit()
1633
    for item in successfulAutoDecrease:
1632
    for item in successfulAutoDecrease:
Line 1844... Line 1843...
1844
        return 'MEDIUM'
1843
        return 'MEDIUM'
1845
    else:
1844
    else:
1846
        return 'LOW'  
1845
        return 'LOW'  
1847
 
1846
 
1848
def groupData(previousTimestamp,timestampNow):
1847
def groupData(previousTimestamp,timestampNow):
1849
    print "inside grouping data*****"
-
 
1850
    previousData = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==previousTimestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).all()
1848
    previousData = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==previousTimestamp).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).all()
1851
    for data in previousData:
1849
    for data in previousData:
1852
        latestItemData = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==timestampNow).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.item_id==data.item_id).first()
1850
        latestItemData = session.query(MarketPlaceHistory).filter(MarketPlaceHistory.timestamp==timestampNow).filter(MarketPlaceHistory.source==OrderSource.SNAPDEAL).filter(MarketPlaceHistory.item_id==data.item_id).first()
1853
        if latestItemData is None:
1851
        if latestItemData is None:
1854
            continue
1852
            continue
1855
        if data.ourSellingPrice == latestItemData.ourSellingPrice and data.ourOfferPrice == latestItemData.ourOfferPrice and data.competitiveCategory == latestItemData.competitiveCategory:
1853
        if data.ourSellingPrice == latestItemData.ourSellingPrice and data.ourOfferPrice == latestItemData.ourOfferPrice and data.competitiveCategory == latestItemData.competitiveCategory:
1856
            print "yes found",data.item_id
-
 
1857
            if data.toGroup is None:
1854
            if data.toGroup is None:
1858
                data.toGroup=False
1855
                data.toGroup=False
1859
                latestItemData.toGroup=True
1856
                latestItemData.toGroup=True
1860
            else:
1857
            else:
1861
                latestItemData.toGroup=True
1858
                latestItemData.toGroup=True
1862
                data.toGroup=False
1859
                data.toGroup=False
1863
        else:
1860
        else:
1864
            latestItemData=None
1861
            latestItemData=None
1865
    session.commit()
1862
    session.commit()
1866
    print "commit****"
-
 
1867
    time.sleep(10)
-
 
1868
     
1863
     
1869
    
1864
    
1870
def main():
1865
def main():
1871
    parser = optparse.OptionParser()
1866
    parser = optparse.OptionParser()
1872
    parser.add_option("-t", "--type", dest="runType",
1867
    parser.add_option("-t", "--type", dest="runType",
Line 1900... Line 1895...
1900
    sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
1895
    sendAutoPricingMail(successfulAutoDecrease,successfulAutoIncrease)
1901
    processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
1896
    processLostBuyBoxItems(previousProcessingTimestamp[0],timestamp)
1902
    updatePricesOnSnapdeal(successfulAutoDecrease,successfulAutoIncrease)
1897
    updatePricesOnSnapdeal(successfulAutoDecrease,successfulAutoIncrease)
1903
    
1898
    
1904
if __name__ == '__main__':
1899
if __name__ == '__main__':
1905
     main()
-
 
1906
1900
    main()
-
 
1901
1907
1902