From 021349c60e753752b40c781c89478f6121c3c52d Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Wed, 11 Mar 2026 18:13:03 +0800 Subject: [PATCH 1/3] f --- app/main/api/desc/admin/admin_agent.api | 1 + .../admin_agent/admingetagentlistlogic.go | 58 ++++++++++++------- app/main/api/internal/types/types.go | 1 + 3 files changed, 38 insertions(+), 22 deletions(-) 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"` // 创建时间 } From 96a02f73d4dc211fd0df3c85dfeeba8f6a528fa4 Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Wed, 11 Mar 2026 18:26:09 +0800 Subject: [PATCH 2/3] f --- app/main/api/desc/admin/admin_agent.api | 1 + .../admin_agent/admingetagentlistlogic.go | 71 ++++++++++--------- app/main/api/internal/types/types.go | 1 + 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/app/main/api/desc/admin/admin_agent.api b/app/main/api/desc/admin/admin_agent.api index 6595e20..c71cc26 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"` // 是否已实名 + RealName string `json:"real_name"` // 姓名(实名认证的姓名) IdCardPlain string `json:"id_card_plain"` // 身份证号(解密后的明文) CreateTime string `json:"create_time"` // 创建时间 } diff --git a/app/main/api/internal/logic/admin_agent/admingetagentlistlogic.go b/app/main/api/internal/logic/admin_agent/admingetagentlistlogic.go index 0b26acd..aef445d 100644 --- a/app/main/api/internal/logic/admin_agent/admingetagentlistlogic.go +++ b/app/main/api/internal/logic/admin_agent/admingetagentlistlogic.go @@ -80,26 +80,28 @@ 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 - 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 + // 查询实名认证信息(数据库姓名明文、身份证密文,解密后明文返回不脱敏) + realNameInfo, _ := l.svcCtx.AgentRealNameModel.FindOneByAgentId(l.ctx, agent.Id) + isRealName := false + realName := "" + idCardPlain := "" // 解密后明文返回 + if realNameInfo != nil { + if realNameInfo.VerifyTime.Valid { + isRealName = true // verify_time不为空表示已通过三要素核验 + } + realName = realNameInfo.Name + 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 } @@ -114,24 +116,25 @@ 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, - IdCardPlain: idCardPlain, - 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, + RealName: realName, + 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 692b267..bea6ded 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"` // 是否已实名 + RealName string `json:"real_name"` // 姓名(实名认证的姓名) IdCardPlain string `json:"id_card_plain"` // 身份证号(解密后的明文) CreateTime string `json:"create_time"` // 创建时间 } From d209270630a91368033c7abf968e76566d3d9e16 Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Thu, 12 Mar 2026 14:29:53 +0800 Subject: [PATCH 3/3] f --- app/main/api/desc/admin/admin_agent.api | 12 ++++ .../adminupdateagentmobilehandler.go | 30 ++++++++ app/main/api/internal/handler/routes.go | 5 ++ .../adminupdateagentmobilelogic.go | 69 +++++++++++++++++++ app/main/api/internal/types/types.go | 10 +++ 5 files changed, 126 insertions(+) create mode 100644 app/main/api/internal/handler/admin_agent/adminupdateagentmobilehandler.go create mode 100644 app/main/api/internal/logic/admin_agent/adminupdateagentmobilelogic.go diff --git a/app/main/api/desc/admin/admin_agent.api b/app/main/api/desc/admin/admin_agent.api index c71cc26..5550f04 100644 --- a/app/main/api/desc/admin/admin_agent.api +++ b/app/main/api/desc/admin/admin_agent.api @@ -82,6 +82,10 @@ service main { // 邀请码列表查询 @handler AdminGetInviteCodeList get /invite_code/list (AdminGetInviteCodeListReq) returns (AdminGetInviteCodeListResp) + + // 代理手机号修改 + @handler AdminUpdateAgentMobile + post /mobile/update (AdminUpdateAgentMobileReq) returns (AdminUpdateAgentMobileResp) } type ( @@ -431,5 +435,13 @@ type ( Total int64 `json:"total"` // 总数 Items []InviteCodeListItem `json:"items"` // 列表数据 } + // 代理手机号修改 + AdminUpdateAgentMobileReq { + AgentId string `json:"agent_id"` // 代理ID + Mobile string `json:"mobile"` // 新手机号 + } + AdminUpdateAgentMobileResp { + Success bool `json:"success"` + } ) diff --git a/app/main/api/internal/handler/admin_agent/adminupdateagentmobilehandler.go b/app/main/api/internal/handler/admin_agent/adminupdateagentmobilehandler.go new file mode 100644 index 0000000..c8fcb8a --- /dev/null +++ b/app/main/api/internal/handler/admin_agent/adminupdateagentmobilehandler.go @@ -0,0 +1,30 @@ +package admin_agent + +import ( + "net/http" + + "ycc-server/app/main/api/internal/logic/admin_agent" + "ycc-server/app/main/api/internal/svc" + "ycc-server/app/main/api/internal/types" + "ycc-server/common/result" + "ycc-server/pkg/lzkit/validator" + + "github.com/zeromicro/go-zero/rest/httpx" +) + +func AdminUpdateAgentMobileHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req types.AdminUpdateAgentMobileReq + if err := httpx.Parse(r, &req); err != nil { + result.ParamErrorResult(r, w, err) + return + } + if err := validator.Validate(req); err != nil { + result.ParamValidateErrorResult(r, w, err) + return + } + l := admin_agent.NewAdminUpdateAgentMobileLogic(r.Context(), svcCtx) + resp, err := l.AdminUpdateAgentMobile(&req) + result.HttpResult(r, w, resp, err) + } +} diff --git a/app/main/api/internal/handler/routes.go b/app/main/api/internal/handler/routes.go index e591e41..a717918 100644 --- a/app/main/api/internal/handler/routes.go +++ b/app/main/api/internal/handler/routes.go @@ -94,6 +94,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { Path: "/product_config/update", Handler: admin_agent.AdminUpdateAgentProductConfigHandler(serverCtx), }, + { + Method: http.MethodPost, + Path: "/mobile/update", + Handler: admin_agent.AdminUpdateAgentMobileHandler(serverCtx), + }, { Method: http.MethodGet, Path: "/real_name/list", diff --git a/app/main/api/internal/logic/admin_agent/adminupdateagentmobilelogic.go b/app/main/api/internal/logic/admin_agent/adminupdateagentmobilelogic.go new file mode 100644 index 0000000..33d164a --- /dev/null +++ b/app/main/api/internal/logic/admin_agent/adminupdateagentmobilelogic.go @@ -0,0 +1,69 @@ +package admin_agent + +import ( + "context" + "regexp" + + "ycc-server/app/main/model" + "ycc-server/common/xerr" + "ycc-server/pkg/lzkit/crypto" + + "github.com/pkg/errors" + + "ycc-server/app/main/api/internal/svc" + "ycc-server/app/main/api/internal/types" + + "github.com/zeromicro/go-zero/core/logx" +) + +// 手机号正则:11 位大陆手机号 +var mobileRegexp = regexp.MustCompile(`^1[3-9]\d{9}$`) + +type AdminUpdateAgentMobileLogic struct { + logx.Logger + ctx context.Context + svcCtx *svc.ServiceContext +} + +func NewAdminUpdateAgentMobileLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AdminUpdateAgentMobileLogic { + return &AdminUpdateAgentMobileLogic{ + Logger: logx.WithContext(ctx), + ctx: ctx, + svcCtx: svcCtx, + } +} + +func (l *AdminUpdateAgentMobileLogic) AdminUpdateAgentMobile(req *types.AdminUpdateAgentMobileReq) (resp *types.AdminUpdateAgentMobileResp, err error) { + // 1. 校验手机号格式 + if req.Mobile == "" { + return nil, errors.Wrapf(xerr.NewErrMsg("手机号不能为空"), "") + } + if !mobileRegexp.MatchString(req.Mobile) { + return nil, errors.Wrapf(xerr.NewErrMsg("手机号格式不正确"), "") + } + + // 2. 查询代理 + agent, err := l.svcCtx.AgentModel.FindOne(l.ctx, req.AgentId) + if err != nil { + if errors.Is(err, model.ErrNotFound) { + return nil, errors.Wrapf(xerr.NewErrMsg("代理不存在"), "") + } + return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "查询代理失败, %v", err) + } + + // 3. 加密新手机号 + encryptedMobile, err := crypto.EncryptMobile(req.Mobile, l.svcCtx.Config.Encrypt.SecretKey) + if err != nil { + return nil, errors.Wrapf(xerr.NewErrCode(xerr.SERVER_COMMON_ERROR), "加密手机号失败, %v", err) + } + + // 4. 更新代理手机号 + agent.Mobile = encryptedMobile + if err := l.svcCtx.AgentModel.UpdateWithVersion(l.ctx, nil, agent); err != nil { + return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "更新手机号失败, %v", err) + } + + return &types.AdminUpdateAgentMobileResp{ + Success: true, + }, nil +} diff --git a/app/main/api/internal/types/types.go b/app/main/api/internal/types/types.go index bea6ded..701cc5a 100644 --- a/app/main/api/internal/types/types.go +++ b/app/main/api/internal/types/types.go @@ -872,6 +872,16 @@ type AdminUpdateAgentProductConfigResp struct { Success bool `json:"success"` } +// 代理手机号修改 +type AdminUpdateAgentMobileReq struct { + AgentId string `json:"agent_id"` // 代理ID + Mobile string `json:"mobile"` // 新手机号 +} + +type AdminUpdateAgentMobileResp struct { + Success bool `json:"success"` +} + type AdminUpdateApiReq struct { Id string `path:"id"` ApiName string `json:"api_name"`