feat(payments,mcp): 押金运营安全网——unforfeit 补救通道 + 批量没收告警(#545) - #661
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#545 押金运营安全网:
unforfeit补救通道 + 批量没收告警A.
unforfeit(错没收的人工救济)payments/order.exupdate :unforfeit:CASforfeited → refunding(claim单点,与retry_refund同形)+ after_action 入队PaymentRefundWorker(与 refund 同链,查单幂等不重复退)+LogAdminAction :order_unforfeit(from_status/reason/amount_cents进 metadata)mcp/tools/unforfeit_order.ex(新)meta: platform_admin(Wrapper 族)+ 两段确认(摘要带金额/渠道/理由);reason1–500 字工具层前置校验;非forfeited快速失败不建 pending原 issue 里低优先级的「迟到核销补偿」被本通道覆盖:错没收 → 人工核实 →
unforfeit→ 原路全退(无需补录 attendance)。B. 批量没收告警(双口径)
Logger.error("BATCH ALERT …")(event uuid 文本化,可直接拷贝查询):deposit_forfeit_batch_alert(该场 forfeited 计数 ≥5,HAVING下推)走apply_rule/3刷新语义 → unforfeit 降到阈值下自动删除(自愈)/admin/reconciliation页天然可见,零前端工作sync_batch_alert_findings自带 rescue:Finding 段落 raise 只落 error,不把已提交的结算拍拖进 Oban 重试阈值
@batch_alert_threshold = 5硬编码(101 场规模,Finding moduledoc 规16 同步口径)。验证
mix precommit→ 2389/2389 passed(终态);alert_batch_forfeits+sync_batch_alert_findings两处调用 → Finding 用例红(22/23)→ 恢复 23/23 绿;Forbidden;paid 单 →order_already_processed);MCP 非 platform admin(含工作台 Owner)→ forbidden 不建 pending;check 自检
inspect(event_id)输出 binary 字节串不可读 → 改 uuid 文本化(兼容 worker 内两条 SQL 的不同返回形态,注释已说明);unforfeit刻意不注册 GraphQL mutation,MCP-only 入口 →schema.graphql无变更);资金回流安全链完整(双层 PlatformAdmin + CAS + 两段确认 + 必填 reason + 审计);target_id收窄(既有沙箱纪律,新测试已遵守)。非目标
不给 web 加订单/退款页面(运营是 agent-first,避免第二套入口);不改
refund/retry_refund的既有权限组;不引入告警通道(Findings + Logger 已足够,且不阻塞结算主链)。