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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
package yunzmall
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
type refundLogic struct {
}
type RefundBeforeRes struct {
CommonRes
Data map[string]string `json:"data"`
}
func (s *Client) RefundBefore(ctx context.Context, req string) (res *RefundBeforeRes, err error) {
var method = "/app/afterSales/getAfterSalesTypeNameMap"
result, err := s.get(ctx, method, g.Map{
"order_item_id": req,
})
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
type RefundDetailRes struct {
CommonRes
Data struct {
AfterSales struct {
Id int `json:"id"`
CreatedAt int `json:"created_at"`
UpdatedAt int `json:"updated_at"`
AfterSaleSn string `json:"after_sale_sn"`
UserId int `json:"user_id"`
Amount int `json:"amount"`
PracticalAmount int `json:"practical_amount"`
ReasonType int `json:"reason_type"`
Reason string `json:"reason"`
Description string `json:"description"`
OrderId int `json:"order_id"`
OrderItemId int `json:"order_item_id"`
SkuId int `json:"sku_id"`
ProductId int `json:"product_id"`
ShippingAddressId int `json:"shipping_address_id"`
IsReceived int `json:"is_received"`
PayMethod int `json:"pay_method"`
ReturnOrderExpressId int `json:"return_order_express_id"`
Status int `json:"status"`
Type int `json:"type"`
DetailImages interface{} `json:"detail_images"`
Logs []struct {
CreatedAt string `json:"created_at"`
AdminId int `json:"admin_id"`
Content string `json:"content"`
Price int `json:"price"`
RefundTypeName string `json:"refund_type_name"`
ReasonTypeName string `json:"reason_type_name"`
Description string `json:"description"`
} `json:"logs"`
User struct {
Id int `json:"id"`
Avatar string `json:"avatar"`
Username string `json:"username"`
Nickname string `json:"nickname"`
} `json:"user"`
RefundReasonName string `json:"refund_reason_name"`
SuccessAt interface{} `json:"success_at"`
StatusName string `json:"status_name"`
Order struct {
Id int `json:"id"`
OrderSn int64 `json:"order_sn"`
ApplicationId int `json:"application_id"`
} `json:"order"`
OrderItem struct {
Id int `json:"id"`
SkuTitle string `json:"sku_title"`
Title string `json:"title"`
ProductId int `json:"product_id"`
OrderId int `json:"order_id"`
ImageUrl string `json:"image_url"`
SendStatus int `json:"send_status"`
Amount int `json:"amount"`
} `json:"order_item"`
AfterSalesAudit struct {
Id int `json:"id"`
CreatedAt int `json:"created_at"`
UpdatedAt int `json:"updated_at"`
AfterSalesId int `json:"after_sales_id"`
AdminId int `json:"admin_id"`
ReasonType int `json:"reason_type"`
Reason string `json:"reason"`
Status int `json:"status"`
Cause string `json:"cause"`
StatusName string `json:"status_name"`
RefundName string `json:"refund_name"`
} `json:"after_sales_audit"`
ReturnOrderExpress struct {
Id int `json:"id"`
CreatedAt interface{} `json:"created_at"`
UpdatedAt interface{} `json:"updated_at"`
AfterSalesId int `json:"after_sales_id"`
CompanyName string `json:"company_name"`
CompanyCode string `json:"company_code"`
ExpressNo string `json:"express_no"`
} `json:"return_order_express"`
} `json:"after_sales"`
} `json:"data"`
}
// RefundDetail 详情
func (s *Client) RefundDetail(ctx context.Context, req interface{}) (res *RefundDetailRes, err error) {
var method = "/app/afterSales/get"
result, err := s.get(ctx, method, g.Map{
"id": gconv.Int(req),
})
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
type RefundAddressRes struct {
CommonRes
Data struct {
Id int `json:"id"`
Contacts string `json:"contacts"`
Tel string `json:"tel"`
Plane string `json:"plane"`
Country string `json:"country"`
Province int `json:"province"`
City int `json:"city"`
District int `json:"district"`
Address string `json:"address"`
AddressType []string `json:"address_type"`
IsDefault int `json:"is_default"`
SupplierId int `json:"supplier_id"`
ProvinceName struct {
Id int `json:"id"`
ParentId int `json:"parent_id"`
Name string `json:"name"`
Level int `json:"level"`
} `json:"province_name"`
CityName struct {
Id int `json:"id"`
ParentId int `json:"parent_id"`
Name string `json:"name"`
Level int `json:"level"`
} `json:"city_name"`
DistrictName struct {
Id int `json:"id"`
ParentId int `json:"parent_id"`
Name string `json:"name"`
Level int `json:"level"`
} `json:"district_name"`
Supplier struct {
Id int `json:"id"`
Name string `json:"name"`
Supplier string `json:"supplier"`
} `json:"supplier"`
} `json:"data"`
}
// RefundAddress 退货地址
func (s *Client) RefundAddress(ctx context.Context, req interface{}) (res *RefundAddressRes, err error) {
var method = "/app/supplier/findShopAddressByOrderId"
result, err := s.get(ctx, method, g.Map{
"after_sales_id": gconv.Int(req),
})
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
type RefundReasonRes struct {
Code int `json:"code"`
Data struct {
Reasons map[string]string `json:"reasons"`
} `json:"data"`
Msg string `json:"msg"`
}
// RefundReason 售后原因
func (s *Client) RefundReason(ctx context.Context, afterSaleType, isReceived int) (res *RefundReasonRes, err error) {
var method = "/app/afterSales/reason/list"
result, err := s.get(ctx, method, g.Map{
"after_sale_type": afterSaleType,
"is_received": isReceived,
})
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
type RefundCreateReq struct {
OrderId int `json:"order_id,omitempty"` //订单id
ThirdOrderSn string `json:"third_order_sn,omitempty"` //采购端订单号
OrderItemId int `json:"order_item_id"` //子订单id
ReasonType int `json:"reason_type"` //售后原因
Description string `json:"description"` //描述
Reason string `json:"reason"` //售后原因是 其他的的时候填写
RefundType int `json:"refund_type"` //退款还是退货退款
IsReceived int `json:"is_received"` //是否收到货 1是0否
DetailImages []string `json:"detail_images,omitempty"` //图片凭证
RefundWay int `json:"refund_way,omitempty"` //退款方式
Num int `json:"num"` //退款商品个数
BarterSkuId int `json:"barter_sku_id,omitempty"` //换货中台规格id
BarterNum int `json:"barter_num,omitempty"` //换货数量
}
type RefundCreateRes struct {
CommonRes
Data int `json:"data"`
}
// RefundCreate 申请售后
func (s *Client) RefundCreate(ctx context.Context, req RefundCreateReq) (res *RefundCreateRes, err error) {
var method = "/app/afterSales/create"
result, err := s.post(ctx, method, gconv.Map(req))
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
type RefundSendReq struct {
AfterSalesID int `json:"after_sales_id"` //售后id
CompanyName string `json:"company_name"` //物流公司名称
CompanyCode string `json:"company_code"` //物流公司code
ExpressNo string `json:"express_no"` //物流单号
ShippingAddressID int `json:"shipping_address_id"` //售后商家收货地址 通过售后id获取默认商家售后退货地址 获得
}
// RefundSend 售后发货
func (s *Client) RefundSend(ctx context.Context, req RefundSendReq) (res *CommonRes, err error) {
var method = "app/afterSales/send"
result, err := s.post(ctx, method, gconv.Map(req))
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}