fix: 优化发票判断是否有票校验逻辑

This commit is contained in:
7a1dd609-d238-4580-9d5f-ee8412b0f5bc 2025-01-15 01:30:27 +08:00
parent 3bce3545fc
commit 1f5988a145

65
host.py
View File

@ -71,62 +71,23 @@ def ticket():
else:
userId = int(userId)
timestamp = int(time.time())
charge_data = charge(userId)
i = 0
while i < 10:
try:
if charge_data['userChargeList'][i]['chargeId'] == 6 and charge_data['userChargeList'][i]['stock'] == 0:
login_data = login(userId, timestamp)
if login_data['returnCode'] == 102:
returnCode = 403
status = "403 Forbidden"
info = "Unable to operate. Please refresh QrCode."
log = []
break
elif login_data['returnCode'] == 100:
returnCode = 403
status = "403 Forbidden"
info = "Unable to operate. Probably User has logged in."
log = []
break
elif login_data['returnCode'] == 1:
ticket_data = get_ticket(userId)
if ticket_data['returnCode'] == 0:
logout(userId, timestamp)
returnCode = 405
status = "405 Method Not Allowed"
info = "WARNING: THIS INFO SHOULD NEVER APPEARS. IF YOU SEE THIS WARNING PLEASE CONTACT Telegram@sasakure. Unable to operate. Successfully Logged in. Probably User has had one ticket."
log = {"UserLoginApiStatus": 1, "UserLogoutApiStatus": 1}
break
elif ticket_data['returnCode'] == 1:
logout(userId, timestamp)
returnCode = 200
status = "200 OK"
info = "Succeed."
log = {"UserLoginApiStatus": 1, "UpsertUserChargelogStatus": 1, "UserLogoutApiStatus": 1}
break
elif charge_data['userChargeList'][i]['chargeId'] == 6 and charge_data['userChargeList'][i]['stock'] == 1:
if '{"chargeId": 6, "stock": 1' in json.dumps(charge(userId)):
returnCode = 403
status = "403 Forbidden"
info = "User has had a ticket."
log = []
break
log = {}
else:
i = i + 1
except IndexError:
login_data = login(userId, timestamp)
if login_data['returnCode'] == 102:
returnCode = 403
status = "403 Forbidden"
info = "Unable to operate. Please refresh QrCode."
log = []
break
log = {}
elif login_data['returnCode'] == 100:
returnCode = 403
status = "403 Forbidden"
info = "Unable to operate. Probably User has logged in."
log = []
break
log = {}
elif login_data['returnCode'] == 1:
ticket_data = get_ticket(userId)
if ticket_data['returnCode'] == 0:
@ -135,20 +96,12 @@ def ticket():
status = "405 Method Not Allowed"
info = "WARNING: THIS INFO SHOULD NEVER APPEARS. IF YOU SEE THIS WARNING PLEASE CONTACT Telegram@sasakure. Unable to operate. Successfully Logged in. Probably User has had one ticket."
log = {"UserLoginApiStatus": 1, "UserLogoutApiStatus": 1}
break
elif ticket_data['returnCode'] == 1:
logout(userId, timestamp)
returnCode = 200
status = "200 OK"
info = "Succeed."
log = {"UserLoginApiStatus": 1, "UpsertUserChargelogStatus": 1, "UserLogoutApiStatus": 1}
break
else:
returnCode = 500
status = "500 Internal Server Error"
info = "Unknown Error. Failed in UserLogin"
log = login_data
break
data = jsonify({"status": status, "timestamp": timestamp, "info": info, "apiName": "ticket", "date": datetime.now(pytz.timezone('Asia/Shanghai')).strftime('%a, %d %b %Y %H:%M:%S GMT+8'), "userId": userId})
return data, returnCode
@ -165,12 +118,12 @@ def mapstock_process():
returnCode = 403
status = "403 Forbidden"
info = "Unable to operate. Please refresh QrCode."
log = []
log = {}
elif login_data['returnCode'] == 100:
returnCode = 403
status = "403 Forbidden"
info = "Unable to operate. Probably User has logged in."
log = []
log = {}
elif login_data['returnCode'] == 1:
userdata_result = userdata(userId)
logout(userId, timestamp)
@ -178,7 +131,7 @@ def mapstock_process():
returnCode = 403
status = "403 Forbidden"
info = "User has stocked 99 kilometers."
log = []
log = {}
else:
while True:
login(userId, timestamp)
@ -230,12 +183,12 @@ def music_post():
returnCode = 403
status = "403 Forbidden"
info = "Unable to operate. Please refresh QrCode."
log = []
log = {}
elif login_data['returnCode'] == 100:
returnCode = 403
status = "403 Forbidden"
info = "Unable to operate. Probably User has logged in."
log = []
log = {}
elif login_data['returnCode'] == 1:
logout(userId, timestamp)
music_data = request_data['music']