// 创建会员 func (this *Member) create(m *member.ValueMember) (int, error) { if this.UsrIsExist() { return -1, errors.New("用户名已经被使用") } if len(m.Phone) > 0 && this.PhoneIsExist(m.Phone) { return -1, member.ErrPhoneHasBind } t := time.Now().Unix() m.State = 1 m.RegTime = t m.LastLoginTime = t m.Level = 1 m.Exp = 1 m.Avatar = "resource/no_avatar.gif" m.BirthDay = "1970-01-01" m.DynamicToken = m.Pwd m.Exp = 0 if len(m.RegFrom) == 0 { m.RegFrom = "API-INTERNAL" } // 如果昵称为空,则跟用户名相同 if len(m.Name) == 0 { m.Name = m.Usr } m.InvitationCode = this.generateInvitationCode() // 创建一个邀请码 id, err := this._rep.SaveMember(m) if id != 0 { this._value.Id = id } return id, err }