feat: 分层轮询、重置日前加密与激活前流量结算
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m37s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m37s
- 轮询配置新增套餐状态、资产状态、重置日前窗口与窗口内流量间隔(迁移 248),间隔三态:正数按间隔、0 不检查、空继承 - 配置按 priority, id 排序合并;在库与已销售无套餐未匹配时告警不入队 - 新增优先级整体重排、匹配预览、立即重算到期时间(异步只提前)、分层统计与重置日前加密统计接口 - 已切换日快照计量的卡流量按观测时间归属,激活前用量只记已结算 - 订单购买与实名激活补齐资产级激活锁,激活前对已切换卡结算一次流量,失败只告警不阻塞,结算不触发通道阈值判定
This commit is contained in:
@@ -257,6 +257,10 @@ func (p *PollingInitializer) initBatch(ctx context.Context, cards []*model.IotCa
|
||||
cmdCount = 0
|
||||
}
|
||||
|
||||
// 分层轮询按批预取套餐状态,避免逐卡查库。
|
||||
if tier := p.configMgr.TierResolver(); tier != nil {
|
||||
tier.Prefill(ctx, cards)
|
||||
}
|
||||
for _, card := range cards {
|
||||
intervals := p.configMgr.MergedTaskIntervals(card)
|
||||
if len(intervals) == 0 {
|
||||
@@ -271,6 +275,10 @@ func (p *PollingInitializer) initBatch(ctx context.Context, cards []*model.IotCa
|
||||
for taskType, info := range intervals {
|
||||
lastCheckAt := lastCheckAtByTaskType(card, taskType)
|
||||
nextCheck := calculateNextCheckTime(lastCheckAt, info.Interval, now)
|
||||
// 重置日前加密:窗口规则算出的时间更早时(如需截断到窗口起点)以它为准。
|
||||
if windowDue := p.configMgr.NextCheckAt(ctx, card, taskType, info, now); windowDue.Before(nextCheck) && windowDue.After(now) {
|
||||
nextCheck = windowDue
|
||||
}
|
||||
pipe.ZAdd(ctx, constants.RedisPollingShardQueueKey(shardID, taskType), redis.Z{
|
||||
Score: float64(nextCheck.Unix()), Member: cardIDStr,
|
||||
})
|
||||
@@ -289,7 +297,8 @@ func (p *PollingInitializer) initBatch(ctx context.Context, cards []*model.IotCa
|
||||
"last_gateway_reading_mb": card.LastGatewayReadingMB,
|
||||
"data_usage_mb": card.DataUsageMB,
|
||||
"stop_reason": card.StopReason, "is_standalone": boolToStr(card.IsStandalone),
|
||||
"cached_at": now.Unix(),
|
||||
"asset_status": card.AssetStatus,
|
||||
"cached_at": now.Unix(),
|
||||
}
|
||||
if card.CurrentMonthStartDate != nil {
|
||||
cacheData["current_month_start_date"] = card.CurrentMonthStartDate.Unix()
|
||||
|
||||
Reference in New Issue
Block a user