From 722c133816ddfa90b770a019a9e9b84911399061 Mon Sep 17 00:00:00 2001 From: zhanglibo <zhanglibo@stbz.net> Date: Mon, 4 Nov 2024 09:45:26 +0800 Subject: [PATCH] dwd LogisticsTrace --- upstream/dwd/dwd_logistics.go | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 upstream/dwd/dwd_logistics.go diff --git a/upstream/dwd/dwd_logistics.go b/upstream/dwd/dwd_logistics.go new file mode 100644 index 0000000..3e1af90 --- /dev/null +++ b/upstream/dwd/dwd_logistics.go @@ -0,0 +1,72 @@ +package dwd + +import ( + "context" + "github.com/gogf/gf/encoding/gjson" + "github.com/gogf/gf/util/gconv" +) + +type logisticsDwd struct { +} + +var Logistics = logisticsDwd{} + +type LogisticsTraceReq struct { + BatchNo string `json:"batch_no,omitempty"` + OutOrderId string `json:"out_order_id,omitempty"` + OrderId int `json:"order_id"` +} +type LogisticsTraceRes struct { + LogisticsDetail struct { + Contacter string `json:"contacter"` + Mobile string `json:"mobile"` + DeliveryComCode string `json:"delivery_com_code"` + DeliveryComName string `json:"delivery_com_name"` + Note string `json:"note"` + UpdatedAtFormat string `json:"updated_at_format"` + } `json:"logisticsDetail"` + TranceDetail struct { + DeliveryNo string `json:"delivery_no"` + DeliveryComCode string `json:"delivery_com_code"` + DeliveryComName string `json:"delivery_com_name"` + Status int `json:"status"` + StatusText string `json:"status_text"` + Msg []struct { + Time string `json:"time"` + Context string `json:"context"` + Ftime string `json:"ftime,omitempty"` + AreaName string `json:"areaName,omitempty"` + Status string `json:"status,omitempty"` + Location string `json:"location,omitempty"` + } `json:"msg"` + ResetRecord []struct { + OldDeliveryNo string `json:"old_delivery_no"` + OldDeliveryComCode string `json:"old_delivery_com_code"` + OldDeliveryComName string `json:"old_delivery_com_name"` + DeliveryNo string `json:"delivery_no"` + DeliveryComCode string `json:"delivery_com_code"` + DeliveryComName string `json:"delivery_com_name"` + CreatedAt int `json:"created_at"` + } `json:"resetRecord"` + } `json:"tranceDetail"` + ReTranceDetail struct { + } `json:"reTranceDetail"` + DeliveryWay int `json:"delivery_way"` + SubDeliveryNoList []struct { + DeliveryComCode string `json:"delivery_com_code"` + DeliveryComName string `json:"delivery_com_name"` + DeliveryNo string `json:"delivery_no"` + } `json:"sub_delivery_no_list"` + SubDeliveryNo string `json:"sub_delivery_no"` +} + +// Trace 物æµè½¨è¿¹ +func (*logisticsDwd) Trace(ctx context.Context, req LogisticsTraceReq) (res *LogisticsTraceRes, err error) { + method := "order.expressTrace" + result, err := post(ctx, method, gconv.Map(req)) + if err != nil { + return + } + _ = gjson.New(result.Data).Scan(&res) + return +} -- 2.18.1