1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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 {
Errno int `json:"errno"`
Errmsg string `json:"errmsg"`
Data *LogisticsTraceData `json:"data"`
RequestId string `json:"request_id"`
Timestamp int `json:"timestamp"`
Signature string `json:"signature"`
}
type LogisticsTraceData 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
}
res = &LogisticsTraceRes{
Errno: result.Errno,
Errmsg: result.Errmsg,
RequestId: result.RequestId,
Timestamp: result.Timestamp,
Signature: result.Signature,
}
_ = gjson.New(result.Data).Scan(&res.Data)
return
}