- 整理饿百与京东PAGE API
This commit is contained in:
@@ -159,6 +159,157 @@ type PageShopHealthInfo struct {
|
||||
Week string `json:"week"`
|
||||
}
|
||||
|
||||
type ActivityTagInfo struct {
|
||||
Color struct {
|
||||
BgColor string `json:"bg_color"`
|
||||
FrameColor string `json:"frame_color"`
|
||||
FrontColor string `json:"front_color"`
|
||||
} `json:"color"`
|
||||
Discount string `json:"discount"`
|
||||
Msg string `json:"msg"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
type PageListInnerShopInfo struct {
|
||||
ActivityTag []*ActivityTagInfo `json:"activity_tag"`
|
||||
BrandName string `json:"brand_name"`
|
||||
BusinessStatus int `json:"business_status"`
|
||||
BusinessTime []struct {
|
||||
End string `json:"end"`
|
||||
Start string `json:"start"`
|
||||
} `json:"business_time"`
|
||||
CanRefund int `json:"can_refund"`
|
||||
CashGiftComment string `json:"cash_gift_comment"`
|
||||
DeliveryTime int `json:"delivery_time"`
|
||||
DisplayRefundLabel int `json:"display_refund_label"`
|
||||
Distance float64 `json:"distance"`
|
||||
EleID string `json:"ele_id"`
|
||||
FlashsalesStyleShop int `json:"flashsales_style_shop"`
|
||||
HasFoodEnsurance int `json:"has_food_ensurance"`
|
||||
HasServiceCommitment int `json:"has_service_commitment"`
|
||||
HitGod int `json:"hit_god"`
|
||||
IsBrand int `json:"is_brand"`
|
||||
IsDoubleTwelve int `json:"is_double_twelve"`
|
||||
IsRank int `json:"is_rank"`
|
||||
IsTransfer int `json:"is_transfer"`
|
||||
LogoURL string `json:"logo_url"`
|
||||
OverallRating float64 `json:"overall_rating"`
|
||||
SaledMonth int `json:"saled_month"`
|
||||
SameBrandFolding []struct {
|
||||
DeliveryTime int `json:"delivery_time"`
|
||||
Distance float64 `json:"distance"`
|
||||
EleID string `json:"ele_id"`
|
||||
IsTransfer int `json:"is_transfer"`
|
||||
ShopName string `json:"shop_name"`
|
||||
Wid string `json:"wid"`
|
||||
} `json:"same_brand_folding"`
|
||||
ShopLabels string `json:"shop_labels"`
|
||||
ShopName string `json:"shop_name"`
|
||||
TakeoutCost float64 `json:"takeout_cost"`
|
||||
TakeoutPrice int `json:"takeout_price"`
|
||||
Type interface{} `json:"type"`
|
||||
WelfareInfo []struct {
|
||||
IconColor struct {
|
||||
BgColor string `json:"bg_color"`
|
||||
FrameColor string `json:"frame_color"`
|
||||
FrontColor string `json:"front_color"`
|
||||
} `json:"icon_color"`
|
||||
IconName string `json:"icon_name"`
|
||||
IconNameOther string `json:"icon_name_other"`
|
||||
Msg string `json:"msg"`
|
||||
Type string `json:"type"`
|
||||
} `json:"welfare_info"`
|
||||
Wid string `json:"wid"`
|
||||
}
|
||||
|
||||
type PageListShopInfo struct {
|
||||
ActivityEntry interface{} `json:"activity_entry"`
|
||||
AoiID string `json:"aoi_id"`
|
||||
DisplayWindow []struct {
|
||||
CategoryIds []string `json:"category_ids"`
|
||||
CurrentPrice string `json:"current_price"`
|
||||
Image string `json:"image"`
|
||||
ItemID string `json:"item_id"`
|
||||
LeftNum int `json:"left_num"`
|
||||
Name string `json:"name"`
|
||||
OriginPrice string `json:"origin_price"`
|
||||
SkuID string `json:"sku_id"`
|
||||
} `json:"display_window"`
|
||||
ShopInfo *PageListInnerShopInfo `json:"shop_info"`
|
||||
}
|
||||
|
||||
type PageListInfo struct {
|
||||
ShopList []*PageListShopInfo `json:"shop_list"`
|
||||
Total int `json:"total"`
|
||||
UserType string `json:"user_type"`
|
||||
}
|
||||
|
||||
type PageShopInfo struct {
|
||||
Activities []struct {
|
||||
IconColor struct {
|
||||
BgColor string `json:"bg_color"`
|
||||
FrameColor string `json:"frame_color"`
|
||||
FrontColor string `json:"front_color"`
|
||||
} `json:"icon_color"`
|
||||
IconName string `json:"icon_name"`
|
||||
IconNameOther string `json:"icon_name_other"`
|
||||
Msg string `json:"msg"`
|
||||
Type string `json:"type"`
|
||||
} `json:"activities"`
|
||||
ActivityTag []*ActivityTagInfo `json:"activity_tag"`
|
||||
Address string `json:"address"`
|
||||
Albums []interface{} `json:"albums"`
|
||||
BdHeadBg string `json:"bd_head_bg"`
|
||||
BdHeadColor string `json:"bd_head_color"`
|
||||
Brand string `json:"brand"`
|
||||
BusinessStatus int `json:"business_status"`
|
||||
CanRefund int `json:"can_refund"`
|
||||
Category string `json:"category"`
|
||||
CityID string `json:"city_id"`
|
||||
CurrentBusinessTime string `json:"current_business_time"`
|
||||
DeliveryInfo []interface{} `json:"delivery_info"`
|
||||
DeliveryMode struct {
|
||||
Tag []interface{} `json:"tag"`
|
||||
Text string `json:"text"`
|
||||
} `json:"delivery_mode"`
|
||||
Description string `json:"description"`
|
||||
DisplayRefundLabel int `json:"display_refund_label"`
|
||||
Distance int `json:"distance"`
|
||||
EleBusinessState int `json:"ele_business_state"`
|
||||
EleID string `json:"ele_id"`
|
||||
FirstOpenTime struct {
|
||||
End string `json:"end"`
|
||||
Start string `json:"start"`
|
||||
} `json:"first_open_time"`
|
||||
HitGod int `json:"hit_god"`
|
||||
ImagePath string `json:"image_path"`
|
||||
IsColdChain int `json:"is_cold_chain"`
|
||||
IsDoubleTwelve int `json:"is_double_twelve"`
|
||||
IsMedicineShop int `json:"is_medicine_shop"`
|
||||
IsOwnTheme int `json:"is_own_theme"`
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
MedicineQualification []interface{} `json:"medicine_qualification"`
|
||||
Name string `json:"name"`
|
||||
NewStyle bool `json:"new_style"`
|
||||
OTakoutCost int `json:"o_takout_cost"`
|
||||
OTakoutPrice int `json:"o_takout_price"`
|
||||
OrderLeadTime interface{} `json:"order_lead_time"`
|
||||
Phone string `json:"phone"`
|
||||
PromotionInfo string `json:"promotion_info"`
|
||||
Qualification string `json:"qualification"`
|
||||
RecentOrderNum int `json:"recent_order_num"`
|
||||
ShopID string `json:"shop_id"`
|
||||
ShopScore int `json:"shop_score"`
|
||||
ShopSourceFrom int `json:"shop_source_from"`
|
||||
SkuCount int `json:"sku_count"`
|
||||
TakeoutCost int `json:"takeout_cost"`
|
||||
TakeoutInvoice int `json:"takeout_invoice"`
|
||||
TakeoutInvoiceMinPrice string `json:"takeout_invoice_min_price"`
|
||||
TakeoutOpenTime string `json:"takeout_open_time"`
|
||||
TakeoutPrice int `json:"takeout_price"`
|
||||
}
|
||||
|
||||
func (a *API) SetStoreCookie(key, value string) {
|
||||
a.locker.Lock()
|
||||
defer a.locker.Unlock()
|
||||
@@ -406,6 +557,19 @@ func (a *API) PageGetCustomCatList(baiduShopID int64) (catList []map[string]inte
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (a *API) GetStoreList(lng string, lat string) (retVal map[string]interface{}, err error) {
|
||||
retVal, err = a.AccessStorePageNoCookie(fmt.Sprintf("/newretail/main/shoplist?channel=kitchen&pn=1&rn=999&lng=%s&lat=%s", lng, lat))
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (a *API) GetStoreList2(lng float64, lat float64) (shopListInfo *PageListInfo, err error) {
|
||||
retVal, err := a.AccessStorePageNoCookie(fmt.Sprintf("/newretail/main/shoplist?channel=kitchen&pn=1&rn=999&lng=%f&lat=%f", lng, lat))
|
||||
if err == nil {
|
||||
err = utils.Map2StructByJson(retVal, &shopListInfo, true)
|
||||
}
|
||||
return shopListInfo, err
|
||||
}
|
||||
|
||||
func (a *API) GetStoreInfo(storeId string) (storeInfo map[string]interface{}, err error) {
|
||||
retVal, err := a.AccessStorePageNoCookie(fmt.Sprintf("newretail/shop/getshopinfo?&lat=0&lng=0&shop_id=%s", storeId))
|
||||
if err != nil {
|
||||
@@ -417,6 +581,17 @@ func (a *API) GetStoreInfo(storeId string) (storeInfo map[string]interface{}, er
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (a *API) GetStoreInfo2(storeID string) (storeInfo *PageShopInfo, err error) {
|
||||
retVal, err := a.AccessStorePageNoCookie(fmt.Sprintf("newretail/shop/getshopinfo?&lat=0&lng=0&shop_id=%s", storeID))
|
||||
if err == nil {
|
||||
if retVal != nil {
|
||||
retVal["shop_id"] = storeID
|
||||
err = utils.Map2StructByJson(retVal, &storeInfo, true)
|
||||
}
|
||||
}
|
||||
return storeInfo, err
|
||||
}
|
||||
|
||||
func (a *API) AccessStorePageNoCookie(subURL string) (retVal map[string]interface{}, err error) {
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
@@ -442,11 +617,6 @@ func (a *API) AccessStorePageNoCookie(subURL string) (retVal map[string]interfac
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (a *API) GetStoreList(lng string, lat string) (retVal map[string]interface{}, err error) {
|
||||
retVal, err = a.AccessStorePageNoCookie(fmt.Sprintf("/newretail/main/shoplist?channel=kitchen&pn=1&rn=999&lng=%s&lat=%s", lng, lat))
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (a *API) SwitchShop(baiduShopID int64) (switchShopCookie string, err error) {
|
||||
result, err := a.AccessStorePage("crm/manager/switchshop", map[string]interface{}{
|
||||
"switch_shop_id": baiduShopID,
|
||||
|
||||
@@ -114,6 +114,14 @@ func TestGetStoreList(t *testing.T) {
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetStoreList2(t *testing.T) {
|
||||
result, err := api.GetStoreList2(104.057218, 30.6949)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetStoreInfo(t *testing.T) {
|
||||
result, err := api.GetStoreInfo("170879219")
|
||||
if err != nil {
|
||||
@@ -121,3 +129,11 @@ func TestGetStoreInfo(t *testing.T) {
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetStoreInfo2(t *testing.T) {
|
||||
result, err := api.GetStoreInfo2("170879219")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user