From 8b761d7d0521a6fa41a904317d8102e8c7c889f1 Mon Sep 17 00:00:00 2001 From: chengma Date: Mon, 24 Aug 2026 00:17:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8C=89=E8=AE=A2=E5=8D=95=E6=95=B0?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E9=A1=BA=E8=BF=90=E5=AE=9D=E9=A2=9C=E8=89=B2?= =?UTF-8?q?=E6=9D=A5=E6=BA=90=20(#293)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/service/color_mapping.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/admin/service/color_mapping.go b/admin/service/color_mapping.go index c1a9096..cf6b700 100644 --- a/admin/service/color_mapping.go +++ b/admin/service/color_mapping.go @@ -155,11 +155,14 @@ func collectProductColors(q repository.Execer, goodsID string) ([]ProductColorSo formalCount, sybCount int } byKey := map[string]*accumulator{} - add := func(raw string, formal bool) { + add := func(raw string, formal bool, count int) { key := NormalizeProductColorKey(raw) if key == "" { return } + if count < 1 { + count = 1 + } item := byKey[key] if item == nil { item = &accumulator{raw: strings.TrimSpace(raw)} @@ -168,9 +171,9 @@ func collectProductColors(q repository.Execer, goodsID string) ([]ProductColorSo item.raw = candidate } if formal { - item.formalCount++ + item.formalCount += count } else { - item.sybCount++ + item.sybCount += count } } skus, err := repository.ListShopeeSKUsByGoodsID(q, goodsID) @@ -178,7 +181,7 @@ func collectProductColors(q repository.Execer, goodsID string) ([]ProductColorSo return nil, err } for _, sku := range skus { - add(sku.Color, true) + add(sku.Color, true, 1) } observations, err := repository.ListSybSpecObservations(q, goodsID) if err != nil { @@ -186,7 +189,7 @@ func collectProductColors(q repository.Execer, goodsID string) ([]ProductColorSo } for _, observation := range observations { if parsed, ok := spec.ParseShopeeSpec(observation.SpecRaw); ok { - add(parsed.Color, false) + add(parsed.Color, false, observation.OrderCount) } } result := make([]ProductColorSource, 0, len(byKey))