diff --git a/app/user/cmd/api/internal/logic/query/querydetailbyorderidlogic.go b/app/user/cmd/api/internal/logic/query/querydetailbyorderidlogic.go index df5afd6..2a1d6b3 100644 --- a/app/user/cmd/api/internal/logic/query/querydetailbyorderidlogic.go +++ b/app/user/cmd/api/internal/logic/query/querydetailbyorderidlogic.go @@ -6,14 +6,15 @@ import ( "encoding/hex" "encoding/json" "fmt" - "github.com/jinzhu/copier" - "github.com/pkg/errors" "time" "tydata-server/common/xerr" "tydata-server/pkg/lzkit/crypto" "tydata-server/pkg/lzkit/delay" "tydata-server/pkg/lzkit/lzUtils" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "tydata-server/app/user/cmd/api/internal/svc" "tydata-server/app/user/cmd/api/internal/types" @@ -209,25 +210,18 @@ func (l *QueryDetailByOrderIdLogic) UpdateFeatureAndProductFeature(productID int // 遍历 productFeatures,找到与 feature.ID 关联且 enable == 1 的项 var featureData map[string]interface{} - foundFeature := false - + // foundFeature := false + sort := 0 for _, pf := range productFeatures { if pf.FeatureId == feature.Id { // 确保和 Feature 关联 - foundFeature = true - if pf.Enable == 1 { - featureData = map[string]interface{}{ - "featureName": feature.Name, - "sort": pf.Sort, - } - break // 找到第一个符合条件的就退出循环 - } + sort = int(pf.Sort) + break // 找到第一个符合条件的就退出循环 + } } - - // 如果没有符合条件的 feature 或者 featureData 为空,则删除当前 queryItem - if !foundFeature || featureData == nil { - *target = append((*target)[:i], (*target)[i+1:]...) - continue + featureData = map[string]interface{}{ + "featureName": feature.Name, + "sort": sort, } // 更新 queryItem 的 Feature 字段(不是数组) diff --git a/app/user/cmd/api/internal/logic/query/querydetailbyordernologic.go b/app/user/cmd/api/internal/logic/query/querydetailbyordernologic.go index 82d91db..7adad8f 100644 --- a/app/user/cmd/api/internal/logic/query/querydetailbyordernologic.go +++ b/app/user/cmd/api/internal/logic/query/querydetailbyordernologic.go @@ -4,12 +4,13 @@ import ( "context" "encoding/hex" "fmt" - "github.com/jinzhu/copier" - "github.com/pkg/errors" "time" "tydata-server/common/xerr" "tydata-server/pkg/lzkit/delay" + "github.com/jinzhu/copier" + "github.com/pkg/errors" + "tydata-server/app/user/cmd/api/internal/svc" "tydata-server/app/user/cmd/api/internal/types" @@ -172,25 +173,18 @@ func (l *QueryDetailByOrderNoLogic) UpdateFeatureAndProductFeature(productID int // 遍历 productFeatures,找到与 feature.ID 关联且 enable == 1 的项 var featureData map[string]interface{} - foundFeature := false - + // foundFeature := false + sort := 0 for _, pf := range productFeatures { if pf.FeatureId == feature.Id { // 确保和 Feature 关联 - foundFeature = true - if pf.Enable == 1 { - featureData = map[string]interface{}{ - "featureName": feature.Name, - "sort": pf.Sort, - } - break // 找到第一个符合条件的就退出循环 - } + sort = int(pf.Sort) + break // 找到第一个符合条件的就退出循环 + } } - - // 如果没有符合条件的 feature 或者 featureData 为空,则删除当前 queryItem - if !foundFeature || featureData == nil { - *target = append((*target)[:i], (*target)[i+1:]...) - continue + featureData = map[string]interface{}{ + "featureName": feature.Name, + "sort": sort, } // 更新 queryItem 的 Feature 字段(不是数组)