diff --git a/app/main/api/internal/logic/agent/applyforagentlogic.go b/app/main/api/internal/logic/agent/applyforagentlogic.go index 4afcc3e..5cdb5fb 100644 --- a/app/main/api/internal/logic/agent/applyforagentlogic.go +++ b/app/main/api/internal/logic/agent/applyforagentlogic.go @@ -66,7 +66,7 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type // 两种情况,1. 已注册账号然后申请代理 2. 未注册账号申请代理 user, findUserErr := l.svcCtx.UserModel.FindOneByMobile(l.ctx, sql.NullString{String: encryptedMobile, Valid: true}) if findUserErr != nil && !errors.Is(findUserErr, model.ErrNotFound) { - return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "代理申请, 读取数据库获取用户失败, mobile: %s, err: %+v", encryptedMobile, err) + return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "代理申请, 读取数据库获取用户失败, mobile: %s, err: %+v", encryptedMobile, findUserErr) } if user == nil { if claims != nil && claims.UserType == model.UserTypeNormal { @@ -88,7 +88,7 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type } // 使用SelectBuilder构建查询,查找符合user_id的记录并按创建时间降序排序获取最新一条 - builder := l.svcCtx.AgentAuditModel.SelectBuilder().Where("user_id = ?", user.Id).OrderBy("create_time DESC").Limit(1) + builder := l.svcCtx.AgentAuditModel.SelectBuilder().Where("user_id = ?", userID).OrderBy("create_time DESC").Limit(1) agentAuditList, findAgentAuditErr := l.svcCtx.AgentAuditModel.FindAll(transCtx, builder, "") if findAgentAuditErr != nil { return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "代理申请, 查找审核列表失败%+v", findAgentAuditErr) @@ -104,7 +104,7 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type } var agentAudit model.AgentAudit - agentAudit.UserId = user.Id + agentAudit.UserId = userID agentAudit.Mobile = encryptedMobile agentAudit.Region = req.Region agentAudit.Status = 1 diff --git a/app/main/api/internal/service/userService.go b/app/main/api/internal/service/userService.go index 0eabd8d..8fb5691 100644 --- a/app/main/api/internal/service/userService.go +++ b/app/main/api/internal/service/userService.go @@ -207,11 +207,13 @@ func (s *UserService) TempUserBindUser(ctx context.Context, session sqlx.Session return errors.New("无临时用户") } + // 使用事务上下文查询临时用户 userTemp, err := s.userTempModel.FindOne(ctx, claims.UserId) if err != nil { return err } + // 检查是否已经注册过 userAuth, err := s.userAuthModel.FindOneByAuthTypeAuthKey(ctx, userTemp.AuthType, userTemp.AuthKey) if err != nil && !errors.Is(err, model.ErrNotFound) { return err @@ -230,7 +232,13 @@ func (s *UserService) TempUserBindUser(ctx context.Context, session sqlx.Session if err != nil { return err } - err = s.userTempModel.DeleteSoft(ctx, session, userTemp) + + // 重新获取最新的userTemp数据,确保版本号是最新的 + latestUserTemp, err := s.userTempModel.FindOne(ctx, claims.UserId) + if err != nil { + return err + } + err = s.userTempModel.DeleteSoft(ctx, session, latestUserTemp) if err != nil { return err } @@ -249,13 +257,18 @@ func (s *UserService) TempUserBindUser(ctx context.Context, session sqlx.Session if err != nil { return err } - err = s.userTempModel.DeleteSoft(ctx, session, userTemp) + + // 重新获取最新的userTemp数据,确保版本号是最新的 + latestUserTemp, err := s.userTempModel.FindOne(ctx, claims.UserId) + if err != nil { + return err + } + err = s.userTempModel.DeleteSoft(ctx, session, latestUserTemp) if err != nil { return err } return nil } - } // _bak_RegisterUUIDUser 注册UUID用户,返回用户ID diff --git a/pkg/lzkit/crypto/ecb_test.go b/pkg/lzkit/crypto/ecb_test.go index a25e4e9..9e5024f 100644 --- a/pkg/lzkit/crypto/ecb_test.go +++ b/pkg/lzkit/crypto/ecb_test.go @@ -9,7 +9,7 @@ import ( func TestAesEcbMobileEncryption(t *testing.T) { // 测试手机号加密 - mobile := "13930867138" + mobile := "18680618651" keyStr := "ff83609b2b24fc73196aac3d3dfb874f" // 测试加密