This commit is contained in:
邹宗楠
2024-02-29 09:38:09 +08:00
parent c067af71b6
commit 9f7906134e
2 changed files with 15 additions and 15 deletions

View File

@@ -588,18 +588,20 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
if storeIDsMap[int(utils.Interface2Int64WithDefault(params["storeID"], 0))] == 0 { if storeIDsMap[int(utils.Interface2Int64WithDefault(params["storeID"], 0))] == 0 {
params["storeID"] = nil params["storeID"] = nil
} }
} else { } else if len(storeIDsMap) > 0 {
if len(storeIDsMap) > 0 { for k, _ := range storeIDsMap {
for k, _ := range storeIDsMap { storeIDs2 = append(storeIDs2, k)
storeIDs2 = append(storeIDs2, k)
}
} else {
//storeIDs2 = append(storeIDs2, -1)l
// 商家小程序用户切换门店,如果角色storeIDsMap没有数据则查询传入数据
storeIDs2 = append(storeIDs2, int(utils.Interface2Int64WithDefault(params["storeID"], 0)))
} }
} else {
//storeIDs2 = append(storeIDs2, -1)l
// 商家小程序用户切换门店,如果角色storeIDsMap没有数据则查询传入数据
storeIDs2 = append(storeIDs2, int(utils.Interface2Int64WithDefault(params["storeID"], 0)))
} }
} }
roleInfo, _ := GetUserRoleList(ctx, ctx.GetUserID())
for _, v := range roleInfo {
storeIDs2 = append(storeIDs2, v.StoreID)
}
if data, err := json.Marshal(storeIDs2); err == nil { if data, err := json.Marshal(storeIDs2); err == nil {
params["storeIDs"] = string(data) params["storeIDs"] = string(data)
} }

View File

@@ -343,13 +343,11 @@ func GetUserStoresResultMap(userID string) (resultMap map[int]int, err error) {
) )
resultMap = make(map[int]int) resultMap = make(map[int]int)
user, _ := dao.GetUserByID(db, "user_id", userID) user, _ := dao.GetUserByID(db, "user_id", userID)
if user != nil { if user != nil && user.BindStoreID != "" {
if user.BindStoreID != "" { for _, v := range strings.Split(user.BindStoreID, ",") {
for _, v := range strings.Split(user.BindStoreID, ",") { resultMap[utils.Str2Int(v)] = utils.Str2Int(v)
resultMap[utils.Str2Int(v)] = utils.Str2Int(v)
}
return resultMap, err
} }
return resultMap, err
} }
userRoles, err2 := dao.GetUserRole2(db, []string{userID}, nil) userRoles, err2 := dao.GetUserRole2(db, []string{userID}, nil)
err = err2 err = err2