使用腾讯地图,百度和高德不在使用
This commit is contained in:
@@ -2057,7 +2057,7 @@ func RefreshJdsOrderConsigneeInfo(ctx *jxcontext.Context, vendorOrderID string)
|
||||
order.ConsigneeMobile2 = jdshop.Decrypt(jdsOrder.ConsigneeInfo.Telephone, order.VendorOrgCode)
|
||||
order.BuyerComment = jdsOrder.OrderRemark
|
||||
if order.ConsigneeAddress != "" {
|
||||
lng, lat, _ := api.AutonaviAPI.GetCoordinateFromAddress(order.ConsigneeAddress, "")
|
||||
lng, lat, _, _, _ := api.TencentMapAPI.GetCoordinateFromAddress(order.ConsigneeAddress, "")
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat)
|
||||
}
|
||||
@@ -2384,16 +2384,16 @@ func result2Orders(ctx *jxcontext.Context, result *jdshopapi.AllOrdersResult) (o
|
||||
}
|
||||
}
|
||||
//if cityCode != 0 {
|
||||
lng, lat, _ = api.AutonaviAPI.GetCoordinateFromAddressByPage(order.ConsigneeAddress, cityCode)
|
||||
//lng, lat, _ = api.AutonaviAPI.GetCoordinateFromAddressByPage(order.ConsigneeAddress, cityCode)
|
||||
//} else {
|
||||
lng2, lat2, _ = api.AutonaviAPI.GetCoordinateFromAddress(order.ConsigneeAddress, "")
|
||||
if err == nil && lng != 0 && lat != 0 {
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat)
|
||||
} else {
|
||||
lng2, lat2, _, _, err = api.TencentMapAPI.GetCoordinateFromAddress(order.ConsigneeAddress, utils.Int2Str(cityCode))
|
||||
if err == nil && lng2 != 0 && lat2 != 0 {
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng2)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat2)
|
||||
}
|
||||
} /* else {
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng2)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat2)
|
||||
}*/
|
||||
//}
|
||||
distance := jxutils.EarthDistance(lng, lat, lng2, lat2)
|
||||
if distance > 1 {
|
||||
|
||||
@@ -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 := `
|
||||
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)
|
||||
//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)
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 := `
|
||||
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)
|
||||
//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)
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package ditu
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"math"
|
||||
"strings"
|
||||
|
||||
"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/globals/api"
|
||||
@@ -76,12 +77,11 @@ func GetDistrictCoordinateList(districtCode int, radius, gridWith int) (coordLis
|
||||
}
|
||||
|
||||
func GetCityCoordinateList(cityCode int, radius, gridWith int) (coordList []*Coordinate) {
|
||||
//place, err := dao.GetPlaces(dao.GetDB(), []int{cityCode})
|
||||
//if err != nil {
|
||||
// return nil
|
||||
//}
|
||||
//level+1
|
||||
districts, err := api.AutonaviAPI.GetDistricts(2, utils.Int2Str(cityCode))
|
||||
place, err := dao.GetPlaces(dao.GetDB(), []int{cityCode})
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
districts, err := api.TencentMapAPI.GetDistricts(2, utils.Int2Str(cityCode), int(place[0].Level+1))
|
||||
if err == nil {
|
||||
if len(districts) > 0 {
|
||||
roundLng, roundLat := GetRound4Radius(districts[0].Lng, districts[0].Lat, gridWith)
|
||||
@@ -98,7 +98,7 @@ func GetCityCoordinateList(cityCode int, radius, gridWith int) (coordList []*Coo
|
||||
return coordList
|
||||
}
|
||||
|
||||
func needCheckTown(place *autonavi.District) bool {
|
||||
func needCheckTown(place *tencent_map.District) bool {
|
||||
for _, v := range []string{"街道", "镇"} {
|
||||
if strings.Index(place.Name, v) >= 0 {
|
||||
return true
|
||||
@@ -107,7 +107,7 @@ func needCheckTown(place *autonavi.District) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func getDistrictCoordinateList(districtList []*autonavi.District, radius, gridWith, roundLng, roundLat int) (coordList []*Coordinate) {
|
||||
func getDistrictCoordinateList(districtList []*tencent_map.District, radius, gridWith, roundLng, roundLat int) (coordList []*Coordinate) {
|
||||
coordMap := make(map[int64]*Coordinate)
|
||||
for _, v := range districtList {
|
||||
if (v.Level <= 3 || (v.Level == 4 && needCheckTown(v))) && v.Lng != 0 && v.Lat != 0 {
|
||||
@@ -131,3 +131,29 @@ func getDistrictCoordinateList(districtList []*autonavi.District, radius, gridWi
|
||||
}
|
||||
return coordList
|
||||
}
|
||||
|
||||
// 老版本
|
||||
//func getDistrictCoordinateList(districtList []*autonavi.District, radius, gridWith, roundLng, roundLat int) (coordList []*Coordinate) {
|
||||
// coordMap := make(map[int64]*Coordinate)
|
||||
// for _, v := range districtList {
|
||||
// if (v.Level <= 3 || (v.Level == 4 && needCheckTown(v))) && v.Lng != 0 && v.Lat != 0 {
|
||||
// realRadius := radius
|
||||
// if v.Level == 2 {
|
||||
// realRadius = 2 * radius
|
||||
// } else if v.Level == 2 {
|
||||
// realRadius = radius / 2
|
||||
// }
|
||||
// tmpCoordList := GetGridsFromCoordinate(v.Lng, v.Lat, realRadius, roundLng, roundLat)
|
||||
// if v.Level <= 3 {
|
||||
// tmpCoordList = append(tmpCoordList, getDistrictCoordinateList(v.Districts, radius, gridWith, roundLng, roundLat)...)
|
||||
// }
|
||||
// for _, coord := range tmpCoordList {
|
||||
// coordMap[coord.GetMapKey()] = coord
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// for _, coord := range coordMap {
|
||||
// coordList = append(coordList, coord)
|
||||
// }
|
||||
// return coordList
|
||||
//}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/rand"
|
||||
@@ -271,16 +271,32 @@ func EarthDistance(lng1, lat1, lng2, lat2 float64) float64 {
|
||||
return dist * radius
|
||||
}
|
||||
|
||||
// 返回结果单元为公里
|
||||
// WalkingDistance 返回结果单元为公里
|
||||
func WalkingDistance(lng1, lat1, lng2, lat2 float64) (distance float64) {
|
||||
if distance = api.AutonaviAPI.WalkingDistance(lng1, lat1, lng2, lat2); distance == 0 {
|
||||
param := &tencent_map.TencentCyclingPlanningReq{
|
||||
From: fmt.Sprintf("%.6f,%.6f", lat1, lng1),
|
||||
To: fmt.Sprintf("%.6f,%.6f", lat2, lng2),
|
||||
}
|
||||
distanceMetre, _ := api.TencentMapAPI.WalkingDistance(param)
|
||||
|
||||
if distanceMetre == 0 {
|
||||
distance = EarthDistance(lng1, lat1, lng2, lat2) * 1.4
|
||||
} else {
|
||||
distance /= 1000
|
||||
distance = float64(distanceMetre) / float64(1000)
|
||||
}
|
||||
return distance
|
||||
}
|
||||
|
||||
// 老版本百度
|
||||
//func WalkingDistance(lng1, lat1, lng2, lat2 float64) (distance float64) {
|
||||
// if distance = api.AutonaviAPI.WalkingDistance(lng1, lat1, lng2, lat2); distance == 0 {
|
||||
// distance = EarthDistance(lng1, lat1, lng2, lat2) * 1.4
|
||||
// } else {
|
||||
// distance /= 1000
|
||||
// }
|
||||
// return distance
|
||||
//}
|
||||
|
||||
//经纬度坐标转换到平面坐标
|
||||
func MillierConvertion(lat float64, lon float64) [2]float64 {
|
||||
var L, H, W, temp, mill, x, y float64
|
||||
@@ -312,22 +328,50 @@ func IntCoordinate2Standard(value int) float64 {
|
||||
func IntCoordinate2MarsStandard(gpsLng, gpsLat int, coordinateType int) (marsLng, marsLat float64, err error) {
|
||||
marsLng = IntCoordinate2Standard(gpsLng)
|
||||
marsLat = IntCoordinate2Standard(gpsLat)
|
||||
coordSys := ""
|
||||
coordSys := 0
|
||||
switch coordinateType {
|
||||
case model.CoordinateTypeGPS:
|
||||
coordSys = autonavi.CoordSysGPS
|
||||
coordSys = tencent_map.CoordinateChangeTypeGPS
|
||||
case model.CoordinateTypeMars:
|
||||
return marsLng, marsLat, nil
|
||||
case model.CoordinateTypeBaiDu:
|
||||
coordSys = autonavi.CoordSysBaidu
|
||||
coordSys = tencent_map.CoordinateChangeTypeBaidu
|
||||
case model.CoordinateTypeMapbar:
|
||||
coordSys = autonavi.CoordSysMapbar
|
||||
coordSys = tencent_map.CoordinateChangeTypeMapbar
|
||||
default:
|
||||
panic(fmt.Sprintf("known coordinate type:%d", coordinateType))
|
||||
}
|
||||
return api.AutonaviAPI.CoordinateConvert(marsLng, marsLat, coordSys)
|
||||
|
||||
result, err := api.TencentMapAPI.TencentCoordinateChange(&tencent_map.TencentCoordinateChangeReq{
|
||||
Locations: fmt.Sprintf("%.6f,%.6f", marsLat, marsLng),
|
||||
Type: coordSys,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
return utils.Str2Float64(result[0].Lng), utils.Str2Float64(result[0].Lat), nil
|
||||
}
|
||||
|
||||
//func IntCoordinate2MarsStandard(gpsLng, gpsLat int, coordinateType int) (marsLng, marsLat float64, err error) {
|
||||
// marsLng = IntCoordinate2Standard(gpsLng)
|
||||
// marsLat = IntCoordinate2Standard(gpsLat)
|
||||
// coordSys := ""
|
||||
// switch coordinateType {
|
||||
// case model.CoordinateTypeGPS:
|
||||
// coordSys = autonavi.CoordSysGPS
|
||||
// case model.CoordinateTypeMars:
|
||||
// return marsLng, marsLat, nil
|
||||
// case model.CoordinateTypeBaiDu:
|
||||
// coordSys = autonavi.CoordSysBaidu
|
||||
// case model.CoordinateTypeMapbar:
|
||||
// coordSys = autonavi.CoordSysMapbar
|
||||
// default:
|
||||
// panic(fmt.Sprintf("known coordinate type:%d", coordinateType))
|
||||
// }
|
||||
// return api.TencentMapAPI.CoordinateConvert(marsLng, marsLat, coordSys)
|
||||
//}
|
||||
|
||||
func IntPrice2Standard(value int64) float64 {
|
||||
return float64(value) / 100
|
||||
}
|
||||
|
||||
@@ -57,14 +57,14 @@ func getStorePageInfo(ctx *jxcontext.Context, handler partner.IPurchasePlatformN
|
||||
|
||||
func updatePageShopCityDistrictInfo(ctx *jxcontext.Context, storePageInfo *model.PageShop, cityCode int) {
|
||||
if !(storePageInfo.Lng != 0 && storePageInfo.Lat != 0) {
|
||||
storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(cityCode))
|
||||
storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode, _, _ = api.TencentMapAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(cityCode))
|
||||
if storePageInfo.DistrictCode == 0 && cityCode != 0 {
|
||||
if place, err := dao.GetPlaceByCode(dao.GetDB(), cityCode); err == nil {
|
||||
storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(place.ParentCode))
|
||||
storePageInfo.Lng, storePageInfo.Lat, storePageInfo.DistrictCode, _, _ = api.TencentMapAPI.GetCoordinateFromAddress(storePageInfo.Address, utils.Int2Str(place.ParentCode))
|
||||
}
|
||||
}
|
||||
} else if storePageInfo.DistrictCode == 0 {
|
||||
storePageInfo.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(storePageInfo.Lng, storePageInfo.Lat)
|
||||
storePageInfo.DistrictCode = api.TencentMapAPI.GetCoordinateDistrictCode(storePageInfo.Lng, storePageInfo.Lat)
|
||||
}
|
||||
if storePageInfo.CityCode == 0 {
|
||||
if storePageInfo.DistrictCode != 0 {
|
||||
|
||||
@@ -214,7 +214,7 @@ func StoreDetail2ShopInfo(storeDetail *dao.StoreDetail2) (shopInfo *dadaapi.Shop
|
||||
if dadaDistrictMap[districtName] != "" {
|
||||
if dadaDistrictMap[districtName] == "1" { // 区镇信息
|
||||
cityName = districtName
|
||||
districtName, _ = api.AutonaviAPI.GetCoordinateTownInfo(lng, lat)
|
||||
districtName, _ = api.TencentMapAPI.GetCoordinateTownInfo(lng, lat)
|
||||
}
|
||||
if dadaDistrictMap[districtName] != "" {
|
||||
districtName = dadaDistrictMap[storeDetail.DistrictName]
|
||||
|
||||
@@ -2,9 +2,9 @@ package ebai
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||
@@ -201,9 +201,17 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
lat := getCoordintate(result["latitude"])
|
||||
if utils.Interface2String(result["coord_type"]) == ebaiapi.CoordTypeBaidu {
|
||||
var err2 error
|
||||
if lng, lat, err2 = api.AutonaviAPI.CoordinateConvert(lng, lat, autonavi.CoordSysBaidu); err2 != nil {
|
||||
lngAndLat, err2 := api.TencentMapAPI.TencentCoordinateChange(&tencent_map.TencentCoordinateChangeReq{
|
||||
Locations: fmt.Sprintf("%.6f,%.6f", lat, lng),
|
||||
Type: tencent_map.CoordinateChangeTypeBaidu,
|
||||
})
|
||||
if err2 != nil {
|
||||
globals.SugarLogger.Debugf("CoordinateConvert err : %v", err)
|
||||
}
|
||||
if len(lngAndLat) != 0 {
|
||||
lng = utils.Str2Float64(lngAndLat[0].Lng)
|
||||
lat = utils.Str2Float64(lngAndLat[0].Lat)
|
||||
}
|
||||
}
|
||||
retVal.Lng = jxutils.StandardCoordinate2Int(lng)
|
||||
retVal.Lat = jxutils.StandardCoordinate2Int(lat)
|
||||
@@ -220,7 +228,7 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
}
|
||||
}
|
||||
if retVal.DistrictCode == 0 {
|
||||
retVal.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
|
||||
retVal.DistrictCode = api.TencentMapAPI.GetCoordinateDistrictCode(lng, lat)
|
||||
if retVal.CityCode == 0 {
|
||||
if district, err := dao.GetPlaceByCode(db, retVal.DistrictCode); err == nil {
|
||||
retVal.CityCode = district.ParentCode
|
||||
|
||||
@@ -2,6 +2,7 @@ package jd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -12,7 +13,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
@@ -306,10 +306,16 @@ func Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder) {
|
||||
originalLng := utils.MustInterface2Float64(result["buyerLng"])
|
||||
originalLat := utils.MustInterface2Float64(result["buyerLat"])
|
||||
if coordinateType == 1 {
|
||||
lng, lat, err2 := api.AutonaviAPI.CoordinateConvert(originalLng, originalLat, autonavi.CoordSysGPS)
|
||||
if err2 == nil {
|
||||
originalLng = lng
|
||||
originalLat = lat
|
||||
//lng, lat, err2 := api.TencentMapAPI.TencentCoordinateChange(originalLng, originalLat, autonavi.CoordSysGPS)
|
||||
originalPoint, err2 := api.TencentMapAPI.TencentCoordinateChange(&tencent_map.TencentCoordinateChangeReq{
|
||||
Locations: fmt.Sprintf("%.6f,%.6f", originalLat, originalLng),
|
||||
Type: tencent_map.CoordinateChangeTypeGPS,
|
||||
})
|
||||
if err2 == nil && len(originalPoint) != 0 {
|
||||
//originalLng = lng
|
||||
//originalLat = lat
|
||||
originalLng = utils.Str2Float64(originalPoint[0].Lng)
|
||||
originalLat = utils.Str2Float64(originalPoint[0].Lat)
|
||||
} else {
|
||||
// 如果没有转成功,保留原始数据
|
||||
order.CoordinateType = model.CoordinateTypeGPS
|
||||
|
||||
@@ -98,7 +98,7 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
}
|
||||
}
|
||||
if retVal.DistrictCode == 0 {
|
||||
retVal.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
|
||||
retVal.DistrictCode = api.TencentMapAPI.GetCoordinateDistrictCode(lng, lat)
|
||||
if retVal.CityCode == 0 {
|
||||
if district, err := dao.GetPlaceByCode(db, retVal.DistrictCode); err == nil {
|
||||
retVal.CityCode = district.ParentCode
|
||||
|
||||
@@ -150,22 +150,22 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
cityCode = place.Code
|
||||
}
|
||||
}
|
||||
lng, lat, err2 := api.AutonaviAPI.GetCoordinateFromAddressByPage(order.ConsigneeAddress, cityCode)
|
||||
if err = err2; err != nil {
|
||||
globals.SugarLogger.Infof("高德page err: %v", err)
|
||||
}
|
||||
lng2, lat2, _ := api.AutonaviAPI.GetCoordinateFromAddress(order.ConsigneeAddress, "")
|
||||
distance := jxutils.EarthDistance(lng, lat, lng2, lat2)
|
||||
if distance > 1 {
|
||||
order.OrderType = model.OrderTypeAddressErr
|
||||
lng, lat, _, _, err := api.TencentMapAPI.GetCoordinateFromAddress(order.ConsigneeAddress, utils.Int2Str(cityCode))
|
||||
if err != nil {
|
||||
globals.SugarLogger.Infof("腾讯地图 GetCoordinateFromAddress err: %v", err)
|
||||
}
|
||||
//lng2, lat2, _, err := api.TencentMapAPI.GetCoordinateFromAddress(order.ConsigneeAddress, "")
|
||||
//distance := jxutils.EarthDistance(lng, lat, lng2, lat2)
|
||||
//if distance > 1 {
|
||||
// order.OrderType = model.OrderTypeAddressErr
|
||||
//}
|
||||
if err == nil && lng != 0 && lat != 0 {
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat)
|
||||
} else {
|
||||
} /*else {
|
||||
order.ConsigneeLng = jxutils.StandardCoordinate2Int(lng2)
|
||||
order.ConsigneeLat = jxutils.StandardCoordinate2Int(lat2)
|
||||
}
|
||||
}*/
|
||||
order.CoordinateType = model.CoordinateTypeMars
|
||||
}
|
||||
// storeList, err := common.GetStoreListByLocation(jxcontext.AdminCtx, jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), 3000, false, true, 0)
|
||||
|
||||
@@ -340,23 +340,22 @@ func (p *PurchaseHandler) CreateStore2(db *dao.DaoDB, storeID int, userName stri
|
||||
}
|
||||
//证明这个店可能隶属直辖市或者东莞
|
||||
if model.ZXCityCodeMap[store.CityCode] != "" {
|
||||
result, _ := api.AutonaviAPI.GetCoordinateAreaInfo(jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat))
|
||||
if result["regeocode"] != nil {
|
||||
street := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})["township"].(string)
|
||||
if street != "" {
|
||||
result1, _ := api.JdShopAPI.GetProvince()
|
||||
for _, v := range result1 {
|
||||
if strings.Contains(store.CityName, v.AreaName) {
|
||||
result2, _ := api.JdShopAPI.GetCity(v.AreaID)
|
||||
for _, vv := range result2 {
|
||||
if strings.Contains(store.DistrictName, vv.AreaName) {
|
||||
result3, _ := api.JdShopAPI.GetCounty(vv.AreaID)
|
||||
for _, vvv := range result3 {
|
||||
if street == vvv.AreaName {
|
||||
createEntityStoreParam.AddCode = vvv.AreaID
|
||||
param.AddCode3 = vvv.AreaID
|
||||
break
|
||||
}
|
||||
//result, _ := api.AutonaviAPI.GetCoordinateAreaInfo(jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat))
|
||||
street, _ := api.TencentMapAPI.GetCoordinateTownInfo(jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat))
|
||||
//street := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})["township"].(string)
|
||||
if street != "" {
|
||||
result1, _ := api.JdShopAPI.GetProvince()
|
||||
for _, v := range result1 {
|
||||
if strings.Contains(store.CityName, v.AreaName) {
|
||||
result2, _ := api.JdShopAPI.GetCity(v.AreaID)
|
||||
for _, vv := range result2 {
|
||||
if strings.Contains(store.DistrictName, vv.AreaName) {
|
||||
result3, _ := api.JdShopAPI.GetCounty(vv.AreaID)
|
||||
for _, vvv := range result3 {
|
||||
if street == vvv.AreaName {
|
||||
createEntityStoreParam.AddCode = vvv.AreaID
|
||||
param.AddCode3 = vvv.AreaID
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ func (p *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
lng := jxutils.IntCoordinate2Standard(retVal.Lng)
|
||||
lat := jxutils.IntCoordinate2Standard(retVal.Lat)
|
||||
db := dao.GetDB()
|
||||
retVal.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
|
||||
retVal.DistrictCode = api.TencentMapAPI.GetCoordinateDistrictCode(lng, lat)
|
||||
city, err := dao.GetPlaceByCode(db, result.CityID)
|
||||
retVal.CityName = city.Name
|
||||
retVal.CityCode = result.CityID
|
||||
|
||||
@@ -3,12 +3,12 @@ package tiktok_store
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
instantShopping_reportRiderLocation_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/instantShopping_reportRiderLocation/request"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok_shop/ascription_place"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
@@ -251,9 +251,18 @@ func (p *PurchaseHandler) GetOrderRider(vendorOrgCode, vendorStoreID string, par
|
||||
//return tiktokShop.NewExpress(appKey, appSecret, "").OrderStatusAndPsInfoNew(param)
|
||||
if param["latitude"].(string) != "" && param["longitude"].(string) != "" {
|
||||
if len(param["latitude"].(string)) > len("39.978573") && len(param["longitude"].(string)) > len("116.5031060") { // 是否为百度坐标
|
||||
lng, lat, _ := api.AutonaviAPI.CoordinateConvert(utils.Str2Float64(param["latitude"].(string)), utils.Str2Float64(param["longitude"].(string)), autonavi.CoordSysBaidu)
|
||||
param["latitude"] = utils.Float64ToStr(lat)
|
||||
param["longitude"] = utils.Float64ToStr(lng)
|
||||
//lng, lat, _ := api.AutonaviAPI.CoordinateConvert(utils.Str2Float64(param["latitude"].(string)), utils.Str2Float64(param["longitude"].(string)), autonavi.CoordSysBaidu)
|
||||
//param["latitude"] = utils.Float64ToStr(lat)
|
||||
//param["longitude"] = utils.Float64ToStr(lng)
|
||||
|
||||
lngAndLat, err := api.TencentMapAPI.TencentCoordinateChange(&tencent_map.TencentCoordinateChangeReq{
|
||||
Locations: fmt.Sprintf("%s,%s", param["latitude"].(string), param["longitude"].(string)),
|
||||
Type: tencent_map.CoordinateChangeTypeBaidu,
|
||||
})
|
||||
if err == nil && len(lngAndLat) != 0 {
|
||||
param["latitude"] = lngAndLat[0].Lat
|
||||
param["longitude"] = lngAndLat[0].Lng
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -961,7 +961,7 @@ func (P *PurchaseHandler) ReadStore(ctx *jxcontext.Context, vendorOrgCode, vendo
|
||||
lng := jxutils.IntCoordinate2Standard(retVal.Lng)
|
||||
lat := jxutils.IntCoordinate2Standard(retVal.Lat)
|
||||
db := dao.GetDB()
|
||||
retVal.DistrictCode = api.AutonaviAPI.GetCoordinateDistrictCode(lng, lat)
|
||||
retVal.DistrictCode = api.TencentMapAPI.GetCoordinateDistrictCode(lng, lat)
|
||||
city, err := dao.GetPlaceByCode(db, utils.Str2Int(vendorStore.StoreDetail.Store.CityCode))
|
||||
retVal.CityName = city.Name
|
||||
retVal.CityCode = utils.Str2Int(vendorStore.StoreDetail.Store.CityCode)
|
||||
|
||||
@@ -31,10 +31,10 @@ taoVegetableServerUrl = "https://eco.taobao.com/router/rest"
|
||||
# mtwmCookieStr = "_lxsdk_cuid=16ddced5e9a95-0a65869c427a14-48714616-15f900-16ddced5e9b2b; _hc.v=cfebbfd1-79a7-9823-d8df-77e59646cb34.1571369610; _lxsdk=16ddced5e9a95-0a65869c427a14-48714616-15f900-16ddced5e9b2b; uuid_update=true; uuid=7b28e71504f5414e382b.1579155871.1.0.0; device_uuid=!64dedf83-b510-4910-8a31-b2b13d0bdd73; pushToken=00kRvxlerO15kB0dJFWDwYuctAoe04xGMNd0r3BqvLUA*; acctId=57396785; brandId=-1; wmPoiId=-1; isOfflineSelfOpen=0; city_id=0; isChain=1; existBrandPoi=true; ignore_set_router_proxy=true; region_id=; region_version=0; newCategory=false; bsid=OyqgRLyV54i9JKP0zRCI9jPyXc4UBU-6KReDAkPIwSlljhb97JPyFUIXfYQvhlJb6G1erzHQKbvtZ2pSWOYDxQ; cityId=510100; provinceId=510000; city_location_id=0; location_id=0; igateApp=shangouepc; wpush_server_url=wss://wpush.meituan.com; token=0MScAPaSa57iwRpgpCmGLf21tiA4yU4Uy-nDZlv8wNWs*; shopCategory=food; set_info=%7B%22wmPoiId%22%3A-1%2C%22ignoreSetRouterProxy%22%3Atrue%7D; JSESSIONID=105dgww27nsy6yfp68q7wmcni; LX_SC_CONSTANT=c_shangou_online_e_znrurnrc; _lxsdk_s=17041b590ac-3d-689-a8c%7C%7C15"
|
||||
|
||||
autonaviKey = "ef64f638f31e05cb7bde28790f7309fe"
|
||||
|
||||
# baidunaviAK = "eL94zToVOdGDTkNQxV8dnEQ1ZRcB2UKb"
|
||||
baidunaviAK = "wW2AwzPS0hdaPy5QLalzso7ARX5uYZtZ"
|
||||
baidunaviSK = "ZG0OOpOsOVURUwAkkmoHQFKRCbzn0zGb"
|
||||
TencentKey = "Q2KBZ-YXFLN-LEVFD-STWQY-6RBBE-A4FLF"
|
||||
TencentSK = "vIO9yPPnp4pWmIywsR1DHCu0OFpQONeW"
|
||||
|
||||
disableElm = true
|
||||
disableWeimob = true
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/qywxapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/sfps2"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tao_vegetable"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
|
||||
"git.rosy.net.cn/baseapi/platformapi/tiktok"
|
||||
tiktokShop "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/tiktok_api"
|
||||
"git.rosy.net.cn/baseapi/platformapi/trenditapi"
|
||||
@@ -31,8 +32,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/alipayapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/baidunavi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/ebaiapi"
|
||||
@@ -100,8 +99,10 @@ var (
|
||||
|
||||
AliPayAPI *alipayapi.API
|
||||
|
||||
AutonaviAPI *autonavi.API
|
||||
BaiDuNaviAPI *baidunavi.API
|
||||
// BaiDuNaviAPI *baidunavi.API 百度
|
||||
TencentMapAPI *tencent_map.API // 腾讯
|
||||
//AutonaviAPI *autonavi.API // 高德
|
||||
|
||||
QiniuAPI *qbox.Mac
|
||||
ShowAPI *showapi.API
|
||||
WeimobAPI *weimobapi.API
|
||||
@@ -290,8 +291,11 @@ func Init() {
|
||||
if globals.TLPayNotifyURL != "" {
|
||||
TLpayAPI = tonglianpayapi.New(beego.AppConfig.DefaultString("tonglianPayAppID", ""), beego.AppConfig.DefaultString("tonglianPayKey", ""), beego.AppConfig.DefaultString("tonglianPayCusID", ""))
|
||||
}
|
||||
AutonaviAPI = autonavi.New(beego.AppConfig.DefaultString("autonaviKey", ""))
|
||||
BaiDuNaviAPI = baidunavi.New(beego.AppConfig.DefaultString("baidunaviAK", ""), beego.AppConfig.DefaultString("baidunaviSK", ""))
|
||||
|
||||
//AutonaviAPI = autonavi.New(beego.AppConfig.DefaultString("autonaviKey", ""))
|
||||
//BaiDuNaviAPI = baidunavi.New(beego.AppConfig.DefaultString("baidunaviAK", ""), beego.AppConfig.DefaultString("baidunaviSK", ""))
|
||||
TencentMapAPI = tencent_map.New(beego.AppConfig.DefaultString("TencentKey", ""), beego.AppConfig.DefaultString("TencentSK", ""))
|
||||
|
||||
QiniuAPI = qbox.NewMac(beego.AppConfig.DefaultString("qiniuAK", ""), beego.AppConfig.DefaultString("qiniuSK", ""))
|
||||
ShowAPI = showapi.New(beego.AppConfig.DefaultInt("showAppID", 0), beego.AppConfig.DefaultString("showAppSecret", ""))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user