Merge branch 'master' of https://e.coding.net/rosydev/baseapi
This commit is contained in:
@@ -26,6 +26,7 @@ func init() {
|
||||
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_izAHEkoEl4lV-w4JdJFNww") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_r36FEse6_ywebQI65FNNWA") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
cookieStr := `
|
||||
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -359,6 +358,17 @@ type RiderRealPhoneNumberInfo struct {
|
||||
RiderRealPhoneNumber string `json:"rider_real_phone_number"` // 骑手真实手机号
|
||||
}
|
||||
|
||||
// GetRiderDeliveryPath 获取骑手坐标
|
||||
type GetRiderDeliveryPath struct {
|
||||
//Code int64 `json:"code"`
|
||||
//Msg string `json:"msg"`
|
||||
//Data []struct {
|
||||
Longitude int `json:"longitude"`
|
||||
Latitude int `json:"latitude"`
|
||||
Time int64 `json:"time"`
|
||||
//} `json:"data"`
|
||||
}
|
||||
|
||||
func (a *API) OrderReceived(orderID int64) (err error) {
|
||||
_, err = a.AccessAPI("order/poi_received", true, map[string]interface{}{
|
||||
KeyOrderID: orderID,
|
||||
@@ -555,16 +565,41 @@ func (a *API) OrderLogisticsCancel(orderID int64, reason string) (err error) {
|
||||
}
|
||||
|
||||
// OrderLogisticsStatus 获取订单状态
|
||||
func (a *API) OrderLogisticsStatus(orderID int64) (status int64, err error) {
|
||||
func (a *API) OrderLogisticsStatus(orderID int64) (status *utils.RiderInfo, err error) {
|
||||
result, err := a.AccessAPI("order/logistics/status", true, map[string]interface{}{
|
||||
KeyOrderID: orderID,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logistics := &utils.RiderInfo{}
|
||||
data := result.(map[string]interface{})
|
||||
return utils.Interface2Int64WithDefault(data["logistics_status"], 0), err
|
||||
logistics.LogisticsStatus = int(utils.Interface2Int64WithDefault(data["logistics_status"], 0))
|
||||
logistics.CourierName = utils.Interface2String(data["dispatcher_name"])
|
||||
logistics.CourierPhone = utils.Interface2String(data["dispatcher_mobile"])
|
||||
return logistics, err
|
||||
}
|
||||
|
||||
func (a *API) GetDeliveryPath(orderId int64, appPoiCode string) (lng, lat int, err error) {
|
||||
result, err := a.AccessAPI("order/getDeliveryPath", true, map[string]interface{}{
|
||||
KeyOrderID: orderId,
|
||||
KeyAppPoiCode: appPoiCode,
|
||||
})
|
||||
if err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
|
||||
if result == nil {
|
||||
return 0, 0, nil
|
||||
}
|
||||
|
||||
path, _ := json.Marshal(result)
|
||||
riderPath := make([]*GetRiderDeliveryPath, 0, 0)
|
||||
if err := json.Unmarshal(path, &riderPath); err != nil {
|
||||
return 0, 0, err
|
||||
}
|
||||
return riderPath[len(riderPath)-1].Longitude, riderPath[len(riderPath)-1].Latitude, nil
|
||||
}
|
||||
|
||||
// OrderLogisticsFee 获取订单配送费
|
||||
@@ -572,7 +607,6 @@ func (a *API) OrderLogisticsFee(orderID int64) (payFee float64, err error) {
|
||||
result, err := a.AccessAPI("order/logistics/status", true, map[string]interface{}{
|
||||
KeyOrderID: orderID,
|
||||
})
|
||||
globals.SugarLogger.Debugf("=resutl := %s", utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -77,18 +77,22 @@ func TestOrderApplyPartRefund(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderLogisticsStatus(t *testing.T) {
|
||||
result, err := api.OrderLogisticsStatus(1100687990339131759)
|
||||
result, err := api.OrderLogisticsStatus(1100710754248464487)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result == 0 {
|
||||
if result == nil {
|
||||
t.Fatal("result should have value")
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetDeliveryPath(t *testing.T) {
|
||||
api.GetDeliveryPath(1000713330160837459, "7821254")
|
||||
}
|
||||
|
||||
func TestOrderLogisticsFee(t *testing.T) {
|
||||
result, err := api.OrderLogisticsFee(900699454211738469)
|
||||
result, err := api.OrderLogisticsFee(1100709560902354698)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user