1
This commit is contained in:
@@ -1,10 +1,14 @@
|
|||||||
package mtwmapi
|
package mtwmapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
"encoding/json"
|
||||||
"strings"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"io/ioutil"
|
||||||
|
"math"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -13,6 +17,7 @@ const (
|
|||||||
CommentReplyStatusReplied = 1 // 已回复
|
CommentReplyStatusReplied = 1 // 已回复
|
||||||
|
|
||||||
MaxCommentQueryPageSize = 20
|
MaxCommentQueryPageSize = 20
|
||||||
|
CommentUrl = "https://shangoue.meituan.com/api/support/customer/comment/r/list"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OrderComment struct {
|
type OrderComment struct {
|
||||||
@@ -48,7 +53,7 @@ type CommentOrderDetailList struct {
|
|||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据门店id批量查询评价信息(新版)
|
// CommentQuery 根据门店id批量查询评价信息(新版)
|
||||||
// http://developer.waimai.meituan.com/home/docDetail/191
|
// 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) {
|
func (a *API) CommentQuery(poiCode string, startDateStr, endDateStr string, offset, limit int, replyStatus int) (commentList []*OrderComment, err error) {
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
@@ -97,7 +102,7 @@ func (a *API) CommentQuery(poiCode string, startDateStr, endDateStr string, offs
|
|||||||
return commentList, nil
|
return commentList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据评价id添加商家回复
|
// CommentAddReply 根据评价id添加商家回复
|
||||||
// http://developer.waimai.meituan.com/home/docDetail/194
|
// http://developer.waimai.meituan.com/home/docDetail/194
|
||||||
func (a *API) CommentAddReply(poiCode string, commentID int64, reply string) (err error) {
|
func (a *API) CommentAddReply(poiCode string, commentID int64, reply string) (err error) {
|
||||||
_, err = a.AccessAPI("poi/comment/add_reply", false, map[string]interface{}{
|
_, 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
|
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))
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ package mtwmapi
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -39,3 +43,115 @@ func TestCommentAddReply(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetCommonList(t *testing.T) {
|
||||||
|
param := map[string]interface{}{
|
||||||
|
"wmPoiId": -1,
|
||||||
|
"appType": 3,
|
||||||
|
"pageNum": 1,
|
||||||
|
"rate": 0,
|
||||||
|
"reply": -1,
|
||||||
|
"context": -1,
|
||||||
|
"startDate": "2024-07-30",
|
||||||
|
"endDate": "2024-07-31",
|
||||||
|
"timeType": 4,
|
||||||
|
}
|
||||||
|
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`
|
||||||
|
result, err := api.GetComment4ShanGou(param, true, cookie)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, mtwmComment := range result {
|
||||||
|
// 商品的名称集合
|
||||||
|
foodNameList := make(map[string]int, 0)
|
||||||
|
// 好评商品
|
||||||
|
for _, fn := range mtwmComment.PraiseFoodList {
|
||||||
|
foodNameList[fn] = 1
|
||||||
|
}
|
||||||
|
// 差评商品
|
||||||
|
for _, fn := range mtwmComment.CriticFoodList {
|
||||||
|
foodNameList[fn] = 1
|
||||||
|
}
|
||||||
|
// 列表商品
|
||||||
|
for _, fn := range mtwmComment.SpuCommentList {
|
||||||
|
foodNameList[fn.SpuName] = 1
|
||||||
|
}
|
||||||
|
// 包含()中文括号的商品
|
||||||
|
for _, fn := range mtwmComment.OrderStatus.Details {
|
||||||
|
if len(fn.FoodName)-strings.LastIndex(fn.FoodName, ")") > 3 {
|
||||||
|
foodNameList[strings.TrimSuffix(fn.FoodName, " ")] = 1
|
||||||
|
} else {
|
||||||
|
foodNameList[strings.TrimSuffix(fn.FoodName[0:strings.LastIndex(fn.FoodName, "(")], " ")] = 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foodName := make([]string, 0, len(foodNameList))
|
||||||
|
for fnl, _ := range foodNameList {
|
||||||
|
foodName = append(foodName, fnl)
|
||||||
|
}
|
||||||
|
|
||||||
|
globals.SugarLogger.Debugf("vendorStoreId :%d , skuName: %s", mtwmComment.WmPoiId, strings.Join(foodName, ","))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCommonList2(t *testing.T) {
|
||||||
|
url := "https://shangoue.meituan.com/api/support/customer/comment/r/list"
|
||||||
|
|
||||||
|
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"wmPoiId\"\r\n\r\n-1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"appType\"\r\n\r\n3\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"pageNum\"\r\n\r\n1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"rate\"\r\n\r\n0\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"reply\"\r\n\r\n-1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"context\"\r\n\r\n-1\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"startDate\"\r\n\r\n2024-07-29\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"endDate\"\r\n\r\n2024-07-31\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"timeType\"\r\n\r\n4\r\n-----011000010111000001101001--\r\n\r\n")
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCommonList3(t *testing.T) {
|
||||||
|
param := map[string]interface{}{
|
||||||
|
"wmPoiId": -1,
|
||||||
|
"appType": 3,
|
||||||
|
"pageNum": 1,
|
||||||
|
"rate": 0,
|
||||||
|
"reply": -1,
|
||||||
|
"context": -1,
|
||||||
|
"startDate": "2024-07-30",
|
||||||
|
"endDate": "2024-07-31",
|
||||||
|
"timeType": 4,
|
||||||
|
}
|
||||||
|
api.AccessStoreComment2(param)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMNMath(t *testing.T) {
|
||||||
|
|
||||||
|
mathProbability := map[string]float64{
|
||||||
|
"order1": 0.800,
|
||||||
|
"order2": 0.750,
|
||||||
|
"order3": 0.900,
|
||||||
|
"order4": 0.981,
|
||||||
|
"order5": 0.230,
|
||||||
|
}
|
||||||
|
|
||||||
|
var values []float64
|
||||||
|
for _, v := range mathProbability {
|
||||||
|
values = append(values, v)
|
||||||
|
}
|
||||||
|
sort.Slice(values, func(i, j int) bool {
|
||||||
|
if values[i] > values[j] {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
for k, v := range mathProbability {
|
||||||
|
if v == values[0] {
|
||||||
|
fmt.Println(k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ func init() {
|
|||||||
|
|
||||||
//商超
|
//商超
|
||||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_s_eXEi_n4M9EIM8noEJAOQ") //token_n4TwqCntWWuvQwAawzxC0w
|
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_s_eXEi_n4M9EIM8noEJAOQ") //token_n4TwqCntWWuvQwAawzxC0w
|
||||||
cookieStr := `
|
//cookieStr := `
|
||||||
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
// acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||||
`
|
//`
|
||||||
api.SetCookieWithStr(cookieStr)
|
//api.SetCookieWithStr(cookieStr)
|
||||||
|
api.SetCookieWithStr(`__jdu=16496474755891719920568; unpl=JF8EALNnNSttDU0HBElWE0BAQ1oHWw4KGEcLOmRRUVhQHlUBHlIeEBF7XlVdXhRKEh9vZxRUWFNIVQ4YBysSEXteU11bD00VB2xXVgQFDQ8WUUtBSUt-SF1UXVsJSxMHbG4GZG1bS2QFGjIbFRVDWlFYWA5PEwpnZwNUVVBIVQEcCysiF3ttZFpaCUMTC19mNVVtGh8IDRwGGhMQBl1TW1UPThEGaWMBXVVYTVQNEwEaFhdCbVVuXg; areaId=22; ipLoc-djd=22-1930-0-0; PCSYCityID=CN_510000_510100_0; __jdv=122270672|baidu|-|organic|notset|1649658041982; pinId=0P4L2K_8z11ZUOOc8Pyh4w; pin=jxc4liulei; unick=jxc4liulei; _tp=SNh2AuY0LCWg91owlmuS1Q%3D%3D; _pst=jxc4liulei; ceshi3.com=000; _vender_=TNK3O6PALVQGG3P24NJQFXSBHYQNFQDBDAAAFNJIJAECQG2WSQGU5RJ6KSCMVVQQRHQZD6AECSQT3YKKYMRQJDFZHEEPXXHCR3STQEL55G2S4OB7Q6QUPCVBRUAZKDRVRF2MP5BK57JOU57NKALCQQWNR5XRJWJ4AGVNOAVSZUQ4QLRQZLY62QPOMBQHAQAGNLFRNQDWAO2N2HSD33FC2BJBV3S3QAJEAEJCDK4QQCZD6R72KBKNNWCITHQ32SVZKLN526Z2KM5T3DCVCND4YAK4AZMYIVI7ULYSDQD34K63YVC2TN5AJHZFWVYZEQGPZ65I6MTWTEDVOTLQ5D2AY2PBT4JHYXKEV6DFST3FWH5NOTDOJY3IASEKA7SG6LJSRN63HAW554GZVREIKMQHQAC5IVI445ONJ6GMFECU4SNRFRAYRKKYNISVYBKRTNHJCGFX2442SELHC4MUUVLVNBKEDYTDRCC4ZMMDMWSG75UUSWWXISJA; wlfstk_smdl=91h55jyt5sfm1901tdbgehyi67o5iaor; language=zh_CN; TrackID=1oqBrsNfaNsPFZVtK-124Hk1wwpg113ZwmS2Cajw8VwRsb0RCE3ph1kEhr7BLLOhyaQ196cgJsdscvrvGuBRoZm_dfJ1RuXfLocegNnMjRM8; thor=01BA10CC3862D8315A8F658F7DD2838C910211F45B05336172446EFDFC25E684EB4B9A81E2F1012525DBB65E171F7F5049FBFB076DA4FAC0AE7898C136389DC95DE18C259981364B775EAB7385F4CFFB2BEA505D94D2C1B8D5899C421825A32F0E60967FBF20170B0F1F31A27F795E2C40F4F9A141DD7260894C5EA879FE0810E99DDEFFC34ED45459429571A06DB76E; b-sec=3XU3DWGGC3WZSRRUDORQHBODFJXKGJRSNQI4WVMLXDV5NBOUPIJGYAR6Q5ZBP3KGR7GY3A37P62ZS; __jda=191429163.16496474755891719920568.1649647476.1649658035.1649658042.4; __jdc=191429163; 3AB9D23F7A4B3C9B=CKENC5MAUU744ZQDKVRY2L7UIJ23PJRDYJ6HF3ZMQHC5FFD46FMUQXRINFCOC4SKHL5MU3PPNPP4C4AX5ZYBXJ7LZ4; _base_=YKH2KDFHMOZBLCUV7NSRBWQUJPBI7JIMU5R3EFJ5UDHJ5LCU7R2NILKK5UJ6GLA2RGYT464UKXAI5KK7PNC5B5UHJ2HVQ4ENFP57OC2XJVD24IJG4VRA63GZVNQY5IXRTCNE6YVKRXISVJLYYILNIP6OVKS3GKYL2ZCNGXSSG4SOQWCP5WPWO6EFS7HEHMRWVKBRVHB33TFD4SMNBHRJCTDFHU6SZXCZD6RFXX2OORYGL5H2GYF2IIH2KKD4T72IR4F577G2E5II2OMMXYF2GDYNTS7WGAUXFEWRJ3CTKDBDWMHUKJQF4ZFOTNBBYBIZRXZYERXXIG6ASWNF62HTTIQSOQAEZEGZNSDAGQWOFW3BKDHOZ5FDR4MS74LDWUDI4FNIT374F4VDI; _BELONG_CLIENT_=WPSC4XJXWK5USS4JNZY2X7VRLR5MCBKRSVHEXABGTHDGISIQK5YOLZUXYE7IOIM7MOKO74H6CRN6WHAAR4TMDV3XZWMXZRCRT5XRNE3V356BTOB2Y7LPK66VWQK6HPTGWVXIDXDCPVE3W5WMHAIO6AT2LX2XXVNUCXR34ZWFK6HY45CORGIKOSYDYZBF27WOKTUX6BS4FZMIJWNUX6CB4JAA25ZLF7ZEKYOO4QV5HTSBXGNRM3E242MBI6V5D4C5VJDQ3EOYCOW5BMTUJZACIBHXQFAVLRF76VQY5PNJGGJNBEZHSFYYJA3YORRT7FB5AHCOIFQKF3W5RWNUX6CB4JAA26JNMO7AYWNUPZF5HTSBXGNRM3E242MBI6V5D4C5VJDQ3EOYCOW5BWZDKMOJ5BS6II53ERY6ALV3ZWPF42L4CPUHEGPYIII35KDC4FCNVCORCXFD6IVNLBEDPB2GGP4UHWNRUDOQBDIW7RZJXBA2WV5ANZOTEGUCDWYRVQS2YUTIZNZ276PRYG4N56V6YTII7MBKBC7LYHO7C555HTSBXGNRM3E466AYN67DHWVM5HQFJ4NFDO5BSREF6DFQ4KIBNVW4OYQNH5G7P3A; _vender_new_=GI63BGTJFDBQ5WAGCFF7AT6OUYWYFPVBHAMTKOO3UVWYDSOEMFHDXQYGEAIFTLTM6ICNHRYEWG53Y3EUFLXVKLH6RMKWRM7G5WA6AFWSDWJGOQXV26K6RBZHAU5DFEA4TBIYSVY45F3GK7X3Q5FHPNMZOCRLURVOQKFM7B2D4BBXHS2QRSAAEO6RPWOL62CWNGPOHMGMAGVAJ77C4IC2ET3NVN6PBVCLI56OPZPR7RNFOAEYFZTP2BSCS5ZMNTWN4HIOX5NUKDT5EUE5QQ722X2U2H7DKPHIF7OHQ6IR4HMB5NA7ACWBHEXOENOEOZZIHVQJO7KJEXLBYIYCIDSN4MFK5XWTHEBPJHFWGJBRDK2VBA6IMVCSGASA4TPDBKXN5UZZAL2JZNRSJTR363NRPUBYOPSTMWNXIMF4UYZPUUZPLTJX56EXDHFSRQF3F4FZXK47M3A33GZHU6UCVEAOAOFE3CAHDO4DMIK7334CESHKG3LT2KSPPDT3GXU5UUQOJGGQTYURJRST3PF7U6LS5URX2WPD7XV3OBKJQ2C3NFHU35TKJPWKEJUIFFUHXPJBS6AEJ7JV4RL5QDPT7ZGGIHSED3ZCDW563MYWFUFFCNMWQEZXMPDHUOHRDBNSOWPCAI4ZR4B4NENJLWZUO3XKK4L3AUAJKICWYY6MNDA`)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccessAPI(t *testing.T) {
|
func TestAccessAPI(t *testing.T) {
|
||||||
|
|||||||
Reference in New Issue
Block a user