修改自配送,状态,添加打印机打印参数

This commit is contained in:
邹宗楠
2022-06-01 15:33:32 +08:00
parent 98a75d53fe
commit 3c30456fcb
6 changed files with 334 additions and 7 deletions

View File

@@ -19,10 +19,10 @@ func init() {
baseapi.Init(sugarLogger)
// 菜市
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
// 果园
api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
//商超
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_vI4fNBaB5J1qvft0WmZG_g") //token_nH_IlcWQKAkZBqklwItNRw

View File

@@ -1,6 +1,7 @@
package mtwmapi
import (
"encoding/json"
"errors"
"git.rosy.net.cn/baseapi/utils"
"time"
@@ -413,7 +414,6 @@ func (a *API) OrderDelivering(orderID int64) (err error) {
return errors.New("美团系统操作异常,订单查询ng")
}
}
return err
}
@@ -697,3 +697,70 @@ func (a *API) OrderStatusAndPsInfo(params map[string]interface{}) (err error) {
_, err = a.AccessAPI("ecommerce/order/logistics/sync", false, params)
return err
}
// 获取取消跑腿理由刘表
// https://open-shangou.meituan.com/home/docDetail/482
func (a *API) GetCancelDeliveryReason(orderId int64, appPoiCode string) ([]*ReasonList, error) {
data, err := a.AccessAPI("order/getCancelDeliveryReason", false, map[string]interface{}{"order_id": orderId, "app_poi_code": appPoiCode})
if err != nil {
return nil, err
}
result := &CancelDeliveryReasonList{}
if err := json.Unmarshal([]byte(utils.Interface2String(data)), result); err != nil {
return nil, err
}
return result.Data.ReasonList, nil
}
type CancelDeliveryReasonList struct {
Data *Data `json:"data"`
}
type Data struct {
Code int `json:"code"`
Title string `json:"title"`
ReasonList []*ReasonList `json:"reasonList"`
Msg string `json:"msg"`
DeliveryStatus int `json:"deliveryStatus"`
}
type ReasonList struct {
Code string `json:"code"`
Content string `json:"content"`
PreCancelCode int `json:"preCancelCode"`
PreCancelMsg string `json:"preCancelMsg"`
}
// 取消跑腿配送
func (a *API) CancelLogisticsByWmOrderId(param *CancelOrderParam) error {
data, err := a.AccessAPI("order/getCancelDeliveryReason", false, utils.Struct2FlatMap(param))
if err != nil {
return err
}
result := &ResultMsg{}
if err := json.Unmarshal([]byte(utils.Interface2String(data)), result); err != nil {
return err
}
if result.Data != "ok" {
return errors.New(result.Error.Msg)
}
return nil
}
type ResultMsg struct {
Data string `json:"data"`
Error *struct {
Code int `json:"code"`
Msg string `json:"msg"`
}
}
// 取消跑腿配送请求参数
type CancelOrderParam struct {
ReasonCode string `json:"reason_code"` // 取消原因code 请开发者一定要先调用
DetailContent string `json:"detail_content"` // 取消原因
AppPoiCode string `json:"app_poi_code"` // 门店号
OrderId string `json:"order_id"` // 订单id
}

View File

@@ -21,3 +21,11 @@ func TestGetDistributeOrderDetail(t *testing.T) {
}
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
}
func TestCancelReason(t *testing.T) {
result, err := api.GetCancelDeliveryReason(140382470610780245, "14038247")
if err != nil {
t.Fatal(err)
}
baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
}