feat: 新增银行卡检查插件及相关依赖与配置文件

This commit is contained in:
2026-10-29 14:21:30 +08:00
parent 0a32518060
commit c77a26cd99
494 changed files with 66923 additions and 2714 deletions
+181
View File
@@ -0,0 +1,181 @@
# -*- coding: utf-8 -*-
"""xq0041 新美大平台核对 - 配置常量与全局钩子。
插件自包含:只依赖标准库 / 第三方库 / 底座注入的 RunContext。
各业务模块统一经 config.log() / config.progress() 输出,由 run() 启动时注入 ctx。
"""
import os
import time
# ==================== 平台:美团经营宝 ====================
HOME_URL = 'https://ecom.meituan.com/'
# 登录成功的落地页:经营宝按商家类型分流(kdb → ecom.meituan.com/meishi,
# dp → e.dianping.com/app/...)。命中任一即已登录。
BACKEND_HINTS = (
'ecom.meituan.com/meishi',
'e.dianping.com/app/',
'e.dianping.com/meishi/',
)
LOGIN_PAGE_HINT = 'bizaccount/login.html'
BIZ_CHOICE_HINT = 'bizaccount/biz-choice.html'
PASSPORT_HINTS = (
'passport.meituan.com', 'epassport.meituan.com', 'unifiedlogin', 'ssologin',
'passport.dianping.com', 'account.dianping.com/login', 'e.dianping.com/login',
)
# ==================== 打款记录(h5 账单页,iframe 内 smartBill 接口) ====================
PAYMENT_PAGE_URL = (
'https://e.dianping.com/app/merchant-platform/02a5e2f40d5d4b0'
'?iUrl=Ly9oNS5kaWFucGluZy5jb20vL2FwcC9tZXJjaGFudC1iaWxsLXN0YXRpYy9pbmRleC5odG1sIy9wYXltZW50cmVjb3Jk')
PAYMENT_LIST_API = 'https://e.dianping.com/gw/smartBill/paymentlist'
PAYMENT_DOWNLOAD_API = 'https://e.dianping.com/gw/smartBill/paymentdownload'
PAYMENT_HISTORY_API = 'https://e.dianping.com/gw/smartBill/paymenthistory'
PAYMENT_FILE_TYPE = 6 # 6 = 打款记录
PAYMENT_NAME_KEY = '打款记录'
# ==================== 收益明细(PC 商户中心 downloadManagement 接口) ====================
PROFIT_PAGE_URL = 'https://e.dianping.com/finance/web/payment/download/list'
SHOP_API = 'https://e.dianping.com/smartBill/queryAllShopIds'
PRODUCT_API = 'https://e.dianping.com/finance/ajax/downloadManagement/productCodeList'
PROFIT_REQUEST_API = 'https://e.dianping.com/finance/ajax/downloadManagement/request'
PROFIT_LIST_API = 'https://e.dianping.com/finance/ajax/downloadManagement/list'
PROFIT_LINK_API = 'https://e.dianping.com/finance/ajax/downloadManagement/downloadLink'
PROFIT_FILE_TYPE = 201 # 201 = 收益明细
# ==================== 台账 ====================
WORK_DIR = r'D:\资料\财务\新美大平台核对' # 账单 + 台账统一目录
LEDGER_GLOB = '新美大到账统计*.xlsx'
LEDGER_SHEET = '金色印象--新美大导出(收)'
STAT_SHEET = '新美大核对统计'
TIME_COL = '验券/退款/调整时间'
DETAIL_GLOB = '团购收益明细_*.xlsx'
HEADER_ROW = 2
DATA_START_ROW = 3
# 「新美大核对统计」V/W 列的外部工作簿(与台账历史 62 条链接一致)
SHARE_ROOT = r'\\caiwu01\共享文件夹\1111\TG'
LINK_BOOK = '马敏团购总表'
LINK_SHEET = '资金组取数'
# ==================== 运行参数 ====================
LOGIN_WAIT = 600 # 等待人工登录(含选商家)超时
BACKEND_STABLE = 20 # 后台页连续稳定秒数(/meishi 未登录也会停留约 20s 再跳)
SETTLE_WAIT = 8 # 登录成功后等首屏请求结束再抓 cookie
POLL_SECONDS = 2
RECORD_SECONDS = 120 # 账单生成后轮询记录的最长时间
REUSE_MAX_AGE_MIN = 10 # 账单复用时效:记录生成时间距今 ≤ N 分钟才复用
RETRY_MAX = 3
HEADLESS = False # 人工登录必须可见浏览器
# ==================== 共享路径 ====================
def _app_data_dir():
return os.path.join(
os.getenv('LOCALAPPDATA') or os.getenv('APPDATA') or os.path.expanduser('~'),
'37duAutomation')
SESSIONS_DIR = os.path.join(_app_data_dir(), '.sessions')
COOKIE_FILE = os.path.join(SESSIONS_DIR, 'meituan_cookies.json')
COOKIE_HEADER_FILE = os.path.join(SESSIONS_DIR, 'meituan_cookies_header.txt')
TOKEN_FILE = os.path.join(SESSIONS_DIR, 'meituan_tokens.json')
META_FILE = os.path.join(SESSIONS_DIR, 'meituan_session_meta.json')
def get_browser_profile_dir():
"""独立固定浏览器用户目录:登录态跨次保留,不占用日常 Chrome 配置。"""
return os.path.join(_app_data_dir(), 'browser_sessions', 'xq0041')
# ==================== 浏览器窗口(全屏 + 置顶) ====================
def apply_window_mode(page):
"""把浏览器窗口设为全屏并置顶。
登录需要人工操作(账号密码 / 短信 / 扫码 / 选商家),窗口被其它窗口遮挡或最小化时
用户容易漏看;置顶保证它一直在最前面。失败仅告警,不影响流程。
"""
try:
page.set.window.full()
except Exception as e:
log(f'设置窗口全屏失败(忽略):{e}', 'WARN')
if os.name == 'nt':
try:
_set_topmost(page.process_id)
except Exception as e:
log(f'设置窗口置顶失败(忽略):{e}', 'WARN')
def _set_topmost(pid):
"""把指定进程的主窗口设为 HWND_TOPMOST(Win32 SetWindowPos,仅 Windows)。"""
if not pid:
return
import ctypes
from ctypes import wintypes
user32 = ctypes.windll.user32
user32.IsWindowVisible.argtypes = [wintypes.HWND]
user32.GetWindowTextLengthW.argtypes = [wintypes.HWND]
user32.GetWindowThreadProcessId.argtypes = [wintypes.HWND, ctypes.POINTER(wintypes.DWORD)]
hwnds = []
@ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM)
def _collect(hwnd, _lparam):
if user32.IsWindowVisible(hwnd) and user32.GetWindowTextLengthW(hwnd) > 0:
proc = wintypes.DWORD()
user32.GetWindowThreadProcessId(hwnd, ctypes.byref(proc))
if proc.value == pid:
hwnds.append(hwnd)
return True
user32.EnumWindows.argtypes = [ctypes.WINFUNCTYPE(wintypes.BOOL, wintypes.HWND, wintypes.LPARAM),
wintypes.LPARAM]
user32.EnumWindows(_collect, 0)
user32.SetWindowPos.argtypes = [wintypes.HWND, wintypes.HWND, ctypes.c_int,
ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_uint]
for hwnd in hwnds:
user32.SetWindowPos(hwnd, wintypes.HWND(-1), 0, 0, 0, 0, 0x0001 | 0x0002) # NOSIZE | NOMOVE
# ==================== 全局钩子(run() 启动时注入) ====================
_log = None
_progress = None
_debug = False
def set_log(fn):
global _log
_log = fn
def set_progress(fn):
global _progress
_progress = fn
def set_debug(on):
global _debug
_debug = bool(on)
def debug_enabled():
return _debug
def log(msg, level='INFO'):
text = f'[{time.strftime("%H:%M:%S")}] {msg}'
if level == 'DEBUG' and not _debug:
return
if _log:
_log(str(msg), level)
else:
print(f'[{level}] {text}')
def progress(pct):
if _progress:
try:
_progress(int(pct))
except Exception:
pass