fix: 修复轮询检测到首次实名时未记录 first_realname_at 的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m13s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m13s
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user