This commit is contained in:
suyl
2021-05-11 15:41:24 +08:00
parent 1e0f5a0513
commit c84d75e161

View File

@@ -2,9 +2,11 @@ package dao
import (
"fmt"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/globals/api"
"strings"
)
type PageShopWithPlaceName struct {
@@ -117,7 +119,7 @@ func QueryPageStores2(db *DaoDB, pageSize, offset int, keyword string, vendorSto
`
sql := `
SELECT SQL_CALC_FOUND_ROWS
t1.*
t1.*, t2.code city_code
FROM (
`
if vendorID == -1 {
@@ -137,6 +139,7 @@ func QueryPageStores2(db *DaoDB, pageSize, offset int, keyword string, vendorSto
}
sql += `
)t1
LEFT JOIN place t2 ON t2.name = t1.city_name AND t2.level = 2
WHERE 1 = 1
`
sqlParams := []interface{}{}
@@ -208,18 +211,17 @@ func QueryPageStores2(db *DaoDB, pageSize, offset int, keyword string, vendorSto
var newShopList []*PageShopWithPlaceName
for _, v := range shopList {
if v.Address != "" && v.CityName != "" {
if city, _ := GetPlaceByName(db, v.CityName, 2, 0); city != nil {
lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddressByPage(v.Address, city.Code)
v.CityCode = city.Code
v.Lng = lng
v.Lat = lat
if lng1 > 0 {
if !(lng >= lng1 && lat >= lat1 && lng <= lng2 && lat <= lat2) {
newShopList = append(newShopList, v)
}
} else {
result, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, v.CityCode)
coords := strings.Split(result.Pois[0].Location, ",")
lng, lat := utils.Str2Float64(coords[0]), utils.Str2Float64(coords[1])
v.DistrictName = result.Pois[0].Adname
v.Lng, v.Lat = lng, lat
if lng1 > 0 {
if !(lng >= lng1 && lat >= lat1 && lng <= lng2 && lat <= lat2) {
newShopList = append(newShopList, v)
}
} else {
newShopList = append(newShopList, v)
}
newShopList = append(newShopList, v)
} else {