- 高德API的KEY改为公司认证的KEY,可访问量更大

- 拉取门店信息时要获取坐标及区信息
- 饿百订单买家的坐标转换为高德坐标
This commit is contained in:
gazebo
2019-09-11 10:14:40 +08:00
parent b72043257c
commit f1fbcf6366
6 changed files with 18 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/ditu"
@@ -81,6 +82,9 @@ func getStoreListByCoordinates(ctx *jxcontext.Context, parentTask tasksch.ITask,
storeID := batchItemList[0].(string)
storePageInfo, err := handler.GetStorePageInfo(ctx, cityInfo, storeID)
if err == nil && storePageInfo != nil {
if storePageInfo.DistrictCode == 0 && (storePageInfo.Lng != 0 && storePageInfo.Lat != 0) {
storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(storePageInfo.Lng, storePageInfo.Lat)
}
return []interface{}{storePageInfo}, nil
}
return nil, err
@@ -122,9 +126,9 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
gridWith = DefGridWith
}
task := tasksch.NewSeqTask("GetAndStoreCitiesShops", ctx,
func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
cityCode := cityCodeList[step]
task := tasksch.NewParallelTask("GetAndStoreCitiesShops", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
cityCode := batchItemList[0].(int)
globals.SugarLogger.Debugf("process city:%d", cityCode)
shopList, err := GetCityShops(ctx, task, vendorIDs, cityCode, radius, gridWith)
if err == nil {
@@ -150,8 +154,8 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
}
}
globals.SugarLogger.Debugf("process city:%d, len(shopList):%d, err:%v", cityCode, len(shopList), err)
return nil, nil // 强制继续
}, len(cityCodeList))
return nil, err
}, cityCodeList)
tasksch.ManageTask(task).Run()
if !isAsync {
_, err = task.GetResult(0)

View File

@@ -1,6 +1,7 @@
package ebai
import (
"git.rosy.net.cn/baseapi/platformapi/autonavi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/ditu"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
@@ -24,8 +25,7 @@ func (c *PurchaseHandler) GetStoreIDListByCoordinates(ctx *jxcontext.Context, co
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 := 0
// districtCode := api.AutonaviAPI.GetCoordinateDistrictCode(shopInfo.Longitude, shopInfo.Latitude)
lng, lat, _ := api.AutonaviAPI.CoordinateConvert(shopInfo.Longitude/100000, shopInfo.Latitude/100000, autonavi.CoordSysBaidu)
return &model.PageShop{
Name: shopInfo.Name,
VendorID: model.VendorIDEBAI,
@@ -34,9 +34,9 @@ func (c *PurchaseHandler) GetStorePageInfo(ctx *jxcontext.Context, cityInfo, sto
VendorStatus: utils.Int2Str(shopInfo.BusinessStatus),
Address: shopInfo.Address,
Lng: shopInfo.Longitude / 100000,
Lat: shopInfo.Latitude / 100000,
DistrictCode: districtCode,
Lng: lng,
Lat: lat,
DistrictCode: 0,
Tel1: shopInfo.Phone,

View File

@@ -212,7 +212,7 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
}
}
deliveryGeo := userMap["coord"].(map[string]interface{})
deliveryGeo := userMap["coord_amap"].(map[string]interface{})
originalLng := utils.Interface2Float64WithDefault(deliveryGeo["longitude"], 0.0) // 饿百的订单在过一段时间后,经纬度信息会变成字符串"**"
originalLat := utils.Interface2Float64WithDefault(deliveryGeo["latitude"], 0.0)
lng, lat, err2 := api.AutonaviAPI.CoordinateConvert(originalLng, originalLat, autonavi.CoordSysBaidu)

View File

@@ -387,6 +387,7 @@ func genStoreMapFromStore(store *tEbaiStoreInfo) map[string]interface{} {
params["address"] = store.Address
// todo 饿百 开店审核通过后不允许修改商户信息
if store.SyncStatus&(model.SyncFlagNewMask /*|model.SyncFlagStoreAddress*/) != 0 {
// todo 这里应该要做坐标转换吧
params["longitude"] = jxutils.IntCoordinate2Standard(store.Lng)
params["latitude"] = jxutils.IntCoordinate2Standard(store.Lat)
params["coord_type"] = ebaiapi.CoordTypeAutonavi

View File

@@ -32,8 +32,7 @@ func (c *PurchaseHandler) GetStorePageInfo(ctx *jxcontext.Context, cityInfo, sto
if err = err2; err == nil && shopInfo != nil {
var lng, lat float64
districtCode := 0
// 由于高德API免费有调用次数限制暂时不取坐标信息
// lng, lat, districtCode := api.AutonaviAPI.GetCoordinateFromAddress(shopInfo.StoreInfo.StoreAddress, cityInfo)
lng, lat, districtCode = api.AutonaviAPI.GetCoordinateFromAddress(shopInfo.StoreInfo.StoreAddress, cityInfo)
return &model.PageShop{
Name: shopInfo.StoreInfo.StoreName,
VendorID: model.VendorIDJD,

View File

@@ -16,7 +16,7 @@ mtwmAppID = "589"
mtwmSecret = "a81eb3df418d83d6a1a4b7c572156d2f"
mtwmCallbackURL = "http://callback.jxc4.com"
autonaviKey = "4427170f870af2110becb8852d36ab08"
autonaviKey = "ef64f638f31e05cb7bde28790f7309fe"
baidunaviAK = "eL94zToVOdGDTkNQxV8dnEQ1ZRcB2UKb"
baidunaviSK = "ZG0OOpOsOVURUwAkkmoHQFKRCbzn0zGb"