添加ebaiapi.OrderCommetGet
This commit is contained in:
@@ -18,10 +18,6 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ReplyStatusAll = -1
|
|
||||||
ReplyStatusNotReplied = 0
|
|
||||||
ReplyStatusReplied = 1
|
|
||||||
|
|
||||||
CommentLevelAll = -1
|
CommentLevelAll = -1
|
||||||
CommentLevel1 = 1
|
CommentLevel1 = 1
|
||||||
CommentLevel2 = 2
|
CommentLevel2 = 2
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func TestGetStoreOrderInfoList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetEleCommentList(t *testing.T) {
|
func TestGetEleCommentList(t *testing.T) {
|
||||||
commentList, err := api.GetEleCommentList(utils.Str2Time("2019-06-25 00:00:00"), utils.Str2Time("2019-06-25 23:30:00"), "", "", ReplyStatusAll, CommentLevelAll, CommentContentAll)
|
commentList, err := api.GetEleCommentList(utils.Str2Time("2019-09-29 00:00:00"), utils.Str2Time("2019-09-30 23:30:00"), "", "", ReplyStatusAll, CommentLevelAll, CommentContentAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,49 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ReplyStatusAll = -1
|
||||||
|
ReplyStatusNotReplied = 0
|
||||||
|
ReplyStatusReplied = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
type GoodsComment struct {
|
||||||
|
CommentID int64 `json:"comment_id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Rating int `json:"rating"`
|
||||||
|
RatingContent string `json:"rating_content"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderComment struct {
|
||||||
|
CommentID int64 `json:"comment_id"`
|
||||||
|
PackageRating int `json:"package_rating"`
|
||||||
|
QualityRating int `json:"quality_rating"`
|
||||||
|
RatingAt int64 `json:"rating_at"`
|
||||||
|
RatingContent string `json:"rating_content"`
|
||||||
|
ReplyAt int64 `json:"reply_at"`
|
||||||
|
ReplyContent string `json:"reply_content"`
|
||||||
|
ServiceRating int `json:"service_rating"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ShopOrderComment struct {
|
||||||
|
AnonymousRating string `json:"anonymous_rating"`
|
||||||
|
CanEditReply string `json:"can_edit_reply"`
|
||||||
|
CanReply string `json:"can_reply"`
|
||||||
|
DishRateList []*GoodsComment `json:"dish_rate_list"`
|
||||||
|
OrderID int64 `json:"order_id"`
|
||||||
|
OrderRateList []*OrderComment `json:"order_rate_list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// 不要使用此接口,用OrderCommetGet
|
||||||
func (a *API) OrderRatesGet(shopID string, baiduShopID int64, startTime, endTime time.Time, replyStatus int) (commentList []map[string]interface{}, err error) {
|
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, 0)
|
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||||||
if !utils.IsTimeZero(startTime) {
|
if !utils.IsTimeZero(startTime) {
|
||||||
params["startTime"] = startTime
|
params["startTime"] = startTime.Unix()
|
||||||
}
|
}
|
||||||
if !utils.IsTimeZero(endTime) {
|
if !utils.IsTimeZero(endTime) {
|
||||||
params["endTime"] = endTime
|
params["endTime"] = endTime.Unix()
|
||||||
}
|
}
|
||||||
if replyStatus >= 0 {
|
if replyStatus != ReplyStatusAll {
|
||||||
params["replyStatus"] = replyStatus
|
params["replyStatus"] = replyStatus
|
||||||
}
|
}
|
||||||
pageNo := 1
|
pageNo := 1
|
||||||
@@ -41,3 +75,37 @@ func (a *API) OrderRatesReply(shopID string, baiduShopID int64, commentID, conte
|
|||||||
_, err = a.AccessAPI("ugc.reply", params)
|
_, err = a.AccessAPI("ugc.reply", params)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 此函数在用户匿名评价时,order_id为0,还是只有扒网页
|
||||||
|
func (a *API) OrderCommetGet(shopID string, baiduShopID int64, startTime, endTime time.Time, replyStatus int) (commentList []*ShopOrderComment, err error) {
|
||||||
|
params := a.genShopIDParams(shopID, baiduShopID, 0)
|
||||||
|
if !utils.IsTimeZero(startTime) {
|
||||||
|
params["startTime"] = startTime.Unix()
|
||||||
|
}
|
||||||
|
if !utils.IsTimeZero(endTime) {
|
||||||
|
params["endTime"] = endTime.Unix()
|
||||||
|
}
|
||||||
|
if replyStatus != ReplyStatusAll {
|
||||||
|
params["replyStatus"] = replyStatus
|
||||||
|
}
|
||||||
|
pageNo := 1
|
||||||
|
for {
|
||||||
|
params["page"] = pageNo
|
||||||
|
result, err := a.AccessAPI("ugc.ordercomment.get", params)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
data := result.Data.(map[string]interface{})
|
||||||
|
var pageCommentList []*ShopOrderComment
|
||||||
|
if err = utils.Map2StructByJson(data["comment_list"], &pageCommentList, false); err == nil {
|
||||||
|
commentList = append(commentList, pageCommentList...)
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
total := int(utils.MustInterface2Int64(data["total"]))
|
||||||
|
if len(commentList) >= total {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return commentList, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,7 +8,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestOrderRatesGet(t *testing.T) {
|
func TestOrderRatesGet(t *testing.T) {
|
||||||
commentList, err := api.OrderRatesGet("100119", 0, utils.DefaultTimeValue, utils.DefaultTimeValue, -1)
|
commentList, err := api.OrderRatesGet("102002", 0, utils.Str2Time("2019-09-25"), utils.Str2Time("2019-10-10"), ReplyStatusAll)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOrderCommetGet(t *testing.T) {
|
||||||
|
commentList, err := api.OrderCommetGet("102002", 0, utils.Str2Time("2019-09-29"), utils.Str2Time("2019-09-30"), ReplyStatusAll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user