fix: 实名轮询防止上游接口故障时误降级已实名状态
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m34s

Gateway 返回 data=null 时 sonic 解析为零值结构体(ICCID="" RealStatus=false),
导致已实名卡被误判为未实名并触发停机。

通过检查响应中 ICCID 是否回填来判断数据有效性:
- ICCID 为空:视为上游接口故障,重新入队,不更新实名状态
- ICCID 有值:响应有效,正常处理(含合法的未实名降级)
This commit is contained in:
2026-04-16 16:48:14 +08:00
parent 7e4c61e6e9
commit 0ec16d4afa

View File

@@ -81,12 +81,24 @@ func (h *PollingRealnameHandler) Handle(ctx context.Context, t *asynq.Task) erro
h.base.updateStats(ctx, constants.TaskTypePollingRealname, false, time.Since(startTime)) h.base.updateStats(ctx, constants.TaskTypePollingRealname, false, time.Since(startTime))
return h.base.requeueCard(ctx, cardID, constants.TaskTypePollingRealname) return h.base.requeueCard(ctx, cardID, constants.TaskTypePollingRealname)
} }
// 上游接口故障时 Gateway 可能返回 data=null
// sonic 将其解析为零值结构体ICCID="" RealStatus=false
// 需通过 ICCID 是否回填来判断响应是否有效。
if result.ICCID == "" {
h.base.logger.Warn("实名查询响应异常ICCID 为空,疑似上游接口故障,跳过本次同步",
zap.Uint("card_id", cardID),
zap.String("iccid", card.ICCID))
h.base.updateStats(ctx, constants.TaskTypePollingRealname, false, time.Since(startTime))
return h.base.requeueCard(ctx, cardID, constants.TaskTypePollingRealname)
}
realStatusBool = result.RealStatus realStatusBool = result.RealStatus
if result.RealStatus { if result.RealStatus {
newStatus = constants.RealNameStatusVerified newStatus = constants.RealNameStatusVerified
} else { } else {
newStatus = constants.RealNameStatusNotVerified newStatus = constants.RealNameStatusNotVerified
} }
if h.base.verboseLog { if h.base.verboseLog {
h.base.logger.Info("实名状态轮询详情", h.base.logger.Info("实名状态轮询详情",
zap.Uint("card_id", cardID), zap.Uint("card_id", cardID),