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

View File

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