京东商城一堆
This commit is contained in:
@@ -19,6 +19,10 @@ const (
|
||||
|
||||
CreateCatType = "3"
|
||||
UpdateCatType = "1"
|
||||
|
||||
TransportID = 2158480
|
||||
JxBrandId = 559853
|
||||
JdShopMaxStock = 9999
|
||||
)
|
||||
|
||||
type API struct {
|
||||
@@ -109,3 +113,43 @@ func (a *API) AccessAPI(action string, url string, bizParams map[string]interfac
|
||||
})
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI2(action string, url string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
params := make(map[string]interface{})
|
||||
params["access_token"] = a.accessToken
|
||||
params["app_key"] = a.appKey
|
||||
params["timestamp"] = utils.Time2Str(time.Now())
|
||||
params["method"] = action
|
||||
params["v"] = "2.0"
|
||||
params = utils.MergeMaps(params, bizParams)
|
||||
signStr := a.signParam(params)
|
||||
params["sign"] = signStr
|
||||
fullURL := utils.GenerateGetURL(url, "", nil)
|
||||
// delete(params, "ware")
|
||||
// delete(params, "skus")
|
||||
// ware := bizParams["ware"].(string)
|
||||
// skus := bizParams["skus"].(string)
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
request, _ := http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.URLQueryEscape(utils.Map2URLValues(params).Encode())))
|
||||
request.Header.Set("charset", "UTF-8")
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
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 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))
|
||||
baseapi.SugarLogger.Debugf("jdeclp AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
}
|
||||
retVal = jsonResult1
|
||||
}
|
||||
return errLevel, err
|
||||
})
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user