Files
junhong_cmp_fiber/openspec/changes/archive/2026-04-22-fix-traffic-deduction-on-device-card/proposal.md
huang 6b1fbf4a92
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m30s
修复金额的问题
2026-04-23 10:09:23 +08:00

37 lines
2.1 KiB
Markdown
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.
## Why
当前线上存在“卡流量已同步但套餐流量不变化”的问题,导致计费与停复机判断失真。该问题集中出现在绑定设备的卡和小流量高频上报场景,已经影响流量扣减准确性,需要优先修复。
## What Changes
- feature-001-traffic-deduction-carrier-routing修正轮询流量扣减时的载体路由逻辑避免固定按 `iot_card` 扣减导致设备级套餐无法命中。
- feature-002-traffic-deduction-fractional-precision修正流量扣减精度消除 `float64 -> int64` 截断造成的 `<1MB` 增量长期丢失。
- feature-003-traffic-field-semantics-clarify明确字段语义与展示口径
- `current_month_usage_mb`:系统自然月累计流量(卡维度)
- `last_gateway_reading_mb`:运营商当前周期累计读数(卡维度)
- 保持现有分层架构与任务链路不变Handler → Service → Store → Model仅调整扣减判定与数据口径说明无 BREAKING API 变更。
## Capabilities
### New Capabilities
-
### Modified Capabilities
- `polling-task-handlers``polling_carddata_handler` 在触发套餐扣减时,需支持“卡绑定设备时按设备载体命中套餐”而非固定卡载体。
- `package-usage-priority``DeductDataUsage` 需支持小数 MB 增量累计后扣减,保证小流量高频上报场景下扣减准确。
- `asset-queries`:资产流量字段语义说明补充,避免将 `current_month_usage_mb` 误用为运营商周期口径。
## Impact
- 受影响代码:
- `internal/task/polling_carddata_handler.go`
- `internal/service/package/usage_service.go`
- `internal/service/iot_card/service.go`
- `internal/model/dto/asset_dto.go`(描述语义)
- 受影响数据:
- `tb_package_usage.data_usage_mb` 的增长将更贴近上游真实增量(尤其是 <1MB 高频增量场景)
- API 兼容性:
- 无接口路径和结构变更
- 前端展示口径建议改为读取 `last_gateway_reading_mb` 表达“运营商周期累计流量”
- 依赖与基础设施:无新增外部依赖、无数据库迁移。