mirror of
https://github.com/zhinianboke/xianyu-auto-reply.git
synced 2025-08-02 04:27:36 +08:00
修复自动点确认发货的bug
This commit is contained in:
parent
9f296164ad
commit
cbdd8de61a
@ -78,7 +78,7 @@ xianyu-auto-reply/
|
|||||||
│ ├── ai_reply_engine.py # AI智能回复引擎
|
│ ├── ai_reply_engine.py # AI智能回复引擎
|
||||||
│ ├── file_log_collector.py # 日志收集和管理
|
│ ├── file_log_collector.py # 日志收集和管理
|
||||||
│ ├── config.py # 配置文件管理
|
│ ├── config.py # 配置文件管理
|
||||||
│ └── secure_confirm_ultra.py # 自动确认发货模块(加密保护)
|
│ └── secure_confirm_ultra.py # 自动确认发货模块(超级加密保护)
|
||||||
├── 🛠️ 工具模块
|
├── 🛠️ 工具模块
|
||||||
│ └── utils/
|
│ └── utils/
|
||||||
│ ├── xianyu_utils.py # 闲鱼API工具函数
|
│ ├── xianyu_utils.py # 闲鱼API工具函数
|
||||||
@ -270,7 +270,7 @@ docker rm -f xianyu-auto-reply
|
|||||||
|
|
||||||
### 🤖 智能功能模块
|
### 🤖 智能功能模块
|
||||||
- **`ai_reply_engine.py`** - AI智能回复引擎,支持多种AI模型
|
- **`ai_reply_engine.py`** - AI智能回复引擎,支持多种AI模型
|
||||||
- **`secure_confirm_ultra.py`** - 自动确认发货模块(加密保护)
|
- **`secure_confirm_ultra.py`** - 自动确认发货模块(超级加密保护)
|
||||||
- **`file_log_collector.py`** - 日志收集和管理,提供实时日志查看
|
- **`file_log_collector.py`** - 日志收集和管理,提供实时日志查看
|
||||||
|
|
||||||
### 🛠️ 工具模块
|
### 🛠️ 工具模块
|
||||||
|
@ -530,7 +530,7 @@ class XianyuLive:
|
|||||||
|
|
||||||
async def get_item_info(self, item_id, retry_count=0):
|
async def get_item_info(self, item_id, retry_count=0):
|
||||||
"""获取商品信息,自动处理token失效的情况"""
|
"""获取商品信息,自动处理token失效的情况"""
|
||||||
if retry_count >= 3: # 最多重试3次
|
if retry_count >= 4: # 最多重试3次
|
||||||
logger.error("获取商品信息失败,重试次数过多")
|
logger.error("获取商品信息失败,重试次数过多")
|
||||||
return {"error": "获取商品信息失败,重试次数过多"}
|
return {"error": "获取商品信息失败,重试次数过多"}
|
||||||
|
|
||||||
@ -596,6 +596,23 @@ class XianyuLive:
|
|||||||
) as response:
|
) as response:
|
||||||
res_json = await response.json()
|
res_json = await response.json()
|
||||||
|
|
||||||
|
# 检查并更新Cookie
|
||||||
|
if 'set-cookie' in response.headers:
|
||||||
|
new_cookies = {}
|
||||||
|
for cookie in response.headers.getall('set-cookie', []):
|
||||||
|
if '=' in cookie:
|
||||||
|
name, value = cookie.split(';')[0].split('=', 1)
|
||||||
|
new_cookies[name.strip()] = value.strip()
|
||||||
|
|
||||||
|
# 更新cookies
|
||||||
|
if new_cookies:
|
||||||
|
self.cookies.update(new_cookies)
|
||||||
|
# 生成新的cookie字符串
|
||||||
|
self.cookies_str = '; '.join([f"{k}={v}" for k, v in self.cookies.items()])
|
||||||
|
# 更新数据库中的Cookie
|
||||||
|
await self.update_config_cookies()
|
||||||
|
logger.debug("已更新Cookie到数据库")
|
||||||
|
|
||||||
logger.debug(f"商品信息获取成功: {res_json}")
|
logger.debug(f"商品信息获取成功: {res_json}")
|
||||||
# 检查返回状态
|
# 检查返回状态
|
||||||
if isinstance(res_json, dict):
|
if isinstance(res_json, dict):
|
||||||
@ -603,10 +620,7 @@ class XianyuLive:
|
|||||||
# 检查ret是否包含成功信息
|
# 检查ret是否包含成功信息
|
||||||
if not any('SUCCESS::调用成功' in ret for ret in ret_value):
|
if not any('SUCCESS::调用成功' in ret for ret in ret_value):
|
||||||
logger.warning(f"商品信息API调用失败,错误信息: {ret_value}")
|
logger.warning(f"商品信息API调用失败,错误信息: {ret_value}")
|
||||||
# 处理响应中的Set-Cookie
|
|
||||||
if 'Set-Cookie' in response.headers:
|
|
||||||
logger.debug("检测到Set-Cookie,需要更新cookie")
|
|
||||||
# TODO: 实现cookie更新逻辑
|
|
||||||
await asyncio.sleep(0.5)
|
await asyncio.sleep(0.5)
|
||||||
return await self.get_item_info(item_id, retry_count + 1)
|
return await self.get_item_info(item_id, retry_count + 1)
|
||||||
else:
|
else:
|
||||||
@ -1077,7 +1091,7 @@ class XianyuLive:
|
|||||||
async def auto_confirm(self, order_id, retry_count=0):
|
async def auto_confirm(self, order_id, retry_count=0):
|
||||||
"""自动确认发货 - 使用加密模块"""
|
"""自动确认发货 - 使用加密模块"""
|
||||||
try:
|
try:
|
||||||
# 导入超级混淆模块
|
# 导入超级混淆加密模块
|
||||||
from secure_confirm_ultra import SecureConfirm
|
from secure_confirm_ultra import SecureConfirm
|
||||||
|
|
||||||
# 创建加密确认实例
|
# 创建加密确认实例
|
||||||
@ -1274,7 +1288,7 @@ class XianyuLive:
|
|||||||
|
|
||||||
async def _get_api_card_content(self, rule, retry_count=0):
|
async def _get_api_card_content(self, rule, retry_count=0):
|
||||||
"""调用API获取卡券内容,支持重试机制"""
|
"""调用API获取卡券内容,支持重试机制"""
|
||||||
max_retries = 3
|
max_retries = 4
|
||||||
|
|
||||||
if retry_count >= max_retries:
|
if retry_count >= max_retries:
|
||||||
logger.error(f"API调用失败,已达到最大重试次数({max_retries})")
|
logger.error(f"API调用失败,已达到最大重试次数({max_retries})")
|
||||||
@ -2531,7 +2545,7 @@ class XianyuLive:
|
|||||||
page_size (int): 每页数量,默认20
|
page_size (int): 每页数量,默认20
|
||||||
retry_count (int): 重试次数,内部使用
|
retry_count (int): 重试次数,内部使用
|
||||||
"""
|
"""
|
||||||
if retry_count >= 3: # 最多重试3次
|
if retry_count >= 4: # 最多重试3次
|
||||||
logger.error("获取商品信息失败,重试次数过多")
|
logger.error("获取商品信息失败,重试次数过多")
|
||||||
return {"error": "获取商品信息失败,重试次数过多"}
|
return {"error": "获取商品信息失败,重试次数过多"}
|
||||||
|
|
||||||
@ -2603,6 +2617,23 @@ class XianyuLive:
|
|||||||
) as response:
|
) as response:
|
||||||
res_json = await response.json()
|
res_json = await response.json()
|
||||||
|
|
||||||
|
# 检查并更新Cookie
|
||||||
|
if 'set-cookie' in response.headers:
|
||||||
|
new_cookies = {}
|
||||||
|
for cookie in response.headers.getall('set-cookie', []):
|
||||||
|
if '=' in cookie:
|
||||||
|
name, value = cookie.split(';')[0].split('=', 1)
|
||||||
|
new_cookies[name.strip()] = value.strip()
|
||||||
|
|
||||||
|
# 更新cookies
|
||||||
|
if new_cookies:
|
||||||
|
self.cookies.update(new_cookies)
|
||||||
|
# 生成新的cookie字符串
|
||||||
|
self.cookies_str = '; '.join([f"{k}={v}" for k, v in self.cookies.items()])
|
||||||
|
# 更新数据库中的Cookie
|
||||||
|
await self.update_config_cookies()
|
||||||
|
logger.debug("已更新Cookie到数据库")
|
||||||
|
|
||||||
logger.info(f"商品信息获取响应: {res_json}")
|
logger.info(f"商品信息获取响应: {res_json}")
|
||||||
|
|
||||||
# 检查响应是否成功
|
# 检查响应是否成功
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user