From 594de29ba05cec64ac978111589d17dd3ec91292 Mon Sep 17 00:00:00 2001 From: zhouyonggao <1971162852@qq.com> Date: Mon, 15 Dec 2025 17:44:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E5=A2=9E=E5=BC=BA=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E5=8E=BB=E9=87=8D=E9=80=BB=E8=BE=91=E4=BB=A5=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=98=93=E7=A0=81=E9=80=9A=E5=AE=A2=E6=88=B7=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在exports.go和templates.go中新增逻辑,确保在处理易码通数据时,若同时选择order.merchant_name与merchant.name,仅保留merchant.name。此改动提升了字段去重的准确性,确保返回的数据符合预期。 --- server/internal/api/exports.go | 28 ++++++++++++++++++++++++++++ server/internal/api/templates.go | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/server/internal/api/exports.go b/server/internal/api/exports.go index 4eae75b..29658ef 100644 --- a/server/internal/api/exports.go +++ b/server/internal/api/exports.go @@ -300,6 +300,34 @@ func (a *ExportsAPI) create(w http.ResponseWriter, r *http.Request) { filtered = deduped } } + // 易码通客户名称字段去重:若同时选择 order.merchant_name 与 merchant.name,仅保留 merchant.name + if ds == "ymt" { + hasOrderMerchant := false + hasMerchantName := false + for _, tf := range filtered { + if tf == "order.merchant_name" { + hasOrderMerchant = true + } + if tf == "merchant.name" { + hasMerchantName = true + } + } + if hasOrderMerchant && hasMerchantName { + deduped := make([]string, 0, len(filtered)) + removed := []string{} + for _, tf := range filtered { + if tf == "order.merchant_name" { + removed = append(removed, tf) + continue + } + deduped = append(deduped, tf) + } + if len(removed) > 0 { + logging.JSON("INFO", map[string]interface{}{"event": "fields_deduplicated_customer_name", "removed": removed, "reason": "易码通客户名称仅保留 merchant.name"}) + } + filtered = deduped + } + } labels := FieldLabels() // 相同列名(中文标签)去重:如果多个表的字段共享同一列名,优先保留主表字段 { diff --git a/server/internal/api/templates.go b/server/internal/api/templates.go index 5fccd99..a79ee2b 100644 --- a/server/internal/api/templates.go +++ b/server/internal/api/templates.go @@ -120,6 +120,12 @@ func (a *TemplatesAPI) listTemplates(w http.ResponseWriter, r *http.Request) { if !wl[tf] { continue } + // special dedupe: when both order.merchant_name and merchant.name exist, only count merchant.name + if ds == "ymt" && tf == "order.merchant_name" { + if _, ok := seen["merchant.name"]; ok { + continue + } + } if _, ok := seen[tf]; ok { continue }