fix(master_node): 修复请求数据格式及添加接口返回日志

- 将请求参数由 form-data 格式改为 JSON 格式,确保接口正确接收数据
- 添加日志记录接口返回的响应内容及提交的数据,方便调试和问题排查
- 优化了加密数据的构建方式,使代码结构更清晰
This commit is contained in:
danial
2025-11-13 22:14:08 +08:00
parent d217b9df48
commit 2947beef22

View File

@@ -43,19 +43,20 @@ class MasterNodeService:
with self.single_lock:
try:
self.single_lock.acquire()
data = {
"machineId": encrypt_with_aes(
f"{machineId}:{int(time.time())}",
AESKey.load_from_base64(
"P0x6Gy6dXIpPbhE7PHxaHbfZHhsbT2qNPlx3qbHTP1o="
),
AESKey.load_from_base64("nywao1XkDXeYwbPeWh+SxA=="),
),
}
response = self.__client.post(
urljoin(
self.__address, "/api/cardInfo/appleCard/rechargeOrder/handler"
),
data={
"machineId": encrypt_with_aes(
f"{machineId}:{int(time.time())}",
AESKey.load_from_base64(
"P0x6Gy6dXIpPbhE7PHxaHbfZHhsbT2qNPlx3qbHTP1o="
),
AESKey.load_from_base64("nywao1XkDXeYwbPeWh+SxA=="),
),
},
json=data,
proxies={
"http": "",
"https": "",
@@ -65,6 +66,7 @@ class MasterNodeService:
},
timeout=30,
)
logger.info(f"接口返回数据:{response.text} 提交数据:{data}")
response_json = response.json()
except Exception as e:
logger.error(f"请求数据异常,{e}")