ok
This commit is contained in:
parent
5135f15c5d
commit
ee303dbd63
@ -7,6 +7,7 @@ import datetime
|
||||
import hashlib
|
||||
import binascii
|
||||
import pymysql
|
||||
import traceback
|
||||
import urllib.request
|
||||
import tornado.ioloop
|
||||
import tornado.web
|
||||
@ -58,7 +59,7 @@ def fetchConfirmedOrderList():
|
||||
conn = getMysqlConn('')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('SELECT idx, orderid '
|
||||
'FROM confirmed_order WHERE idx>%d;' % last_idx)
|
||||
'FROM confirmed_order WHERE idx>%d AND status=0;' % last_idx)
|
||||
rows = cursor.fetchall();
|
||||
for row in rows:
|
||||
confirmed_order_list.append({
|
||||
@ -70,6 +71,28 @@ def fetchConfirmedOrderList():
|
||||
print(e)
|
||||
return
|
||||
|
||||
def confirmOneOrder(orderid):
|
||||
try:
|
||||
conn = getMysqlConn('')
|
||||
cursor = conn.cursor()
|
||||
cursor.execute('UPDATE orderinfo SET status=1, confirmtime=%d '
|
||||
'WHERE orderid="%s";' %
|
||||
(
|
||||
time.time(),
|
||||
conn.escape_string(orderid))
|
||||
)
|
||||
conn.commit()
|
||||
cursor.execute('UPDATE confirmed_order SET status=1, confirm_time=%d '
|
||||
'WHERE orderid="%s";' %
|
||||
(
|
||||
time.time(),
|
||||
conn.escape_string(orderid))
|
||||
)
|
||||
conn.commit()
|
||||
except Exception as e :
|
||||
info('confirOneOrder orderid:' + orderid + ' error:' + str(e))
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
|
||||
def sendOneOrder(conf, idx, orderid):
|
||||
global notifyapi_json
|
||||
try:
|
||||
@ -80,6 +103,7 @@ def sendOneOrder(conf, idx, orderid):
|
||||
row = cursor.fetchone()
|
||||
if (not row) or (row[0] != 1):
|
||||
return True
|
||||
info(row[4])
|
||||
if row[6] == 0:
|
||||
timestamp = time.time()
|
||||
params = {
|
||||
@ -93,11 +117,16 @@ def sendOneOrder(conf, idx, orderid):
|
||||
url = notifyapi_json[str(row[5])]['notify_url'] + '×tamp=' + str(timestamp) + '&sign=' + md5signstr
|
||||
req = urllib.request.Request(url)
|
||||
data = urllib.request.urlopen(req).read()
|
||||
info(str(data))
|
||||
jsonobj = json.loads(data)
|
||||
if jsonobj['errcode'] != 0:
|
||||
return False
|
||||
confirmOneOrder(orderid)
|
||||
info('sendNotify end')
|
||||
return True
|
||||
except Exception as e:
|
||||
print('sendOneOrder error:' + e)
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
return False
|
||||
|
||||
def sendNotify(conf, sendtime):
|
||||
@ -114,6 +143,7 @@ def sendNotify(conf, sendtime):
|
||||
break
|
||||
except Exception as e:
|
||||
info('sendNotify error: ' + str(e))
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
|
||||
#进入下一次循环
|
||||
if len(confirmed_order_list) > 0:
|
||||
|
Loading…
x
Reference in New Issue
Block a user