This commit is contained in:
richboo111
2023-09-20 11:10:17 +08:00
8 changed files with 108 additions and 37 deletions

View File

@@ -12,6 +12,7 @@ const (
// 错误码 // 错误码
const ( const (
DAILYQUERYOVERLIMIT = "10003" // 访问已超出日访问量 DAILYQUERYOVERLIMIT = "10003" // 访问已超出日访问量
USERDAILYQUERYOVERLIMIT = "10044" // 账号纬度的超出日访问量
) )
// BaseUrl 基础访问链接 // BaseUrl 基础访问链接

View File

@@ -192,6 +192,7 @@ func (a *API) AccessAPI(apiStr string, params map[string]interface{}) (retVal in
return retVal, err return retVal, err
} }
// BatchCoordinateConvert 坐标转换
func (a *API) BatchCoordinateConvert(coords []*Coordinate, fromCoordSys, toCoordSys int) (outCoords []*Coordinate, err error) { func (a *API) BatchCoordinateConvert(coords []*Coordinate, fromCoordSys, toCoordSys int) (outCoords []*Coordinate, err error) {
if fromCoordSys == toCoordSys { if fromCoordSys == toCoordSys {
return coords, nil 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()) request, err := url.Parse(prodURL2 + "/" + apiStr + "?" + params.Encode())
if nil != err { if nil != err {
fmt.Printf("host error: %v", err) return nil, err
return
} }
resp, err1 := http.Get(request.String()) resp, err1 := http.Get(request.String())
fmt.Printf("url: %s\n", request.String())
defer resp.Body.Close() defer resp.Body.Close()
if err1 != nil { if err1 != nil {
fmt.Printf("request error: %v", err1) return nil, err1
return
} }
body, err2 := ioutil.ReadAll(resp.Body) body, err2 := ioutil.ReadAll(resp.Body)
if err2 != nil { if err2 != nil {
fmt.Printf("response error: %v", err2) return nil, err2
} }
result := string(body) result := string(body)

View File

@@ -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"`
}

View File

@@ -3,7 +3,6 @@ package platformapi
import ( import (
"fmt" "fmt"
"sort" "sort"
"strings"
"testing" "testing"
"time" "time"
@@ -62,11 +61,3 @@ func Test_store(b *testing.T) {
}) })
fmt.Println(tempTagList) fmt.Println(tempTagList)
} }
func Test_string_byte(t *testing.T) {
aa := `<b>%s</b><b>1111111111111111111</b>`
bb := strings.Replace(aa, "<b>", "<hb>", -1)
cc := strings.Replace(bb, "</b>", "</hb>", -1)
fmt.Println("bb===========", bb)
fmt.Println("cc===========", cc)
}

View File

@@ -57,7 +57,7 @@ type CallbackRefundInfo struct {
IsAppeal int `json:"is_appeal"` IsAppeal int `json:"is_appeal"`
Pictures string `json:"pictures"` Pictures string `json:"pictures"`
PictureList []string `json:"pictureList"` PictureList []string `json:"pictureList"`
Status string `json:"status"`
Food string `json:"food"` Food string `json:"food"`
FoodList []*RefundSkuDetail `json:"foodList"` FoodList []*RefundSkuDetail `json:"foodList"`
Money float32 `json:"money"` Money float32 `json:"money"`

View File

@@ -599,8 +599,11 @@ func (a *API) GetDeliveryPath(orderId int64, appPoiCode string) (lng, lat int, e
if err := json.Unmarshal(path, &riderPath); err != nil { if err := json.Unmarshal(path, &riderPath); err != nil {
return 0, 0, err return 0, 0, err
} }
if len(riderPath) > 0 {
return riderPath[len(riderPath)-1].Longitude, riderPath[len(riderPath)-1].Latitude, nil return riderPath[len(riderPath)-1].Longitude, riderPath[len(riderPath)-1].Latitude, nil
} }
return 0, 0, nil
}
// OrderLogisticsFee 获取订单配送费 // OrderLogisticsFee 获取订单配送费
func (a *API) OrderLogisticsFee(orderID int64) (payFee float64, err error) { func (a *API) OrderLogisticsFee(orderID int64) (payFee float64, err error) {

View File

@@ -88,7 +88,12 @@ func TestOrderLogisticsStatus(t *testing.T) {
} }
func TestGetDeliveryPath(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) { func TestOrderLogisticsFee(t *testing.T) {
@@ -252,5 +257,7 @@ func TestLen(t *testing.T) {
} }
func TestName(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)
} }

View File

@@ -42,17 +42,15 @@ func (a *API) QueryOrderDetail(req *request2.AlibabaAelophyOrderGetRequest) (*do
// DeliveryFinish 订单一下的没一个状态通知接口 // DeliveryFinish 订单一下的没一个状态通知接口
// ACCEPTED = 商户接单 REJECTED = 商户取消订单 PICKED = 拣货完成 PACKAGED = 打包出库 SHIPPING = 开始配送 SIGN = 用户签收 REFUSED = 用户拒收 // ACCEPTED = 商户接单 REJECTED = 商户取消订单 PICKED = 拣货完成 PACKAGED = 打包出库 SHIPPING = 开始配送 SIGN = 用户签收 REFUSED = 用户拒收
func (a *API) DeliveryFinish(req *request2.AlibabaAelophyOrderWorkCallbackRequest) error { func (a *API) DeliveryFinish(req *request2.AlibabaAelophyOrderWorkCallbackRequest) error {
//globals.SugarLogger.Debugf("进入 DeliveryFinish: %s", utils.Format4Output(req, false))
client := ability591.NewAbility591(&a.client) client := ability591.NewAbility591(&a.client)
//globals.SugarLogger.Debugf("param := %s", utils.Format4Output(req, false))
data, err := client.AlibabaAelophyOrderWorkCallback(req, a.token) data, err := client.AlibabaAelophyOrderWorkCallback(req, a.token)
fmt.Println(err) if err != nil {
return err
}
if data != nil && !*data.ApiResult.Success { 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) return fmt.Errorf(*data.ApiResult.ErrMsg)
} }
//globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data, false))
return nil return nil
} }