popcode
This commit is contained in:
@@ -225,9 +225,16 @@ func CreateUser(user *model.User, creatorName string) (err error) {
|
||||
dao.WrapAddIDCULDEntity(user, creatorName)
|
||||
user.UserID = utils.GetUUID()
|
||||
user.Status = model.UserStatusNormal
|
||||
// user.DividePercentage = 1
|
||||
//推广码
|
||||
user.PopCode = jxutils.GenRandomString(6)
|
||||
popCode := ""
|
||||
for {
|
||||
popCode = jxutils.GenRandomString(6)
|
||||
user, _ := dao.GetUserByID(dao.GetDB(), "pop_code", popCode)
|
||||
if user == nil {
|
||||
user.PopCode = popCode
|
||||
break
|
||||
}
|
||||
}
|
||||
return dao.CreateEntity(nil, user)
|
||||
}
|
||||
|
||||
@@ -613,6 +620,17 @@ func UpdateUser(ctx *jxcontext.Context, payload map[string]interface{}) (err err
|
||||
return err
|
||||
}
|
||||
}
|
||||
//暂时用这个字段作为更新他的推广人
|
||||
if payload["popCode"] != nil {
|
||||
if user, err := dao.GetUserByID(db, "pop_code", payload["popCode"].(string)); err == nil {
|
||||
if user != nil {
|
||||
payload["popUser"] = user.UserID
|
||||
delete(payload, "popCode")
|
||||
} else {
|
||||
return fmt.Errorf("未查询到此推广人!%v", payload["popCode"])
|
||||
}
|
||||
}
|
||||
}
|
||||
valid := dao.StrictMakeMapByStructObject(payload, user, ctx.GetUserName())
|
||||
if len(valid) > 0 {
|
||||
dao.Begin(db)
|
||||
|
||||
@@ -57,6 +57,7 @@ type User struct {
|
||||
LastLoginIP string `orm:"size(64);column(last_login_ip)" json:"lastLoginIP"`
|
||||
LastLoginType string `orm:"size(16)" json:"lastLoginType"`
|
||||
PopCode string `json:"popCode"` //推广码
|
||||
PopUser string `json:"popUser"` //推广人
|
||||
}
|
||||
|
||||
func (*User) TableUnique() [][]string {
|
||||
|
||||
Reference in New Issue
Block a user