Merge branch 'xjjdev'
This commit is contained in:
commit
73264cde5d
@ -168,24 +168,34 @@ func (a *ArtistInfoUserProvider) GetUserMsg(ctx context.Context, req *artistInfo
|
||||
|
||||
// 绑定邀请人和受邀请人的账号,并加入到次数统计
|
||||
func (a *ArtistInfoUserProvider) BindInviteInvitedAccount(ctx context.Context, in *artistInfoUser.BindInviteInvitedAccountRequest) (res *artistInfoUser.BindInviteInvitedAccountRespond, err error) {
|
||||
// 查询邀请人是否存在
|
||||
var thisUser model.User
|
||||
// 查询被邀请人是否存在
|
||||
var invitedUser model.User
|
||||
if in.InvitedUserId == 0 {
|
||||
if err = db.DB.Debug().Where("invited_code = ?", in.InviteCode).First(&thisUser).Error; err != nil {
|
||||
if err = db.DB.Debug().Where("invited_code = ?", in.InviteCode).First(&invitedUser).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, errors.New("邀请人不存在")
|
||||
return nil, errors.New("被邀请人不存在")
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
fmt.Println("邀请人userId:", thisUser.ID)
|
||||
// 查询邀请人是否存在
|
||||
var inviteUser model.User
|
||||
if err = db.DB.Debug().Where("invited_code = ?", in.InviteCode).First(&inviteUser).Error; err != nil {
|
||||
if err == gorm.ErrRecordNotFound {
|
||||
return nil, errors.New("邀请人不存在")
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
fmt.Println("邀请人userId:", inviteUser.ID)
|
||||
fmt.Println("被邀请人userId:", invitedUser.ID)
|
||||
var data model.Invite
|
||||
// 受邀请者只能绑定一个邀请人
|
||||
if err = db.DB.Debug().Where("invite_code = ? AND invited_code = ?", in.InviteCode, in.InvitedCode).Find(&data).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data.UserId = int32(thisUser.ID)
|
||||
data.UserId = int32(inviteUser.ID)
|
||||
data.InvitedId = in.InvitedUserId
|
||||
data.InvitedCode = in.InvitedCode
|
||||
data.InviteCode = in.InviteCode
|
||||
|
Loading…
Reference in New Issue
Block a user