| Line 30... |
Line 30... |
| 30 |
select * from order_view order by id desc limit %s offset %s
|
30 |
select * from order_view order by id desc limit %s offset %s
|
| 31 |
'''
|
31 |
'''
|
| 32 |
ORDERS_DATE_QUERY = '''
|
32 |
ORDERS_DATE_QUERY = '''
|
| 33 |
select * from order_view where created > %s and store_id = %s
|
33 |
select * from order_view where created > %s and store_id = %s
|
| 34 |
'''
|
34 |
'''
|
| - |
|
35 |
ORDERS_DATE_QUERY1 = '''
|
| - |
|
36 |
select * from orders where created > %s and store_id = %s
|
| - |
|
37 |
'''
|
| 35 |
|
38 |
|
| 36 |
ORDERS_COUNT_QUERY='''
|
39 |
ORDERS_COUNT_QUERY='''
|
| 37 |
select count(*) from order_view
|
40 |
select count(*) from order_view
|
| 38 |
'''
|
41 |
'''
|
| 39 |
|
42 |
|
| Line 65... |
Line 68... |
| 65 |
template = "<html><head><style>td,th{border:1px solid;padding:2px}</style></head><div>Total Orders: %s</div><br/><body><table style='font-size:12px;border:1px solid grey;border-spacing:0;cell-spacing:0;border-bottom:1px solid grey;border-bottom:1px solid transparent'>%s</table></body></html>"
|
68 |
template = "<html><head><style>td,th{border:1px solid;padding:2px}</style></head><div>Total Orders: %s</div><br/><body><table style='font-size:12px;border:1px solid grey;border-spacing:0;cell-spacing:0;border-bottom:1px solid grey;border-bottom:1px solid transparent'>%s</table></body></html>"
|
| 66 |
tbodyarr = []
|
69 |
tbodyarr = []
|
| 67 |
colhead="<tr><th>Id</th><th>User Id</th><th>Store Id</th><th>Order Url</th><th>Subtag</th><th>Statu</th><th>Created on</th></tr>"
|
70 |
colhead="<tr><th>Id</th><th>User Id</th><th>Store Id</th><th>Order Url</th><th>Subtag</th><th>Statu</th><th>Created on</th></tr>"
|
| 68 |
tbodyarr.append(colhead)
|
71 |
tbodyarr.append(colhead)
|
| 69 |
for row in result:
|
72 |
for row in result:
|
| 70 |
tbodyarr.append("<tr><td>" + xstr(row[0]) + "</td><td>" + xstr(row[1]) +"</td><td>" + xstr(row[2]) +"</td><td><a target='_blank' href='/rawhtml/" + xstr(row[0]) + "'>" + xstr(row[3])[:90] +"</a></td><td>" + xstr(row[4]) + "</td><td>" + row[5][:15]+ "</td><td>" + row[6].strftime("%Y-%m-%d %H:%M:%S") + "</td></tr>")
|
73 |
tbodyarr.append("<tr><td>" + xstr(row[0]) + "</td><td>" + xstr(row[1]) +"</td><td>" + xstr(row[2]) +"</td><td><a target='_blank' href='/rawhtml/" + xstr(row[0]) + "'>" + xstr(row[3])[:130] +"</a></td><td>" + xstr(row[4]) + "</td><td>" + row[5]+ "</td><td>" + row[6].strftime("%Y-%m-%d %H:%M:%S") + "</td></tr>")
|
| 71 |
|
74 |
|
| 72 |
return template%(total_count, "".join(tbodyarr))
|
75 |
return template%(total_count, "".join(tbodyarr))
|
| 73 |
except:
|
76 |
except:
|
| 74 |
traceback.print_exc()
|
77 |
traceback.print_exc()
|
| 75 |
finally:
|
78 |
finally:
|
| Line 97... |
Line 100... |
| 97 |
result = cursor.fetchall()
|
100 |
result = cursor.fetchall()
|
| 98 |
return result
|
101 |
return result
|
| 99 |
finally:
|
102 |
finally:
|
| 100 |
conn.close()
|
103 |
conn.close()
|
| 101 |
|
104 |
|
| - |
|
105 |
def getOrdersAfterDate1(afterDate, storeId):
|
| - |
|
106 |
try:
|
| - |
|
107 |
conn = getDbConnection()
|
| - |
|
108 |
cursor = conn.cursor()
|
| - |
|
109 |
afterDate = datetime.strftime(afterDate,"\'%Y-%m-%d\'")
|
| - |
|
110 |
cursor.execute(ORDERS_DATE_QUERY1%(afterDate, storeId))
|
| - |
|
111 |
result = cursor.fetchall()
|
| - |
|
112 |
return result
|
| - |
|
113 |
finally:
|
| - |
|
114 |
conn.close()
|
| - |
|
115 |
|
| 102 |
def main():
|
116 |
def main():
|
| 103 |
print getOrdersAfterDate(datetime.now() - timedelta(days=10), 3)
|
117 |
print getOrdersAfterDate(datetime.now() - timedelta(days=10), 3)
|
| 104 |
|
118 |
|
| 105 |
|
119 |
|
| 106 |
if __name__ == '__main__':
|
120 |
if __name__ == '__main__':
|