Files
37duAutomation/plugins/xq0047/config/__init__.py
T
puddy 843ff244a6 feat: 新增多插件 UI 支持及运行日志集中回传功能
本次提交包含多项功能更新:
1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持
2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储
3. 新增插件分类字段支持,用于场景库分组管理
4. 优化 xq0034/0037/0048 等插件的功能及描述
5. 修复控制面响应兼容问题,支持新旧版本数据格式
6. 新增 xq0033 插件的状态存储模块,用于历史记录管理
7. 优化 CRM 登录窗口模式,支持全屏置顶
2026-10-26 15:42:50 +08:00

135 lines
5.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""xq0047 微盟数据导出 插件 - 配置常量与全局钩子。
插件自包含:本包只依赖 Python 标准库 / 第三方库 / 底座注入的 RunContext。
业务模块统一经 config.log() 输出日志(转发到 ctx.log,无 ctx 时回落到 print)。
商家标识默认内置金色印象账号值(与原影刀流程一致),其他账号需改本文件常量。
"""
import os
import ctypes
from pathlib import Path
# ==================== 微盟平台 ====================
LOGIN_URL = 'https://account.weimob.com/login.html'
SUCCESS_KEYWORD = 'master.weimob.com/bos/products/home'
ORDER_LIST_URL = ("https://master.weimob.com/bos/products/ecOrder/4022571268153/"
"4sidacmmkX1q2pyt1eX4sinvqste/order/order/orderlist")
QUERY_LIST_URL = "https://master.weimob.com/api3/mall/mgr/order/queryOrderList"
EXPORT_URL = "https://master.weimob.com/api3/mall/mgr/order/exportOrder"
DOWNLOAD_LIST_URL = "https://master.weimob.com/api3/merchant/backstage/service/download/list"
# 导出模块要求的页面路由头(缺失会被鉴权拒绝)
X_PAGE_ROUTE = ("/bos/products/ecOrder/4022571268153/"
"4sidacmmkX1q2pyt1eX4sinvqste/order/order/orderlist")
X_AGGS_ROUTE = "products/ecOrder/4sidacmmkX1q2pyt1eX4sinvqste/order/order/orderlist"
REFER_EXTEND = "/bos/products/ecOrder/{bosId}/{key}/order/order/orderlist"
# ==================== 商家配置(金色印象,其他账号改这里) ====================
BOS_ID = '4022571268153'
MERCHANT_ID = 2000527625153
VID = 6017432629153
PRODUCT_ID = 145
PRODUCT_VERSION_ID = '12010'
PRODUCT_INSTANCE_ID = 22515052153
TCODE = 'weimob'
# ==================== 输出与切分配置 ====================
FILE_PREFIX = '微盟订单' # 最终文件名前缀
SEG_TARGET = 45000 # 单段目标订单数(接口 Excel 上限 5w,留约 10% 明细行余量)
MIN_SPLIT_MS = 3600 * 1000 # 最小细分粒度(1 小时):到该粒度仍超限则直接导出尝试
INTERVAL_MIN = 3 # 请求间限流下限(秒)
INTERVAL_MAX = 5 # 请求间限流上限(秒,随机化模拟人工节奏,降低风控触发)
# ==================== 运行参数(项目规范:全局重试3次) ====================
RETRY_MAX = 3 # 单段 exportOrder 最大重试次数
POLL_MAX = 180 # 统一轮询 download/list 最大次数(180×10s ≈ 30 分钟)
POLL_INTERVAL = 10 # 轮询间隔(秒)
DOWNLOAD_WORKERS = 4 # 并发下载线程数
TIMEOUT = 25 # 接口请求超时(秒)
DOWNLOAD_TIMEOUT = 180 # 文件下载超时(秒)
HEADER_ROWS = 1 # 导出 xlsx 表头行数(合并时跳过,后续追加数据)
# ==================== 登录参数 ====================
LOGIN_WAIT = 180 # 登录等待总时长(秒):含人工处理腾讯验证码的时间
HEADLESS = False # 微盟登录需人工兜底验证码,必须可见浏览器
# ==================== 共享路径 ====================
def _app_data_dir():
return os.path.join(
os.environ.get('LOCALAPPDATA') or os.environ.get('APPDATA') or os.path.expanduser('~'),
'37duAutomation')
SESSIONS_DIR = os.path.join(_app_data_dir(), '.sessions')
COOKIE_FILE = os.path.join(SESSIONS_DIR, 'weimob_cookies.json') # 与影刀版共用,可互相复用
TOKEN_FILE = os.path.join(SESSIONS_DIR, 'weimob_tokens.json')
def get_desktop():
"""获取真实桌面路径,适配 OneDrive 等重定向的不同电脑。"""
try:
from ctypes import wintypes
guid = wintypes.GUID(
data1=0xB4BFCC3A, data2=0xDB2C, data3=0x424C,
data4=(0xB0, 0x29, 0x7F, 0xE9, 0x9A, 0x87, 0xC6, 0x41))
func = ctypes.windll.shell32.SHGetKnownFolderPath
func.argtypes = [wintypes.GUID, wintypes.DWORD, wintypes.HANDLE,
ctypes.POINTER(ctypes.c_wchar_p)]
ptr = ctypes.c_wchar_p()
func(ctypes.byref(guid), 0, None, ctypes.byref(ptr))
return ptr.value
except Exception:
return str(Path.home() / 'Desktop')
def default_output_dir():
"""默认输出目录:桌面/微盟订单导出。"""
return os.path.join(get_desktop(), '微盟订单导出')
def get_browser_profile_dir():
"""独立固定浏览器用户目录:登录态跨次保留(免重复验证码),不占用日常 Chrome 配置。"""
return os.path.join(_app_data_dir(), 'browser_sessions', 'xq0047')
# ==================== 全局钩子(run() 启动时注入) ====================
_log = None
def set_log(fn):
"""注入 ctx.log(RunContext.log),各模块经 log()/logger 输出。"""
global _log
_log = fn
def log(msg, level="INFO"):
if _log:
_log(str(msg), level)
else:
print(f"[{level}] {msg}")
class _ModuleLogger:
"""模块级 logger 适配:统一转发到 config.log。"""
@staticmethod
def debug(msg, *args):
log(msg % args if args else msg, "DEBUG")
@staticmethod
def info(msg, *args):
log(msg % args if args else msg, "INFO")
@staticmethod
def warning(msg, *args):
log(msg % args if args else msg, "WARN")
@staticmethod
def error(msg, *args):
log(msg % args if args else msg, "ERROR")
logger = _ModuleLogger()