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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package alibaba
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type logisticsAli struct {
}
var Logistics = logisticsAli{}
type LogisticsInfosRes struct {
CommonRes
Result []struct {
Sender struct {
SenderName string `json:"senderName"`
SenderMobile string `json:"senderMobile"`
Encrypt string `json:"encrypt"`
SenderProvinceCode string `json:"senderProvinceCode"`
SenderCityCOde string `json:"senderCityC ode"`
SenderCountyCode string `json:"senderCountyCode"`
SenderAddress string `json:"senderAddress"`
SenderProvince string `json:"senderProvince"`
SenderCity string `json:"senderCity"`
SenderCounty string `json:"senderCounty"`
} `json:"sender"`
OrderEntryIds string `json:"orderEntryIds"`
LogisticsBillNo string `json:"logisticsBillNo"`
LogisticsId string `json:"logisticsId "`
Receiver struct {
ReceiverName string `json:"receiverName"`
ReceiverPhone string `json:"receiverPhone"`
ReceiverMobile string `json:"receiverMobile"`
Encrypt string `json:"encrypt"`
ReceiverProvinceCode string `json:"receiverProvinceCode"`
ReceiverCityCode string `json:"receiverCityCode"`
ReceiverCountyCode string `json:"receiverCountyCode"`
ReceiverAddresS string `json:"receiverAddres s"`
ReceiverProvince string `json:"receiverProvince"`
ReceiverCity string `json:"receiverCity"`
ReceiverCounty string `json:"receiverCounty"`
} `json:"receiver"`
LogisticsCompanyName string `json:"logisticsCompanyName"`
Status string `json:"status"`
SendGoods []struct {
GoodName string `json:"goodName"`
Quantity string `json:"quantity"`
Unit string `json:"unit"`
} `json:"sendGoods"`
Remarks string `json:"remarks"`
LogisticsCompanyId string `json:"logisticsCompanyId"`
} `json:"result"`
}
type LogisticsTraceRes struct {
CommonRes
LogisticsTrace []struct {
LogisticsId string `json:"logisticsId"`
OrderId int64 `json:"orderId"`
LogisticsBillNo string `json:"logisticsBillNo"`
LogisticsSteps []struct {
AcceptTime string `json:"acceptTime"`
Remark string `json:"remark"`
} `json:"logisticsSteps"`
} `json:"logisticsTrace"`
}
//Info 物流详情
func (*logisticsAli) Info(ctx context.Context, orderSn string) (res *LogisticsInfosRes, err error) {
method := "com.alibaba.logistics/alibaba.trade.getLogisticsInfos.buyerView"
result, err := server.Post(ctx, method, g.Map{
"access_token": server.AccessToken,
"webSite": WebSite,
"orderId": orderSn,
})
_ = gjson.New(result).Scan(&res)
return
}
//Trace 物流轨迹
func (*logisticsAli) Trace(ctx context.Context, orderSn string) (res *LogisticsTraceRes, err error) {
method := "com.alibaba.logistics/alibaba.trade.getLogisticsTraceInfo.buyerView"
result, err := server.Post(ctx, method, g.Map{
"access_token": server.AccessToken,
"webSite": WebSite,
"orderId": orderSn,
})
_ = gjson.New(result).Scan(&res)
return
}
type LogisticsCompanyRes struct {
CommonRes
Result []LogisticsCompanyItem `json:"result"` //result
}
type LogisticsCompanyItem struct {
Id int64 `json:"id"`
CompanyName string `json:"companyName"` //物流公司名称
CompanyNo string `json:"companyNo"` // 物流公司编号
}
//Company 物流公司
func (s *logisticsAli) Company(ctx context.Context) (res *LogisticsCompanyRes, err error) {
method := "com.alibaba.logistics/alibaba.logistics.OpQueryLogisticCompanyList"
result, err := server.Post(ctx, method, g.Map{
"access_token": server.AccessToken,
})
_ = gjson.New(result).Scan(&res)
return
}