diff --git a/platformapi/ebaiapi/ugc.go b/platformapi/ebaiapi/ugc.go new file mode 100644 index 00000000..dac1bb7f --- /dev/null +++ b/platformapi/ebaiapi/ugc.go @@ -0,0 +1,43 @@ +package ebaiapi + +import ( + "time" + + "git.rosy.net.cn/baseapi/utils" +) + +func (a *API) OrderRatesGet(shopID string, baiduShopID int64, startTime, endTime time.Time, replyStatus int) (commentList []map[string]interface{}, err error) { + params := a.genShopIDParams(shopID, baiduShopID) + if !utils.IsTimeZero(startTime) { + params["startTime"] = startTime + } + if !utils.IsTimeZero(endTime) { + params["endTime"] = endTime + } + if replyStatus >= 0 { + params["replyStatus"] = replyStatus + } + pageNo := 1 + for { + params["page"] = pageNo + result, err := a.AccessAPI("ugc.orderrates.get", params) + if err != nil { + return nil, err + } + data := result.Data.(map[string]interface{}) + commentList = append(commentList, utils.Slice2MapSlice(data["comment_list"].([]interface{}))...) + total := int(utils.MustInterface2Int64(data["total"])) + if len(commentList) >= total { + break + } + } + return commentList, err +} + +func (a *API) OrderRatesReply(shopID string, baiduShopID int64, commentID, content string) (err error) { + params := a.genShopIDParams(shopID, baiduShopID) + params["comment_id"] = commentID + params["content"] = content + _, err = a.AccessAPI("ugc.reply", params) + return err +} diff --git a/platformapi/ebaiapi/ugc_test.go b/platformapi/ebaiapi/ugc_test.go new file mode 100644 index 00000000..b6c5f088 --- /dev/null +++ b/platformapi/ebaiapi/ugc_test.go @@ -0,0 +1,16 @@ +package ebaiapi + +import ( + "testing" + + "git.rosy.net.cn/baseapi" + "git.rosy.net.cn/baseapi/utils" +) + +func TestOrderRatesGet(t *testing.T) { + commentList, err := api.OrderRatesGet("100119", 0, utils.DefaultTimeValue, utils.DefaultTimeValue, -1) + if err != nil { + t.Fatal(err) + } + baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false)) +}