From dd559f2f78d9eaecf1f3ae76692ddeb81bbfc3e4 Mon Sep 17 00:00:00 2001 From: zhouyonggao <1971162852@qq.com> Date: Thu, 18 Dec 2025 23:26:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20=E8=B0=83=E6=95=B4=E6=9D=83?= =?UTF-8?q?=E9=99=90=E5=90=88=E5=B9=B6=E9=80=BB=E8=BE=91=E4=BB=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81plan=5Fid=5Feq=E5=92=8Creseller=5Fid=5Feq=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在marketing数据源且主资源为order或order_info时 - 若filters包含非空的plan_id_eq或reseller_id_eq,则跳过creator过滤 - 优化了对权限中多个可能user id字段的检测逻辑 - 统一将识别到的用户ID写入filters的creator_in字段 - 保留了对reseller_id和merchant_id的兼容处理逻辑 --- server/internal/api/exports.go | 50 +++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/server/internal/api/exports.go b/server/internal/api/exports.go index 95ed0d8..6212503 100644 --- a/server/internal/api/exports.go +++ b/server/internal/api/exports.go @@ -1559,35 +1559,47 @@ func mergePermissionIntoFilters(ds, main string, perm map[string]interface{}, fi if hasNonEmptyIDs(filters["creator_in"]) { return filters } - // try known keys - candidates := []string{"creator_in", "creator_ids", "user_ids", "user_id_in", "user_id", "owner_id"} - ids := []interface{}{} - for _, k := range candidates { - if perm == nil { - break + // 如果传递了 plan_id_eq 或 reseller_id_eq 且不为空,则不再过滤 creator + if ds == "marketing" && (main == "order" || main == "order_info") { + if v, ok := filters["plan_id_eq"]; ok && v != nil && v != "" && v != 0 { + goto skipCreator } - if v, ok := perm[k]; ok { - ids = normalizeIDs(v) - if len(ids) > 0 { - break - } + if v, ok := filters["reseller_id_eq"]; ok && v != nil && v != "" && v != 0 { + goto skipCreator } } - // also check filters incoming alternative keys and normalize into creator_in - if len(ids) == 0 { - alt := []string{"creator_ids", "user_ids", "user_id_in", "user_id", "owner_id"} - for _, k := range alt { - if v, ok := filters[k]; ok { + // try known keys + { + candidates := []string{"creator_in", "creator_ids", "user_ids", "user_id_in", "user_id", "owner_id"} + ids := []interface{}{} + for _, k := range candidates { + if perm == nil { + break + } + if v, ok := perm[k]; ok { ids = normalizeIDs(v) if len(ids) > 0 { break } } } + // also check filters incoming alternative keys and normalize into creator_in + if len(ids) == 0 { + alt := []string{"creator_ids", "user_ids", "user_id_in", "user_id", "owner_id"} + for _, k := range alt { + if v, ok := filters[k]; ok { + ids = normalizeIDs(v) + if len(ids) > 0 { + break + } + } + } + } + if len(ids) > 0 { + filters["creator_in"] = ids + } } - if len(ids) > 0 { - filters["creator_in"] = ids - } +skipCreator: // map alternative permission boundaries to supported filters // reseller/merchant -> reseller_id_eq if v, ok := pickFirst(perm, filters, []string{"reseller_id", "merchant_id"}); ok {