From 595906bdd2a5d956e2b4c7ac6da70601c82dcf16 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 5 Dec 2018 12:22:38 +0800 Subject: [PATCH] - get city and district info from coordinate correctly. --- business/partner/purchase/ebai/store.go | 6 ++++-- business/partner/purchase/jd/store.go | 14 ++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/business/partner/purchase/ebai/store.go b/business/partner/purchase/ebai/store.go index a9cc08f83..beb791ae6 100644 --- a/business/partner/purchase/ebai/store.go +++ b/business/partner/purchase/ebai/store.go @@ -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 } diff --git a/business/partner/purchase/jd/store.go b/business/partner/purchase/jd/store.go index 3317123af..9f244d9ac 100644 --- a/business/partner/purchase/jd/store.go +++ b/business/partner/purchase/jd/store.go @@ -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 {