Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -132,7 +132,7 @@ def pay(auth_id):
|
|
132 |
if resultCode == 2323:
|
133 |
return f"✅缴费成功 {fee}元"
|
134 |
elif resultCode == 3138:
|
135 |
-
return f"
|
136 |
elif resultCode == 0:
|
137 |
return f"❌支付码已经使用 {fee}元"
|
138 |
else:
|
@@ -140,9 +140,10 @@ def pay(auth_id):
|
|
140 |
|
141 |
|
142 |
else:
|
143 |
-
return "
|
144 |
except Exception as e:
|
145 |
print("异常>>>>>>>>>>>问题原因:",e )
|
|
|
146 |
|
147 |
|
148 |
|
@@ -169,10 +170,34 @@ for k,v in enumerate(authorization_list):
|
|
169 |
|
170 |
|
171 |
history = []
|
172 |
-
def gradio_baoneng(auth_id):
|
173 |
-
pay_result = pay(auth_id)
|
174 |
-
history.append([str((datetime.now()+ timedelta(hours=6)).strftime("%Y-%m-%d %H:%M:%S")) , str(pay_result) ,str(auth_id) ])
|
175 |
-
return history
|
176 |
|
177 |
-
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
if resultCode == 2323:
|
133 |
return f"✅缴费成功 {fee}元"
|
134 |
elif resultCode == 3138:
|
135 |
+
return f"❌请求频繁系统拒绝 {fee}元"
|
136 |
elif resultCode == 0:
|
137 |
return f"❌支付码已经使用 {fee}元"
|
138 |
else:
|
|
|
140 |
|
141 |
|
142 |
else:
|
143 |
+
return "🈲无法查询到车辆入场信息"
|
144 |
except Exception as e:
|
145 |
print("异常>>>>>>>>>>>问题原因:",e )
|
146 |
+
return "🚫请求异常"
|
147 |
|
148 |
|
149 |
|
|
|
170 |
|
171 |
|
172 |
history = []
|
|
|
|
|
|
|
|
|
173 |
|
174 |
+
with gr.Blocks() as demo:
|
175 |
+
|
176 |
+
query_button = gr.Button("查询")
|
177 |
+
@query_button.click(inputs=None, outputs= gr.Json(label="查询结果"))
|
178 |
+
def query_click():
|
179 |
+
authorization = authorization_list[0]
|
180 |
+
# print("authorization:",authorization)
|
181 |
+
first_results = request_first(authorization)
|
182 |
+
third_no,fee,begin,duration,user_id = first_results
|
183 |
+
|
184 |
+
return {"费用":fee,"入场时间":begin,"时长":duration}
|
185 |
+
|
186 |
+
|
187 |
+
|
188 |
+
|
189 |
+
# 输入组件:单选按钮
|
190 |
+
auth_id = gr.Radio(radio_num, label="选择授权ID")
|
191 |
+
# 输出组件:文本和 DataFrame
|
192 |
+
output = gr.Dataframe(headers=["支付时间", "支付结果", "使用ID"], label="支付历史")
|
193 |
+
|
194 |
+
# 支付按钮组件
|
195 |
+
pay_button = gr.Button("支付")
|
196 |
+
@pay_button.click(inputs=auth_id, outputs= output)
|
197 |
+
def pay_click(auth_id):
|
198 |
+
pay_result = pay(auth_id)
|
199 |
+
history.append([str((datetime.now()+ timedelta(hours=6)).strftime("%Y-%m-%d %H:%M:%S")) , str(pay_result) ,str(auth_id) ])
|
200 |
+
return history
|
201 |
+
|
202 |
+
|
203 |
+
demo.launch(auth=("admin", "eyJ0eXAiOiJKV1QiLCJhbGciOiJUzI1NiIsI"))
|