mtwmapi.OrderModityTips and GetDistributeOrderDetail
This commit is contained in:
@@ -11,7 +11,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
userURL = "http://i.waimai.meituan.com"
|
||||
userURL = "http://i.waimai.meituan.com"
|
||||
orderURL = "https://shangoue.meituan.com/v2"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -37,20 +38,31 @@ type ListShopItem struct {
|
||||
WmPoiScore int `json:"wmPoiScore"`
|
||||
}
|
||||
|
||||
func (a *API) AccessUserPage(subURL string, params map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
func getRootURL(subURL string) (rootURL string) {
|
||||
if strings.Index(subURL, "order/receive/processed/r/distribute") >= 0 {
|
||||
return orderURL
|
||||
}
|
||||
return userURL
|
||||
}
|
||||
|
||||
func (a *API) AccessUserPage2(subURL string, params map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
||||
if a.GetCookieCount() == 0 {
|
||||
return nil, fmt.Errorf("需要设置User Cookie才能使用此方法")
|
||||
}
|
||||
rootURL := getRootURL(subURL)
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
var request *http.Request
|
||||
fullURL := utils.GenerateGetURL(userURL, subURL, nil)
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
request.Header.Set("charset", "UTF-8")
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
request.Header.Set("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1")
|
||||
request.Header.Set("Pragma", "no-cache")
|
||||
|
||||
if isPost {
|
||||
fullURL := utils.GenerateGetURL(rootURL, subURL, nil)
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
request.Header.Set("charset", "UTF-8")
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
request.Header.Set("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1")
|
||||
request.Header.Set("Pragma", "no-cache")
|
||||
} else {
|
||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(rootURL, subURL, params), nil)
|
||||
}
|
||||
a.FillRequestCookies(request)
|
||||
return request
|
||||
},
|
||||
@@ -66,12 +78,16 @@ func (a *API) AccessUserPage(subURL string, params map[string]interface{}) (retV
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
}
|
||||
newErr := utils.NewErrorIntCode(jsonResult1["msg"].(string), code)
|
||||
baseapi.SugarLogger.Debugf("ebai AccessStorePage failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
baseapi.SugarLogger.Debugf("mtwm AccessUserPage failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
})
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (a *API) AccessUserPage(subURL string, params map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
return a.AccessUserPage2(subURL, params, true)
|
||||
}
|
||||
|
||||
func (a *API) GetStoreList(lng, lat float64) (shopList []*ListShopItem, err error) {
|
||||
params := map[string]interface{}{
|
||||
"sortId": 1,
|
||||
|
||||
Reference in New Issue
Block a user