From 4770e053ee8906c84cc13f9943de26fd2ffb21f9 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 2 Apr 2026 10:52:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=BD=AE=E8=AF=A2?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=88=B0=E9=A6=96=E6=AC=A1=E5=AE=9E=E5=90=8D?= =?UTF-8?q?=E6=97=B6=E6=9C=AA=E8=AE=B0=E5=BD=95=20first=5Frealname=5Fat=20?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- internal/task/polling_handler.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/task/polling_handler.go b/internal/task/polling_handler.go index d46f1e4..ca8c88a 100644 --- a/internal/task/polling_handler.go +++ b/internal/task/polling_handler.go @@ -144,6 +144,11 @@ func (h *PollingHandler) HandleRealnameCheck(ctx context.Context, t *asynq.Task) // 检测状态变化 statusChanged := newRealnameStatus != card.RealNameStatus + // 提前检测首次实名(之前未实名 → 现在已实名),用于同步记录 first_realname_at + isFirstRealname := statusChanged && + card.RealNameStatus != constants.RealNameStatusVerified && + newRealnameStatus == constants.RealNameStatusVerified + // 更新数据库 now := time.Now() updates := map[string]any{ @@ -152,6 +157,10 @@ func (h *PollingHandler) HandleRealnameCheck(ctx context.Context, t *asynq.Task) if statusChanged { updates["real_name_status"] = newRealnameStatus } + // 首次实名时记录实名时间,后续实名状态不覆盖 + if isFirstRealname { + updates["first_realname_at"] = now + } if err := h.db.Model(&model.IotCard{}). Where("id = ?", cardID). @@ -170,9 +179,6 @@ func (h *PollingHandler) HandleRealnameCheck(ctx context.Context, t *asynq.Task) zap.Int("old_status", card.RealNameStatus), zap.Int("new_status", newRealnameStatus)) - // 检测首次实名(之前未实名 → 现在已实名),触发待激活套餐激活 - isFirstRealname := card.RealNameStatus != constants.RealNameStatusVerified && - newRealnameStatus == constants.RealNameStatusVerified if isFirstRealname { h.triggerFirstRealnameActivation(ctx, uint(cardID)) }