This commit is contained in:
gazebo
2019-11-27 17:24:21 +08:00
parent cea72b06de
commit 47803c64e4

View File

@@ -88,12 +88,18 @@ func (c *NetSpiderController) QueryPageStores() {
lng1, lat1, lng2, lat2) lng1, lat1, lng2, lat2)
if err == nil { if err == nil {
if params.Radius > 0 && (params.Offset != 0 || params.PageSize != model.UnlimitedPageSize) { if params.Radius > 0 && (params.Offset != 0 || params.PageSize != model.UnlimitedPageSize) {
shopList, _ := pagedInfo.Data.([]*dao.PageShopWithPlaceName) shopList2, _ := pagedInfo.Data.([]*dao.PageShopWithPlaceName)
pagedInfo.TotalCount = len(shopList) var shopList []*dao.PageShopWithPlaceName
if len(shopList) > 0 { pagedInfo.TotalCount = 0
if len(shopList2) > 0 {
for _, v := range shopList { for _, v := range shopList {
v.Distance = int(jxutils.EarthDistance(v.Lng, v.Lat, lng, lat) * 1000) v.Distance = int(jxutils.EarthDistance(v.Lng, v.Lat, lng, lat) * 1000)
if v.Distance <= params.Radius {
shopList = append(shopList, v)
} }
}
pagedInfo.TotalCount = len(shopList)
if pagedInfo.TotalCount > 0 {
sort.Sort(PageShopList(shopList)) sort.Sort(PageShopList(shopList))
if params.Offset < len(shopList) { if params.Offset < len(shopList) {
index := params.Offset + params.PageSize index := params.Offset + params.PageSize
@@ -105,6 +111,7 @@ func (c *NetSpiderController) QueryPageStores() {
shopList = nil shopList = nil
} }
} }
}
pagedInfo.Data = shopList pagedInfo.Data = shopList
} }
retVal = pagedInfo retVal = pagedInfo