This commit is contained in:
邹宗楠
2025-08-28 17:38:48 +08:00
parent 57d7ff29c3
commit f51dd7226f
8 changed files with 99 additions and 201 deletions

View File

@@ -12,44 +12,41 @@ import (
)
func TestCommentQuery(t *testing.T) {
result, err := api.CommentQuery("17896509", "20250716", "20250717", 0, 20, CommentReplyStatusAll)
result, err := api.CommentQuery("7070710", "20250820", "20250824", 0, 20, CommentReplyStatusAll)
if err != nil {
t.Fatal(err)
}
for _, mtwmComment := range result {
if mtwmComment.CommentID == 8667486211 {
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
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
}
}