| Line 91... |
Line 91... |
| 91 |
directory = "/SnapAff/"
|
91 |
directory = "/SnapAff/"
|
| 92 |
curDate = directory + datetime.now().strftime('%Y-%m-%d')
|
92 |
curDate = directory + datetime.now().strftime('%Y-%m-%d')
|
| 93 |
if not os.path.exists(directory):
|
93 |
if not os.path.exists(directory):
|
| 94 |
os.makedirs(directory)
|
94 |
os.makedirs(directory)
|
| 95 |
for status in statuses:
|
95 |
for status in statuses:
|
| - |
|
96 |
if status == "approved":
|
| - |
|
97 |
print "app"
|
| 96 |
reportUrl = NEW_REPORT_URI_TEMPLATE%(startDate, endDate, status)
|
98 |
reportUrl = NEW_REPORT_URI_TEMPLATE%(startDate, endDate, status)
|
| 97 |
print reportUrl
|
99 |
print reportUrl
|
| 98 |
filename=curDate + "-" + status
|
100 |
filename=curDate + "-" + status
|
| 99 |
fileobj = open(filename,"wb")
|
101 |
fileobj = open(filename,"wb")
|
| 100 |
fileobj.write(utils.ungzipResponse(br.open(reportUrl)))
|
102 |
fileobj.write(utils.ungzipResponse(br.open(reportUrl)))
|
| Line 695... |
Line 697... |
| 695 |
session.close()
|
697 |
session.close()
|
| 696 |
|
698 |
|
| 697 |
def covertToObj(self,offer):
|
699 |
def covertToObj(self,offer):
|
| 698 |
product,category,order_code,quantity,price,sales,commission_rate,commission_earned,datetime1,affiliate_sub_id1,affiliate_sub_id2 = offer
|
700 |
product,category,order_code,quantity,price,sales,commission_rate,commission_earned,datetime1,affiliate_sub_id1,affiliate_sub_id2 = offer
|
| 699 |
offer1 = AffiliateInfo(affiliate_sub_id1, 3, None, None, utils.toTimeStamp(datetime.strptime(datetime1, "%m-%d-%Y %H:%M")),
|
701 |
offer1 = AffiliateInfo(affiliate_sub_id1, 3, None, None, utils.toTimeStamp(datetime.strptime(datetime1, "%m-%d-%Y %H:%M")),
|
| 700 |
0 if "-" else int(float(commission_earned)), None, None, int(float(sales)))
|
702 |
0 if commission_earned=="-" else int(float(commission_earned)), None, None, int(float(sales)))
|
| 701 |
offer1.orderId = order_code if order_code else None
|
703 |
offer1.orderId = order_code if order_code else None
|
| 702 |
offer1.productCode = product
|
704 |
offer1.productCode = product
|
| 703 |
offer1.unitPrice = int(float(price))
|
705 |
offer1.unitPrice = int(float(price))
|
| 704 |
offer1.quantity = int(quantity)
|
706 |
offer1.quantity = int(quantity)
|
| - |
|
707 |
offer1.payOut
|
| 705 |
return offer1
|
708 |
return offer1
|
| 706 |
def getPostData(token, page = 1, limit= 20, startDate=None, endDate=None):
|
709 |
def getPostData(token, page = 1, limit= 20, startDate=None, endDate=None):
|
| 707 |
endDate=date.today() + timedelta(days=1)
|
710 |
endDate=date.today() + timedelta(days=1)
|
| 708 |
startDate=endDate - timedelta(days=31)
|
711 |
startDate=endDate - timedelta(days=31)
|
| 709 |
|
712 |
|
| Line 737... |
Line 740... |
| 737 |
#print todict([1,2,"3"])
|
740 |
#print todict([1,2,"3"])
|
| 738 |
store = getStore(3)
|
741 |
store = getStore(3)
|
| 739 |
#store.parseOrderRawHtml(332221, "3232311", 2, "32311243", "https://m.snapdeal.com/orderSummary?code=3fbc8a02a1c4d3c4e906f46886de0464&order=5808451506")
|
742 |
#store.parseOrderRawHtml(332221, "3232311", 2, "32311243", "https://m.snapdeal.com/orderSummary?code=3fbc8a02a1c4d3c4e906f46886de0464&order=5808451506")
|
| 740 |
#store.scrapeStoreOrders()
|
743 |
#store.scrapeStoreOrders()
|
| 741 |
#store._isSubOrderActive(8, "5970688907")
|
744 |
#store._isSubOrderActive(8, "5970688907")
|
| 742 |
#store.scrapeAffiliate(datetime(2015,4,1))
|
745 |
store.scrapeAffiliate(datetime(2015,4,1))
|
| 743 |
#store.scrapeStoreOrders()
|
746 |
#store.scrapeStoreOrders()
|
| 744 |
store.parseInfo()
|
747 |
#store.parseInfo()
|
| 745 |
|
748 |
|
| 746 |
|
749 |
|
| 747 |
|
750 |
|
| 748 |
def todict(obj, classkey=None):
|
751 |
def todict(obj, classkey=None):
|
| 749 |
if isinstance(obj, dict):
|
752 |
if isinstance(obj, dict):
|