diff --git a/app/main/api/desc/admin/admin_agent.api b/app/main/api/desc/admin/admin_agent.api index 6bb808d..6595e20 100644 --- a/app/main/api/desc/admin/admin_agent.api +++ b/app/main/api/desc/admin/admin_agent.api @@ -109,6 +109,7 @@ type ( FrozenBalance float64 `json:"frozen_balance"` // 冻结余额 WithdrawnAmount float64 `json:"withdrawn_amount"` // 提现总额 IsRealName bool `json:"is_real_name"` // 是否已实名 + IdCardPlain string `json:"id_card_plain"` // 身份证号(解密后的明文) CreateTime string `json:"create_time"` // 创建时间 } AdminGetAgentListResp { diff --git a/app/main/api/internal/logic/admin_agent/admingetagentlistlogic.go b/app/main/api/internal/logic/admin_agent/admingetagentlistlogic.go index a259f93..0b26acd 100644 --- a/app/main/api/internal/logic/admin_agent/admingetagentlistlogic.go +++ b/app/main/api/internal/logic/admin_agent/admingetagentlistlogic.go @@ -2,6 +2,7 @@ package admin_agent import ( "context" + "encoding/hex" "ycc-server/app/main/api/internal/svc" "ycc-server/app/main/api/internal/types" @@ -79,14 +80,26 @@ func (l *AdminGetAgentListLogic) AdminGetAgentList(req *types.AdminGetAgentListR // 查询钱包信息 wallet, _ := l.svcCtx.AgentWalletModel.FindOneByAgentId(l.ctx, agent.Id) - // 查询实名认证信息 - realNameInfo, _ := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agent.Id) - isRealName := false - if realNameInfo != nil && realNameInfo.VerifyTime.Valid { + // 查询实名认证信息(数据库姓名明文、身份证密文,解密后明文返回不脱敏) + realNameInfo, _ := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agent.Id) + isRealName := false + idCardPlain := "" // 解密后明文返回 + if realNameInfo != nil { + if realNameInfo.VerifyTime.Valid { isRealName = true // verify_time不为空表示已通过三要素核验 } + if realNameInfo.IdCard != "" { + key, keyErr := hex.DecodeString(l.svcCtx.Config.Encrypt.SecretKey) + if keyErr == nil { + decrypted, err := crypto.DecryptIDCard(realNameInfo.IdCard, key) + if err == nil { + idCardPlain = decrypted + } + } + } + } - wechatId := "" + wechatId := "" if agent.WechatId.Valid { wechatId = agent.WechatId.String } @@ -101,23 +114,24 @@ func (l *AdminGetAgentListLogic) AdminGetAgentList(req *types.AdminGetAgentListR region = agent.Region.String } - item := types.AgentListItem{ - Id: agent.Id, - UserId: agent.UserId, - Level: agent.Level, - LevelName: levelName, - Region: region, - Mobile: agent.Mobile, - WechatId: wechatId, - TeamLeaderId: teamLeaderId, - AgentCode: agent.AgentCode, - Balance: 0, - TotalEarnings: 0, - FrozenBalance: 0, - WithdrawnAmount: 0, - IsRealName: isRealName, - CreateTime: agent.CreateTime.Format("2006-01-02 15:04:05"), - } + item := types.AgentListItem{ + Id: agent.Id, + UserId: agent.UserId, + Level: agent.Level, + LevelName: levelName, + Region: region, + Mobile: agent.Mobile, + WechatId: wechatId, + TeamLeaderId: teamLeaderId, + AgentCode: agent.AgentCode, + Balance: 0, + TotalEarnings: 0, + FrozenBalance: 0, + WithdrawnAmount: 0, + IsRealName: isRealName, + IdCardPlain: idCardPlain, + CreateTime: agent.CreateTime.Format("2006-01-02 15:04:05"), + } if wallet != nil { item.Balance = wallet.Balance diff --git a/app/main/api/internal/types/types.go b/app/main/api/internal/types/types.go index 5b0f26a..692b267 100644 --- a/app/main/api/internal/types/types.go +++ b/app/main/api/internal/types/types.go @@ -1110,6 +1110,7 @@ type AgentListItem struct { FrozenBalance float64 `json:"frozen_balance"` // 冻结余额 WithdrawnAmount float64 `json:"withdrawn_amount"` // 提现总额 IsRealName bool `json:"is_real_name"` // 是否已实名 + IdCardPlain string `json:"id_card_plain"` // 身份证号(解密后的明文) CreateTime string `json:"create_time"` // 创建时间 }