diff --git a/app/mix/service/apiservice_business_validation.go b/app/mix/service/apiservice_business_validation.go index 4af569af..2467272f 100644 --- a/app/mix/service/apiservice_business_validation.go +++ b/app/mix/service/apiservice_business_validation.go @@ -106,19 +106,6 @@ func (s *Service) ApiLoginByVeriCodeBusinessValidate(ctx *gin.Context, req *logi // 2.如果错误码是登录信息不存在,则判断为首次登录,业务逻辑将创建用户信息 if ec == errcode.ErrCodeLoginNotExist { vericode, _ = resultList[3].(*dbstruct.VeriCode) - if req.Inviter != nil { - inviter, err := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{ - UserId: req.Inviter, - }) - if err != nil || inviter == nil { - ec = errcode.ErrCodeAccountInviterNotExist - return - } - if util.DerefInt64(inviter.Role) != consts.Streamer { - ec = errcode.ErrCodeAccountInviterIsNotAStreamer - return - } - } return } else if ec == errcode.ErrCodeLoginSrvOk { login, _ = resultList[1].(*dbstruct.Login) diff --git a/app/mix/service/opservice_business_validation.go b/app/mix/service/opservice_business_validation.go index cd8b9627..b5915924 100644 --- a/app/mix/service/opservice_business_validation.go +++ b/app/mix/service/opservice_business_validation.go @@ -1,7 +1,6 @@ package service import ( - "service/api/consts" "service/api/errcode" accountproto "service/api/proto/account/proto" accountrelationproto "service/api/proto/accountrelation/proto" @@ -19,7 +18,6 @@ import ( userwxaddcheckproto "service/api/proto/userwxaddcheck/proto" vericodeproto "service/api/proto/vericode/proto" businessvalidator "service/app/mix/service/business_validator" - "service/bizcommon/util" "service/dbstruct" "service/library/logger" "service/library/mycrypto" @@ -114,19 +112,7 @@ func (s *Service) OpLoginByVeriCodeBusinessValidate(ctx *gin.Context, req *login // 2.如果错误码是登录信息不存在,则判断为首次登录,将创建用户信息 if ec == errcode.ErrCodeLoginNotExist { - if req.Inviter != nil { - inviter, err := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{ - UserId: req.Inviter, - }) - if err != nil || inviter == nil { - ec = errcode.ErrCodeAccountInviterNotExist - return - } - if util.DerefInt64(inviter.Role) != consts.Streamer { - ec = errcode.ErrCodeAccountInviterIsNotAStreamer - return - } - } + vericode, _ = resultList[3].(*dbstruct.VeriCode) return } else if ec == errcode.ErrCodeLoginSrvOk { login, _ = resultList[1].(*dbstruct.Login) diff --git a/app/mix/service/utilservice.go b/app/mix/service/utilservice.go index 9f64d7a3..34d15292 100644 --- a/app/mix/service/utilservice.go +++ b/app/mix/service/utilservice.go @@ -2,6 +2,7 @@ package service import ( "fmt" + "service/api/consts" "service/api/errcode" accountproto "service/api/proto/account/proto" contact_customer_service_sessionproto "service/api/proto/contact_customer_service_session/proto" @@ -21,9 +22,24 @@ import ( // 注册账户 func (s *Service) utilRegisterUser(ctx *gin.Context, req *loginproto.MobilePhoneInfoComponent, inviter *int64) (login *dbstruct.Login, account *dbstruct.Account, ec errcode.ErrCode) { var err error + inviterUserId := int64(0) ec = errcode.ErrCodeLoginSrvOk + //判断邀请人是否是主播 + if inviter != nil { + account, err := _DefaultAccount.OpListByUserId(ctx, &accountproto.OpListByUserIdReq{ + UserId: inviter, + }) + if err != nil || account == nil { + logger.Error("inviter does not exist: err:%v", err) + } else if util.DerefInt64(account.Role) != consts.Streamer { + logger.Error("inviter is not a streamer") + } else { + inviterUserId = util.DerefInt64(inviter) + } + } + // 使用发号器发放一个user_id userIdSeq, err := _DefaultUserId.OpGetNextNormalUserId(ctx) if err != nil { @@ -44,7 +60,9 @@ func (s *Service) utilRegisterUser(ctx *gin.Context, req *loginproto.MobilePhone account.MobilePhone = goproto.String(req.MobilePhone) account.RegionCode = goproto.String(req.RegionCode) account.PhoneHash = goproto.String(req.PhoneHash) - account.Inviter = inviter + if inviterUserId != 0 { + account.Inviter = goproto.Int64(inviterUserId) + } // 创建账户,生成mid err = _DefaultAccount.OpCreate(ctx, &accountproto.OpCreateReq{