1
This commit is contained in:
@@ -4,7 +4,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -401,6 +400,16 @@ type Errors struct {
|
|||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 专快混配送转为商家自配送
|
||||||
|
// 预定单不能调用此接口
|
||||||
|
// https://developer.waimai.meituan.com/home/myquestionDetail/7382
|
||||||
|
func (a *API) OrderLogisticsChange2Self(orderID int64) (err error) {
|
||||||
|
_, err = a.AccessAPI("order/logistics/change/poi_self", false, map[string]interface{}{
|
||||||
|
KeyOrderID: orderID,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (a *API) OrderDelivering(orderID int64) (err error) {
|
func (a *API) OrderDelivering(orderID int64) (err error) {
|
||||||
retval, err := a.AccessAPI("order/delivering", true, map[string]interface{}{
|
retval, err := a.AccessAPI("order/delivering", true, map[string]interface{}{
|
||||||
KeyOrderID: orderID,
|
KeyOrderID: orderID,
|
||||||
@@ -589,19 +598,6 @@ func (a *API) OrderGetRiderInfoPhoneNumber(poiCode string, offset, limit int) (r
|
|||||||
return realNumberList, err
|
return realNumberList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// 专快混配送转为商家自配送
|
|
||||||
// 预定单不能调用此接口
|
|
||||||
// https://developer.waimai.meituan.com/home/myquestionDetail/7382
|
|
||||||
func (a *API) OrderLogisticsChange2Self(orderID int64) (err error) {
|
|
||||||
_, err = a.AccessAPI("order/logistics/change/poi_self", false, map[string]interface{}{
|
|
||||||
KeyOrderID: orderID,
|
|
||||||
})
|
|
||||||
if strings.Contains(err.Error(), "1047") {
|
|
||||||
return a.OrderDelivering(orderID)
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// refundOrderDetailList不能定义为[]*RefundOrderDetail,否则会有解析错误,原因不明
|
// refundOrderDetailList不能定义为[]*RefundOrderDetail,否则会有解析错误,原因不明
|
||||||
func (a *API) GetOrderRefundDetail(orderID int64, refundType int) (refundOrderDetailList []*RefundOrderDetail, err error) {
|
func (a *API) GetOrderRefundDetail(orderID int64, refundType int) (refundOrderDetailList []*RefundOrderDetail, err error) {
|
||||||
params := map[string]interface{}{
|
params := map[string]interface{}{
|
||||||
@@ -704,24 +700,24 @@ func (a *API) OrderStatusAndPsInfo(params map[string]interface{}) (err error) {
|
|||||||
|
|
||||||
// 获取取消跑腿理由刘表
|
// 获取取消跑腿理由刘表
|
||||||
// https://open-shangou.meituan.com/home/docDetail/482
|
// https://open-shangou.meituan.com/home/docDetail/482
|
||||||
func (a *API) GetCancelDeliveryReason(orderId int64, appPoiCode string) ([]*ReasonList, error) {
|
func (a *API) GetCancelDeliveryReason(orderId int64, appPoiCode string) (string, error) {
|
||||||
data, err := a.AccessAPI("order/getCancelDeliveryReason", false, map[string]interface{}{"order_id": orderId, "app_poi_code": appPoiCode})
|
data, err := a.AccessAPI("order/getCancelDeliveryReason", false, map[string]interface{}{"order_id": orderId, "app_poi_code": appPoiCode})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
result := &CancelDeliveryReasonList{}
|
str, _ := json.Marshal(data)
|
||||||
if err := json.Unmarshal([]byte(utils.Interface2String(data)), result); err != nil {
|
result := &DeliveryData{}
|
||||||
return nil, err
|
if err := json.Unmarshal(str, result); err != nil {
|
||||||
|
return "", err
|
||||||
}
|
}
|
||||||
return result.Data.ReasonList, nil
|
|
||||||
|
list, _ := json.Marshal(&result.ReasonList)
|
||||||
|
|
||||||
|
return string(list), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type CancelDeliveryReasonList struct {
|
type DeliveryData struct {
|
||||||
Data *Data `json:"data"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Data struct {
|
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
ReasonList []*ReasonList `json:"reasonList"`
|
ReasonList []*ReasonList `json:"reasonList"`
|
||||||
@@ -737,8 +733,14 @@ type ReasonList struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 取消跑腿配送
|
// 取消跑腿配送
|
||||||
func (a *API) CancelLogisticsByWmOrderId(param *CancelOrderParam) error {
|
func (a *API) CancelLogisticsByWmOrderId(reasonCode, detailContent, appPoiCode, orderId string) error {
|
||||||
data, err := a.AccessAPI("order/getCancelDeliveryReason", false, utils.Struct2FlatMap(param))
|
param := &CancelOrderParam{
|
||||||
|
ReasonCode: reasonCode,
|
||||||
|
DetailContent: detailContent,
|
||||||
|
AppPoiCode: appPoiCode,
|
||||||
|
OrderId: orderId,
|
||||||
|
}
|
||||||
|
data, err := a.AccessAPI("order/cancelLogisticsByWmOrderId", false, utils.Struct2FlatMap(param))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ func TestGetDistributeOrderDetail(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCancelReason(t *testing.T) {
|
func TestCancelReason(t *testing.T) {
|
||||||
result, err := api.GetCancelDeliveryReason(140382470610780245, "14038247")
|
result, err := api.GetCancelDeliveryReason(148815412592716910, "14881541")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,8 +173,13 @@ func TestAa2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleving(t *testing.T) {
|
func TestDeleving(t *testing.T) {
|
||||||
err := api.OrderLogisticsChange2Self(148815412830472574)
|
err := api.OrderLogisticsChange2Self(148815413321281654)
|
||||||
|
|
||||||
fmt.Println(strings.Contains(err.Error(), "1047"))
|
fmt.Println(strings.Contains(err.Error(), "1047"))
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOrderDelivering(t *testing.T) {
|
||||||
|
err := api.OrderDelivering(148815413321281654)
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user