From 1f5988a145586cbad61435868b3cde7412dfef72 Mon Sep 17 00:00:00 2001 From: 7a1dd609-d238-4580-9d5f-ee8412b0f5bc <7a1dd609-d238-4580-9d5f-ee8412b0f5bc@bankofchina.com> Date: Wed, 15 Jan 2025 01:30:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=8F=91=E7=A5=A8?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E6=9C=89=E7=A5=A8=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- host.py | 119 +++++++++++++++++--------------------------------------- 1 file changed, 36 insertions(+), 83 deletions(-) diff --git a/host.py b/host.py index df031d5..34635e8 100644 --- a/host.py +++ b/host.py @@ -71,84 +71,37 @@ 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: - returnCode = 403 - status = "403 Forbidden" - info = "User has had a ticket." - log = [] - break - 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 - 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 - else: - returnCode = 500 - status = "500 Internal Server Error" - info = "Unknown Error. Failed in UserLogin" - log = login_data - break + if '{"chargeId": 6, "stock": 1' in json.dumps(charge(userId)): + returnCode = 403 + status = "403 Forbidden" + info = "User has had a ticket." + log = {} + else: + login_data = login(userId, timestamp) + if login_data['returnCode'] == 102: + returnCode = 403 + status = "403 Forbidden" + info = "Unable to operate. Please refresh QrCode." + log = {} + elif login_data['returnCode'] == 100: + returnCode = 403 + status = "403 Forbidden" + info = "Unable to operate. Probably User has logged in." + log = {} + 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} + elif ticket_data['returnCode'] == 1: + logout(userId, timestamp) + returnCode = 200 + status = "200 OK" + info = "Succeed." + log = {"UserLoginApiStatus": 1, "UpsertUserChargelogStatus": 1, "UserLogoutApiStatus": 1} 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']