使用腾讯地图,百度和高德不在使用
This commit is contained in:
@@ -2,6 +2,7 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
"math"
|
||||
"reflect"
|
||||
"regexp"
|
||||
@@ -10,8 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/partner/purchase/ebai"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils/errlist"
|
||||
@@ -230,11 +229,11 @@ func UpdatePlace(ctx *jxcontext.Context, placeCode int, payload map[string]inter
|
||||
}
|
||||
|
||||
func GetCoordinateDistrictCode(ctx *jxcontext.Context, lng, lat float64) (code int, err error) {
|
||||
return api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat), nil
|
||||
return api.TencentMapAPI.GetCoordinateDistrictCode(lng, lat), nil
|
||||
}
|
||||
|
||||
func GetCoordinateCityInfo(ctx *jxcontext.Context, lng, lat float64) (name string, err error) {
|
||||
name, _ = api.AutonaviAPI.GetCoordinateCityInfo(lng, lat)
|
||||
name, _ = api.TencentMapAPI.GetCoordinateCityInfo(lng, lat)
|
||||
return name, err
|
||||
}
|
||||
|
||||
@@ -593,19 +592,18 @@ func GetCityBankBranches(ctx *jxcontext.Context, cityCode int, bankCode string)
|
||||
|
||||
// GetSToURidingDistance 获取商家与用户间步行距离
|
||||
func GetSToURidingDistance(sLng, sLat, uLng, uLat float64, orderId string) (stepInfo interface{}, err error) {
|
||||
var coords []*baidunavi.Coordinate
|
||||
coords = append(coords, &baidunavi.Coordinate{
|
||||
Lng: sLng,
|
||||
Lat: sLat,
|
||||
}, &baidunavi.Coordinate{
|
||||
Lat: uLat,
|
||||
Lng: uLng,
|
||||
coordList, err := api.TencentMapAPI.TencentCoordinateChange(&tencent_map.TencentCoordinateChangeReq{
|
||||
Locations: fmt.Sprintf("%.6f,%.6f;%.6f,%.6f", sLat, sLng, uLat, uLng),
|
||||
Type: tencent_map.CoordinateChangeTypeBaidu,
|
||||
})
|
||||
if coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGaoDe2Baidu); err == nil {
|
||||
if len(coords) > 0 {
|
||||
if stepInfo, err = api.BaiDuNaviAPI.DirectionLiteRide(coords); err == nil {
|
||||
return stepInfo, nil
|
||||
}
|
||||
|
||||
if err == nil && len(coordList) == 2 {
|
||||
param := &tencent_map.TencentCyclingPlanningReq{
|
||||
From: fmt.Sprintf("%s,%s", coordList[0].Lat, coordList[0].Lng),
|
||||
To: fmt.Sprintf("%s,%s", coordList[1].Lat, coordList[1].Lng),
|
||||
}
|
||||
if stepInfo, err = api.TencentMapAPI.WalkingDistance(param); err == nil {
|
||||
return stepInfo, nil
|
||||
}
|
||||
}
|
||||
return 0, err
|
||||
@@ -722,7 +720,7 @@ func GetSToURidingDistance2(sLng, sLat, uLng, uLat float64, orderId string) (way
|
||||
// GetCyclingLine 获取骑行路线
|
||||
func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, distance, duration int64, err error) {
|
||||
// 百度
|
||||
var coords []*baidunavi.Coordinate
|
||||
/*var coords []*baidunavi.Coordinate
|
||||
coords = append(coords, &baidunavi.Coordinate{
|
||||
Lng: sLng,
|
||||
Lat: sLat,
|
||||
@@ -732,36 +730,13 @@ func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, dist
|
||||
})
|
||||
|
||||
// 高德坐标转换成百度坐标
|
||||
coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGaoDe2Baidu)
|
||||
coords, err = api.TencentMapAPI.TencentCoordinateChange(coords, baidunavi.CoordSysGaoDe2Baidu)
|
||||
if err != nil || len(coords) <= model.NO {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
data, err := api.BaiDuNaviAPI.DirectionLiteRide(coords)
|
||||
if err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
if data == "" {
|
||||
return nil, 0, 0, fmt.Errorf("获取骑行规划路线错误")
|
||||
}
|
||||
path := &baidunavi.RiderPath{}
|
||||
if err := utils.Map2StructByJson(data, path, false); err != nil {
|
||||
return nil, 0, 0, err
|
||||
}
|
||||
|
||||
polyLine := make([]string, 0, 0)
|
||||
if path != nil && len(path.Routes) != 0 {
|
||||
distance = int64(path.Routes[0].Distance) // 距离
|
||||
duration = int64(path.Routes[0].Duration) // 时间
|
||||
|
||||
for _, v := range path.Routes[0].Steps {
|
||||
polyLine = append(polyLine, strings.Split(v.Path, ";")...)
|
||||
}
|
||||
}
|
||||
|
||||
// 百度坐标转高德坐标
|
||||
polyLineList = jxutils.BaiDuCoord2Gaode2(polyLine)
|
||||
if len(polyLineList) == 0 || polyLineList == nil {
|
||||
polyLineList = polyLine
|
||||
}
|
||||
}*/
|
||||
distance, duration, polyLineList, err = api.TencentMapAPI.TencentCyclingPlanning(&tencent_map.TencentCyclingPlanningReq{
|
||||
From: fmt.Sprintf("%.6f,%.6f", sLat, sLng),
|
||||
To: fmt.Sprintf("%.6f,%.6f", uLat, uLng),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
"io"
|
||||
"math"
|
||||
"mime/multipart"
|
||||
@@ -45,8 +46,6 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -689,25 +688,25 @@ func GetStores(ctx *jxcontext.Context, keyword string, params map[string]interfa
|
||||
// 导出门店地图标信息时,可能会需要转换门店坐标
|
||||
needConver2Baidu := int(utils.Interface2Int64WithDefault(params["coordinateType"], 0)) == model.CoordinateTypeBaiDu
|
||||
if needConver2Baidu {
|
||||
task := tasksch.NewParallelTask("坐标转换", tasksch.NewParallelConfig().SetParallelCount(4).SetBatchSize(autonavi.MaxConvertCount), ctx,
|
||||
task := tasksch.NewParallelTask("坐标转换", tasksch.NewParallelConfig().SetParallelCount(4).SetBatchSize(tencent_map.MaxConvertCount), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
var coords []*baidunavi.Coordinate
|
||||
var coords []*tencent_map.Coordinate
|
||||
for _, v := range batchItemList {
|
||||
store := v.(*StoreExt)
|
||||
coords = append(coords, &baidunavi.Coordinate{
|
||||
coords = append(coords, &tencent_map.Coordinate{
|
||||
Lng: store.FloatLng,
|
||||
Lat: store.FloatLat,
|
||||
})
|
||||
}
|
||||
coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGaoDe2Baidu)
|
||||
if err == nil {
|
||||
for k, v := range batchItemList {
|
||||
store := v.(*StoreExt)
|
||||
coord := coords[k]
|
||||
store.FloatLng = coord.Lng
|
||||
store.FloatLat = coord.Lat
|
||||
}
|
||||
//coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGaoDe2Baidu)
|
||||
//if err == nil {
|
||||
for k, v := range batchItemList {
|
||||
store := v.(*StoreExt)
|
||||
coord := coords[k]
|
||||
store.FloatLng = coord.Lng
|
||||
store.FloatLat = coord.Lat
|
||||
}
|
||||
//}
|
||||
return retVal, err
|
||||
}, retVal.Stores)
|
||||
task.Run()
|
||||
@@ -4280,7 +4279,7 @@ func CreateStoreAudit(ctx *jxcontext.Context, storeAudit *model.StoreAudit) (err
|
||||
return fmt.Errorf("门店地址必填!")
|
||||
}
|
||||
if storeAudit.Lng == 0 || storeAudit.Lat == 0 {
|
||||
lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddress(storeAudit.Address, "")
|
||||
lng, lat, _, _, _ := api.TencentMapAPI.GetCoordinateFromAddress(storeAudit.Address, "")
|
||||
if lng != 0 && lat != 0 {
|
||||
storeAudit.Lng = jxutils.StandardCoordinate2Int(lng)
|
||||
storeAudit.Lat = jxutils.StandardCoordinate2Int(lat)
|
||||
@@ -4887,14 +4886,22 @@ func RefreshPageStore() {
|
||||
//result, _ := api.AutonaviAPI.GetCoordinateFromAddressAll(v.Address, v.Remark)
|
||||
//lng, lat, dis := utils.Float64ToStr(result.Lng), utils.Float64ToStr(result.Lat), result.AdName
|
||||
place, _ := dao.GetPlaceByName(db, v.BakInfo, 2, 0)
|
||||
if result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, place.Code); result1 != nil {
|
||||
/*if result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, place.Code); result1 != nil {
|
||||
if result1.Lng == 0 || result1.Lat == 0 {
|
||||
result2, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, 0)
|
||||
lng, lat, dis = result2.Lng, result2.Lat, result2.AdName
|
||||
} else {
|
||||
lng, lat, dis = result1.Lng, result1.Lat, result1.AdName
|
||||
}
|
||||
}*/
|
||||
lngTencent, latTencent, _, disName, err := api.TencentMapAPI.GetCoordinateFromAddress(v.Address, utils.Int2Str(place.Code))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("RefreshPageStore err := %v", err)
|
||||
continue
|
||||
}
|
||||
lng = lngTencent
|
||||
lat = latTencent
|
||||
dis = disName
|
||||
sql := `
|
||||
UPDATE jingdong_showd SET lng = ?, lat = ?, district_name = ? WHERE id = ?
|
||||
`
|
||||
@@ -4903,10 +4910,16 @@ func RefreshPageStore() {
|
||||
}
|
||||
dao.ExecuteSQL(db, sql, sqlparams)
|
||||
} else {
|
||||
result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, 0)
|
||||
lng, lat, dis = result1.Lng, result1.Lat, result1.AdName
|
||||
lngTencent, latTencent, _, disName, err := api.TencentMapAPI.GetCoordinateFromAddress(v.Address, utils.Int2Str(0))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("RefreshPageStore err := %v", err)
|
||||
continue
|
||||
}
|
||||
lng, lat, dis = lngTencent, latTencent, disName
|
||||
//result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, 0)
|
||||
//lng, lat, dis = result1.Lng, result1.Lat, result1.AdName
|
||||
sql := `
|
||||
UPDATE jingdong_showd SET lng = ?, lat = ?, district_name = ? WHERE id = ?
|
||||
UPDATE jingdong_showd SET lng = ?, lat = ?, district_name = ? WHERE id = ?
|
||||
`
|
||||
sqlparams := []interface{}{
|
||||
lng, lat, dis, v.ID,
|
||||
@@ -4928,36 +4941,31 @@ func RefreshPageStore() {
|
||||
)
|
||||
if (v.Lat == "" && v.Lng == "") || (v.Lat == "0" && v.Lng == "0") {
|
||||
if v.Address != "" {
|
||||
if v.CityName != "" {
|
||||
//result, _ := api.AutonaviAPI.GetCoordinateFromAddressAll(v.Address, v.Remark)
|
||||
//lng, lat, dis := utils.Float64ToStr(result.Lng), utils.Float64ToStr(result.Lat), result.AdName
|
||||
place, _ := dao.GetPlaceByName(db, v.CityName, 2, 0)
|
||||
if result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, place.Code); result1 != nil {
|
||||
if result1.Lng == 0 || result1.Lat == 0 {
|
||||
result2, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, 0)
|
||||
lng, lat, dis = result2.Lng, result2.Lat, result2.AdName
|
||||
} else {
|
||||
lng, lat, dis = result1.Lng, result1.Lat, result1.AdName
|
||||
}
|
||||
}
|
||||
sql := `
|
||||
//if v.CityName != "" {
|
||||
//result, _ := api.AutonaviAPI.GetCoordinateFromAddressAll(v.Address, v.Remark)
|
||||
//lng, lat, dis := utils.Float64ToStr(result.Lng), utils.Float64ToStr(result.Lat), result.AdName
|
||||
place, _ := dao.GetPlaceByName(db, v.CityName, 2, 0)
|
||||
if lngTencent, latTencent, _, disName, err := api.TencentMapAPI.GetCoordinateFromAddress(v.Address, utils.Int2Str(place.Code)); err == nil {
|
||||
lng, lat, dis = lngTencent, latTencent, disName
|
||||
}
|
||||
sql := `
|
||||
UPDATE meituan_showd SET lng = ?, lat = ?, district_name = ? WHERE id = ?
|
||||
`
|
||||
sqlparams := []interface{}{
|
||||
lng, lat, dis, v.ID,
|
||||
}
|
||||
dao.ExecuteSQL(db, sql, sqlparams)
|
||||
} else {
|
||||
result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, 0)
|
||||
lng, lat, dis = result1.Lng, result1.Lat, result1.AdName
|
||||
sql := `
|
||||
UPDATE meituan_showd SET lng = ?, lat = ?, district_name = ? WHERE id = ?
|
||||
`
|
||||
sqlparams := []interface{}{
|
||||
lng, lat, dis, v.ID,
|
||||
}
|
||||
dao.ExecuteSQL(db, sql, sqlparams)
|
||||
sqlparams := []interface{}{
|
||||
lng, lat, dis, v.ID,
|
||||
}
|
||||
dao.ExecuteSQL(db, sql, sqlparams)
|
||||
/* } else {
|
||||
result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, 0)
|
||||
lng, lat, dis = result1.Lng, result1.Lat, result1.AdName
|
||||
sql := `
|
||||
UPDATE meituan_showd SET lng = ?, lat = ?, district_name = ? WHERE id = ?
|
||||
`
|
||||
sqlparams := []interface{}{
|
||||
lng, lat, dis, v.ID,
|
||||
}
|
||||
dao.ExecuteSQL(db, sql, sqlparams)
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4974,36 +4982,31 @@ func RefreshPageStore() {
|
||||
)
|
||||
if (v.Lat == "" && v.Lng == "") || (v.Lat == "0" && v.Lng == "0") {
|
||||
if v.Address != "" {
|
||||
if v.Remark != "" {
|
||||
//result, _ := api.AutonaviAPI.GetCoordinateFromAddressAll(v.Address, v.Remark)
|
||||
//lng, lat, dis := utils.Float64ToStr(result.Lng), utils.Float64ToStr(result.Lat), result.AdName
|
||||
place, _ := dao.GetPlaceByName(db, v.Remark, 2, 0)
|
||||
if result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, place.Code); result1 != nil {
|
||||
if result1.Lng == 0 || result1.Lat == 0 {
|
||||
result2, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, 0)
|
||||
lng, lat, dis = result2.Lng, result2.Lat, result2.AdName
|
||||
} else {
|
||||
lng, lat, dis = result1.Lng, result1.Lat, result1.AdName
|
||||
}
|
||||
}
|
||||
sql := `
|
||||
//if v.Remark != "" {
|
||||
//result, _ := api.AutonaviAPI.GetCoordinateFromAddressAll(v.Address, v.Remark)
|
||||
//lng, lat, dis := utils.Float64ToStr(result.Lng), utils.Float64ToStr(result.Lat), result.AdName
|
||||
place, _ := dao.GetPlaceByName(db, v.Remark, 2, 0)
|
||||
if lngTencent, latTencent, _, disName, err := api.TencentMapAPI.GetCoordinateFromAddress(v.Address, utils.Int2Str(place.Code)); err == nil {
|
||||
lng, lat, dis = lngTencent, latTencent, disName
|
||||
}
|
||||
sql := `
|
||||
UPDATE elm_showd SET lng = ?, lat = ?, district_name = ? WHERE store_id = ?
|
||||
`
|
||||
sqlparams := []interface{}{
|
||||
lng, lat, dis, v.StoreID,
|
||||
}
|
||||
dao.ExecuteSQL(db, sql, sqlparams)
|
||||
} else {
|
||||
result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, 0)
|
||||
lng, lat, dis = result1.Lng, result1.Lat, result1.AdName
|
||||
sql := `
|
||||
UPDATE elm_showd SET lng = ?, lat = ?, district_name = ? WHERE store_id = ?
|
||||
`
|
||||
sqlparams := []interface{}{
|
||||
lng, lat, dis, v.StoreID,
|
||||
}
|
||||
dao.ExecuteSQL(db, sql, sqlparams)
|
||||
sqlparams := []interface{}{
|
||||
lng, lat, dis, v.StoreID,
|
||||
}
|
||||
dao.ExecuteSQL(db, sql, sqlparams)
|
||||
//} else {
|
||||
// result1, _ := api.AutonaviAPI.GetCoordinateFromAddressByPageAll(v.Address, 0)
|
||||
// lng, lat, dis = result1.Lng, result1.Lat, result1.AdName
|
||||
// sql := `
|
||||
// UPDATE elm_showd SET lng = ?, lat = ?, district_name = ? WHERE store_id = ?
|
||||
//`
|
||||
// sqlparams := []interface{}{
|
||||
// lng, lat, dis, v.StoreID,
|
||||
// }
|
||||
// dao.ExecuteSQL(db, sql, sqlparams)
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ func setUserAddress(db *dao.DaoDB, user *model.User, order *model.GoodsOrder) {
|
||||
user.DistrictCode = store.DistrictCode
|
||||
} else if dao.IsNoRowsError(err) {
|
||||
if order.ConsigneeLng != 0 && order.ConsigneeLat != 0 {
|
||||
if user.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat)); user.DistrictCode > 0 {
|
||||
if user.DistrictCode = api.TencentMapAPI.GetCoordinateDistrictCode(jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat)); user.DistrictCode > 0 {
|
||||
if placeInfo, err := dao.GetPlaceByCode(db, user.DistrictCode); err == nil {
|
||||
user.CityCode = placeInfo.ParentCode
|
||||
}
|
||||
@@ -658,10 +658,10 @@ func DeleteUsers4Role(ctx *jxcontext.Context, r *authz.RoleInfo, userIDList []st
|
||||
}
|
||||
|
||||
func getAddressInfoFromCoord(db *dao.DaoDB, lng, lat float64) (formattedAddress string, districtCode, cityCode int, err error) {
|
||||
regeoInfo, err := api.AutonaviAPI.GeoCodeRegeoSingle(lng, lat, 0, false, nil, 0, 0)
|
||||
regeoInfo, err := api.TencentMapAPI.GeoCodeRegeoSingle(lng, lat, 0, false, nil, 0, 0)
|
||||
if err == nil {
|
||||
formattedAddress = regeoInfo.FormattedAddress
|
||||
districtCode = int(utils.Str2Int64WithDefault(regeoInfo.AddressComponent.Adcode, 0))
|
||||
formattedAddress = regeoInfo.Result.Address
|
||||
districtCode = int(utils.Str2Int64WithDefault(regeoInfo.Result.AdInfo.Adcode, 0))
|
||||
if districtCode == 0 {
|
||||
err = fmt.Errorf("坐标lng:%f,lat:%f找不到位置信息", lng, lat)
|
||||
} else if districtInfo, err2 := dao.GetPlaceByCode(db, districtCode); err2 == nil {
|
||||
|
||||
@@ -2,9 +2,9 @@ package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
"sort"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
@@ -205,14 +205,14 @@ func GetStoreListByLocation(ctx *jxcontext.Context, lng, lat float64, maxRadius
|
||||
|
||||
// 如果要求以步行距离来算
|
||||
if needWalkDistance {
|
||||
var coordList []*autonavi.Coordinate
|
||||
var coordList []*tencent_map.Coordinate
|
||||
for _, v := range storeList2 {
|
||||
coordList = append(coordList, &autonavi.Coordinate{
|
||||
coordList = append(coordList, &tencent_map.Coordinate{
|
||||
Lng: v.FloatLng,
|
||||
Lat: v.FloatLat,
|
||||
})
|
||||
}
|
||||
if distanceList, err2 := api.AutonaviAPI.BatchWalkingDistance(lng, lat, coordList); err2 == nil {
|
||||
if distanceList, err2 := api.TencentMapAPI.BatchWalkingDistance(lng, lat, coordList); err2 == nil {
|
||||
for k, v := range storeList2 {
|
||||
v.WalkDistance = int(distanceList[k])
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ package initdata
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
@@ -18,9 +18,9 @@ func TruncateTable(db *dao.DaoDB, tableName string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
func insertPlace(ctx *jxcontext.Context, db *dao.DaoDB, parent *autonavi.District, placeList []*autonavi.District) (err error) {
|
||||
func insertPlace(ctx *jxcontext.Context, db *dao.DaoDB, parent *tencent_map.District, placeList []*tencent_map.District) (err error) {
|
||||
for _, v := range placeList {
|
||||
if v.Level <= autonavi.DistrictLevelDistrict {
|
||||
if v.Level <= tencent_map.DistrictLevelDistrict {
|
||||
place := &model.Place{
|
||||
Code: int(utils.Str2Int64(v.Adcode)),
|
||||
Name: v.Name,
|
||||
@@ -44,13 +44,14 @@ func insertPlace(ctx *jxcontext.Context, db *dao.DaoDB, parent *autonavi.Distric
|
||||
}
|
||||
|
||||
func InitPlace(ctx *jxcontext.Context) (err error) {
|
||||
placeList, err2 := api.AutonaviAPI.GetDistricts(autonavi.DistrictLevelDistrict, "")
|
||||
// 这个地方是更新全国的place表,因为两个不兼容且上传时间不会发送改变,暂时不做返回
|
||||
placeList, err2 := api.TencentMapAPI.GetDistricts(tencent_map.DistrictLevelDistrict, "", 0)
|
||||
if err = err2; err != nil {
|
||||
return err
|
||||
}
|
||||
placeList = placeList[0].Districts
|
||||
db := dao.GetDB()
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
@@ -146,7 +147,7 @@ func InitVendorCategory(ctx *jxcontext.Context, vendorID int, isAsync bool) (hin
|
||||
}
|
||||
case 1:
|
||||
db := dao.GetDB()
|
||||
txDB , _ := dao.Begin(db)
|
||||
txDB, _ := dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil || err != nil {
|
||||
dao.Rollback(db, txDB)
|
||||
|
||||
Reference in New Issue
Block a user