docs: 更新 AGENTS/README 平台架构说明与月度总结,运行日志视图支持已取消状态
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
"""XQ0041 新美大平台核对 —— webhost 场景插件入口。
|
||||
|
||||
执行过程由 action 决定(UI 的两个开关派生):
|
||||
action='download' → 只下载:登录经营宝,按勾选下载打款记录 / 团购收益明细 / 预订收益明细;
|
||||
action='download' → 只下载:登录经营宝(界面配了账号密码则自动填写提交,验证码/选商家仍需人工),
|
||||
按勾选下载打款记录 / 团购收益明细 / 预订收益明细;
|
||||
action='reconcile' → 只核对:**不开浏览器**,直接用本机最新的台账与收益明细并入台账、
|
||||
更新核对统计(适合数据已下载、只想重算的场景);
|
||||
action='all' → 下载后再核对(默认)。
|
||||
@@ -68,16 +69,20 @@ def _resolve_action(fields):
|
||||
class Xq0041Plugin(ScenePlugin):
|
||||
id = 'xq0041'
|
||||
name = '新美大平台核对'
|
||||
version = '1.1.8'
|
||||
version = '1.1.14'
|
||||
description = ('美团经营宝账单自动下载与台账核对:按需下载打款记录、团购收益明细、'
|
||||
'预订收益明细,把新产生的收益按验券时间并入月份台账,'
|
||||
'并按日期把核对统计表整行同源取数公式(资金组取数)换成当天共享总表的链接')
|
||||
'并按日期把核对统计表整行同源取数公式(资金组取数)换成当天共享总表的链接;'
|
||||
'界面可配账号密码自动登录并自动选「非餐饮商家版」(验证码/具体门店仍需人工)')
|
||||
platform = '' # 插件自带登录(经营宝 SSO + 选商家),不用底座共享登录态
|
||||
uses_month = False
|
||||
capabilities = ['xq0041']
|
||||
permissions = {'platforms': []}
|
||||
# 与 plugin.json.fields 一致(ui=true,前端按此渲染表单)
|
||||
fields = {
|
||||
'mt_username': {'type': 'string', 'title': '经营宝账号', 'default': ''},
|
||||
'mt_password': {'type': 'string', 'title': '经营宝登录密码', 'default': '',
|
||||
'format': 'password'},
|
||||
'action': {'type': 'string', 'title': '执行过程', 'default': 'all',
|
||||
'enum': ['all', 'download', 'reconcile']},
|
||||
'do_download': {'type': 'boolean', 'title': '下载数据', 'default': True},
|
||||
@@ -89,6 +94,8 @@ class Xq0041Plugin(ScenePlugin):
|
||||
'profit_booking': {'type': 'boolean', 'title': '下载预订收益明细', 'default': True},
|
||||
'profit_date_from': {'type': 'string', 'title': '收益明细-开始日期', 'default': ''},
|
||||
'profit_date_to': {'type': 'string', 'title': '收益明细-结束日期', 'default': ''},
|
||||
'save_dir': {'type': 'string', 'title': '保存目录', 'default': ''},
|
||||
'force_login': {'type': 'boolean', 'title': '强制重新登录', 'default': False},
|
||||
'run_merge': {'type': 'boolean', 'title': '并入台账', 'default': True},
|
||||
'run_links': {'type': 'boolean', 'title': '更新核对统计', 'default': True},
|
||||
'dry_run': {'type': 'boolean', 'title': '只核对不写入', 'default': False},
|
||||
@@ -118,7 +125,13 @@ class Xq0041Plugin(ScenePlugin):
|
||||
dry_run = bool(fields.get('dry_run'))
|
||||
run_merge = bool(fields.get('run_merge', True))
|
||||
run_links = bool(fields.get('run_links', True))
|
||||
save_dir = str(fields.get('save_dir') or config.WORK_DIR).strip().strip('"') or config.WORK_DIR
|
||||
force_login = bool(fields.get('force_login'))
|
||||
# 保存目录同时是台账目录:并入台账 / 更新核对统计都读它
|
||||
save_dir = config.set_work_dir(fields.get('save_dir'))
|
||||
|
||||
# 登录账号密码(界面配置;留空 = 完全手工登录)
|
||||
mt_user = str(fields.get('mt_username') or '').strip()
|
||||
mt_pwd = str(fields.get('mt_password') or '').strip()
|
||||
|
||||
if do_download and not pay_on and not codes:
|
||||
raise RuntimeError('请至少勾选一项要下载的内容(打款记录 / 团购 / 预订)')
|
||||
@@ -145,7 +158,7 @@ class Xq0041Plugin(ScenePlugin):
|
||||
plan.append('更新核对统计' if run_links else '')
|
||||
plan = [p for p in plan if p]
|
||||
config.log(('本次执行:' + ';'.join(plan) if plan else '本次没有可执行的动作')
|
||||
+ (f';目录 {save_dir}' if do_download else '')
|
||||
+ f';目录 {save_dir}'
|
||||
+ ('(只核对不写入)' if dry_run else ''))
|
||||
|
||||
detail = {'action': action, 'pay': None, 'profit': None, 'merge': None, 'links': None}
|
||||
@@ -154,9 +167,11 @@ class Xq0041Plugin(ScenePlugin):
|
||||
# ---------- 1~3:登录 + 下载 ----------
|
||||
if do_download:
|
||||
ctx.progress(2)
|
||||
page = browser.open_page()
|
||||
page = browser.open_page(force_login=force_login)
|
||||
try:
|
||||
ok, msg = meituan_login.ensure_login(page)
|
||||
config.log('登录方式:' + ('界面配置的账号密码自动登录'
|
||||
if (mt_user and mt_pwd) else '手工登录'))
|
||||
ok, msg = meituan_login.ensure_login(page, mt_user, mt_pwd)
|
||||
config.log(msg)
|
||||
if not ok:
|
||||
raise RuntimeError(f'登录失败:{msg}')
|
||||
@@ -167,7 +182,10 @@ class Xq0041Plugin(ScenePlugin):
|
||||
if not r1.get('ok'):
|
||||
raise RuntimeError(f'打款记录下载失败:{r1.get("message")}')
|
||||
config.log(r1.get('message') or '')
|
||||
if r1.get('path'):
|
||||
if r1.get('empty'):
|
||||
# 区间内没有打款记录:正常跳过,不影响收益明细下载与核对
|
||||
config.log('打款记录区间内无数据,已跳过本项', 'WARN')
|
||||
elif r1.get('path'):
|
||||
files.append(r1['path'])
|
||||
detail['pay'] = r1
|
||||
ctx.progress(45 if do_reconcile else 65)
|
||||
@@ -209,6 +227,8 @@ class Xq0041Plugin(ScenePlugin):
|
||||
|
||||
# ---------- 汇总 ----------
|
||||
parts = []
|
||||
if detail['pay'] and detail['pay'].get('empty'):
|
||||
parts.append(f'打款记录 {pay_from}~{pay_to} 无数据')
|
||||
if files:
|
||||
parts.append(f'下载 {len(files)} 个文件')
|
||||
if detail['merge'] and detail['merge'].get('appended'):
|
||||
|
||||
Reference in New Issue
Block a user