feat(reconcile): 差异定位重构(对齐去漂移 + 仅展示真差异)+ 计件标志修正#11
Merged
Conversation
后端
- 新增 service/reconcile_align.go:逐模型自动探测整点位移(shift∈{-1,0,+1})
对齐供方系统性小时漂移;仅 hour 粒度做"等额才整对清零"的相邻抵消(day 粒度
跳过,避免误隐藏真实日级差异);过滤出真差异桶并分类 diff_kind(price_only/
usage/missing_local/missing_supplier/mixed);buildDiffBreakdown 产出 Top-N 归因。
- Compare 接入对齐结果:替换 Rows/单边计数/RowsCount/diff_breakdown,并给 by_model
打 diff_kind;summary / by_model 数值保持权威,不受对齐影响;drift 分析仍跑全量 trace。
- dto:DiffRow 加 diff_kind/align_shift_hours/supplier_bucket;Summary 加 diff_breakdown;
ByModelStat 加 diff_kind;新增 DiffBreakdownItem。
- common:新增对齐/显著性/TopN 等常量。
- task_billing.go:LogTaskConsumption 按 PerCallBilling(TaskPricePatches∪UsePrice)
gate count_billing,taskBillingOther 按 bc.PerCallBilling gate——token 计费任务不再
被误标计件(修既有 bug)。
前端(web/classic)
- 页面顺序改为 总览 → 按模型汇总 → 明细差异。
- 明细表删除"明细合并"选择器与客户端聚合,直接展示后端真差异行;新增"差异类型"列、
计件用量展示、时段对齐提示(供方 HH:00(对齐 ±Nh))。
- 按模型汇总按 |Δ¥| 降序 + diff_kind 标签;总览新增"差异构成"。
- 新增共享 diffKind.js(标签/颜色)。
测试
- reconcile_align_test.go:系统性 ±1/0、部分漂移保留、等额抵消、day 跳过抵消、
价差/用量/单边分类、breakdown TopN、聚合不可变性。
- task_billing_count_test.go:按次/ token 计费/ nil 上下文的 count_billing gate。
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.
背景
对账功能用真实并行账单回归时发现:① 视频/计件模型在明细里数量记为 0、不可见;② 明细被供方系统性整点漂移产生的
仅供应商/仅我方伪差异刷屏,需手动试"明细合并",且看不出差异在哪个模型/小时/维度。本 PR 做 v3.1 差异定位重构 + 计件标志修正。后端
service/reconcile_align.go:逐模型自动探测整点位移shift∈{-1,0,+1}对齐供方系统性小时漂移;仅 hour 粒度做"等额才整对清零"的相邻抵消(day 跳过);过滤真差异桶 + 分类diff_kind(price_only/usage/missing_local/missing_supplier/mixed);buildDiffBreakdown产出 Top-N 归因。reconcile_compare.go:接入对齐结果替换 Rows/单边计数/diff_breakdown,给 by_model 打 diff_kind。summary / by_model 数值保持权威,不受对齐影响。dto/common:新增字段与常量。task_billing.go:LogTaskConsumption与taskBillingOther按PerCallBilling(TaskPricePatches ∪ UsePrice)gatecount_billing——按次任务正常标计件,token 计费任务不再误标(修既有 bug)。前端(web/classic)
diffKind.js。测试
reconcile_align_test.go/task_billing_count_test.go;go build ./...、go test ./service/全绿。已知限制
token 计费的异步任务渠道只对账金额、不对账 token(任务日志未落结构化 token,既有数据局限,对当前部署无影响)。
经 Codex review 三轮,所有真实可修问题已闭环。