From d26e0e540616bfa202aaf4bb039c5f77dbf35dfc 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:55:40 +0800 Subject: [PATCH 1/8] 1 --- platformapi/autonavi/gaode_const.go | 3 +- platformapi/baidunavi/baidunavi.go | 18 ++++-- platformapi/baidunavi/baidunavi_model.go | 73 ++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 platformapi/baidunavi/baidunavi_model.go diff --git a/platformapi/autonavi/gaode_const.go b/platformapi/autonavi/gaode_const.go index ee02fb40..e3f72eb2 100644 --- a/platformapi/autonavi/gaode_const.go +++ b/platformapi/autonavi/gaode_const.go @@ -11,7 +11,8 @@ const ( // 错误码 const ( - DAILYQUERYOVERLIMIT = "10003" // 访问已超出日访问量 + DAILYQUERYOVERLIMIT = "10003" // 访问已超出日访问量 + USERDAILYQUERYOVERLIMIT = "10044" // 账号纬度的超出日访问量 ) // BaseUrl 基础访问链接 diff --git a/platformapi/baidunavi/baidunavi.go b/platformapi/baidunavi/baidunavi.go index 6d8424fb..29966bb8 100644 --- a/platformapi/baidunavi/baidunavi.go +++ b/platformapi/baidunavi/baidunavi.go @@ -2,7 +2,9 @@ package baidunavi import ( "crypto/md5" + "encoding/json" "fmt" + "git.rosy.net.cn/jx-callback/globals" "io/ioutil" "net/http" "net/url" @@ -192,6 +194,7 @@ func (a *API) AccessAPI(apiStr string, params map[string]interface{}) (retVal in return retVal, err } +// BatchCoordinateConvert 坐标转换 func (a *API) BatchCoordinateConvert(coords []*Coordinate, fromCoordSys, toCoordSys int) (outCoords []*Coordinate, err error) { if fromCoordSys == toCoordSys { return coords, nil @@ -244,22 +247,25 @@ func (a *API) DirectionLiteRide(coords []*Coordinate) (retVal interface{}, err e // 发起请求 request, err := url.Parse(prodURL2 + "/" + apiStr + "?" + params.Encode()) if nil != err { - fmt.Printf("host error: %v", err) - return + return nil, err } resp, err1 := http.Get(request.String()) - fmt.Printf("url: %s\n", request.String()) defer resp.Body.Close() if err1 != nil { - fmt.Printf("request error: %v", err1) - return + return nil, err1 } body, err2 := ioutil.ReadAll(resp.Body) if err2 != nil { - fmt.Printf("response error: %v", err2) + return nil, err2 } result := string(body) + path := &RiderPath{} + if err := json.Unmarshal([]byte(result), path); err != nil { + return result, nil + } + globals.SugarLogger.Debugf("=======path := %s", utils.Format4Output(path, false)) + return result, nil } diff --git a/platformapi/baidunavi/baidunavi_model.go b/platformapi/baidunavi/baidunavi_model.go new file mode 100644 index 00000000..5df28e53 --- /dev/null +++ b/platformapi/baidunavi/baidunavi_model.go @@ -0,0 +1,73 @@ +package baidunavi + +// RiderPath 骑行路线 +//type RiderPath struct { +// Status int `json:"status"` // 状态码 0-成功,1-服务器内部错误,2-参数无效,7-无结果返回 +// Message string `json:"message"` // 状态码对应的信息 +// Result struct { +// RiderResult +// Routes []struct { +// Distance int `json:"distance"` // 距离米 +// Duration int `json:"duration"` // 时间秒 +// Steps []struct { +// Distance int `json:"distance"` +// Duration int `json:"duration"` +// Direction int `json:"direction"` +// TurnType string `json:"turn_type"` +// Name string `json:"name"` +// Instruction string `json:"instruction"` +// RestrictionsInfo string `json:"restrictions_info"` +// Path string `json:"path"` +// StartLocation RiderCoordinate `json:"start_location"` +// EndLocation RiderCoordinate `json:"end_location"` +// } `json:"steps"` +// } `json:"routes"` +// } `json:"result"` +//} +// +//type RiderResult struct { +// Origin RiderCoordinate `json:"origin"` // 起点经纬度 +// Destination RiderCoordinate `json:"destination"` // 终点经纬度 +//} +// +//type RiderCoordinate struct { +// Lng float64 `json:"lng"` // 经度 +// Lat float64 `json:"lat"` // 纬度 +//} + +type RiderPath struct { + Status int `json:"status"` + Message string `json:"message"` + Result struct { + Origin struct { + Lng float64 `json:"lng"` + Lat float64 `json:"lat"` + } `json:"origin"` + Destination struct { + Lng float64 `json:"lng"` + Lat float64 `json:"lat"` + } `json:"destination"` + Routes []struct { + Distance int `json:"distance"` + Duration int `json:"duration"` + Steps []struct { + Distance int `json:"distance"` + Duration int `json:"duration"` + Direction int `json:"direction"` + TurnType string `json:"turn_type"` + Name string `json:"name"` + Instruction string `json:"instruction"` + RestrictionsInfo string `json:"restrictions_info"` + Path string `json:"path"` + StartLocation struct { + Lng string `json:"lng"` + Lat string `json:"lat"` + } `json:"start_location"` + EndLocation struct { + Lng string `json:"lng"` + Lat string `json:"lat"` + } `json:"end_location"` + } `json:"steps"` + } `json:"routes"` + } `json:"result"` +} From 72fe439cdf452acc5d31a3c5d52f80d31f79ceb5 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 15:38:23 +0800 Subject: [PATCH 2/8] 1 --- platformapi/baidunavi/baidunavi.go | 8 -------- platformapi/mtwmapi/order_test.go | 7 ++++++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/platformapi/baidunavi/baidunavi.go b/platformapi/baidunavi/baidunavi.go index 29966bb8..4c1a7d09 100644 --- a/platformapi/baidunavi/baidunavi.go +++ b/platformapi/baidunavi/baidunavi.go @@ -2,9 +2,7 @@ package baidunavi import ( "crypto/md5" - "encoding/json" "fmt" - "git.rosy.net.cn/jx-callback/globals" "io/ioutil" "net/http" "net/url" @@ -261,11 +259,5 @@ func (a *API) DirectionLiteRide(coords []*Coordinate) (retVal interface{}, err e } result := string(body) - path := &RiderPath{} - if err := json.Unmarshal([]byte(result), path); err != nil { - return result, nil - } - globals.SugarLogger.Debugf("=======path := %s", utils.Format4Output(path, false)) - return result, nil } diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go index b00c793e..a2c314e1 100644 --- a/platformapi/mtwmapi/order_test.go +++ b/platformapi/mtwmapi/order_test.go @@ -88,7 +88,12 @@ func TestOrderLogisticsStatus(t *testing.T) { } func TestGetDeliveryPath(t *testing.T) { - api.GetDeliveryPath(1000713330160837459, "7821254") + data1, data2, err := api.GetDeliveryPath(1100718012566212160, "7290541") + fmt.Println(data1) + fmt.Println(data2) + fmt.Println(utils.Float64ToStr(float64(data1) / 1000000)) + fmt.Println(utils.Float64ToStr(float64(data2) / 1000000)) + fmt.Println(err) } func TestOrderLogisticsFee(t *testing.T) { From 5a7fc9b9b138e44fafd9fb420ecda00a72e3d6f0 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 17:07:46 +0800 Subject: [PATCH 3/8] 1 --- platformapi/mtwmapi/order_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go index a2c314e1..118d18ae 100644 --- a/platformapi/mtwmapi/order_test.go +++ b/platformapi/mtwmapi/order_test.go @@ -257,5 +257,7 @@ func TestLen(t *testing.T) { } func TestName(t *testing.T) { - fmt.Println((10 & 2) != 0) + data := map[int]int{101: 1, 102: 1, 103: 1} + + fmt.Println(data[1] == 1) } From 0eb0d3c2aefc38fee862001a7f168be1059dc9dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 12 Sep 2023 18:05:42 +0800 Subject: [PATCH 4/8] 1 --- platformapi/tao_vegetable/order_delivery.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platformapi/tao_vegetable/order_delivery.go b/platformapi/tao_vegetable/order_delivery.go index 2123ccaa..64aab1ae 100644 --- a/platformapi/tao_vegetable/order_delivery.go +++ b/platformapi/tao_vegetable/order_delivery.go @@ -47,7 +47,9 @@ func (a *API) DeliveryFinish(req *request2.AlibabaAelophyOrderWorkCallbackReques //globals.SugarLogger.Debugf("param := %s", utils.Format4Output(req, false)) data, err := client.AlibabaAelophyOrderWorkCallback(req, a.token) - fmt.Println(err) + if err != nil { + return err + } if data != nil && !*data.ApiResult.Success { //globals.SugarLogger.Debugf("requestId[%s],err[%s]", data.RequestId, utils.Format4Output(data, false)) return fmt.Errorf(*data.ApiResult.ErrMsg) From 928910f8240f0e79bde2239e86f789092519973b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 12 Sep 2023 18:59:58 +0800 Subject: [PATCH 5/8] 1 --- platformapi/limit_access_speed_test.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/platformapi/limit_access_speed_test.go b/platformapi/limit_access_speed_test.go index 2723571e..800ea310 100644 --- a/platformapi/limit_access_speed_test.go +++ b/platformapi/limit_access_speed_test.go @@ -3,7 +3,6 @@ package platformapi import ( "fmt" "sort" - "strings" "testing" "time" @@ -62,11 +61,3 @@ func Test_store(b *testing.T) { }) fmt.Println(tempTagList) } - -func Test_string_byte(t *testing.T) { - aa := `%s1111111111111111111` - bb := strings.Replace(aa, "", "", -1) - cc := strings.Replace(bb, "", "", -1) - fmt.Println("bb===========", bb) - fmt.Println("cc===========", cc) -} From b1765035d59f5f1186424b761b128724d7746cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 13 Sep 2023 15:30:31 +0800 Subject: [PATCH 6/8] 1 --- platformapi/tao_vegetable/order_delivery.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/platformapi/tao_vegetable/order_delivery.go b/platformapi/tao_vegetable/order_delivery.go index 64aab1ae..93760577 100644 --- a/platformapi/tao_vegetable/order_delivery.go +++ b/platformapi/tao_vegetable/order_delivery.go @@ -42,19 +42,15 @@ func (a *API) QueryOrderDetail(req *request2.AlibabaAelophyOrderGetRequest) (*do // DeliveryFinish 订单一下的没一个状态通知接口 // ACCEPTED = 商户接单 REJECTED = 商户取消订单 PICKED = 拣货完成 PACKAGED = 打包出库 SHIPPING = 开始配送 SIGN = 用户签收 REFUSED = 用户拒收 func (a *API) DeliveryFinish(req *request2.AlibabaAelophyOrderWorkCallbackRequest) error { - //globals.SugarLogger.Debugf("进入 DeliveryFinish: %s", utils.Format4Output(req, false)) client := ability591.NewAbility591(&a.client) - //globals.SugarLogger.Debugf("param := %s", utils.Format4Output(req, false)) data, err := client.AlibabaAelophyOrderWorkCallback(req, a.token) if err != nil { return err } if data != nil && !*data.ApiResult.Success { - //globals.SugarLogger.Debugf("requestId[%s],err[%s]", data.RequestId, utils.Format4Output(data, false)) return fmt.Errorf(*data.ApiResult.ErrMsg) } - //globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data, false)) return nil } From 4524867791195b25e740e74d84957dc69dae19e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 14 Sep 2023 12:44:53 +0800 Subject: [PATCH 7/8] 1 --- platformapi/mtwmapi/callback.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/platformapi/mtwmapi/callback.go b/platformapi/mtwmapi/callback.go index f0cd9569..08e0d4e2 100644 --- a/platformapi/mtwmapi/callback.go +++ b/platformapi/mtwmapi/callback.go @@ -48,19 +48,19 @@ type CallbackRefundInfo struct { AppID string `json:"app_id"` Sig string `json:"sig"` - OrderID int64 `json:"order_id"` - NotifyType string `json:"notify_type"` - RefundID int64 `json:"refund_id"` - Ctime int64 `json:"ctime"` - Reason string `json:"reason"` - ResType int `json:"res_type"` - IsAppeal int `json:"is_appeal"` - Pictures string `json:"pictures"` - PictureList []string `json:"pictureList"` - - Food string `json:"food"` - FoodList []*RefundSkuDetail `json:"foodList"` - Money float32 `json:"money"` + OrderID int64 `json:"order_id"` + NotifyType string `json:"notify_type"` + RefundID int64 `json:"refund_id"` + Ctime int64 `json:"ctime"` + Reason string `json:"reason"` + ResType int `json:"res_type"` + IsAppeal int `json:"is_appeal"` + Pictures string `json:"pictures"` + PictureList []string `json:"pictureList"` + Status string `json:"status"` + Food string `json:"food"` + FoodList []*RefundSkuDetail `json:"foodList"` + Money float32 `json:"money"` } type CallbackMsg struct { From de0332cf8b6116f7bb625f7f127abf69219e9396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 15 Sep 2023 09:15:50 +0800 Subject: [PATCH 8/8] 1 --- platformapi/mtwmapi/order.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platformapi/mtwmapi/order.go b/platformapi/mtwmapi/order.go index 8aabe9cd..8587a931 100644 --- a/platformapi/mtwmapi/order.go +++ b/platformapi/mtwmapi/order.go @@ -599,7 +599,10 @@ func (a *API) GetDeliveryPath(orderId int64, appPoiCode string) (lng, lat int, e if err := json.Unmarshal(path, &riderPath); err != nil { return 0, 0, err } - return riderPath[len(riderPath)-1].Longitude, riderPath[len(riderPath)-1].Latitude, nil + if len(riderPath) > 0 { + return riderPath[len(riderPath)-1].Longitude, riderPath[len(riderPath)-1].Latitude, nil + } + return 0, 0, nil } // OrderLogisticsFee 获取订单配送费