1
This commit is contained in:
@@ -2,7 +2,6 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"math"
|
||||
"reflect"
|
||||
"regexp"
|
||||
@@ -759,41 +758,10 @@ func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, dist
|
||||
}
|
||||
}
|
||||
|
||||
polyLineList = utils.BaiDuCoord2Gaode2(polyLine)
|
||||
// 百度坐标转高德坐标
|
||||
polyLineList = jxutils.BaiDuCoord2Gaode2(polyLine)
|
||||
if len(polyLineList) == 0 || polyLineList == nil {
|
||||
polyLineList = polyLine
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 美团只认识高德地图坐标点,的转一下
|
||||
func baiDuCoord2Gaode(baiduCoordinat []string) ([]string, error) {
|
||||
count := len(baiduCoordinat) / 100
|
||||
if i := len(baiduCoordinat) % 100; i != 0 {
|
||||
count += 1
|
||||
}
|
||||
|
||||
gaoCoordinat := make([]string, 0, 0)
|
||||
for i := 1; i <= count; i++ {
|
||||
var discordant = make([]string, 0, 0)
|
||||
if i == count {
|
||||
discordant = append(discordant, baiduCoordinat[(i-1)*100:]...)
|
||||
} else {
|
||||
discordant = append(discordant, baiduCoordinat[(i-1)*100:i*100]...)
|
||||
}
|
||||
coords, err := api.BaiDuNaviAPI.BatchCoordinateConvertBai2Gao(discordant, baidunavi.CoordSysBaidu2Gaode)
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("百度坐标转换异常:%v", err)
|
||||
break
|
||||
}
|
||||
|
||||
for _, v := range coords {
|
||||
gaoCoordinat = append(gaoCoordinat, fmt.Sprintf("%.6f,%.6f", v.Lng, v.Lat))
|
||||
}
|
||||
}
|
||||
|
||||
if len(gaoCoordinat) == 0 || len(gaoCoordinat) != len(baiduCoordinat) {
|
||||
|
||||
}
|
||||
return gaoCoordinat, nil
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"crypto/md5"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/rand"
|
||||
@@ -16,7 +17,6 @@ import (
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/autonavi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/baseapi/utils/routinepool"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/excel"
|
||||
@@ -230,6 +230,23 @@ func GetUniversalOrderIDFromOrderStatus(status *model.OrderStatus) string {
|
||||
return ComposeUniversalOrderID(status.VendorOrderID, status.VendorID)
|
||||
}
|
||||
|
||||
// BaiDuCoord2Gaode2 将百度坐标转换为高德坐标
|
||||
func BaiDuCoord2Gaode2(baiduCoordinat []string) []string {
|
||||
gaoCoordinat := make([]string, 0, 0)
|
||||
for _, v := range baiduCoordinat {
|
||||
var XPI = math.Pi * 3000.0 / 180.0
|
||||
coords := strings.Split(v, ",")
|
||||
var x = utils.Str2Float64(coords[0]) - 0.0065
|
||||
var y = utils.Str2Float64(coords[1]) - 0.006
|
||||
var z = math.Sqrt(x*x+y*y) - 0.00002*math.Sin(y*XPI)
|
||||
var theta = math.Atan2(y, x) - 0.000003*math.Cos(x*XPI)
|
||||
var gg_lng = z * math.Cos(theta)
|
||||
var gg_lat = z * math.Sin(theta)
|
||||
gaoCoordinat = append(gaoCoordinat, fmt.Sprintf("%.6f,%.6f", gg_lng, gg_lat))
|
||||
}
|
||||
return gaoCoordinat
|
||||
}
|
||||
|
||||
// distance单位为米
|
||||
func ConvertDistanceToLogLat(lng, lat, distance, angle float64) (newLng, newLat float64) {
|
||||
oneDu := 111319.55 // 单位为米
|
||||
@@ -364,18 +381,6 @@ func MapValue2Scope(value, fromMin, fromMax, toMin, toMax int64) int64 {
|
||||
return int64(math.Round(float64(value-fromMin)/float64(fromMax-fromMin)*float64(toMax-toMin) + float64(toMin)))
|
||||
}
|
||||
|
||||
func Errs2Str(sep string, errs ...error) (retVal string) {
|
||||
if sep == "" {
|
||||
sep = "\n"
|
||||
}
|
||||
for _, err := range errs {
|
||||
if err != nil {
|
||||
retVal += err.Error() + sep
|
||||
}
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func IntWeight2Float(weight int) float32 {
|
||||
return float32(weight) / 1000.0
|
||||
}
|
||||
|
||||
@@ -5,23 +5,19 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/dadaapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jcqapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/jdshopapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/authz/autils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
@@ -308,12 +304,7 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
if order.OrderType == model.OrderTypeAddressErr {
|
||||
buildOrderTo102919(order)
|
||||
}
|
||||
// billParams, _ := GetDaDaBillParams(db, order)
|
||||
// if result, err := api.DadaAPI.QueryDeliverFee(billParams); err == nil {
|
||||
// if result.Fee > 10 {
|
||||
// buildOrderTo102919(order)
|
||||
// }
|
||||
// }
|
||||
|
||||
if store != nil {
|
||||
distance := jxutils.EarthDistance(jxutils.IntCoordinate2Standard(order.ConsigneeLng), jxutils.IntCoordinate2Standard(order.ConsigneeLat), jxutils.IntCoordinate2Standard(store.Lng), jxutils.IntCoordinate2Standard(store.Lat))
|
||||
if distance > 4 {
|
||||
@@ -328,12 +319,6 @@ func result2Orders(msg *jdshopapi.CallBackResult) (order *model.GoodsOrder, err
|
||||
}
|
||||
|
||||
func buildOrderTo102919(order *model.GoodsOrder) {
|
||||
// if order.VendorOrgCode == "1" {
|
||||
// order.StoreID = 102919
|
||||
// order.JxStoreID = 102919
|
||||
// order.StoreName = "商城模板(成都发货)"
|
||||
// order.VendorStoreID = model.JdShopMainVendorStoreID
|
||||
// } else {
|
||||
order.StoreID = model.JdShopMainStoreID
|
||||
order.JxStoreID = model.JdShopMainStoreID
|
||||
order.StoreName = "商城模板店2"
|
||||
@@ -403,81 +388,82 @@ func getAllRealOrderID(orderID string) (orders []*model.GoodsOrder) {
|
||||
return orders
|
||||
}
|
||||
|
||||
func GetDaDaBillParams(db *dao.DaoDB, order *model.GoodsOrder) (billParams *dadaapi.OperateOrderParams, err error) {
|
||||
billParams = &dadaapi.OperateOrderParams{
|
||||
OriginID: jxutils.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID),
|
||||
CargoPrice: jxutils.IntPrice2Standard(limitOrderPrice(order.ActualPayPrice)),
|
||||
IsPrepay: 0,
|
||||
ReceiverName: utils.FilterMb4(order.ConsigneeName),
|
||||
ReceiverAddress: utils.FilterMb4(order.ConsigneeAddress),
|
||||
ReceiverPhone: order.ConsigneeMobile,
|
||||
}
|
||||
if billParams.ShopNo, err = getDadaShopID(order, db); err == nil {
|
||||
if billParams.CityCode, err = getDataCityCodeFromOrder(order, db); err == nil {
|
||||
// storeTel := ""
|
||||
// storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||
// if storeDeatail.Tel2 != "" {
|
||||
// storeTel = ",门店电话:" + storeDeatail.Tel2
|
||||
// }
|
||||
billParams.ReceiverLng, billParams.ReceiverLat, _ = jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
billParams.Info = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, utils.FilterMb4("客户电话:"+order.ConsigneeMobile+","+order.BuyerComment+"配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成定单!"))
|
||||
billParams.CargoType = dadaapi.CargoTypeFresh
|
||||
billParams.CargoWeight = float64(jxutils.IntWeight2Float(limitOrderWeight(order.Weight)))
|
||||
billParams.CargoNum = order.GoodsCount
|
||||
}
|
||||
}
|
||||
return billParams, err
|
||||
}
|
||||
|
||||
func limitOrderPrice(price int64) int64 {
|
||||
var maxOrderPrice int64 = 6399
|
||||
if price > maxOrderPrice {
|
||||
return maxOrderPrice
|
||||
}
|
||||
return price
|
||||
}
|
||||
|
||||
func limitOrderWeight(weight int) int {
|
||||
maxOrderWeight := 5000 // 5公斤
|
||||
if weight > maxOrderWeight {
|
||||
return maxOrderWeight
|
||||
}
|
||||
return weight
|
||||
}
|
||||
|
||||
func getDadaShopID(order *model.GoodsOrder, db *dao.DaoDB) (retVal string, err error) {
|
||||
saleStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
storeCourierList, err2 := dao.GetOpenedStoreCouriersByStoreID(db, saleStoreID, model.VendorIDDada)
|
||||
if err = err2; err != nil && !dao.IsNoRowsError(err) {
|
||||
return "", err
|
||||
}
|
||||
if len(storeCourierList) == 0 {
|
||||
return "", partner.ErrStoreHaveNoCourier
|
||||
}
|
||||
retVal = storeCourierList[0].VendorStoreID
|
||||
if beego.BConfig.RunMode == "dev" {
|
||||
retVal = "test_0001"
|
||||
}
|
||||
return retVal, nil
|
||||
}
|
||||
|
||||
func getDataCityCodeFromOrder(order *model.GoodsOrder, db *dao.DaoDB) (retVal string, err error) {
|
||||
jxStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
sql := `
|
||||
SELECT t2.tel_code
|
||||
FROM store t1
|
||||
JOIN place t2 on t1.city_code = t2.code
|
||||
WHERE t1.id = ?
|
||||
`
|
||||
codeInfo := &struct {
|
||||
TelCode string
|
||||
}{}
|
||||
if err = dao.GetRow(db, codeInfo, sql, jxStoreID); err != nil {
|
||||
if err == nil {
|
||||
err = errors.New("不能找到美团配送站点配置")
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
return codeInfo.TelCode, nil
|
||||
}
|
||||
//
|
||||
//func GetDaDaBillParams(db *dao.DaoDB, order *model.GoodsOrder) (billParams *dadaapi.OperateOrderParams, err error) {
|
||||
// billParams = &dadaapi.OperateOrderParams{
|
||||
// OriginID: jxutils.ComposeUniversalOrderID(order.VendorOrderID, order.VendorID),
|
||||
// CargoPrice: jxutils.IntPrice2Standard(limitOrderPrice(order.ActualPayPrice)),
|
||||
// IsPrepay: 0,
|
||||
// ReceiverName: utils.FilterMb4(order.ConsigneeName),
|
||||
// ReceiverAddress: utils.FilterMb4(order.ConsigneeAddress),
|
||||
// ReceiverPhone: order.ConsigneeMobile,
|
||||
// }
|
||||
// if billParams.ShopNo, err = getDadaShopID(order, db); err == nil {
|
||||
// if billParams.CityCode, err = getDataCityCodeFromOrder(order, db); err == nil {
|
||||
// // storeTel := ""
|
||||
// // storeID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// // storeDeatail, _ := dao.GetStoreDetail(db, storeID, order.VendorID)
|
||||
// // if storeDeatail.Tel2 != "" {
|
||||
// // storeTel = ",门店电话:" + storeDeatail.Tel2
|
||||
// // }
|
||||
// billParams.ReceiverLng, billParams.ReceiverLat, _ = jxutils.IntCoordinate2MarsStandard(order.ConsigneeLng, order.ConsigneeLat, order.CoordinateType)
|
||||
// billParams.Info = fmt.Sprintf("%s第%d号订单, %s", model.VendorChineseNames[order.VendorID], order.OrderSeq, utils.FilterMb4("客户电话:"+order.ConsigneeMobile+","+order.BuyerComment+"配送遇到问题,可联系18048531223取消配送单,禁止未配送直接完成定单!"))
|
||||
// billParams.CargoType = dadaapi.CargoTypeFresh
|
||||
// billParams.CargoWeight = float64(jxutils.IntWeight2Float(limitOrderWeight(order.Weight)))
|
||||
// billParams.CargoNum = order.GoodsCount
|
||||
// }
|
||||
// }
|
||||
// return billParams, err
|
||||
//}
|
||||
//
|
||||
//func limitOrderPrice(price int64) int64 {
|
||||
// var maxOrderPrice int64 = 6399
|
||||
// if price > maxOrderPrice {
|
||||
// return maxOrderPrice
|
||||
// }
|
||||
// return price
|
||||
//}
|
||||
//
|
||||
//func limitOrderWeight(weight int) int {
|
||||
// maxOrderWeight := 5000 // 5公斤
|
||||
// if weight > maxOrderWeight {
|
||||
// return maxOrderWeight
|
||||
// }
|
||||
// return weight
|
||||
//}
|
||||
//
|
||||
//func getDadaShopID(order *model.GoodsOrder, db *dao.DaoDB) (retVal string, err error) {
|
||||
// saleStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// storeCourierList, err2 := dao.GetOpenedStoreCouriersByStoreID(db, saleStoreID, model.VendorIDDada)
|
||||
// if err = err2; err != nil && !dao.IsNoRowsError(err) {
|
||||
// return "", err
|
||||
// }
|
||||
// if len(storeCourierList) == 0 {
|
||||
// return "", partner.ErrStoreHaveNoCourier
|
||||
// }
|
||||
// retVal = storeCourierList[0].VendorStoreID
|
||||
// if beego.BConfig.RunMode == "dev" {
|
||||
// retVal = "test_0001"
|
||||
// }
|
||||
// return retVal, nil
|
||||
//}
|
||||
//
|
||||
//func getDataCityCodeFromOrder(order *model.GoodsOrder, db *dao.DaoDB) (retVal string, err error) {
|
||||
// jxStoreID := jxutils.GetSaleStoreIDFromOrder(order)
|
||||
// sql := `
|
||||
// SELECT t2.tel_code
|
||||
// FROM store t1
|
||||
// JOIN place t2 on t1.city_code = t2.code
|
||||
// WHERE t1.id = ?
|
||||
// `
|
||||
// codeInfo := &struct {
|
||||
// TelCode string
|
||||
// }{}
|
||||
// if err = dao.GetRow(db, codeInfo, sql, jxStoreID); err != nil {
|
||||
// if err == nil {
|
||||
// err = errors.New("不能找到美团配送站点配置")
|
||||
// }
|
||||
// return "", err
|
||||
// }
|
||||
// return codeInfo.TelCode, nil
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user