fix: 修复手动刷新资产时流量直接覆盖为运营商原始读数的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m6s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m6s
RefreshCardDataFromGateway 原先直接将网关返回的累计读数写入 current_month_usage_mb,导致本月已用流量从 312MB 跳变为 29GB。 修复内容: - 流量计算改为增量逻辑(与轮询 calculateFlowUpdates 一致) - 补充更新 last_gateway_reading_mb 基准,防止后续轮询增量异常 - 补充跨月检测和运营商重置日窗口判断 - 通过 DataDeductor 回调触发套餐流量扣减(手动刷新也能更新套餐)
This commit is contained in:
@@ -103,9 +103,12 @@ func initServices(s *stores, deps *Dependencies) *services {
|
||||
accountAudit := accountAuditSvc.NewService(s.AccountOperationLog)
|
||||
account := accountSvc.New(s.Account, s.Role, s.AccountRole, s.ShopRole, s.Shop, s.Enterprise, accountAudit)
|
||||
|
||||
// 创建 IotCard service 并设置 polling callback
|
||||
// 创建 IotCard service 并设置回调
|
||||
iotCard := iotCardSvc.New(deps.DB, s.IotCard, s.Shop, s.AssetAllocationRecord, s.ShopPackageAllocation, s.ShopSeriesAllocation, s.PackageSeries, deps.GatewayClient, deps.Logger)
|
||||
iotCard.SetPollingCallback(polling.NewAPICallback(deps.Redis, deps.Logger))
|
||||
// 注入流量扣减回调,使手动刷新资产时能触发套餐流量扣减
|
||||
usageService := packageSvc.NewUsageService(deps.DB, deps.Redis, s.PackageUsage, s.PackageUsageDailyRecord, deps.Logger)
|
||||
iotCard.SetDataDeductor(usageService)
|
||||
|
||||
// 创建支付配置服务(Order 和 Recharge 依赖)
|
||||
wechatConfig := wechatConfigSvc.New(s.WechatConfig, s.Order, s.AssetRecharge, s.AgentRecharge, accountAudit, deps.Redis, deps.Logger)
|
||||
|
||||
Reference in New Issue
Block a user