package jd import ( "fmt" "git.rosy.net.cn/baseapi/platformapi/jdapi" "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.JdPageAPI.GetStoreList(fmt.Sprintf("%.6f", coord.Lng), fmt.Sprintf("%.6f", coord.Lat)) if err != nil { // time.Sleep(5 * time.Second) 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.JdPageAPI.GetStoreInfo2(storeID) if err = err2; err == nil && shopInfo != nil { var lng, lat float64 districtCode := 0 // 由于高德API免费有调用次数限制,暂时不取坐标信息 // 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: jdapi.MonthSaleNum2Int(shopInfo.StoreInfo.MonthSaleNum), SkuCount: int(utils.Str2Int64WithDefault(shopInfo.StoreInfo.InSaleNum, 0)), BusinessType: shopInfo.StoreInfo.Industry, ShopScore: float64(shopInfo.StoreCommentVO.ScoreAvg), }, nil } return nil, err }