From 5b3ef2cd6d5a9744c6b80d74f698c0a2949b0f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 15 May 2025 14:33:22 +0800 Subject: [PATCH] 1 --- platformapi/mtwmapi/comment_test.go | 48 +++++++++++++++++++---------- platformapi/mtwmapi/retail.go | 2 -- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/platformapi/mtwmapi/comment_test.go b/platformapi/mtwmapi/comment_test.go index ca0c7bce..64ccf6a4 100644 --- a/platformapi/mtwmapi/comment_test.go +++ b/platformapi/mtwmapi/comment_test.go @@ -2,6 +2,7 @@ package mtwmapi import ( "fmt" + "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/globals" "io/ioutil" "net/http" @@ -11,31 +12,46 @@ import ( ) func TestCommentQuery(t *testing.T) { - result, err := api.CommentQuery("7756297", "20250415", "20250507", 0, 20, CommentReplyStatusAll) + result, err := api.CommentQuery("27674533", "20250420", "20250514", 40, 20, CommentReplyStatusAll) if err != nil { t.Fatal(err) } for _, mtwmComment := range result { - foodNameList := make(map[string]int, 0) - for _, fn := range mtwmComment.PraiseRetailList { - foodNameList[fn.Name] = 1 - } - for _, fn := range mtwmComment.CriticRetailList { - foodNameList[fn.Name] = 1 - } + if mtwmComment.CommentID == 8667486211 { - for _, fn := range mtwmComment.CommentOrderDetail { - if len(fn.FoodName)-strings.LastIndex(fn.FoodName, ")") > 3 { - foodNameList[strings.TrimSpace(fn.FoodName)] = 1 - } else { - foodNameList[strings.TrimSpace(fn.FoodName[0:strings.LastIndex(fn.FoodName, "(")])] = 1 + foodNameList := make(map[string]int, 0) + skuIdMap := make(map[string]int, 0) + for _, fn := range mtwmComment.PraiseRetailList { + skuIdMap[fn.SkuId] = 1 + foodNameList[fn.Name] = 1 } + for _, fn := range mtwmComment.CriticRetailList { + skuIdMap[fn.SkuId] = 1 + foodNameList[fn.Name] = 1 + } + + for _, fn := range mtwmComment.CommentOrderDetail { + if len(fn.FoodName)-strings.LastIndex(fn.FoodName, ")") > 3 { + foodNameList[strings.TrimSpace(fn.FoodName)] = 1 + } else { + foodNameList[strings.TrimSpace(fn.FoodName[0:strings.LastIndex(fn.FoodName, "(")])] = 1 + } + } + nameList := make([]string, 0, 0) + skuIdList := make([]int, 0, 0) + for k, _ := range foodNameList { + nameList = append(nameList, k) + } + for k, _ := range skuIdMap { + skuIdList = append(skuIdList, utils.Str2Int(k)) + } + + globals.SugarLogger.Debugf("----------nameList:= %s", utils.Format4Output(nameList, false)) + globals.SugarLogger.Debugf("----------skuIdList:= %s", utils.Format4Output(skuIdList, false)) + break } - fmt.Println(foodNameList) } - fmt.Println(result[19]) - //t.Log(utils.Format4Output(result, false)) } func TestCommentAddReply(t *testing.T) { diff --git a/platformapi/mtwmapi/retail.go b/platformapi/mtwmapi/retail.go index 9a27303c..b951fcd1 100644 --- a/platformapi/mtwmapi/retail.go +++ b/platformapi/mtwmapi/retail.go @@ -333,8 +333,6 @@ func (a *API) RetailSkuPrice(trackInfo, poiCode string, foodData []*BareStoreFoo if err == nil { failedFoodList, err = handleRetailBatchResult(result) } - globals.SugarLogger.Debugf("--------result err:= %v", err) - globals.SugarLogger.Debugf("--------result result:= %v", utils.Format4Output(result, false)) return failedFoodList, err }