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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package ikc
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type orderIkc struct {
}
//Order 订单
var Order = orderIkc{}
type OrderCreateReq struct {
OrderSn string `json:"externalOrderNo"`
Address OrderCreateAddr `json:"address"`
OuterUserId string `json:"outerUserId,omitempty"`
CouponIds []string `json:"couponIds,omitempty"`
List []OrderCreateItem `json:"productList"`
}
type OrderCreateAddr struct {
Name string `json:"name"` //收货人名称
Mobile string `json:"mobile"`
Province string `json:"province"`
City string `json:"city"`
Area string `json:"area"`
Street string `json:"street"`
}
type OrderCreateItem struct {
LiveId string `json:"liveId"` //活动 ID
ProductId string `json:"productId"` //商品 ID
SkuId string `json:"skuId"` //SKU ID
Amount string `json:"amount"` //数量
Price string `json:"settlementPrice"` //商品结算金额 单位分
}
type OrderCreateRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data struct {
PaymentOrder struct {
PaymentNo string `json:"paymentNo"`
TotalAmount int `json:"totalAmount"`
ShipmentAmount int `json:"shipmentAmount"`
DiscountAmount int `json:"discountAmount"`
ProductsAmount int `json:"productsAmount"`
OrderList []struct {
OrderId string `json:"orderId"`
TotalAmount int `json:"totalAmount"`
ShipmentAmount int `json:"shipmentAmount"`
DiscountAmount int `json:"discountAmount"`
OrderStatus interface{} `json:"orderStatus"`
ProductsAmount int `json:"productsAmount"`
PaymentStatus interface{} `json:"paymentStatus"`
OrderDetailList []struct {
OrderDetailId string `json:"orderDetailId"`
SkuId string `json:"skuId"`
ProductId string `json:"productId"`
Price int `json:"price"`
Amount int `json:"amount"`
OrderDetailStatus interface{} `json:"orderDetailStatus"`
AfterSaleStatus interface{} `json:"afterSaleStatus"`
ProductStatus interface{} `json:"productStatus"`
} `json:"orderDetailList"`
} `json:"orderList"`
} `json:"paymentOrder"`
} `json:"data"`
}
//Create 下单
func (*orderIkc) Create(ctx context.Context, req OrderCreateReq) (res *OrderCreateRes, err error) {
method := "order/create"
result, err := post(ctx, method, req)
_ = gjson.New(result).Scan(&res)
return
}
//Cancel 支付前整单取消
//`orderId` 订单号
func (*orderIkc) Cancel(ctx context.Context, orderId string) (res *CommonRes, err error) {
method := "order/before/cancel"
result, err := post(ctx, method, g.Map{
"orderId": orderId,
})
_ = gjson.New(result).Scan(&res)
return
}
//Pay 支付
//`orderId` 订单号
func (*orderIkc) Pay(ctx context.Context, orderId string) (res *CommonRes, err error) {
method := "order/before/cancel"
result, err := post(ctx, method, g.Map{
"orderPaymentNo": orderId,
})
_ = gjson.New(result).Scan(&res)
return
}
//PayCancel 支付后整单取消
//`orderId` 订单号
func (*orderIkc) PayCancel(ctx context.Context, orderId string) (res *CommonRes, err error) {
method := "order/after/cancelByOrder"
result, err := post(ctx, method, g.Map{
"orderId": orderId,
})
_ = gjson.New(result).Scan(&res)
return
}
//GoodsCancel 支付后商品取消
//`orderId` 订单号
//`DetailId` 三级单号
func (*orderIkc) GoodsCancel(ctx context.Context, orderId, DetailId string) (res *CommonRes, err error) {
method := "order/after/cancel"
result, err := post(ctx, method, g.Map{
"orderId": orderId,
"orderDetailId": DetailId,
})
_ = gjson.New(result).Scan(&res)
return
}
type OrderDetailRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data struct {
Order struct {
OrderId string `json:"orderId"`
LiveId string `json:"liveId"`
TotalAmount int `json:"totalAmount"`
ShipmentAmount int `json:"shipmentAmount"`
DiscountAmount int `json:"discountAmount"`
OrderStatus int `json:"orderStatus"`
ProductsAmount int `json:"productsAmount"`
PaymentStatus int `json:"paymentStatus"`
RefundInsurance bool `json:"refundInsurance"`
OrderDetailList []struct {
OrderDetailId string `json:"orderDetailId"`
LiveId string `json:"liveId"`
SkuId string `json:"skuId"`
ProductId string `json:"productId"`
Price int `json:"price"`
Amount int `json:"amount"`
OrderDetailStatus int `json:"orderDetailStatus"`
AfterSaleStatus int `json:"afterSaleStatus"`
ProductStatus int `json:"productStatus"`
AftersaleDeadline string `json:"aftersaleDeadline"`
} `json:"orderDetailList"`
} `json:"order"`
} `json:"data"`
}
//Detail 详情
//`orderId` 订单号
func (*orderIkc) Detail(ctx context.Context, orderId string) (res *OrderDetailRes, err error) {
method := "order/queryByOrderId"
result, err := post(ctx, method, g.Map{
"orderId": orderId,
})
_ = gjson.New(result).Scan(&res)
return
}
type OrderReflectDetailRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data struct {
PaymentOrder struct {
PaymentNo string `json:"paymentNo"`
TotalAmount int `json:"totalAmount"`
ShipmentAmount int `json:"shipmentAmount"`
DiscountAmount int `json:"discountAmount"`
ProductsAmount int `json:"productsAmount"`
RefundInsurance bool `json:"refundInsurance"`
OrderList []struct {
OrderId string `json:"orderId"`
LiveId string `json:"liveId"`
TotalAmount int `json:"totalAmount"`
ShipmentAmount int `json:"shipmentAmount"`
DiscountAmount int `json:"discountAmount"`
OrderStatus int `json:"orderStatus"`
ProductsAmount int `json:"productsAmount"`
PaymentStatus int `json:"paymentStatus"`
OrderDetailList []struct {
OrderDetailId string `json:"orderDetailId"`
LiveId string `json:"liveId"`
SkuId string `json:"skuId"`
ProductId string `json:"productId"`
Price int `json:"price"`
Amount int `json:"amount"`
DiscountAmount float64 `json:"discountAmount"`
SettlementAmount float64 `json:"settlementAmount"`
OrderDetailStatus int `json:"orderDetailStatus"`
AfterSaleStatus int `json:"afterSaleStatus"`
ProductStatus int `json:"productStatus"`
AftersaleDeadline string `json:"aftersaleDeadline"`
} `json:"orderDetailList"`
} `json:"orderList"`
} `json:"paymentOrder"`
} `json:"data"`
}
//ReflectDetail 详情[按外部订单号查询]
func (*orderIkc) ReflectDetail(ctx context.Context, OrderSn string) (res *OrderReflectDetailRes, err error) {
method := "order/queryByExternalOrderNo"
result, err := post(ctx, method, g.Map{
"externalOrderNo": OrderSn,
})
_ = gjson.New(result).Scan(&res)
return
}