usermanager

This commit is contained in:
苏尹岚
2020-11-11 10:43:30 +08:00
parent cb6fa7fa74
commit c2dae8e2bb
3 changed files with 21 additions and 26 deletions

View File

@@ -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) {
var mobileAuth *auth2.AuthInfo
fakeMobile := false
user.Type = model.UserTypeConsumer | model.UserTypeStoreBoss // 先不区分商户与消息者
createName := ctx.GetRealRemoteIP()
authType := auth2.AuthTypeMobile
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 {
return nil, err
}
if manUser.Type&(model.UserTypeOperator|model.UserTypeBoss) == 0 {
return nil, fmt.Errorf("管理员才能添加商户")
}
if utils.Pointer2String(user.Mobile) == "" {
return nil, fmt.Errorf("管理员添加必须指定用户手机号")
}
mobileVerifyCode = auth2.InternalAuthSecret
fakeMobile = true
user.Type |= model.UserTypeStoreBoss
createName = manTokenInfo.GetName()
}
@@ -171,11 +166,6 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri
}
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()
authType = inAuthInfo.GetAuthType()
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) {
var (
db = dao.GetDB()
userID = ctx.GetUserID()
userID string
)
if payload["userID"] != nil {
userID = payload["userID"].(string)
} else {
userID = ctx.GetUserID()
}
user := &model.User{
UserID: userID,
}

View File

@@ -56,12 +56,6 @@ type User struct {
LastLoginAt *time.Time `orm:"null" json:"lastLoginAt"`
LastLoginIP string `orm:"size(64);column(last_login_ip)" json:"lastLoginIP"`
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 {
@@ -98,6 +92,19 @@ func (user *User) GetAvatar() string {
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 {
ModelIDCULD
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 {
ID int64 `orm:"column(id)" json:"-"`
CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"createdAt"`

View File

@@ -15,6 +15,7 @@ func Init() {
orm.RegisterModel(&model.AuthBind{}, &model.User{})
orm.RegisterModel(&model.UserMember{})
orm.RegisterModel(&model.UserDeliveryAddress{})
orm.RegisterModel(&model.UserCityManager{})
//账单
orm.RegisterModel(&model.UserBill{}, &model.BillIncome{}, &model.BillExpend{})
//支付订单