This commit is contained in:
邹宗楠
2024-07-18 14:27:31 +08:00
parent 942fb6f3ab
commit 42108e9793
2 changed files with 19 additions and 6 deletions

View File

@@ -34,6 +34,14 @@ type OrderComment struct {
Result string `json:"result"` Result string `json:"result"`
ShipTime int `json:"ship_time"` ShipTime int `json:"ship_time"`
CommentOrderDetail []CommentOrderDetailList `json:"comment_order_detail"` CommentOrderDetail []CommentOrderDetailList `json:"comment_order_detail"`
PraiseRetailList []RetailList `json:"praise_retail_list"` // 点赞商品列表
CriticRetailList []RetailList `json:"critic_retail_list"` // 点踩商品列表
}
type RetailList struct {
AppSpCode string `json:"app_sp_code"` // app方商品ID
SkuId string `json:"sku_id"`
Name string `json:"name"`
} }
type CommentOrderDetailList struct { type CommentOrderDetailList struct {
FoodName string `json:"food_name"` FoodName string `json:"food_name"`

View File

@@ -4,25 +4,30 @@ import (
"fmt" "fmt"
"strings" "strings"
"testing" "testing"
"time"
) )
func TestCommentQuery(t *testing.T) { func TestCommentQuery(t *testing.T) {
result, err := api.CommentQuery("19271619", "20240711", "20240716", 0, 0, CommentReplyStatusAll) result, err := api.CommentQuery("18477421", "20240712", "20240717", 0, 0, CommentReplyStatusAll)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
for _, mtwmComment := range result { for _, mtwmComment := range result {
foodNameList := make([]string, len(mtwmComment.CommentOrderDetail)) foodNameList := make(map[string]int, 0)
for _, fn := range mtwmComment.PraiseRetailList {
foodNameList[fn.Name] = 1
}
for _, fn := range mtwmComment.CriticRetailList {
foodNameList[fn.Name] = 1
}
for _, fn := range mtwmComment.CommentOrderDetail { for _, fn := range mtwmComment.CommentOrderDetail {
if len(fn.FoodName)-strings.LastIndex(fn.FoodName, "") > 3 { if len(fn.FoodName)-strings.LastIndex(fn.FoodName, "") > 3 {
foodNameList = append(foodNameList, fn.FoodName) foodNameList[fn.FoodName] = 1
} else { } else {
foodNameList = append(foodNameList, fn.FoodName[0:strings.LastIndex(fn.FoodName, "")]) foodNameList[fn.FoodName[0:strings.LastIndex(fn.FoodName, "")]] = 1
} }
} }
fmt.Println(foodNameList) fmt.Println(foodNameList)
time.Sleep(5 * time.Second)
} }
//t.Log(utils.Format4Output(result, false)) //t.Log(utils.Format4Output(result, false))