usermanager
This commit is contained in:
@@ -124,23 +124,18 @@ func init() {
|
|||||||
func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVerifyCode string, inAuthInfo, manTokenInfo *auth2.AuthInfo) (outAuthInfo *auth2.AuthInfo, err error) {
|
func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVerifyCode string, inAuthInfo, manTokenInfo *auth2.AuthInfo) (outAuthInfo *auth2.AuthInfo, err error) {
|
||||||
var mobileAuth *auth2.AuthInfo
|
var mobileAuth *auth2.AuthInfo
|
||||||
fakeMobile := false
|
fakeMobile := false
|
||||||
user.Type = model.UserTypeConsumer | model.UserTypeStoreBoss // 先不区分商户与消息者
|
|
||||||
createName := ctx.GetRealRemoteIP()
|
createName := ctx.GetRealRemoteIP()
|
||||||
authType := auth2.AuthTypeMobile
|
authType := auth2.AuthTypeMobile
|
||||||
if manTokenInfo != nil && mobileVerifyCode == "" {
|
if manTokenInfo != nil && mobileVerifyCode == "" {
|
||||||
manUser, err2 := dao.GetUserByID(dao.GetDB(), "user_id", manTokenInfo.GetID())
|
_, err2 := dao.GetUserByID(dao.GetDB(), "user_id", manTokenInfo.GetID())
|
||||||
if err = err2; err != nil {
|
if err = err2; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if manUser.Type&(model.UserTypeOperator|model.UserTypeBoss) == 0 {
|
|
||||||
return nil, fmt.Errorf("管理员才能添加商户")
|
|
||||||
}
|
|
||||||
if utils.Pointer2String(user.Mobile) == "" {
|
if utils.Pointer2String(user.Mobile) == "" {
|
||||||
return nil, fmt.Errorf("管理员添加必须指定用户手机号")
|
return nil, fmt.Errorf("管理员添加必须指定用户手机号")
|
||||||
}
|
}
|
||||||
mobileVerifyCode = auth2.InternalAuthSecret
|
mobileVerifyCode = auth2.InternalAuthSecret
|
||||||
fakeMobile = true
|
fakeMobile = true
|
||||||
user.Type |= model.UserTypeStoreBoss
|
|
||||||
createName = manTokenInfo.GetName()
|
createName = manTokenInfo.GetName()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,11 +166,6 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri
|
|||||||
}
|
}
|
||||||
|
|
||||||
if inAuthInfo != nil {
|
if inAuthInfo != nil {
|
||||||
if inAuthInfo.AuthBindInfo.Type == dingding.AuthTypeStaff {
|
|
||||||
user.Type |= model.UserTypeOperator
|
|
||||||
} else if user.Mobile != nil {
|
|
||||||
user.Type |= model.UserTypeStoreBoss
|
|
||||||
}
|
|
||||||
createName += "," + inAuthInfo.GetAuthID()
|
createName += "," + inAuthInfo.GetAuthID()
|
||||||
authType = inAuthInfo.GetAuthType()
|
authType = inAuthInfo.GetAuthType()
|
||||||
if user.Avatar == "" {
|
if user.Avatar == "" {
|
||||||
@@ -596,8 +586,13 @@ func InvestMember(ctx *jxcontext.Context, memberID int) (errCode string, err err
|
|||||||
func UpdateUser(ctx *jxcontext.Context, payload map[string]interface{}) (err error) {
|
func UpdateUser(ctx *jxcontext.Context, payload map[string]interface{}) (err error) {
|
||||||
var (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
userID = ctx.GetUserID()
|
userID string
|
||||||
)
|
)
|
||||||
|
if payload["userID"] != nil {
|
||||||
|
userID = payload["userID"].(string)
|
||||||
|
} else {
|
||||||
|
userID = ctx.GetUserID()
|
||||||
|
}
|
||||||
user := &model.User{
|
user := &model.User{
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,12 +56,6 @@ 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"`
|
||||||
|
|
||||||
// ParentMobile string `orm:"size(32)" json:"parentMobile"`
|
|
||||||
// DividePercentage int `json:"dividePercentage"`
|
|
||||||
// Profit int `json:"profit"`
|
|
||||||
// ProfitSum int `json:"profitSum"`
|
|
||||||
// Arrears int `json:"arrears"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*User) TableUnique() [][]string {
|
func (*User) TableUnique() [][]string {
|
||||||
@@ -98,6 +92,19 @@ func (user *User) GetAvatar() string {
|
|||||||
return user.Avatar
|
return user.Avatar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserCityManager struct {
|
||||||
|
ModelIDCULD
|
||||||
|
|
||||||
|
UserID string `orm:"size(48);column(user_id)" json:"userID"` // 内部唯一标识
|
||||||
|
CityCode int `json:"cityCode"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*UserCityManager) TableUnique() [][]string {
|
||||||
|
return [][]string{
|
||||||
|
[]string{"UserID", "CityCode"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type UserPayment struct {
|
type UserPayment struct {
|
||||||
ModelIDCULD
|
ModelIDCULD
|
||||||
UserID string `orm:"size(48);column(user_id)" json:"userID"` // 内部唯一标识
|
UserID string `orm:"size(48);column(user_id)" json:"userID"` // 内部唯一标识
|
||||||
@@ -154,14 +161,6 @@ func (*UserCartItem) TableUnique() [][]string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserAgreement struct {
|
|
||||||
ModelIDCULD
|
|
||||||
Name string `orm:"size(32);index" json:"name"` // 外部显示标识(当前可以重复)
|
|
||||||
Mobile string `orm:"size(32)" json:"mobile"`
|
|
||||||
IDNumber string `orm:"column(id_number);size(20)" json:"idNumber"`
|
|
||||||
BankNumber string `orm:"size(32)" json:"bankNumber"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type UserOrderSms struct {
|
type UserOrderSms struct {
|
||||||
ID int64 `orm:"column(id)" json:"-"`
|
ID int64 `orm:"column(id)" json:"-"`
|
||||||
CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"createdAt"`
|
CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"createdAt"`
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ func Init() {
|
|||||||
orm.RegisterModel(&model.AuthBind{}, &model.User{})
|
orm.RegisterModel(&model.AuthBind{}, &model.User{})
|
||||||
orm.RegisterModel(&model.UserMember{})
|
orm.RegisterModel(&model.UserMember{})
|
||||||
orm.RegisterModel(&model.UserDeliveryAddress{})
|
orm.RegisterModel(&model.UserDeliveryAddress{})
|
||||||
|
orm.RegisterModel(&model.UserCityManager{})
|
||||||
//账单
|
//账单
|
||||||
orm.RegisterModel(&model.UserBill{}, &model.BillIncome{}, &model.BillExpend{})
|
orm.RegisterModel(&model.UserBill{}, &model.BillIncome{}, &model.BillExpend{})
|
||||||
//支付订单
|
//支付订单
|
||||||
|
|||||||
Reference in New Issue
Block a user