1
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -13,6 +17,7 @@ const (
|
||||
CommentReplyStatusReplied = 1 // 已回复
|
||||
|
||||
MaxCommentQueryPageSize = 20
|
||||
CommentUrl = "https://shangoue.meituan.com/api/support/customer/comment/r/list"
|
||||
)
|
||||
|
||||
type OrderComment struct {
|
||||
@@ -48,7 +53,7 @@ type CommentOrderDetailList struct {
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
// 根据门店id批量查询评价信息(新版)
|
||||
// CommentQuery 根据门店id批量查询评价信息(新版)
|
||||
// http://developer.waimai.meituan.com/home/docDetail/191
|
||||
func (a *API) CommentQuery(poiCode string, startDateStr, endDateStr string, offset, limit int, replyStatus int) (commentList []*OrderComment, err error) {
|
||||
params := map[string]interface{}{
|
||||
@@ -97,7 +102,7 @@ func (a *API) CommentQuery(poiCode string, startDateStr, endDateStr string, offs
|
||||
return commentList, nil
|
||||
}
|
||||
|
||||
// 根据评价id添加商家回复
|
||||
// CommentAddReply 根据评价id添加商家回复
|
||||
// http://developer.waimai.meituan.com/home/docDetail/194
|
||||
func (a *API) CommentAddReply(poiCode string, commentID int64, reply string) (err error) {
|
||||
_, err = a.AccessAPI("poi/comment/add_reply", false, map[string]interface{}{
|
||||
@@ -107,3 +112,212 @@ func (a *API) CommentAddReply(poiCode string, commentID int64, reply string) (er
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *API) GetComment4ShanGou(param map[string]interface{}, isPost bool, cookie string) ([]*CommentsList, error) {
|
||||
wmPoiId := NumberCell + fmt.Sprintf("name=\"wmPoiId\"\r\n\r\n%v\r\n", param["wmPoiId"])
|
||||
appType := NumberCell + fmt.Sprintf("name=\"appType\"\r\n\r\n%v\r\n", param["appType"])
|
||||
pageNum := NumberCell + fmt.Sprintf("name=\"pageNum\"\r\n\r\n%v\r\n", param["pageNum"])
|
||||
rate := NumberCell + fmt.Sprintf("name=\"rate\"\r\n\r\n%v\r\n", param["rate"])
|
||||
reply := NumberCell + fmt.Sprintf("name=\"reply\"\r\n\r\n%v\r\n", param["reply"])
|
||||
context := NumberCell + fmt.Sprintf("name=\"context\"\r\n\r\n%v\r\n", param["context"])
|
||||
startDate := NumberCell + fmt.Sprintf("name=\"startDate\"\r\n\r\n%v\r\n", param["startDate"])
|
||||
endDate := NumberCell + fmt.Sprintf("name=\"endDate\"\r\n\r\n%v\r\n", param["endDate"])
|
||||
timeType := NumberCell + fmt.Sprintf("name=\"timeType\"\r\n\r\n%v\r\n-----011000010111000001101001--\r\n\r\n", param["timeType"])
|
||||
date := wmPoiId + appType + pageNum + rate + reply + context + startDate + endDate + timeType
|
||||
|
||||
result, err := a.AccessStoreComment(CommentUrl, date, isPost, cookie)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
comments := result["data"].(map[string]interface{})["comments"].([]interface{})
|
||||
if len(comments) == 0 {
|
||||
return nil, fmt.Errorf("暂未获取到数据")
|
||||
|
||||
}
|
||||
|
||||
vendorCommentsList := make([]*CommentsList, 0, 0)
|
||||
commentsJson, _ := json.Marshal(comments)
|
||||
if err := json.Unmarshal(commentsJson, &vendorCommentsList); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vendorCommentsList, nil
|
||||
|
||||
}
|
||||
|
||||
// AccessStoreComment 拉去美团页面上的评价订单
|
||||
// https://shangoue.meituan.com/api/support/customer/comment/r/list
|
||||
func (a *API) AccessStoreComment(fullURL string, param string, isPost bool, cookie string) (retVal map[string]interface{}, err error) {
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
var request *http.Request
|
||||
if isPost {
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(param))
|
||||
request.Header.Set("Cookie", cookie)
|
||||
request.Header.Set("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
|
||||
}
|
||||
a.FillRequestCookies(request)
|
||||
return request
|
||||
},
|
||||
a.config,
|
||||
func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||||
if jsonResult1 == nil {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||
}
|
||||
if strings.Contains(bodyStr, "登录") || strings.Contains(bodyStr, "访问的内容") {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("cookie可能过期了!")
|
||||
}
|
||||
if err == nil {
|
||||
if jsonResult1["error_response"] != nil {
|
||||
errLevel = platformapi.ErrLevelGeneralFail
|
||||
err = utils.NewErrorCode(jsonResult1["error_response"].(map[string]interface{})["zh_desc"].(string), jsonResult1["error_response"].(map[string]interface{})["code"].(string))
|
||||
}
|
||||
retVal = jsonResult1
|
||||
}
|
||||
return errLevel, err
|
||||
})
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
const (
|
||||
NumberCell = "-----011000010111000001101001\r\nContent-Disposition: form-data; "
|
||||
)
|
||||
|
||||
type CommentsList struct {
|
||||
CommentDimensionList []interface{} `json:"commentDimensionList"`
|
||||
MasterCleanComment string `json:"masterCleanComment"`
|
||||
MasterFastLabelList []interface{} `json:"masterFastLabelList"`
|
||||
MasterPhotoList []string `json:"masterPhotoList"`
|
||||
MasterVideo interface{} `json:"masterVideo"`
|
||||
SpuCommentList []struct {
|
||||
SpuId int64 `json:"spuId"`
|
||||
SpuName string `json:"spuName"`
|
||||
CleanComment string `json:"cleanComment"`
|
||||
FastLabelList []interface{} `json:"fastLabelList"`
|
||||
PhotoList []interface{} `json:"photoList"`
|
||||
VideoList []interface{} `json:"videoList"`
|
||||
} `json:"spuCommentList"` // 商品评论列表
|
||||
Id int64 `json:"id"`
|
||||
WmPoiId int `json:"wm_poi_id"`
|
||||
PoiId int `json:"poi_id"`
|
||||
OrderId int `json:"order_id"`
|
||||
UserId int64 `json:"user_id"`
|
||||
Username string `json:"username"`
|
||||
ShipScore int `json:"ship_score"`
|
||||
Comment string `json:"comment"`
|
||||
Valid int `json:"valid"`
|
||||
Ctime int `json:"ctime"`
|
||||
Utime int `json:"utime"`
|
||||
ShipTime int `json:"ship_time"`
|
||||
CleanComment string `json:"clean_comment"`
|
||||
CommentType int `json:"comment_type"`
|
||||
OrderCommentScore int `json:"order_comment_score"`
|
||||
AddComment interface{} `json:"add_comment"`
|
||||
AddCommentTime int `json:"add_comment_time"`
|
||||
FoodCommentScore int `json:"food_comment_score"`
|
||||
DeliveryCommentScore int `json:"delivery_comment_score"`
|
||||
PictureUrls []string `json:"picture_urls"`
|
||||
BizLabels struct {
|
||||
TagEmotion int `json:"tagEmotion"`
|
||||
Context []interface{} `json:"context"`
|
||||
} `json:"bizLabels"`
|
||||
DeliveryLabels struct {
|
||||
TagEmotion int `json:"tagEmotion"`
|
||||
Context []string `json:"context"`
|
||||
} `json:"deliveryLabels"`
|
||||
PoiName string `json:"poiName"`
|
||||
CreateTime string `json:"createTime"`
|
||||
AddCommentTime1 interface{} `json:"addCommentTime"`
|
||||
OrderStatus struct {
|
||||
Remark string `json:"remark"`
|
||||
DeliveryType string `json:"delivery_type"`
|
||||
Details []struct {
|
||||
FoodName string `json:"food_name"`
|
||||
Count int `json:"count"`
|
||||
} `json:"details"`
|
||||
} `json:"orderStatus"`
|
||||
ScoreMeaning string `json:"scoreMeaning"`
|
||||
Category int `json:"category"`
|
||||
TasteScore int `json:"taste_score"`
|
||||
QualityScore int `json:"quality_score"`
|
||||
PackagingScore int `json:"packaging_score"`
|
||||
PraiseFoodList []string `json:"praise_food_list"` // 表扬食物清单
|
||||
CriticFoodList []string `json:"critic_food_list"` // 批评食物清单
|
||||
ShowSort int `json:"showSort"`
|
||||
ShowReport int `json:"showReport"`
|
||||
WmCommentReportInfo struct {
|
||||
HasReported int `json:"hasReported"`
|
||||
ReportReviewStatus int `json:"reportReviewStatus"`
|
||||
ReportReadStatus int `json:"reportReadStatus"`
|
||||
ReportReviewStatusDesc string `json:"reportReviewStatusDesc"`
|
||||
ReportReviewResultDesc string `json:"reportReviewResultDesc"`
|
||||
ReportReviewEquityDesc string `json:"reportReviewEquityDesc"`
|
||||
ReportReviewEquityDescBoldList []interface{} `json:"reportReviewEquityDescBoldList"`
|
||||
} `json:"wmCommentReportInfo"`
|
||||
CanModify bool `json:"canModify"`
|
||||
EnvironmentLabel bool `json:"environmentLabel"`
|
||||
OverDeliveryTime int `json:"overDeliveryTime"`
|
||||
OverDeliveryTimeDesc *string `json:"overDeliveryTimeDesc"`
|
||||
ShowOrderInfo bool `json:"showOrderInfo"`
|
||||
ShowOrderInfoTime int `json:"showOrderInfoTime"`
|
||||
InterceptDay string `json:"intercept_day"`
|
||||
UserPicUrl string `json:"user_pic_url"`
|
||||
HasAppeal bool `json:"has_appeal"`
|
||||
ContactDisplayStatus int `json:"contactDisplayStatus"`
|
||||
ContactDisableReason string `json:"contactDisableReason"`
|
||||
ContactDisableDetails []struct {
|
||||
ItemName string `json:"itemName"`
|
||||
ItemValue string `json:"itemValue"`
|
||||
StandardValue string `json:"standardValue"`
|
||||
Status bool `json:"status"`
|
||||
StatusDesc string `json:"statusDesc"`
|
||||
} `json:"contactDisableDetails"`
|
||||
FirstContactConsumer bool `json:"firstContactConsumer"`
|
||||
UserDel int `json:"userDel"`
|
||||
BlockedStatus int `json:"blockedStatus"`
|
||||
ECommentList []struct {
|
||||
Id int64 `json:"id"`
|
||||
WmPoiId int `json:"wmPoiId"`
|
||||
UserId int `json:"userId"`
|
||||
UserName string `json:"userName"`
|
||||
Comment string `json:"comment"`
|
||||
ToCommentId int64 `json:"toCommentId"`
|
||||
Type int `json:"type"`
|
||||
Valid int `json:"valid"`
|
||||
Ctime int `json:"ctime"`
|
||||
Utime int `json:"utime"`
|
||||
CleanComment string `json:"cleanComment"`
|
||||
CommentType int `json:"commentType"`
|
||||
ReplyTime string `json:"replyTime"`
|
||||
UserCommentCtime int `json:"userCommentCtime"`
|
||||
CanModify bool `json:"canModify"`
|
||||
CreateTime string `json:"createTime"`
|
||||
} `json:"eCommentList"`
|
||||
}
|
||||
|
||||
func (a *API) AccessStoreComment2(param map[string]interface{}) {
|
||||
url := "https://shangoue.meituan.com/api/support/customer/comment/r/list"
|
||||
|
||||
wmPoiId := NumberCell + fmt.Sprintf("name=\"wmPoiId\"\r\n\r\n%v\r\n", param["wmPoiId"])
|
||||
appType := NumberCell + fmt.Sprintf("name=\"appType\"\r\n\r\n%v\r\n", param["appType"])
|
||||
pageNum := NumberCell + fmt.Sprintf("name=\"pageNum\"\r\n\r\n%v\r\n", param["pageNum"])
|
||||
rate := NumberCell + fmt.Sprintf("name=\"rate\"\r\n\r\n%v\r\n", param["rate"])
|
||||
reply := NumberCell + fmt.Sprintf("name=\"reply\"\r\n\r\n%v\r\n", param["reply"])
|
||||
context := NumberCell + fmt.Sprintf("name=\"context\"\r\n\r\n%v\r\n", param["context"])
|
||||
startDate := NumberCell + fmt.Sprintf("name=\"startDate\"\r\n\r\n%v\r\n", param["startDate"])
|
||||
endDate := NumberCell + fmt.Sprintf("name=\"endDate\"\r\n\r\n%v\r\n", param["endDate"])
|
||||
timeType := NumberCell + fmt.Sprintf("name=\"timeType\"\r\n\r\n%v\r\n-----011000010111000001101001--\r\n\r\n", param["timeType"])
|
||||
date := wmPoiId + appType + pageNum + rate + reply + context + startDate + endDate + timeType
|
||||
|
||||
payload := strings.NewReader(date)
|
||||
req, _ := http.NewRequest("POST", url, payload)
|
||||
req.Header.Add("Cookie", `uuid_update=true; _lxsdk_cuid=18a8c469cebc8-0d5443d9234ef1-26021051-240000-18a8c469cebc8; uuid=19f97d5039dc40979c40.1701152326.1.0.0; device_uuid=!303ca77f-1f5c-4db9-8beb-2140b78696e2; pushToken=01YLhAxagh8b3tlBORRhDbRt9URjGhSdCG84G5-PA1w0*; WEBDFPID=29z4yy3y961959z509u92w75626y558381x7618yx56979584y00uw64-2016762763564-1701402763564QQKUMAGfd79fef3d01d5e9aadc18ccd4d0c95073707; epassport_token=oekR9LsWaVAP0AUg0Z6l85HJoHP0OliCE3WcoMW3Xcluu9DZWqGb3SooLjItdc4BDgNRgeGKKLZYqAtpYp3CuQ; iuuid=6150CECD00F8926053D5784EE8E108EC3F622CECA73B5042408DE46AB37C3D80; _lxsdk=6150CECD00F8926053D5784EE8E108EC3F622CECA73B5042408DE46AB37C3D80; _ga=GA1.2.2133425411.1707118186; e_u_id_3299326472=a22cdb4f9c9a66958f72f3fe4d99aba6; isNewCome=1; userTicket=ABDdQinAblqsCpXDsEdtLNYrSpYSSlbRWYlhFyUm; u=893483812; n=tel1808018; lt=AgFCI__eFEzarguG6ly07rQWhiJFBEsWRgxUWRQPXLNOqeBN-U1C0hQ56pWpHL4sm50cGWeduIqVQwAAAAC4IQAAxbA-z1YAE9bBoB64Id-_ZJV3tTdf3aKBnn8v3h5o6AOWhEVtVcGjAr7ax5V84Mej; mt_c_token=AgFCI__eFEzarguG6ly07rQWhiJFBEsWRgxUWRQPXLNOqeBN-U1C0hQ56pWpHL4sm50cGWeduIqVQwAAAAC4IQAAxbA-z1YAE9bBoB64Id-_ZJV3tTdf3aKBnn8v3h5o6AOWhEVtVcGjAr7ax5V84Mej; wpush_server_url=wss://wpush.meituan.com; acctId=57396785; token=07_OvFPg_ZTHgLwGngAZTjwG214Gt4Yxh5HMgvCfYcas*; brandId=-1; isOfflineSelfOpen=0; city_id=0; isChain=1; existBrandPoi=true; ignore_set_router_proxy=true; region_id=; region_version=0; newCategory=true; bsid=GqPMJNy9tK3SglBZptuLYqkzKquaUJg2vmQCBLmZyMxhiHF4l44JeZRFxbW5eud8t7Ejzrsq2tHbHMnJ65_prw; grayPath=newRoot; cityId=510100; provinceId=510000; city_location_id=0; location_id=0; cacheTimeMark=2024-08-02; igateApp=shangouepc; pharmacistAccount=0; timeout=2000; accessToken=GqPMJNy9tK3SglBZptuLYqkzKquaUJg2vmQCBLmZyMxhiHF4l44JeZRFxbW5eud8t7Ejzrsq2tHbHMnJ65_prw; wmPoiName=京西菜市·新生鲜(珍珠园市场店); shopCategory=market; logistics_support=1; _gw_ab_call_43208_4=TRUE; _gw_ab_43208_4=434; wmPoiId=-1; signToken="L5bPEb0sVnqry/aUnAJMgoY7TH3sRjc6Vh3YXkAPPT1V79wwnQZTpV+zNJc4Zp5bDrwDP07NvrMICxPIAYJW4ztXmoL/p3JuZ28PaGGJ1AkaN5ogSY2xA1K1HOTia30DEMB3DbmR+tLgmCqm3oQd6w=="; logan_session_token=y0ktraxb5ilbbvjryqzn; set_info={"wmPoiId":-1,"ignoreSetRouterProxy":true}; _lxsdk_s=191109f37ec-af3-533-8d7||38`)
|
||||
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
|
||||
res, _ := http.DefaultClient.Do(req)
|
||||
defer res.Body.Close()
|
||||
body, _ := ioutil.ReadAll(res.Body)
|
||||
|
||||
fmt.Println(res)
|
||||
fmt.Println(string(body))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user