- get city and district info from coordinate correctly.

This commit is contained in:
gazebo
2018-12-05 12:22:38 +08:00
parent 5510f9957f
commit 595906bdd2
2 changed files with 14 additions and 6 deletions

View File

@@ -122,8 +122,10 @@ func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error)
retVal.DistrictCode = district.Code
}
}
if retVal.DistrictCode == 0 {
retVal.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
}
if retVal.DistrictCode == 0 {
retVal.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
if retVal.CityCode == 0 {
if district, err := dao.GetPlaceByCode(db, retVal.DistrictCode); err == nil {
retVal.CityCode = district.ParentCode
}

View File

@@ -65,8 +65,10 @@ func (p *PurchaseHandler) ReadStore(vendorStoreID string) (*model.Store, error)
retVal.DistrictCode = district.Code
}
}
if retVal.DistrictCode == 0 {
retVal.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
}
if retVal.DistrictCode == 0 {
retVal.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
if retVal.CityCode == 0 {
if district, err := dao.GetPlaceByCode(db, retVal.DistrictCode); err == nil {
retVal.CityCode = district.ParentCode
}
@@ -118,11 +120,15 @@ func (p *PurchaseHandler) UpdateStore(db *dao.DaoDB, storeID int, userName strin
"coordinateType": 3, // 一直用高德
"lng": jxutils.IntCoordinate2Standard(store.Lng),
"lat": jxutils.IntCoordinate2Standard(store.Lat),
"city": store.JdCityCode,
"county": store.JdDistrictCode,
"phone": store.Tel1,
"mobile": store.Tel2,
}
if store.JdCityCode != 0 {
params["city"] = store.JdCityCode
}
if store.JdDistrictCode != 0 {
params["county"] = store.JdDistrictCode
}
if store.DeliveryRangeType == model.DeliveryRangeTypePolygon {
params["coordinatePoints"] = store.DeliveryRange
} else {