42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package mtwmapi
|
||
|
||
import (
|
||
"fmt"
|
||
"strings"
|
||
"testing"
|
||
)
|
||
|
||
func TestCommentQuery(t *testing.T) {
|
||
result, err := api.CommentQuery("7821254", "20240730", "20240731", 0, 0, 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
|
||
}
|
||
|
||
for _, fn := range mtwmComment.CommentOrderDetail {
|
||
if len(fn.FoodName)-strings.LastIndex(fn.FoodName, ")") > 3 {
|
||
foodNameList[fn.FoodName] = 1
|
||
} else {
|
||
foodNameList[fn.FoodName[0:strings.LastIndex(fn.FoodName, "(")]] = 1
|
||
}
|
||
}
|
||
fmt.Println(foodNameList)
|
||
}
|
||
|
||
//t.Log(utils.Format4Output(result, false))
|
||
}
|
||
|
||
func TestCommentAddReply(t *testing.T) {
|
||
err := api.CommentAddReply("24617232", 2947288966, "非常抱歉让您没有得到十分满意的购物体验,我们会及时与您联系进行确认并解决问题!")
|
||
if err != nil {
|
||
t.Fatal(err)
|
||
}
|
||
}
|