- 创建或更新京西门店,注册用户时,自动根据门店的tel1,tel2添加门店老板角色
This commit is contained in:
@@ -114,6 +114,7 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri
|
||||
user.Type |= model.UserTypeStoreBoss
|
||||
}
|
||||
if err = CreateUser(user, utils.LimitUTF8StringLen(ctx.GetRealRemoteIP()+","+inAuthInfo.GetAuthID(), 32)); err == nil {
|
||||
TryAddStoreBossRole4User(ctx, user)
|
||||
if outAuthInfo, err = auth2.BindUser(mobileAuth, user); err == nil && inAuthInfo != nil {
|
||||
err = auth2.AddAuthBind(&outAuthInfo.UserBasic, inAuthInfo)
|
||||
}
|
||||
@@ -124,6 +125,40 @@ func RegisterUserWithMobile(ctx *jxcontext.Context, user *model.User, mobileVeri
|
||||
return outAuthInfo, err
|
||||
}
|
||||
|
||||
func TryAddStoreBossRole4User(ctx *jxcontext.Context, user *model.User) (err error) {
|
||||
if user.Type&model.UserTypeStoreBoss != 0 {
|
||||
userMobile := user.GetMobile()
|
||||
if userMobile != "" {
|
||||
if storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{userMobile}, ""); err == nil && len(storeList) > 0 {
|
||||
roleList := make([]*authz.RoleInfo, len(storeList))
|
||||
for k, v := range storeList {
|
||||
roleList[k] = autils.NewRole(authz.StoreRoleBoss, v.ID)
|
||||
}
|
||||
err = AddRoles4User(ctx, user.GetID(), roleList)
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func TryAddStoreBossRole4StoreByMobile(ctx *jxcontext.Context, storeID int, mobileList []string) (err error) {
|
||||
if storeID > 0 {
|
||||
var userIDs []string
|
||||
for _, v := range mobileList {
|
||||
if v != "" {
|
||||
if userList, _, err := dao.GetUsers(dao.GetDB(), model.UserTypeStoreBoss, "", nil, "", v, 0, -1); err == nil && len(userList) > 0 {
|
||||
userIDs = append(userIDs, userList[0].GetID())
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(userIDs) > 0 {
|
||||
role := autils.NewRole(authz.StoreRoleBoss, storeID)
|
||||
err = AddUsers4Role(ctx, role, userIDs)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func HandleOrder4Consignee(order *model.GoodsOrder) (err error) {
|
||||
var user *model.User
|
||||
authType := jxutils.GetAuthType4Vendor(order.VendorID)
|
||||
|
||||
Reference in New Issue
Block a user