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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package gome
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type orderGome struct {
}
var Order = orderGome{}
type CreateOrderReq struct {
OuterOrderId string `json:"outerOrderId"`
OnlinePayAmount int `json:"onlinePayAmount"`
ConsigneeInfo struct {
ReceiverName string `json:"receiverName"`
ReceiverMobile int64 `json:"receiverMobile"`
County int `json:"county"`
Town int `json:"town"`
StateName string `json:"stateName"`
CityName string `json:"cityName"`
CountyName string `json:"countyName"`
TownName string `json:"townName"`
DetailAddress string `json:"detailAddress"`
} `json:"consigneeInfo"`
SkuItems []struct {
OuterSkuItemId string `json:"outerSkuItemId"`
MchSkuId int `json:"mchSkuId"`
Quantity int `json:"quantity"`
DealPrice int `json:"dealPrice"`
MchWhseCode string `json:"mchWhseCode"`
} `json:"skuItems"`
}
type CreateOrderRes struct {
*CommonRes
Data bool `json:"data"`
}
type OrderInfoRes struct {
*CommonRes
Data struct {
OuterOrderId string `json:"outerOrderId"`
Finished string `json:"finished"`
DeliveryOrderList []struct {
DeliveryId string `json:"deliveryId"`
DeliveryStatus string `json:"deliveryStatus"`
SkuItemList []struct {
SkuItemId string `json:"skuItemId"`
OuterSkuItemId string `json:"outerSkuItemId"`
MchSkuId string `json:"mchSkuId"`
Quantity int `json:"quantity"`
} `json:"skuItemList"`
} `json:"deliveryOrderList"`
} `json:"data"`
}
type OrderStatusRes struct {
*CommonRes
Data struct {
DeliveryId string `json:"deliveryId"`
CurrentStatus string `json:"currentStatus"`
CurrentStatusTime string `json:"currentStatusTime"`
PastStatuses []struct {
Status string `json:"status"`
StatusTime string `json:"statusTime"`
} `json:"pastStatuses"`
} `json:"data"`
}
type OrderLogisticsRes struct {
*CommonRes
Data struct {
DeliveryId string `json:"deliveryId"`
CompanyCode string `json:"companyCode"`
CompanyName string `json:"companyName"`
CompanyPhone string `json:"companyPhone"`
WaybillCode string `json:"waybillCode"`
CourierName string `json:"courierName"`
CourierPhone string `json:"courierPhone"`
Tracks []struct {
TrackTime string `json:"trackTime"`
Description string `json:"description"`
} `json:"tracks"`
} `json:"data"`
}
type OrderCancelReq struct {
DeliveryId string `json:"deliveryId"`
OuterOrderId string `json:"outerOrderId"`
CancelTime string `json:"cancelTime"`
}
//Create 提交订单
func (orderGome) Create(ctx context.Context, req *CreateOrderReq) (res *CreateOrderRes, err error) {
method := "alamein.order.write.submitAndConfirm"
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}
//Info 订单详情
func (orderGome) Info(ctx context.Context, sn string) (res *OrderInfoRes, err error) {
method := "alamein.order.read.querySubmitAndConfirmResult"
var req = g.Map{
"outerOrderId": sn,
}
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}
//Status 订单关键状态查询
func (orderGome) Status(ctx context.Context, deliveryId string) (res *OrderStatusRes, err error) {
method := "alamein.order.read.queryKeyStatus"
var req = g.Map{
"deliveryId": deliveryId,
}
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}
//Logistics 物流
func (orderGome) Logistics(ctx context.Context, deliveryId string) (res *OrderLogisticsRes, err error) {
method := "alamein.order.read.queryLogisticsTrack"
var req = g.Map{
"deliveryId": deliveryId,
}
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}
//Cancel 支付后取消申请
func (orderGome) Cancel(ctx context.Context, req *OrderCancelReq) (res *CommonRes, err error) {
method := "alamein.order.read.queryLogisticsTrack"
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}