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
package suning
import (
"context"
"encoding/json"
)
type OrderCreateReq struct {
SnRequest struct {
SnBody struct {
AddOrder struct {
Amount string `json:"amount"`
Address string `json:"address"`
TradeNo string `json:"tradeNo"`
ReceiverName string `json:"receiverName"`
Mobile string `json:"mobile"`
InvoiceState string `json:"invoiceState"`
Remark string `json:"remark"`
Telephone string `json:"telephone"`
CityId string `json:"cityId"`
TownId string `json:"townId"`
ChannelCode string `json:"channelcode"`
ProvinceId string `json:"provinceId"`
ServFee string `json:"servFee"`
CountyId string `json:"countyId"`
InvoiceType string `json:"invoiceType"`
HopeArrivalTime string `json:"hopeArrivalTime"`
Payment string `json:"payment"`
Sku []*OrderCreateSku `json:"sku"`
SpecialVatTicket OrderCreateSpecialVatTicket `json:"specialVatTicket"`
InvoiceTitle string `json:"invoiceTitle"`
} `json:"addOrder"`
} `json:"sn_body"`
} `json:"sn_request"`
}
type OrderCreateSku struct {
UnitPrice string `json:"unitPrice"`
Num string `json:"num"`
SupplierCode string `json:"supplierCode"`
SkuId string `json:"skuId"`
}
type OrderCreateSpecialVatTicket struct {
ConsigneeName string `json:"consigneeName"`
RegAccount string `json:"regAccount"`
RegTel string `json:"regTel"`
ConsigneeMobileNum string `json:"consigneeMobileNum"`
RegAdd string `json:"regAdd"`
RegBank string `json:"regBank"`
TaxNo string `json:"taxNo"`
ConsigneeAddress string `json:"consigneeAddress"`
}
type OrderCreateRes struct {
SnResponseContent struct {
SnBody struct {
AddOrder struct {
Amount string `json:"amount"`
B2CId string `json:"b2cId"`
GcId string `json:"gcId"`
OrderId string `json:"orderId"`
Skus []struct {
Num string `json:"num"`
OrderItemId string `json:"orderItemId"`
Price string `json:"price"`
SkuId string `json:"skuId"`
} `json:"skus"`
Success bool `json:"success"`
TradeNo string `json:"tradeNo"`
} `json:"addOrder"`
} `json:"sn_body"`
} `json:"sn_responseContent"`
}
// 创建订单
func OrderCreate(ctx context.Context, req *OrderCreateReq) (res OrderCreateRes, err error) {
req.SnRequest.SnBody.AddOrder.ChannelCode = server.ChannelCode
result, err := post(ctx, "suning.sngoods.order.add", req)
if nil != err {
return
}
err = json.Unmarshal([]byte(result), &res)
return
}
type OrderConfirmReq struct {
SnRequest struct {
SnBody struct {
ConfirmConfirmpaydt struct {
OrderId string `json:"orderId"`
} `json:"confirmConfirmpaydt"`
} `json:"sn_body"`
} `json:"sn_request"`
}
type OrderConfirmRes struct {
SnResponseContent struct {
SnBody struct {
ConfirmConfirmpaydt struct {
OrderId string `json:"orderId"`
} `json:"confirmConfirmpaydt"`
} `json:"sn_body"`
} `json:"sn_responseContent"`
}
// 代扣订单确认支付
func OrderConfirm(ctx context.Context, orderId string) (res OrderConfirmRes, err error) {
params := OrderConfirmReq{}
params.SnRequest.SnBody.ConfirmConfirmpaydt.OrderId = orderId
result, err := post(ctx, "suning.sngoods.confirmpaydt.confirm", params)
if nil != err {
return
}
err = json.Unmarshal([]byte(result), &res)
return
}
type OrderStatusReq struct {
SnRequest struct {
SnBody struct {
GetOrderstatus struct {
OrderId string `json:"orderId"`
} `json:"getOrderstatus"`
} `json:"sn_body"`
} `json:"sn_request"`
}
type OrderStatusRes struct {
SnResponseContent struct {
SnBody struct {
GetOrderstatus struct {
OrderId string `json:"orderId"`
OrderStatus string `json:"orderStatus"`
OrderItemInfoList []struct {
OrderItemId string `json:"orderItemId"`
StatusName string `json:"statusName"`
SkuId string `json:"skuId"`
} `json:"orderItemInfoList"`
} `json:"getOrderstatus"`
} `json:"sn_body"`
} `json:"sn_responseContent"`
}
// 获取订单状态
func GetOrderStatus(ctx context.Context, orderId string) (res OrderStatusRes, err error) {
params := OrderStatusReq{}
params.SnRequest.SnBody.GetOrderstatus.OrderId = orderId
result, err := post(ctx, "suning.sngoods.orderstatus.get", params)
if nil != err {
return
}
err = json.Unmarshal([]byte(result), &res)
return
}