From be8ebf71de422aa0e1aad8010e0c127e6aaeb154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 11 Sep 2023 14:56:03 +0800 Subject: [PATCH] 1 --- business/jxcallback/orderman/waybill.go | 10 +++- business/jxstore/cms/cms.go | 78 ++++++++++++++++++------- 2 files changed, 63 insertions(+), 25 deletions(-) diff --git a/business/jxcallback/orderman/waybill.go b/business/jxcallback/orderman/waybill.go index 543ae4fe9..6988ab3aa 100644 --- a/business/jxcallback/orderman/waybill.go +++ b/business/jxcallback/orderman/waybill.go @@ -252,8 +252,8 @@ func GetComplaintReasons() (complaintReasonList []*dadaapi.ComplaintReason) { return complaintReasonList } -func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, vendorWaybillId string, complaintID int) (err error) { - wayBillList, err := dao.GetComplaintList(dao.GetDB(), vendorOrderID, vendorWaybillId) +func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, waybillVendorID string, complaintID int) (err error) { + wayBillList, err := dao.GetComplaintList(dao.GetDB(), vendorOrderID, "") if err != nil { return err } @@ -262,7 +262,11 @@ func ComplaintRider(ctx *jxcontext.Context, vendorOrderID string, vendorWaybillI } p := partner.GetDeliveryPlatformFromVendorID(wayBillList[0].WaybillVendorID).Handler if err == nil && len(wayBillList) > 0 { - err = p.ComplaintRider(wayBillList[0], complaintID, complaintReasonsMap[complaintID]) + for _, v := range wayBillList { + if utils.Int2Str(v.WaybillVendorID) == waybillVendorID { + err = p.ComplaintRider(wayBillList[0], complaintID, complaintReasonsMap[complaintID]) + } + } } return err diff --git a/business/jxstore/cms/cms.go b/business/jxstore/cms/cms.go index 666535d7f..c20d30c79 100644 --- a/business/jxstore/cms/cms.go +++ b/business/jxstore/cms/cms.go @@ -1,6 +1,7 @@ package cms import ( + "encoding/json" "fmt" "git.rosy.net.cn/baseapi/platformapi/autonavi" "git.rosy.net.cn/baseapi/platformapi/baidunavi" @@ -613,9 +614,9 @@ func GetSToURidingDistance(sLng, sLat, uLng, uLat float64, orderId string) (step // GetSToURidingDistance2 获取商家与用户间步行距离 func GetSToURidingDistance2(sLng, sLat, uLng, uLat float64, orderId string) (wayBill *model.Waybill, err error) { var ( - origin = fmt.Sprintf("%f,%f", sLng, sLat) - destination = fmt.Sprintf("%f,%f", uLng, uLat) - db = dao.GetDB() + //origin = fmt.Sprintf("%f,%f", sLng, sLat) + //destination = fmt.Sprintf("%f,%f", uLng, uLat) + db = dao.GetDB() ) for { @@ -631,7 +632,8 @@ func GetSToURidingDistance2(sLng, sLat, uLng, uLat float64, orderId string) (way //if v.Status >= model.WaybillStatusAccepted && v.Status <= model.WaybillStatusCanceled { // 获取骑行路线图 if v.OriginalData == "" { - originalData, distance, durationTime, err := GetCyclingLine(origin, destination) + //originalData, distance, durationTime, err := GetCyclingLine(origin, destination) + originalData, distance, durationTime, err := GetCyclingLine(sLng, sLat, uLng, uLat) if err != nil { return nil, err } @@ -708,24 +710,56 @@ func GetSToURidingDistance2(sLng, sLat, uLng, uLat float64, orderId string) (way } // GetCyclingLine 获取骑行路线 -func GetCyclingLine(origin, destination string) (polyLineList []string, distance, duration int64, errCode error) { - for { - polyLineList, distance, duration, errCode = api.AutonaviAPI.GetCyclingPlan(origin, destination) - if errCode != nil { - ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "高德地图骑行方案获取错误:", utils.Format4Output(errCode, false)) - } - if errCode != nil && errCode.Error() == autonavi.DAILYQUERYOVERLIMIT { - AutonaviKeyIndex += model.YES - if AutonaviKeyIndex >= len(AutonaviKeyList) { - AutonaviKeyIndex = model.NO - } - api.AutonaviAPI.SetKey(AutonaviKeyList[AutonaviKeyIndex]) - } else if errCode != nil { - return nil, 0, 0, errCode - } +func GetCyclingLine(sLng, sLat, uLng, uLat float64) (polyLineList []string, distance, duration int64, err error) { + // 百度 + var coords []*baidunavi.Coordinate + coords = append(coords, &baidunavi.Coordinate{ + Lng: sLng, + Lat: sLat, + }, &baidunavi.Coordinate{ + Lat: uLat, + Lng: uLng, + }) - if len(polyLineList) > model.NO { - return polyLineList, distance, duration, errCode - } + coords, err = api.BaiDuNaviAPI.BatchCoordinateConvert(coords, baidunavi.CoordSysGCJ02, baidunavi.CoordSysBaiDu) + 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 + } + path := &baidunavi.RiderPath{} + if err := json.Unmarshal([]byte(data.(string)), path); err != nil { + return nil, 0, 0, err + } + distance = int64(path.Result.Routes[0].Distance) // 距离 + duration = int64(path.Result.Routes[0].Duration) // 时间 + + for _, v := range path.Result.Routes[0].Steps { + polyLineList = append(polyLineList, strings.Split(v.Path, ";")...) + } + + // 高德()免费次数太少暂时不用 + //for { + // polyLineList, distance, duration, errCode = api.AutonaviAPI.GetCyclingPlan(origin, destination) + // if errCode != nil { + // ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "2452A93EEB9111EC9B06525400E86DC0", "获取骑行路线:", utils.Format4Output(errCode, false)) + // } + // if errCode != nil && (errCode.Error() == autonavi.DAILYQUERYOVERLIMIT || errCode.Error() == autonavi.USERDAILYQUERYOVERLIMIT) { + // AutonaviKeyIndex += model.YES + // if AutonaviKeyIndex >= len(AutonaviKeyList) { + // AutonaviKeyIndex = model.NO + // } + // api.AutonaviAPI.SetKey(AutonaviKeyList[AutonaviKeyIndex]) + // } else if errCode != nil { + // return nil, 0, 0, errCode + // } + // + // if len(polyLineList) > model.NO { + // return polyLineList, distance, duration, errCode + // } + //} + + return }