fix: 修复轮询停机连坐、实名逆转防抖及carrier_stopped原因写入缺失三个逻辑缺陷
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m37s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m37s
This commit is contained in:
@@ -139,6 +139,8 @@ func (h *PollingRealnameHandler) Handle(ctx context.Context, t *asynq.Task) erro
|
||||
zap.Int("new_status", newStatus))
|
||||
|
||||
if isFirstRealname {
|
||||
// 0→1 时清除逆转计数器
|
||||
h.base.redis.Del(ctx, constants.RedisPollingRealnameReversalCountKey(cardID))
|
||||
// 0→1:首次实名,触发套餐激活并立即复机评估(不等待下一个 carddata/package 周期)
|
||||
h.triggerFirstRealnameActivation(ctx, cardID)
|
||||
h.triggerDeviceRealnameActivation(ctx, cardID)
|
||||
@@ -152,15 +154,26 @@ func (h *PollingRealnameHandler) Handle(ctx context.Context, t *asynq.Task) erro
|
||||
}
|
||||
}
|
||||
} else if newStatus == constants.RealNameStatusNotVerified {
|
||||
// 1→0:实名逆转,立即触发停机评估(不等待下一个 carddata/package 周期,否则最长延迟 1 小时)
|
||||
h.base.logger.Warn("检测到实名逆转,立即触发停机评估",
|
||||
zap.Uint("card_id", cardID))
|
||||
if h.stopResumeSvc != nil {
|
||||
freshCard, loadErr := h.iotCardStore.GetByID(ctx, cardID)
|
||||
if loadErr == nil {
|
||||
if evalErr := h.stopResumeSvc.EvaluateAndAct(ctx, freshCard); evalErr != nil {
|
||||
h.base.logger.Warn("实名逆转后触发停机评估失败",
|
||||
zap.Uint("card_id", cardID), zap.Error(evalErr))
|
||||
reversalKey := constants.RedisPollingRealnameReversalCountKey(cardID)
|
||||
count, incrErr := h.base.redis.Incr(ctx, reversalKey).Result()
|
||||
if incrErr == nil {
|
||||
h.base.redis.Expire(ctx, reversalKey, 10*time.Minute)
|
||||
}
|
||||
h.base.logger.Warn("检测到实名逆转",
|
||||
zap.Uint("card_id", cardID),
|
||||
zap.Int64("reversal_count", count),
|
||||
zap.Int("threshold", constants.PollingRealnameReversalThreshold))
|
||||
if count >= int64(constants.PollingRealnameReversalThreshold) {
|
||||
h.base.redis.Del(ctx, reversalKey)
|
||||
h.base.logger.Warn("实名逆转达到阈值,触发停机评估",
|
||||
zap.Uint("card_id", cardID))
|
||||
if h.stopResumeSvc != nil {
|
||||
freshCard, loadErr := h.iotCardStore.GetByID(ctx, cardID)
|
||||
if loadErr == nil {
|
||||
if evalErr := h.stopResumeSvc.EvaluateAndAct(ctx, freshCard); evalErr != nil {
|
||||
h.base.logger.Warn("实名逆转后触发停机评估失败",
|
||||
zap.Uint("card_id", cardID), zap.Error(evalErr))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user