Skip to content

1398281322-a11y/java-backend-guardrails / skills/java-backend-guardrails/finance-stats

finance-stats

Verified

Use when defining 财务统计口径, GMV, 实收, 支付GMV vs 结算GMV, 退款后净额, 报表切日, or 实时 SUM 大表. Do not mix GMV with platform revenue. Settlement bills are backend-finance-settlement.

财务统计口径

When to Invoke

GMV、销售额、实收、退款率、看板、面试「GMV 怎么算」。财务对数字,口径比 SQL 重要。

When NOT

渠道对账文件 → reconciliation。商家结算打款 → finance-settlement。记账分录 → finance-ledger。渠道分账划款 → pay-split-account。

风险(面试考点)

GMV ≠ 平台收入 ≠ 净利润 ≠ TPV。 平台收入通常是佣金+广告+服务费。TPV 是支付通道吞吐,可含充值、代付。把 GMV 当营收是面试扣分项。

多种 GMV,必须写清发生点。直播/电商面试常考「支付 GMV 有水分」:

名称计入时点含退款?典型用途
下单 GMV创单含未支付战报注水,少用
支付 GMV支付成功含后续退款规模,默认对外口径之一
结算/履约 GMV核销/确认收货且未退净成交质量、可结算、算法权重

同一「今日销售额」,按支付成功还是按切日时区,能差一天。endTime=23:59:59 会漏 1 秒。用 [start, nextDay),时区写死(文旅默认 Asia/Shanghai)。

退款记哪一天必须二选一写死:支付日冲减(改历史日,报表会变)或 退款日冲减(净额另列)。禁止两套 SQL 混用。

优惠、运费、税费、平台补贴 vs 商家补贴是否计入要写进指标字典。平台券往往仍计入 GMV、不计入商家实收。客单价 = 某口径 GMV / 该口径订单数,分母跟错会差一倍。

禁止交易库 SELECT SUM(amount) 扫全量当实时大屏。用流水汇总表、离线数仓、或支付成功时累加计数器(可对账校正)。金额分;跨系统禁止 float。

方案选型(轻量优先)

每个指标一张口径卡:时间窗、时区、状态集合、含不含退/券/运费/补贴、一个算例、数仓表名。

支付GMV(日) = SUM(pay_trade.amount_fen)
  WHERE status=SUCCESS AND paid_at ∈ [D 00:00+08, D+1 00:00+08)

净GMV(日) = 支付GMV - 当日确认成功的退款(或按下单日退回冲减,二选一写死)
平台收入(日) = SUM(佣金分) 同窗   // 不是 GMV

文旅:核销 GMV 常比支付 GMV 更接近可结算。门票未核销退款要从净额扣。预售/定金:只把已收金额计入支付 GMV,尾款另笔支付再计。

实时大屏:支付成功 MQ 累加 Redis;日终用明细重算覆盖。对不上进 reconciliation。

反例

错误:看板 GMV = 订单表全部 CREATED 金额。 正确:按支付成功或核销,并注明。

错误:退款不冲减,年底对不上银行。 正确:净额指标单独命名,冲减规则写死。

错误:运营、财务、BD 各算各的,差 8%。 正确:指标字典,一个 SQL 来源。

错误:把渠道分账到账、商家提现、GMV 加在同一张「今日流水」里给老板。 正确:规模看 GMV;可打款看结算单;通道吞吐看 TPV。

验证

  • 同一日支付成功 10 笔、退 2 笔,支付 GMV 与净 GMV 数字符合口径卡。
  • 23:59:59 与 00:00:00 边界订单只进一天。
  • 大屏不是扫交易明细全表。
  • 换「支付日冲减 / 退款日冲减」后,历史日是否允许变动有文档。

评审清单

  • GMV 与收入、TPV、结算打款分开
  • 时点、时区、退款规则、券/运费/补贴写成文
  • 金额分
  • 无实时全表 SUM

receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 321kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 321kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 321kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 321kUpdated Claude CodeCodexVerifiedInstall