tuiguangm
This commit is contained in:
@@ -226,6 +226,8 @@ func CreateUser(user *model.User, creatorName string) (err error) {
|
|||||||
user.UserID = utils.GetUUID()
|
user.UserID = utils.GetUUID()
|
||||||
user.Status = model.UserStatusNormal
|
user.Status = model.UserStatusNormal
|
||||||
// user.DividePercentage = 1
|
// user.DividePercentage = 1
|
||||||
|
//推广码
|
||||||
|
user.PopCode = jxutils.GenValidateCode(6)
|
||||||
return dao.CreateEntity(nil, user)
|
return dao.CreateEntity(nil, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -893,3 +893,17 @@ func polarTriangleArea(tan1, lng1, tan2, lng2 float64) (s float64) {
|
|||||||
t := tan1 * tan2
|
t := tan1 * tan2
|
||||||
return 2 * math.Atan2(t*math.Sin(deltaLng), 1+t*math.Cos(deltaLng))
|
return 2 * math.Atan2(t*math.Sin(deltaLng), 1+t*math.Cos(deltaLng))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenValidateCode(width int) string {
|
||||||
|
numeric := [36]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
||||||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
|
||||||
|
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}
|
||||||
|
r := len(numeric)
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
|
||||||
|
var sb strings.Builder
|
||||||
|
for i := 0; i < width; i++ {
|
||||||
|
fmt.Fprintf(&sb, "%d", numeric[rand.Intn(r)])
|
||||||
|
}
|
||||||
|
return sb.String()
|
||||||
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ type User struct {
|
|||||||
LastLoginAt *time.Time `orm:"null" json:"lastLoginAt"`
|
LastLoginAt *time.Time `orm:"null" json:"lastLoginAt"`
|
||||||
LastLoginIP string `orm:"size(64);column(last_login_ip)" json:"lastLoginIP"`
|
LastLoginIP string `orm:"size(64);column(last_login_ip)" json:"lastLoginIP"`
|
||||||
LastLoginType string `orm:"size(16)" json:"lastLoginType"`
|
LastLoginType string `orm:"size(16)" json:"lastLoginType"`
|
||||||
|
PopCode string `json:"popCode"` //推广码
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*User) TableUnique() [][]string {
|
func (*User) TableUnique() [][]string {
|
||||||
|
|||||||
Reference in New Issue
Block a user