chore: 激活前流量结算记录开始与完成日志
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m46s

This commit is contained in:
邹进
2026-10-24 17:31:32 +09:00
parent ec5c1996a7
commit 8fc3485061

View File

@@ -47,6 +47,7 @@ func (s *PreActivationSettler) SettleBeforeActivation(ctx context.Context, carri
if hasMain {
return
}
s.logger.Info("激活前流量结算开始", zap.String("carrier_type", carrierType), zap.Uint("asset_id", carrierID))
cards, err := s.cardsOf(ctx, carrierType, carrierID)
if err != nil {
s.logger.Warn("激活前流量结算:查询载体下卡失败,跳过结算", zap.String("carrier_type", carrierType), zap.Uint("carrier_id", carrierID), zap.Error(err))
@@ -86,7 +87,7 @@ func (s *PreActivationSettler) settleCard(ctx context.Context, card *model.IotCa
resetDay = s.carrier.GetDataResetDay(stepCtx, card.CarrierID)
}
observedAt := time.Now().UTC()
_, err = s.observation.ApplyTrafficObservation(stepCtx, carddomain.TrafficObservation{
decision, err := s.observation.ApplyTrafficObservation(stepCtx, carddomain.TrafficObservation{
CardID: card.ID, GatewayReadingMB: float64(response.Used), ResetDay: resetDay,
Metadata: carddomain.ObservationMetadata{
ObservationID: "pre-activation-" + card.ICCID + "-" + observedAt.Format("20060102150405.000"),
@@ -96,7 +97,12 @@ func (s *PreActivationSettler) settleCard(ctx context.Context, card *model.IotCa
})
if err != nil {
s.alert(card, carrierType, carrierID, "流量结算入账失败")
return
}
s.logger.Info("激活前流量结算完成", zap.Uint("card_id", card.ID), zap.String("iccid", card.ICCID),
zap.String("carrier_type", carrierType), zap.Uint("asset_id", carrierID),
zap.Float64("gateway_flow_mb", float64(response.Used)), zap.Float64("increment_mb", decision.IncrementMB),
zap.String("metric", "package.pre_activation_settlement.done"))
}
// alert 写激活前结算失败告警:该卡本月可能多计无套餐期间用量,由运营核对。