Files
37duAutomation/plugins/XQ0001-0100/XQ0047 微盟数据导出/config/__init__.py
T
puddy a2f4e756ae feat: 更新3个插件版本并优化XQ0006考勤异常处理逻辑
- XQ0036门店员工起调薪处理:版本升至0.1.6,优化纳税单位解析逻辑,优先使用接口返回值,新增金色印象、金色湖畔、后浪会馆的纳税单位兜底规则
- XQ0047微盟数据导出:版本升至1.0.5,新增等待生成上限配置项,优化轮询超时处理逻辑
- XQ0006 EHR系统周考勤异常处理:版本升至1.4.1,重构推送逻辑,支持组织架构范围选择,新增dws推送通道,优化自动确认范围为整月轻微异常,新增组织架构同步功能
2026-11-20 13:41:03 +08:00

136 lines
5.3 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_TIMEOUT_MIN = 180 # 等待导出任务生成的默认上限(分钟),界面「等待上限」可覆盖
POLL_TIMEOUT_LIMITS = (5, 720) # 等待上限允许范围(分钟):5 分钟 ~ 12 小时
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()