- api GetEleCommentList added
This commit is contained in:
@@ -14,6 +14,23 @@ const (
|
||||
storeURL = "https://be.ele.me"
|
||||
)
|
||||
|
||||
const (
|
||||
ReplyStatusAll = -1
|
||||
ReplyStatusNotReplied = 0
|
||||
ReplyStatusReplied = 1
|
||||
|
||||
CommentLevelAll = -1
|
||||
CommentLevel1 = 1
|
||||
CommentLevel2 = 2
|
||||
CommentLevel3 = 3
|
||||
CommentLevel4 = 4
|
||||
CommentLevel5 = 5
|
||||
|
||||
CommentContentAll = -1
|
||||
CommentContentHaveContent = 1
|
||||
CommentContentNoContent = 0
|
||||
)
|
||||
|
||||
func (a *API) SetStoreCookie(key, value string) {
|
||||
a.locker.Lock()
|
||||
defer a.locker.Unlock()
|
||||
@@ -102,9 +119,9 @@ func (a *API) GetStoreOrderInfoList(fromTime, toTime string, shopID string, orde
|
||||
}
|
||||
fixedURL := fmt.Sprintf(urlTemplate, params...)
|
||||
for {
|
||||
retVal, err := a.AccessStorePage(fixedURL + "&page=" + utils.Int2Str(pageNo))
|
||||
retVal, err2 := a.AccessStorePage(fixedURL + "&page=" + utils.Int2Str(pageNo))
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(retVal, false))
|
||||
if err == nil {
|
||||
if err = err2; err == nil {
|
||||
resultList := retVal["order_list"].([]interface{})
|
||||
storeOrderList = append(storeOrderList, utils.Slice2MapSlice(resultList)...)
|
||||
if len(storeOrderList) >= int(utils.MustInterface2Int64(retVal["order_count"])) {
|
||||
@@ -117,3 +134,54 @@ func (a *API) GetStoreOrderInfoList(fromTime, toTime string, shopID string, orde
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (a *API) GetEleCommentList(fromTime, toTime string, shopID, supplierID string, replyStatus, level, nonEmpty int) (commentList []map[string]interface{}, err error) {
|
||||
pageSize := 200
|
||||
pageNo := 1
|
||||
urlTemplate := "crm/getelecommentlist?start_time=%s&end_time=%s&page_count=%d"
|
||||
params := []interface{}{
|
||||
fromTime,
|
||||
toTime,
|
||||
pageSize,
|
||||
}
|
||||
if shopID != "" {
|
||||
urlTemplate += "&shop_id=%s"
|
||||
params = append(params, shopID)
|
||||
} else if supplierID != "" {
|
||||
urlTemplate += "&supplier_id=%s"
|
||||
params = append(params, supplierID)
|
||||
}
|
||||
if replyStatus != ReplyStatusAll {
|
||||
urlTemplate += "&reply_status=%d"
|
||||
params = append(params, replyStatus)
|
||||
}
|
||||
if level != CommentLevelAll {
|
||||
urlTemplate += "&level=%d"
|
||||
params = append(params, level)
|
||||
}
|
||||
if nonEmpty != CommentContentAll {
|
||||
urlTemplate += "&nonempty=%d"
|
||||
params = append(params, replyStatus)
|
||||
}
|
||||
fixedURL := fmt.Sprintf(urlTemplate, params...)
|
||||
for {
|
||||
retVal, err2 := a.AccessStorePage(fixedURL + "&page_num=" + utils.Int2Str(pageNo))
|
||||
if err = err2; err == nil {
|
||||
for _, comment := range retVal["comment_list"].([]interface{}) {
|
||||
commentMap := comment.(map[string]interface{})
|
||||
for _, orderComment := range commentMap["order_commentList"].([]interface{}) {
|
||||
orderCommentMap := orderComment.(map[string]interface{})
|
||||
orderCommentMap["order_id"] = commentMap["order_id"]
|
||||
commentList = append(commentList, orderComment.(map[string]interface{}))
|
||||
}
|
||||
}
|
||||
if len(commentList) >= int(utils.MustInterface2Int64(retVal["total"])) {
|
||||
return commentList, nil
|
||||
}
|
||||
pageNo++
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -40,3 +40,14 @@ func TestGetStoreOrderInfoList(t *testing.T) {
|
||||
baseapi.SugarLogger.Debug(len(orderInfoList))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetEleCommentList(t *testing.T) {
|
||||
commentList, err := api.GetEleCommentList("2019-02-14 13:00:00", "2019-02-15 15:30:00", "", "", ReplyStatusAll, CommentLevelAll, CommentContentAll)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if true {
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false))
|
||||
baseapi.SugarLogger.Debug(len(commentList))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user