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..4c1a7d09 100644 --- a/platformapi/baidunavi/baidunavi.go +++ b/platformapi/baidunavi/baidunavi.go @@ -192,6 +192,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,20 +245,17 @@ 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) 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"` +} 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) -} 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 { 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 获取订单配送费 diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go index b00c793e..118d18ae 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) { @@ -252,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) } diff --git a/platformapi/tao_vegetable/order_delivery.go b/platformapi/tao_vegetable/order_delivery.go index 2123ccaa..93760577 100644 --- a/platformapi/tao_vegetable/order_delivery.go +++ b/platformapi/tao_vegetable/order_delivery.go @@ -42,17 +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) - 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) } - //globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data, false)) return nil }