原版
This commit is contained in:
parent
4017ff3998
commit
438819183e
@ -109,6 +109,9 @@ RUN apt-get update && \
|
||||
libxfixes3 \
|
||||
xdg-utils \
|
||||
chromium \
|
||||
xvfb \
|
||||
x11vnc \
|
||||
fluxbox \
|
||||
# OpenCV运行时依赖
|
||||
libgl1 \
|
||||
libglib2.0-0 \
|
||||
|
||||
19
README.md
19
README.md
@ -1337,25 +1337,6 @@ docker run -d -p 8080:8080 --restart always \
|
||||
-v $PWD/xianyu-auto-reply/:/app/data/ \
|
||||
--name xianyu-auto-reply \
|
||||
zhinianblog/xianyu-auto-reply:latest
|
||||
|
||||
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-t your-username/xianyu-auto-reply:latest \
|
||||
-t your-username/xianyu-auto-reply:2.2.0 \
|
||||
--push \
|
||||
.
|
||||
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-t wangli648438/xianyu-auto-reply:latest \
|
||||
--push \
|
||||
.
|
||||
|
||||
docker run -d -p 8083:8080 --restart always \
|
||||
-v /opt/1panel/apps/xianyu-auto-reply/:/app/data/ \
|
||||
--name xianyu-auto-reply \
|
||||
wangli648438/xianyu-auto-reply:latest
|
||||
```
|
||||
|
||||
**验证多架构镜像**:
|
||||
|
||||
@ -493,6 +493,17 @@ class XianyuLive:
|
||||
if expired_deliveries:
|
||||
cleaned_total += len(expired_deliveries)
|
||||
logger.warning(f"【{self.cookie_id}】清理了 {len(expired_deliveries)} 个过期发货记录")
|
||||
|
||||
# 清理过期的已发货记录(与发货冷却保持一致)
|
||||
expired_sent_orders = [
|
||||
order_id for order_id, sent_time in self.delivery_sent_orders.items()
|
||||
if current_time - sent_time > max_delivery_age
|
||||
]
|
||||
for order_id in expired_sent_orders:
|
||||
del self.delivery_sent_orders[order_id]
|
||||
if expired_sent_orders:
|
||||
cleaned_total += len(expired_sent_orders)
|
||||
logger.warning(f"【{self.cookie_id}】清理了 {len(expired_sent_orders)} 个已发货记录")
|
||||
|
||||
# 清理过期的订单确认记录(保留30分钟内的)
|
||||
max_confirm_age = 1800 # 30分钟
|
||||
@ -509,7 +520,9 @@ class XianyuLive:
|
||||
# 只有实际清理了内容才记录总数日志
|
||||
if cleaned_total > 0:
|
||||
logger.info(f"【{self.cookie_id}】实例缓存清理完成,共清理 {cleaned_total} 条记录")
|
||||
logger.warning(f"【{self.cookie_id}】当前缓存数量 - 通知: {len(self.last_notification_time)}, 发货: {len(self.last_delivery_time)}, 确认: {len(self.confirmed_orders)}")
|
||||
logger.warning(
|
||||
f"【{self.cookie_id}】当前缓存数量 - 通知: {len(self.last_notification_time)}, 发货: {len(self.last_delivery_time)}, 已发货: {len(self.delivery_sent_orders)}, 确认: {len(self.confirmed_orders)}"
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"【{self.cookie_id}】清理实例缓存时出错: {self._safe_str(e)}")
|
||||
@ -680,8 +693,8 @@ class XianyuLive:
|
||||
self.confirmed_orders = {} # 记录已确认发货的订单,防止重复确认
|
||||
self.order_confirm_cooldown = 600 # 10分钟内不重复确认同一订单
|
||||
|
||||
# 自动发货已发送订单记录
|
||||
self.delivery_sent_orders = set() # 记录已发货的订单ID,防止重复发货
|
||||
# 自动发货已发送订单记录(存时间戳便于清理)
|
||||
self.delivery_sent_orders = {} # {order_id: timestamp}
|
||||
|
||||
self.session = None # 用于API调用的aiohttp session
|
||||
|
||||
@ -823,7 +836,10 @@ class XianyuLive:
|
||||
|
||||
def mark_delivery_sent(self, order_id: str):
|
||||
"""标记订单已发货"""
|
||||
self.delivery_sent_orders.add(order_id)
|
||||
current_time = time.time()
|
||||
self.delivery_sent_orders[order_id] = current_time
|
||||
# 同步更新冷却时间记录,避免重复发货
|
||||
self.last_delivery_time[order_id] = current_time
|
||||
logger.info(f"【{self.cookie_id}】订单 {order_id} 已标记为发货")
|
||||
|
||||
# 更新订单状态为已发货
|
||||
@ -864,16 +880,27 @@ class XianyuLive:
|
||||
await asyncio.sleep(delay_seconds)
|
||||
|
||||
# 检查锁是否仍然存在且需要释放
|
||||
if lock_key in self._lock_hold_info:
|
||||
lock_info = self._lock_hold_info[lock_key]
|
||||
lock_info = self._lock_hold_info.get(lock_key)
|
||||
if lock_info:
|
||||
current_task = asyncio.current_task()
|
||||
lock_task = lock_info.get('task')
|
||||
if lock_task is not None and lock_task is not current_task:
|
||||
logger.info(f"【{self.cookie_id}】订单锁 {lock_key} 延迟释放被新任务接管,跳过清理")
|
||||
return
|
||||
|
||||
if lock_info.get('locked', False):
|
||||
# 释放锁
|
||||
lock_info['locked'] = False
|
||||
lock_info['release_time'] = time.time()
|
||||
logger.info(f"【{self.cookie_id}】订单锁 {lock_key} 延迟释放完成")
|
||||
|
||||
# 清理锁信息(可选,也可以保留用于统计)
|
||||
# del self._lock_hold_info[lock_key]
|
||||
# 清理锁信息与关联结构,避免内存增长
|
||||
lock_info['task'] = None
|
||||
self._lock_hold_info.pop(lock_key, None)
|
||||
self._lock_usage_times.pop(lock_key, None)
|
||||
order_lock = self._order_locks.get(lock_key)
|
||||
if order_lock and not order_lock.locked():
|
||||
self._order_locks.pop(lock_key, None)
|
||||
|
||||
except asyncio.CancelledError:
|
||||
logger.info(f"【{self.cookie_id}】订单锁 {lock_key} 延迟释放任务被取消")
|
||||
@ -4442,6 +4469,7 @@ class XianyuLive:
|
||||
spec_value=spec_value,
|
||||
quantity=quantity,
|
||||
amount=amount,
|
||||
order_status='processing',
|
||||
cookie_id=self.cookie_id
|
||||
)
|
||||
|
||||
@ -7472,7 +7500,7 @@ class XianyuLive:
|
||||
item_id = f"auto_{user_id}_{int(time.time())}"
|
||||
# 处理订单状态消息
|
||||
try:
|
||||
logger.info(message)
|
||||
logger.info(f"【{self.cookie_id}】🔍 完整消息结构: {message}")
|
||||
msg_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||
|
||||
# 安全地检查订单状态
|
||||
|
||||
@ -1 +1 @@
|
||||
v1.0.5
|
||||
v1.0.6
|
||||
|
||||
28
消息内容记录.txt
Normal file
28
消息内容记录.txt
Normal file
@ -0,0 +1,28 @@
|
||||
地椒userId:450737657, 半夏userId:57023109509
|
||||
|
||||
客户打开聊天对话框/点击文本输入框
|
||||
{'1': [{'1': '57023109509@goofish', '2': 1, '3': 1, '4': '2045669855@goofish'}]}
|
||||
客户的输入框有内容,未发送
|
||||
{'1': [{'1': '57023109509@goofish', '2': 1, '3': 0, '4': '2045669855@goofish'}]}
|
||||
|
||||
卖家查看聊天记录
|
||||
{'1': '57023109509@goofish', '2': 1, '3': '3921113331165.PNM', '4': 1768016480484}
|
||||
{'1': '57023109509@goofish', '2': 1, '3': '3915318906969.PNM', '4': 1768018329103}
|
||||
解析:1为卖家的会话ID,4为毫秒时间戳
|
||||
|
||||
卖家查看聊天记录(表情)
|
||||
{'1': ['3921495719878.PNM'], '2': 2, '3': '57023109509@goofish', '4': 1, '5': 1768017747767}
|
||||
{'1': ['3915318906969.PNM'], '2': 2, '3': '57023109509@goofish', '4': 1, '5': 1768018329176}
|
||||
{'1': '3906494962741.PNM', '2': 1, '3': 0, '4': '57023109509@goofish', '5': 1, '6': 1768017747811}
|
||||
|
||||
|
||||
客户发送聊天消息
|
||||
{'1': {'1': {'1': '450737657@goofish'}, '2': '57023109509@goofish', '3': '3921495719878.PNM', '4': 0, '5': 1768017153964, '6': {'1': 101, '3': {'1': '', '2': '[破涕为笑]', '3': '', '4': 1, '5': '{"atUsers":[],"contentType":1,"text":{"text":"[破涕为笑]"}}'}}, '7': 2, '8': 1, '9': 0, '10': {'_appVersion': '7.24.50', '_platform': 'ios', 'bizTag': '{"sourceId":"S:1","messageId":"04d13d410c304726a356bef3287ec553"}', 'clientIp': '117.176.241.206', 'detailNotice': '[破涕为笑]', 'extJson': '{"quickReply":"1","utdid":"Y5265DtqKEgDAGtrJGK4X72Z","messageId":"04d13d410c304726a356bef3287ec553","umidToken":"9S0BVrpLPIuWWRKbocGda0AvHieOuiby","tag":"u"}', 'port': '52152', 'reminderContent': '[破涕为笑]', 'reminderNotice': '发来一条新消息', 'reminderTitle': '林城友善的地椒', 'reminderUrl': 'fleamarket://message_chat?itemId=1009754769175&peerUserId=450737657&sid=57023109509&messageId=04d13d410c304726a356bef3287ec553&adv=no', 'senderUserId': '450737657', 'senderUserType': '0', 'sessionType': '1', 'umid': 'WV610493265b141c1202107c844b614af', 'umidToken': '9S0BVrpLPIuWWRKbocGda0AvHieOuiby', 'utdid': 'Y5265DtqKEgDAGtrJGK4X72Z'}, '12': 1}, '3': {'needPush': 'true'}}
|
||||
{'1': {'1': {'1': '450737657@goofish'}, '2': '57023109509@goofish', '3': '3921303121308.PNM', '4': 0, '5': 1768018102432, '6': {'1': 101, '3': {'1': '', '2': '看看', '3': '', '4': 1, '5': '{"atUsers":[],"contentType":1,"text":{"text":"看看"}}'}}, '7': 2, '8': 1, '9': 0, '10': {'_appVersion': '7.24.50', '_platform': 'ios', 'bizTag': '{"sourceId":"S:1","messageId":"9465a2f65c03437f9bbec3dd9c140acb"}', 'clientIp': '117.176.241.206', 'detailNotice': '看看', 'extJson': '{"quickReply":"1","utdid":"Y5265DtqKEgDAGtrJGK4X72Z","messageId":"9465a2f65c03437f9bbec3dd9c140acb","umidToken":"9S0BVrpLPIuWWRKbocGda0AvHieOuiby","tag":"u"}', 'port': '52152', 'reminderContent': '看看', 'reminderNotice': '发来一条新消息', 'reminderTitle': '林城友善的地椒', 'reminderUrl': 'fleamarket://message_chat?itemId=1009754769175&peerUserId=450737657&sid=57023109509&messageId=9465a2f65c03437f9bbec3dd9c140acb&adv=no', 'senderUserId': '450737657', 'senderUserType': '0', 'sessionType': '1', 'umid': 'WV610493265b141c1202107c844b614af', 'umidToken': '9S0BVrpLPIuWWRKbocGda0AvHieOuiby', 'utdid': 'Y5265DtqKEgDAGtrJGK4X72Z'}, '12': 1}, '3': {'needPush': 'true'}}
|
||||
{'1': {'1': {'1': '450737657@goofish'}, '2': '57023109509@goofish', '3': '3915318906969.PNM', '4': 0, '5': 1768018292341, '6': {'1': 101, '3': {'1': '', '2': '看看', '3': '', '4': 1, '5': '{"atUsers":[],"contentType":1,"text":{"text":"看看"}}'}}, '7': 2, '8': 1, '9': 0, '10': {'_appVersion': '7.24.50', '_platform': 'ios', 'bizTag': '{"sourceId":"S:1","messageId":"08a707daf2534e46934c6518ed93ebdb"}', 'clientIp': '117.176.241.206', 'detailNotice': '看看', 'extJson': '{"quickReply":"1","utdid":"Y5265DtqKEgDAGtrJGK4X72Z","messageId":"08a707daf2534e46934c6518ed93ebdb","umidToken":"9S0BVrpLPIuWWRKbocGda0AvHieOuiby","tag":"u"}', 'port': '52152', 'reminderContent': '看看', 'reminderNotice': '发来一条新消息', 'reminderTitle': '林城友善的地椒', 'reminderUrl': 'fleamarket://message_chat?itemId=1009754769175&peerUserId=450737657&sid=57023109509&messageId=08a707daf2534e46934c6518ed93ebdb&adv=no', 'senderUserId': '450737657', 'senderUserType': '0', 'sessionType': '1', 'umid': 'WV610493265b141c1202107c844b614af', 'umidToken': '9S0BVrpLPIuWWRKbocGda0AvHieOuiby', 'utdid': 'Y5265DtqKEgDAGtrJGK4X72Z'}, '12': 1}, '3': {'needPush': 'true'}}
|
||||
|
||||
|
||||
{'1': {'1': {'1': '450737657@goofish'}, '2': '57023109509@goofish', '3': '3915344790885.PNM', '4': 0, '5': 1768018563236, '6': {'1': 101, '3': {'1': '', '2': '[我已拍下,待付款]', '3': '', '4': 26, '5': '{"contentType":26,"dxCard":{"item":{"main":{"clickParam":{"arg1":"MsgCard","args":{"task_id":"3exQJHOTmPU1","source":"im","msg_id":"d04a5d39c5ce447abe1da120faf309ef"}},"exContent":{"bgColor":"#FFFFFF","button":{"bgColor":"#FFE60F","borderColor":"#FFE60F","clickParam":{"arg1":"MsgCardAction","args":{"task_id":"3exQJHOTmPU1","source":"im","button_text":"修改价格","msg_id":"d04a5d39c5ce447abe1da120faf309ef"}},"fontColor":"#333333","targetUrl":"fleamarket://adjust_price?flutter=true&bizOrderId=3175042225795735776","text":"修改价格"},"desc":"请双方沟通及时确认价格","descColor":"#A3A3A3","title":"我已拍下,待付款","upgrade":{"targetUrl":"https://h5.m.goofish.com/app/idleFish-F2e/fm-downlaod/home.html?noRedriect=true&canBack=true&checkVersion=true","version":"7.7.90"}},"targetUrl":"fleamarket://order_detail?id=3175042225795735776&role=seller"}},"template":{"name":"idlefish_message_trade_chat_card","url":"https://dinamicx.alibabausercontent.com/pub/idlefish_message_trade_chat_card/1667222052767/idlefish_message_trade_chat_card.zip","version":"1667222052767"}}}'}}, '7': 1, '8': 1, '9': 0, '10': {'bizTag': '{"sourceId":"C2C:3exQJHOTmPU1","taskName":"已拍下_未付款_卖家","materialId":"3exQJHOTmPU1","taskId":"3exQJHOTmPU1"}', 'closePushReceiver': 'false', 'closeUnreadNumber': 'false', 'detailNotice': '[我已拍下,待付款]', 'extJson': '{"msgArgs":{"task_id":"3exQJHOTmPU1","source":"im","msg_id":"d04a5d39c5ce447abe1da120faf309ef"},"quickReply":"1","msgArg1":"MsgCard","updateKey":"57023109509:3175042225795735776:1_not_pay_seller","messageId":"d04a5d39c5ce447abe1da120faf309ef","multiChannel":{"huawei":"EXPRESS","xiaomi":"108000","oppo":"EXPRESS","honor":"NORMAL","agoo":"product","vivo":"ORDER"},"contentType":"26","correlationGroupId":"3exQJHOTmPU1_FFr4GOSn8OQo"}', 'receiver': '2045669855', 'redReminder': '等待买家付款', 'redReminderStyle': '1', 'reminderContent': '[我已拍下,待付款]', 'reminderNotice': '买家已拍下,待付款', 'reminderTitle': '买家已拍下,待付款', 'reminderUrl': 'fleamarket://message_chat?itemId=1009754769175&peerUserId=450737657&sid=57023109509&messageId=d04a5d39c5ce447abe1da120faf309ef&adv=no', 'senderUserId': '450737657', 'senderUserType': '0', 'sessionType': '1', 'updateHead': 'true'}, '12': 1}, '3': {'needPush': 'true'}}
|
||||
|
||||
客户付款成功
|
||||
{'1': '57023109509@goofish', '2': 1, '3': {'redReminder': '等待卖家发货', 'redReminderStyle': '1'}, '4': 1768019610705}
|
||||
Loading…
Reference in New Issue
Block a user