Files
37duAutomation/plugins/XQ0001-0100/XQ0078 金色湖畔小程序数据导出/config/__init__.py
T
puddy 1cb972f2f6 feat(xq0078): 新增金色湖畔小程序数据导出插件(1.0.4)
- 金贵微信端管理平台(vip6.wechat.goldenyun.cn)门票使用统计导出:接口登录 → 搜索接口取核销明细 → 调平台导出接口生成 xlsx

- 核销时间日期段界面可选(默认昨天 00:00:00 ~ 今天 23:59:59);导出接口异常时按同一份数据本地生成同列序 xlsx 兜底
2026-11-06 15:52:15 +08:00

98 lines
3.7 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 -*-
"""xq0078 金色湖畔小程序数据导出 插件 - 配置常量与全局钩子。
插件自包含:本包只依赖 Python 标准库 / 第三方库 / 底座注入的 RunContext。
业务模块统一经 config.log() 输出日志(转发到 ctx.log,无 ctx 时回落到 print)。
"""
import os
# ==================== 金贵微信端管理平台 ====================
# 平台:金贵 GoldenSoft 微信端管理(ASP.NET MVC,服务端渲染 + Cookie 会话)
BASE_URL = 'http://vip6.wechat.goldenyun.cn'
APP_PATH = '/chqhpwq.web'
LOGIN_PATH = '/login'
LIST_PATH = '/wechat/memberreport/ticketconsumelist' # 门票使用统计页(表单 + 导出按钮)
SEARCH_PATH = '/wechat/memberreport/ticketconsumelistreport' # 搜索接口(返回 JSON 数组)
EXPORT_PATH = '/wechat/export/downloadexcel' # 导出接口(收表格 HTML,返回 xlsx)
CHANNEL_WECHAT = 'wechat' # 登录渠道:wechat=微信端 / pad=平板端
DEFAULT_VPN_NAME = '金色湖畔石桥铺会馆'
# ==================== 查询参数 ====================
# 搜索接口接收 frmList 序列化的 Query.* + Pager.*,票种/消费码/账单号/核销人默认留空
PAGE_SIZE = 1000 # 单页条数;接口按页返回时用于翻页拉全量
MAX_PAGES = 100 # 翻页上限保护
# 核销时间格式:与服务端页面 value 一致(2026/11/4 0:00:00,小时不补零、分秒补零)
DATETIME_FMT = '{y}/{m}/{d} {h}:{mi:02d}:{s:02d}'
# 日期段留空时按执行日推算:昨日 00:00:00 ~ 今日 23:59:59
# ==================== 导出行列(与页面表格列序一致) ====================
EXPORT_TITLE = '门票使用统计'
COLUMNS = ['票种', '消费码', '票号', '面值', '核销时间', '核销账单号', '核销人', '核销门店']
# 搜索接口 JSON 字段 → 导出列
ROW_KEYS = ['TicketTypeName', 'TicketGroupId', 'TicketID', 'SellPrice',
'UseDateStr', 'UseBillid', 'UseName', 'UseVpnName']
EMPTY_BILL_TEXT = '人工核销' # 核销账单号为空时页面显示的处理方式
TIMEOUT = 30 # 单请求超时(秒)
SEARCH_MAX_RETRY = 3 # 搜索接口重试次数(仅网络异常/5xx,不含登录)
# ==================== 会话落盘(跨 run 复用登录,减少登录次数) ====================
def get_session_file():
base = os.environ.get('LOCALAPPDATA') or os.path.expanduser('~')
d = os.path.join(base, '37duAutomation', 'sessions')
os.makedirs(d, exist_ok=True)
return os.path.join(d, 'goldenyun_xq0078.json')
# ==================== 默认保存目录 ====================
_DESKTOP = os.path.join(os.path.expanduser('~'), 'Desktop')
def get_desktop():
return _DESKTOP
# ==================== 全局钩子(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()