- 饿百与京东拉门店数据基本OK

This commit is contained in:
gazebo
2019-06-24 21:43:20 +08:00
parent 3fed4d3af9
commit dd92bb99f5
14 changed files with 408 additions and 173 deletions

View File

@@ -0,0 +1,49 @@
package ebai
import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/ditu"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/globals/api"
)
func (c *PurchaseHandler) GetStoreIDListByCoordinates(ctx *jxcontext.Context, coord *ditu.Coordinate) (storeIDList []string, err error) {
shopListInfo, err := api.EbaiAPI.GetStoreList2(coord.Lng, coord.Lat)
if err != nil {
return nil, err
}
if shopListInfo != nil {
for _, v := range shopListInfo.ShopList {
storeIDList = append(storeIDList, v.ShopInfo.Wid)
}
}
return storeIDList, nil
}
func (c *PurchaseHandler) GetStorePageInfo(ctx *jxcontext.Context, cityInfo, storeID string) (storePageInfo *model.PageShop, err error) {
shopInfo, err2 := api.EbaiAPI.GetStoreInfo2(storeID)
if err = err2; err == nil && shopInfo != nil {
_, _, districtCode := api.AutonaviAPI.GetCoordinateFromAddress(shopInfo.Address, cityInfo)
return &model.PageShop{
Name: shopInfo.Name,
VendorID: model.VendorIDEBAI,
VendorStoreID: storeID,
OrgCode: shopInfo.Brand,
VendorStatus: utils.Int2Str(shopInfo.BusinessStatus),
Address: shopInfo.Address,
Lng: shopInfo.Longitude,
Lat: shopInfo.Latitude,
DistrictCode: districtCode,
Tel1: shopInfo.Phone,
RecentOrderNum: shopInfo.RecentOrderNum,
SkuCount: shopInfo.SkuCount,
BusinessType: shopInfo.Category,
ShopScore: float32(shopInfo.ShopScore),
}, nil
}
return nil, err
}

View File

@@ -0,0 +1 @@
package ebai

View File

@@ -0,0 +1,51 @@
package jd
import (
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/ditu"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/globals/api"
)
func (c *PurchaseHandler) GetStoreIDListByCoordinates(ctx *jxcontext.Context, coord *ditu.Coordinate) (storeIDList []string, err error) {
shopListInfo, err := api.JdAPI.GetStoreList(utils.Float64ToStr(coord.Lng), utils.Float64ToStr(coord.Lat))
if err != nil {
return nil, err
}
if shopListInfo != nil {
shopDataList, _ := shopListInfo["data"].(map[string]interface{})["data"].([]interface{})
for _, v := range shopDataList {
floorCellData := v.(map[string]interface{})["floorCellData"].(map[string]interface{})
storeIDList = append(storeIDList, utils.Interface2String(floorCellData["storeId"]))
}
}
return storeIDList, nil
}
func (c *PurchaseHandler) GetStorePageInfo(ctx *jxcontext.Context, cityInfo, storeID string) (storePageInfo *model.PageShop, err error) {
shopInfo, err2 := api.JdAPI.GetStoreInfo2(storeID)
if err = err2; err == nil && shopInfo != nil {
lng, lat, districtCode := api.AutonaviAPI.GetCoordinateFromAddress(shopInfo.StoreInfo.StoreAddress, cityInfo)
return &model.PageShop{
Name: shopInfo.StoreInfo.StoreName,
VendorID: model.VendorIDJD,
VendorStoreID: storeID,
OrgCode: shopInfo.StoreInfo.OrgCode,
VendorStatus: utils.Int2Str(shopInfo.StoreInfo.StationStatus),
Address: shopInfo.StoreInfo.StoreAddress,
Lng: lng,
Lat: lat,
DistrictCode: districtCode,
Tel1: shopInfo.StoreInfo.StoreTel,
RecentOrderNum: int(utils.Str2Int64WithDefault(shopInfo.StoreInfo.MonthSaleNum, 0)),
SkuCount: int(utils.Str2Int64WithDefault(shopInfo.StoreInfo.InSaleNum, 0)),
BusinessType: shopInfo.StoreInfo.Industry,
ShopScore: float32(shopInfo.StoreCommentVO.ScoreAvg),
}, nil
}
return nil, err
}

View File

@@ -0,0 +1 @@
package jd