拉取门店
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
const (
|
||||
accessStorePageCookieName = "shop.o2o.jd.com1"
|
||||
getStoreURL = "https://daojia.jd.com"
|
||||
)
|
||||
|
||||
type SkuPageImg struct {
|
||||
@@ -137,3 +138,36 @@ func (a *API) GetSkuPageImageInfo(skuId int64) (imgList []*SkuPageImg, err error
|
||||
}
|
||||
return imgList, err
|
||||
}
|
||||
|
||||
func (a *API) GetStoreInfo(storeId string) (storeInfo map[string]interface{}, err error) {
|
||||
retVal, err := a.AccessStorePage2(fmt.Sprintf("client?functionId=store/storeDetailV220&body={\"storeId\":\"%s\"}&appVersion=6.1.0", storeId))
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (a *API) AccessStorePage2(subURL string) (retVal map[string]interface{}, err error) {
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
fullURL := utils.GenerateGetURL(getStoreURL, subURL, nil)
|
||||
request, _ := http.NewRequest(http.MethodGet, fullURL, nil)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return request
|
||||
},
|
||||
a.config,
|
||||
func(jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||||
code := jsonResult1["code"].(string)
|
||||
if code == ResponseCodeSuccess && jsonResult1["result"] != nil {
|
||||
retVal = jsonResult1["result"].(map[string]interface{})
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
}
|
||||
newErr := utils.NewErrorCode(jsonResult1["msg"].(string), code)
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
})
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (a *API) GetStoreList(lng string, lat string) (retVal map[string]interface{}, err error) {
|
||||
retVal, err = a.AccessStorePage2(fmt.Sprintf("client?platCode=h5&appVersion=6.5.0&functionId=zone/recommendStoreList&body={\"channelId\":\"3997\",\"currentPage\":1,\"pageSize\":999,\"coordType\":\"2\",\"platform\":\"1\"}&signKey=b63f63fa9e27123b84a0c80ef5cd210d&lng=%s&lat=%s", lng, lat))
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user