1
This commit is contained in:
@@ -34,6 +34,14 @@ type OrderComment struct {
|
||||
Result string `json:"result"`
|
||||
ShipTime int `json:"ship_time"`
|
||||
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 {
|
||||
FoodName string `json:"food_name"`
|
||||
|
||||
@@ -4,25 +4,30 @@ import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
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 {
|
||||
if len(fn.FoodName)-strings.LastIndex(fn.FoodName, ")") > 3 {
|
||||
foodNameList = append(foodNameList, fn.FoodName)
|
||||
foodNameList[fn.FoodName] = 1
|
||||
} else {
|
||||
foodNameList = append(foodNameList, fn.FoodName[0:strings.LastIndex(fn.FoodName, "(")])
|
||||
foodNameList[fn.FoodName[0:strings.LastIndex(fn.FoodName, "(")]] = 1
|
||||
}
|
||||
}
|
||||
fmt.Println(foodNameList)
|
||||
time.Sleep(5 * time.Second)
|
||||
}
|
||||
|
||||
//t.Log(utils.Format4Output(result, false))
|
||||
|
||||
Reference in New Issue
Block a user