fix agent apply
This commit is contained in:
parent
be63c01987
commit
72fb221d1f
@ -66,7 +66,7 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type
|
|||||||
// 两种情况,1. 已注册账号然后申请代理 2. 未注册账号申请代理
|
// 两种情况,1. 已注册账号然后申请代理 2. 未注册账号申请代理
|
||||||
user, findUserErr := l.svcCtx.UserModel.FindOneByMobile(l.ctx, sql.NullString{String: encryptedMobile, Valid: true})
|
user, findUserErr := l.svcCtx.UserModel.FindOneByMobile(l.ctx, sql.NullString{String: encryptedMobile, Valid: true})
|
||||||
if findUserErr != nil && !errors.Is(findUserErr, model.ErrNotFound) {
|
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 user == nil {
|
||||||
if claims != nil && claims.UserType == model.UserTypeNormal {
|
if claims != nil && claims.UserType == model.UserTypeNormal {
|
||||||
@ -88,7 +88,7 @@ func (l *ApplyForAgentLogic) ApplyForAgent(req *types.AgentApplyReq) (resp *type
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 使用SelectBuilder构建查询,查找符合user_id的记录并按创建时间降序排序获取最新一条
|
// 使用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, "")
|
agentAuditList, findAgentAuditErr := l.svcCtx.AgentAuditModel.FindAll(transCtx, builder, "")
|
||||||
if findAgentAuditErr != nil {
|
if findAgentAuditErr != nil {
|
||||||
return errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "代理申请, 查找审核列表失败%+v", findAgentAuditErr)
|
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
|
var agentAudit model.AgentAudit
|
||||||
agentAudit.UserId = user.Id
|
agentAudit.UserId = userID
|
||||||
agentAudit.Mobile = encryptedMobile
|
agentAudit.Mobile = encryptedMobile
|
||||||
agentAudit.Region = req.Region
|
agentAudit.Region = req.Region
|
||||||
agentAudit.Status = 1
|
agentAudit.Status = 1
|
||||||
|
@ -207,11 +207,13 @@ func (s *UserService) TempUserBindUser(ctx context.Context, session sqlx.Session
|
|||||||
return errors.New("无临时用户")
|
return errors.New("无临时用户")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 使用事务上下文查询临时用户
|
||||||
userTemp, err := s.userTempModel.FindOne(ctx, claims.UserId)
|
userTemp, err := s.userTempModel.FindOne(ctx, claims.UserId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查是否已经注册过
|
||||||
userAuth, err := s.userAuthModel.FindOneByAuthTypeAuthKey(ctx, userTemp.AuthType, userTemp.AuthKey)
|
userAuth, err := s.userAuthModel.FindOneByAuthTypeAuthKey(ctx, userTemp.AuthType, userTemp.AuthKey)
|
||||||
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
if err != nil && !errors.Is(err, model.ErrNotFound) {
|
||||||
return err
|
return err
|
||||||
@ -230,7 +232,13 @@ func (s *UserService) TempUserBindUser(ctx context.Context, session sqlx.Session
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -249,13 +257,18 @@ func (s *UserService) TempUserBindUser(ctx context.Context, session sqlx.Session
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// _bak_RegisterUUIDUser 注册UUID用户,返回用户ID
|
// _bak_RegisterUUIDUser 注册UUID用户,返回用户ID
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
func TestAesEcbMobileEncryption(t *testing.T) {
|
func TestAesEcbMobileEncryption(t *testing.T) {
|
||||||
// 测试手机号加密
|
// 测试手机号加密
|
||||||
mobile := "13930867138"
|
mobile := "18680618651"
|
||||||
|
|
||||||
keyStr := "ff83609b2b24fc73196aac3d3dfb874f"
|
keyStr := "ff83609b2b24fc73196aac3d3dfb874f"
|
||||||
// 测试加密
|
// 测试加密
|
||||||
|
Loading…
Reference in New Issue
Block a user