models.go 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. //
  3. // 境内普通商户退款API
  4. //
  5. // 境内普通商户退款功能涉及的API文档
  6. //
  7. // API version: 1.1.1
  8. // Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
  9. package refunddomestic
  10. import (
  11. "encoding/json"
  12. "fmt"
  13. "time"
  14. )
  15. // Account * `AVAILABLE` - 可用余额, 多账户资金准备退款可用余额出资账户类型 * `UNAVAILABLE` - 不可用余额, 多账户资金准备退款不可用余额出资账户类型
  16. type Account string
  17. func (e Account) Ptr() *Account {
  18. return &e
  19. }
  20. // Enums of Account
  21. const (
  22. ACCOUNT_AVAILABLE Account = "AVAILABLE"
  23. ACCOUNT_UNAVAILABLE Account = "UNAVAILABLE"
  24. )
  25. // Amount
  26. type Amount struct {
  27. // 订单总金额,单位为分
  28. Total *int64 `json:"total"`
  29. // 退款标价金额,单位为分,可以做部分退款
  30. Refund *int64 `json:"refund"`
  31. // 退款出资的账户类型及金额信息
  32. From []FundsFromItem `json:"from,omitempty"`
  33. // 现金支付金额,单位为分,只能为整数
  34. PayerTotal *int64 `json:"payer_total"`
  35. // 退款给用户的金额,不包含所有优惠券金额
  36. PayerRefund *int64 `json:"payer_refund"`
  37. // 去掉非充值代金券退款金额后的退款金额,单位为分,退款金额=申请退款金额-非充值代金券退款金额,退款金额<=申请退款金额
  38. SettlementRefund *int64 `json:"settlement_refund"`
  39. // 应结订单金额=订单金额-免充值代金券金额,应结订单金额<=订单金额,单位为分
  40. SettlementTotal *int64 `json:"settlement_total"`
  41. // 优惠退款金额<=退款金额,退款金额-代金券或立减优惠退款金额为现金,说明详见代金券或立减优惠,单位为分
  42. DiscountRefund *int64 `json:"discount_refund"`
  43. // 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY。
  44. Currency *string `json:"currency"`
  45. }
  46. func (o Amount) MarshalJSON() ([]byte, error) {
  47. toSerialize := map[string]interface{}{}
  48. if o.Total == nil {
  49. return nil, fmt.Errorf("field `Total` is required and must be specified in Amount")
  50. }
  51. toSerialize["total"] = o.Total
  52. if o.Refund == nil {
  53. return nil, fmt.Errorf("field `Refund` is required and must be specified in Amount")
  54. }
  55. toSerialize["refund"] = o.Refund
  56. if o.From != nil {
  57. toSerialize["from"] = o.From
  58. }
  59. if o.PayerTotal == nil {
  60. return nil, fmt.Errorf("field `PayerTotal` is required and must be specified in Amount")
  61. }
  62. toSerialize["payer_total"] = o.PayerTotal
  63. if o.PayerRefund == nil {
  64. return nil, fmt.Errorf("field `PayerRefund` is required and must be specified in Amount")
  65. }
  66. toSerialize["payer_refund"] = o.PayerRefund
  67. if o.SettlementRefund == nil {
  68. return nil, fmt.Errorf("field `SettlementRefund` is required and must be specified in Amount")
  69. }
  70. toSerialize["settlement_refund"] = o.SettlementRefund
  71. if o.SettlementTotal == nil {
  72. return nil, fmt.Errorf("field `SettlementTotal` is required and must be specified in Amount")
  73. }
  74. toSerialize["settlement_total"] = o.SettlementTotal
  75. if o.DiscountRefund == nil {
  76. return nil, fmt.Errorf("field `DiscountRefund` is required and must be specified in Amount")
  77. }
  78. toSerialize["discount_refund"] = o.DiscountRefund
  79. if o.Currency == nil {
  80. return nil, fmt.Errorf("field `Currency` is required and must be specified in Amount")
  81. }
  82. toSerialize["currency"] = o.Currency
  83. return json.Marshal(toSerialize)
  84. }
  85. func (o Amount) String() string {
  86. var ret string
  87. if o.Total == nil {
  88. ret += "Total:<nil>, "
  89. } else {
  90. ret += fmt.Sprintf("Total:%v, ", *o.Total)
  91. }
  92. if o.Refund == nil {
  93. ret += "Refund:<nil>, "
  94. } else {
  95. ret += fmt.Sprintf("Refund:%v, ", *o.Refund)
  96. }
  97. ret += fmt.Sprintf("From:%v, ", o.From)
  98. if o.PayerTotal == nil {
  99. ret += "PayerTotal:<nil>, "
  100. } else {
  101. ret += fmt.Sprintf("PayerTotal:%v, ", *o.PayerTotal)
  102. }
  103. if o.PayerRefund == nil {
  104. ret += "PayerRefund:<nil>, "
  105. } else {
  106. ret += fmt.Sprintf("PayerRefund:%v, ", *o.PayerRefund)
  107. }
  108. if o.SettlementRefund == nil {
  109. ret += "SettlementRefund:<nil>, "
  110. } else {
  111. ret += fmt.Sprintf("SettlementRefund:%v, ", *o.SettlementRefund)
  112. }
  113. if o.SettlementTotal == nil {
  114. ret += "SettlementTotal:<nil>, "
  115. } else {
  116. ret += fmt.Sprintf("SettlementTotal:%v, ", *o.SettlementTotal)
  117. }
  118. if o.DiscountRefund == nil {
  119. ret += "DiscountRefund:<nil>, "
  120. } else {
  121. ret += fmt.Sprintf("DiscountRefund:%v, ", *o.DiscountRefund)
  122. }
  123. if o.Currency == nil {
  124. ret += "Currency:<nil>"
  125. } else {
  126. ret += fmt.Sprintf("Currency:%v", *o.Currency)
  127. }
  128. return fmt.Sprintf("Amount{%s}", ret)
  129. }
  130. func (o Amount) Clone() *Amount {
  131. ret := Amount{}
  132. if o.Total != nil {
  133. ret.Total = new(int64)
  134. *ret.Total = *o.Total
  135. }
  136. if o.Refund != nil {
  137. ret.Refund = new(int64)
  138. *ret.Refund = *o.Refund
  139. }
  140. if o.From != nil {
  141. ret.From = make([]FundsFromItem, len(o.From))
  142. for i, item := range o.From {
  143. ret.From[i] = *item.Clone()
  144. }
  145. }
  146. if o.PayerTotal != nil {
  147. ret.PayerTotal = new(int64)
  148. *ret.PayerTotal = *o.PayerTotal
  149. }
  150. if o.PayerRefund != nil {
  151. ret.PayerRefund = new(int64)
  152. *ret.PayerRefund = *o.PayerRefund
  153. }
  154. if o.SettlementRefund != nil {
  155. ret.SettlementRefund = new(int64)
  156. *ret.SettlementRefund = *o.SettlementRefund
  157. }
  158. if o.SettlementTotal != nil {
  159. ret.SettlementTotal = new(int64)
  160. *ret.SettlementTotal = *o.SettlementTotal
  161. }
  162. if o.DiscountRefund != nil {
  163. ret.DiscountRefund = new(int64)
  164. *ret.DiscountRefund = *o.DiscountRefund
  165. }
  166. if o.Currency != nil {
  167. ret.Currency = new(string)
  168. *ret.Currency = *o.Currency
  169. }
  170. return &ret
  171. }
  172. // AmountReq
  173. type AmountReq struct {
  174. // 退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额。
  175. Refund *int64 `json:"refund"`
  176. // 退款需要从指定账户出资时,传递此参数指定出资金额(币种的最小单位,只能为整数)。 同时指定多个账户出资退款的使用场景需要满足以下条件:1、未开通退款支出分离产品功能;2、订单属于分账订单,且分账处于待分账或分账中状态。 参数传递需要满足条件:1、基本账户可用余额出资金额与基本账户不可用余额出资金额之和等于退款金额;2、账户类型不能重复。 上述任一条件不满足将返回错误
  177. From []FundsFromItem `json:"from,omitempty"`
  178. // 原支付交易的订单总金额,币种的最小单位,只能为整数。
  179. Total *int64 `json:"total"`
  180. // 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY。
  181. Currency *string `json:"currency"`
  182. }
  183. func (o AmountReq) MarshalJSON() ([]byte, error) {
  184. toSerialize := map[string]interface{}{}
  185. if o.Refund == nil {
  186. return nil, fmt.Errorf("field `Refund` is required and must be specified in AmountReq")
  187. }
  188. toSerialize["refund"] = o.Refund
  189. if o.From != nil {
  190. toSerialize["from"] = o.From
  191. }
  192. if o.Total == nil {
  193. return nil, fmt.Errorf("field `Total` is required and must be specified in AmountReq")
  194. }
  195. toSerialize["total"] = o.Total
  196. if o.Currency == nil {
  197. return nil, fmt.Errorf("field `Currency` is required and must be specified in AmountReq")
  198. }
  199. toSerialize["currency"] = o.Currency
  200. return json.Marshal(toSerialize)
  201. }
  202. func (o AmountReq) String() string {
  203. var ret string
  204. if o.Refund == nil {
  205. ret += "Refund:<nil>, "
  206. } else {
  207. ret += fmt.Sprintf("Refund:%v, ", *o.Refund)
  208. }
  209. ret += fmt.Sprintf("From:%v, ", o.From)
  210. if o.Total == nil {
  211. ret += "Total:<nil>, "
  212. } else {
  213. ret += fmt.Sprintf("Total:%v, ", *o.Total)
  214. }
  215. if o.Currency == nil {
  216. ret += "Currency:<nil>"
  217. } else {
  218. ret += fmt.Sprintf("Currency:%v", *o.Currency)
  219. }
  220. return fmt.Sprintf("AmountReq{%s}", ret)
  221. }
  222. func (o AmountReq) Clone() *AmountReq {
  223. ret := AmountReq{}
  224. if o.Refund != nil {
  225. ret.Refund = new(int64)
  226. *ret.Refund = *o.Refund
  227. }
  228. if o.From != nil {
  229. ret.From = make([]FundsFromItem, len(o.From))
  230. for i, item := range o.From {
  231. ret.From[i] = *item.Clone()
  232. }
  233. }
  234. if o.Total != nil {
  235. ret.Total = new(int64)
  236. *ret.Total = *o.Total
  237. }
  238. if o.Currency != nil {
  239. ret.Currency = new(string)
  240. *ret.Currency = *o.Currency
  241. }
  242. return &ret
  243. }
  244. // Channel * `ORIGINAL` - 原路退款, 退款渠道 * `BALANCE` - 退回到余额, 退款渠道 * `OTHER_BALANCE` - 原账户异常退到其他余额账户, 退款渠道 * `OTHER_BANKCARD` - 原银行卡异常退到其他银行卡, 退款渠道
  245. type Channel string
  246. func (e Channel) Ptr() *Channel {
  247. return &e
  248. }
  249. // Enums of Channel
  250. const (
  251. CHANNEL_ORIGINAL Channel = "ORIGINAL"
  252. CHANNEL_BALANCE Channel = "BALANCE"
  253. CHANNEL_OTHER_BALANCE Channel = "OTHER_BALANCE"
  254. CHANNEL_OTHER_BANKCARD Channel = "OTHER_BANKCARD"
  255. )
  256. // CreateRequest
  257. type CreateRequest struct {
  258. // 子商户的商户号,由微信支付生成并下发。服务商模式下必须传递此参数
  259. SubMchid *string `json:"sub_mchid,omitempty"`
  260. // 原支付交易对应的微信订单号
  261. TransactionId *string `json:"transaction_id,omitempty"`
  262. // 原支付交易对应的商户订单号
  263. OutTradeNo *string `json:"out_trade_no,omitempty"`
  264. // 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
  265. OutRefundNo *string `json:"out_refund_no"`
  266. // 若商户传入,会在下发给用户的退款消息中体现退款原因
  267. Reason *string `json:"reason,omitempty"`
  268. // 异步接收微信支付退款结果通知的回调地址,通知url必须为外网可访问的url,不能携带参数。 如果参数中传了notify_url,则商户平台上配置的回调地址将不会生效,优先回调当前传的这个地址。
  269. NotifyUrl *string `json:"notify_url,omitempty"`
  270. // 若传递此参数则使用对应的资金账户退款,否则默认使用未结算资金退款(仅对老资金流商户适用) 枚举值: - AVAILABLE:可用余额账户 * `AVAILABLE` - 可用余额
  271. FundsAccount *ReqFundsAccount `json:"funds_account,omitempty"`
  272. // 订单金额信息
  273. Amount *AmountReq `json:"amount"`
  274. // 指定商品退款需要传此参数,其他场景无需传递
  275. GoodsDetail []GoodsDetail `json:"goods_detail,omitempty"`
  276. //商户号
  277. MchId *string `json:"mch_id,omitempty"`
  278. Appid *string `json:"appid,omitempty"`
  279. }
  280. func (o CreateRequest) MarshalJSON() ([]byte, error) {
  281. toSerialize := map[string]interface{}{}
  282. if o.SubMchid != nil {
  283. toSerialize["sub_mchid"] = o.SubMchid
  284. }
  285. if o.TransactionId != nil {
  286. toSerialize["transaction_id"] = o.TransactionId
  287. }
  288. if o.OutTradeNo != nil {
  289. toSerialize["out_trade_no"] = o.OutTradeNo
  290. }
  291. if o.OutRefundNo == nil {
  292. return nil, fmt.Errorf("field `OutRefundNo` is required and must be specified in CreateRequest")
  293. }
  294. toSerialize["out_refund_no"] = o.OutRefundNo
  295. if o.Reason != nil {
  296. toSerialize["reason"] = o.Reason
  297. }
  298. if o.NotifyUrl != nil {
  299. toSerialize["notify_url"] = o.NotifyUrl
  300. }
  301. if o.FundsAccount != nil {
  302. toSerialize["funds_account"] = o.FundsAccount
  303. }
  304. if o.Amount == nil {
  305. return nil, fmt.Errorf("field `Amount` is required and must be specified in CreateRequest")
  306. }
  307. toSerialize["amount"] = o.Amount
  308. if o.GoodsDetail != nil {
  309. toSerialize["goods_detail"] = o.GoodsDetail
  310. }
  311. return json.Marshal(toSerialize)
  312. }
  313. func (o CreateRequest) String() string {
  314. var ret string
  315. if o.SubMchid == nil {
  316. ret += "SubMchid:<nil>, "
  317. } else {
  318. ret += fmt.Sprintf("SubMchid:%v, ", *o.SubMchid)
  319. }
  320. if o.TransactionId == nil {
  321. ret += "TransactionId:<nil>, "
  322. } else {
  323. ret += fmt.Sprintf("TransactionId:%v, ", *o.TransactionId)
  324. }
  325. if o.OutTradeNo == nil {
  326. ret += "OutTradeNo:<nil>, "
  327. } else {
  328. ret += fmt.Sprintf("OutTradeNo:%v, ", *o.OutTradeNo)
  329. }
  330. if o.OutRefundNo == nil {
  331. ret += "OutRefundNo:<nil>, "
  332. } else {
  333. ret += fmt.Sprintf("OutRefundNo:%v, ", *o.OutRefundNo)
  334. }
  335. if o.Reason == nil {
  336. ret += "Reason:<nil>, "
  337. } else {
  338. ret += fmt.Sprintf("Reason:%v, ", *o.Reason)
  339. }
  340. if o.NotifyUrl == nil {
  341. ret += "NotifyUrl:<nil>, "
  342. } else {
  343. ret += fmt.Sprintf("NotifyUrl:%v, ", *o.NotifyUrl)
  344. }
  345. if o.FundsAccount == nil {
  346. ret += "FundsAccount:<nil>, "
  347. } else {
  348. ret += fmt.Sprintf("FundsAccount:%v, ", *o.FundsAccount)
  349. }
  350. ret += fmt.Sprintf("Amount:%v, ", o.Amount)
  351. ret += fmt.Sprintf("GoodsDetail:%v", o.GoodsDetail)
  352. return fmt.Sprintf("CreateRequest{%s}", ret)
  353. }
  354. func (o CreateRequest) Clone() *CreateRequest {
  355. ret := CreateRequest{}
  356. if o.SubMchid != nil {
  357. ret.SubMchid = new(string)
  358. *ret.SubMchid = *o.SubMchid
  359. }
  360. if o.TransactionId != nil {
  361. ret.TransactionId = new(string)
  362. *ret.TransactionId = *o.TransactionId
  363. }
  364. if o.OutTradeNo != nil {
  365. ret.OutTradeNo = new(string)
  366. *ret.OutTradeNo = *o.OutTradeNo
  367. }
  368. if o.OutRefundNo != nil {
  369. ret.OutRefundNo = new(string)
  370. *ret.OutRefundNo = *o.OutRefundNo
  371. }
  372. if o.Reason != nil {
  373. ret.Reason = new(string)
  374. *ret.Reason = *o.Reason
  375. }
  376. if o.NotifyUrl != nil {
  377. ret.NotifyUrl = new(string)
  378. *ret.NotifyUrl = *o.NotifyUrl
  379. }
  380. if o.FundsAccount != nil {
  381. ret.FundsAccount = new(ReqFundsAccount)
  382. *ret.FundsAccount = *o.FundsAccount
  383. }
  384. if o.Amount != nil {
  385. ret.Amount = o.Amount.Clone()
  386. }
  387. if o.GoodsDetail != nil {
  388. ret.GoodsDetail = make([]GoodsDetail, len(o.GoodsDetail))
  389. for i, item := range o.GoodsDetail {
  390. ret.GoodsDetail[i] = *item.Clone()
  391. }
  392. }
  393. return &ret
  394. }
  395. // FundsAccount * `UNSETTLED` - 未结算资金, 退款所使用资金对应的资金账户类型 * `AVAILABLE` - 可用余额, 退款所使用资金对应的资金账户类型 * `UNAVAILABLE` - 不可用余额, 退款所使用资金对应的资金账户类型 * `OPERATION` - 运营户, 退款所使用资金对应的资金账户类型 * `BASIC` - 基本账户(含可用余额和不可用余额), 退款所使用资金对应的资金账户类型
  396. type FundsAccount string
  397. func (e FundsAccount) Ptr() *FundsAccount {
  398. return &e
  399. }
  400. // Enums of FundsAccount
  401. const (
  402. FUNDSACCOUNT_UNSETTLED FundsAccount = "UNSETTLED"
  403. FUNDSACCOUNT_AVAILABLE FundsAccount = "AVAILABLE"
  404. FUNDSACCOUNT_UNAVAILABLE FundsAccount = "UNAVAILABLE"
  405. FUNDSACCOUNT_OPERATION FundsAccount = "OPERATION"
  406. FUNDSACCOUNT_BASIC FundsAccount = "BASIC"
  407. )
  408. // FundsFromItem
  409. type FundsFromItem struct {
  410. // 下面枚举值多选一。 枚举值: AVAILABLE : 可用余额 UNAVAILABLE : 不可用余额 * `AVAILABLE` - 可用余额 * `UNAVAILABLE` - 不可用余额
  411. Account *Account `json:"account"`
  412. // 对应账户出资金额
  413. Amount *int64 `json:"amount"`
  414. }
  415. func (o FundsFromItem) MarshalJSON() ([]byte, error) {
  416. toSerialize := map[string]interface{}{}
  417. if o.Account == nil {
  418. return nil, fmt.Errorf("field `Account` is required and must be specified in FundsFromItem")
  419. }
  420. toSerialize["account"] = o.Account
  421. if o.Amount == nil {
  422. return nil, fmt.Errorf("field `Amount` is required and must be specified in FundsFromItem")
  423. }
  424. toSerialize["amount"] = o.Amount
  425. return json.Marshal(toSerialize)
  426. }
  427. func (o FundsFromItem) String() string {
  428. var ret string
  429. if o.Account == nil {
  430. ret += "Account:<nil>, "
  431. } else {
  432. ret += fmt.Sprintf("Account:%v, ", *o.Account)
  433. }
  434. if o.Amount == nil {
  435. ret += "Amount:<nil>"
  436. } else {
  437. ret += fmt.Sprintf("Amount:%v", *o.Amount)
  438. }
  439. return fmt.Sprintf("FundsFromItem{%s}", ret)
  440. }
  441. func (o FundsFromItem) Clone() *FundsFromItem {
  442. ret := FundsFromItem{}
  443. if o.Account != nil {
  444. ret.Account = new(Account)
  445. *ret.Account = *o.Account
  446. }
  447. if o.Amount != nil {
  448. ret.Amount = new(int64)
  449. *ret.Amount = *o.Amount
  450. }
  451. return &ret
  452. }
  453. // GoodsDetail
  454. type GoodsDetail struct {
  455. // 由半角的大小写字母、数字、中划线、下划线中的一种或几种组成
  456. MerchantGoodsId *string `json:"merchant_goods_id"`
  457. // 微信支付定义的统一商品编号(没有可不传)
  458. WechatpayGoodsId *string `json:"wechatpay_goods_id,omitempty"`
  459. // 商品的实际名称
  460. GoodsName *string `json:"goods_name,omitempty"`
  461. // 商品单价金额,单位为分
  462. UnitPrice *int64 `json:"unit_price"`
  463. // 商品退款金额,单位为分
  464. RefundAmount *int64 `json:"refund_amount"`
  465. // 对应商品的退货数量
  466. RefundQuantity *int64 `json:"refund_quantity"`
  467. }
  468. func (o GoodsDetail) MarshalJSON() ([]byte, error) {
  469. toSerialize := map[string]interface{}{}
  470. if o.MerchantGoodsId == nil {
  471. return nil, fmt.Errorf("field `MerchantGoodsId` is required and must be specified in GoodsDetail")
  472. }
  473. toSerialize["merchant_goods_id"] = o.MerchantGoodsId
  474. if o.WechatpayGoodsId != nil {
  475. toSerialize["wechatpay_goods_id"] = o.WechatpayGoodsId
  476. }
  477. if o.GoodsName != nil {
  478. toSerialize["goods_name"] = o.GoodsName
  479. }
  480. if o.UnitPrice == nil {
  481. return nil, fmt.Errorf("field `UnitPrice` is required and must be specified in GoodsDetail")
  482. }
  483. toSerialize["unit_price"] = o.UnitPrice
  484. if o.RefundAmount == nil {
  485. return nil, fmt.Errorf("field `RefundAmount` is required and must be specified in GoodsDetail")
  486. }
  487. toSerialize["refund_amount"] = o.RefundAmount
  488. if o.RefundQuantity == nil {
  489. return nil, fmt.Errorf("field `RefundQuantity` is required and must be specified in GoodsDetail")
  490. }
  491. toSerialize["refund_quantity"] = o.RefundQuantity
  492. return json.Marshal(toSerialize)
  493. }
  494. func (o GoodsDetail) String() string {
  495. var ret string
  496. if o.MerchantGoodsId == nil {
  497. ret += "MerchantGoodsId:<nil>, "
  498. } else {
  499. ret += fmt.Sprintf("MerchantGoodsId:%v, ", *o.MerchantGoodsId)
  500. }
  501. if o.WechatpayGoodsId == nil {
  502. ret += "WechatpayGoodsId:<nil>, "
  503. } else {
  504. ret += fmt.Sprintf("WechatpayGoodsId:%v, ", *o.WechatpayGoodsId)
  505. }
  506. if o.GoodsName == nil {
  507. ret += "GoodsName:<nil>, "
  508. } else {
  509. ret += fmt.Sprintf("GoodsName:%v, ", *o.GoodsName)
  510. }
  511. if o.UnitPrice == nil {
  512. ret += "UnitPrice:<nil>, "
  513. } else {
  514. ret += fmt.Sprintf("UnitPrice:%v, ", *o.UnitPrice)
  515. }
  516. if o.RefundAmount == nil {
  517. ret += "RefundAmount:<nil>, "
  518. } else {
  519. ret += fmt.Sprintf("RefundAmount:%v, ", *o.RefundAmount)
  520. }
  521. if o.RefundQuantity == nil {
  522. ret += "RefundQuantity:<nil>"
  523. } else {
  524. ret += fmt.Sprintf("RefundQuantity:%v", *o.RefundQuantity)
  525. }
  526. return fmt.Sprintf("GoodsDetail{%s}", ret)
  527. }
  528. func (o GoodsDetail) Clone() *GoodsDetail {
  529. ret := GoodsDetail{}
  530. if o.MerchantGoodsId != nil {
  531. ret.MerchantGoodsId = new(string)
  532. *ret.MerchantGoodsId = *o.MerchantGoodsId
  533. }
  534. if o.WechatpayGoodsId != nil {
  535. ret.WechatpayGoodsId = new(string)
  536. *ret.WechatpayGoodsId = *o.WechatpayGoodsId
  537. }
  538. if o.GoodsName != nil {
  539. ret.GoodsName = new(string)
  540. *ret.GoodsName = *o.GoodsName
  541. }
  542. if o.UnitPrice != nil {
  543. ret.UnitPrice = new(int64)
  544. *ret.UnitPrice = *o.UnitPrice
  545. }
  546. if o.RefundAmount != nil {
  547. ret.RefundAmount = new(int64)
  548. *ret.RefundAmount = *o.RefundAmount
  549. }
  550. if o.RefundQuantity != nil {
  551. ret.RefundQuantity = new(int64)
  552. *ret.RefundQuantity = *o.RefundQuantity
  553. }
  554. return &ret
  555. }
  556. // Promotion
  557. type Promotion struct {
  558. // 券或者立减优惠id
  559. PromotionId *string `json:"promotion_id"`
  560. // 枚举值: - GLOBAL- 全场代金券 - SINGLE- 单品优惠 * `GLOBAL` - 全场代金券 * `SINGLE` - 单品优惠
  561. Scope *Scope `json:"scope"`
  562. // 枚举值: - COUPON- 代金券,需要走结算资金的充值型代金券 - DISCOUNT- 优惠券,不走结算资金的免充值型优惠券 * `COUPON` - 代金券 * `DISCOUNT` - 优惠券
  563. Type *Type `json:"type"`
  564. // 用户享受优惠的金额(优惠券面额=微信出资金额+商家出资金额+其他出资方金额 ),单位为分
  565. Amount *int64 `json:"amount"`
  566. // 优惠退款金额<=退款金额,退款金额-代金券或立减优惠退款金额为用户支付的现金,说明详见代金券或立减优惠,单位为分
  567. RefundAmount *int64 `json:"refund_amount"`
  568. // 优惠商品发生退款时返回商品信息
  569. GoodsDetail []GoodsDetail `json:"goods_detail,omitempty"`
  570. }
  571. func (o Promotion) MarshalJSON() ([]byte, error) {
  572. toSerialize := map[string]interface{}{}
  573. if o.PromotionId == nil {
  574. return nil, fmt.Errorf("field `PromotionId` is required and must be specified in Promotion")
  575. }
  576. toSerialize["promotion_id"] = o.PromotionId
  577. if o.Scope == nil {
  578. return nil, fmt.Errorf("field `Scope` is required and must be specified in Promotion")
  579. }
  580. toSerialize["scope"] = o.Scope
  581. if o.Type == nil {
  582. return nil, fmt.Errorf("field `Type` is required and must be specified in Promotion")
  583. }
  584. toSerialize["type"] = o.Type
  585. if o.Amount == nil {
  586. return nil, fmt.Errorf("field `Amount` is required and must be specified in Promotion")
  587. }
  588. toSerialize["amount"] = o.Amount
  589. if o.RefundAmount == nil {
  590. return nil, fmt.Errorf("field `RefundAmount` is required and must be specified in Promotion")
  591. }
  592. toSerialize["refund_amount"] = o.RefundAmount
  593. if o.GoodsDetail != nil {
  594. toSerialize["goods_detail"] = o.GoodsDetail
  595. }
  596. return json.Marshal(toSerialize)
  597. }
  598. func (o Promotion) String() string {
  599. var ret string
  600. if o.PromotionId == nil {
  601. ret += "PromotionId:<nil>, "
  602. } else {
  603. ret += fmt.Sprintf("PromotionId:%v, ", *o.PromotionId)
  604. }
  605. if o.Scope == nil {
  606. ret += "Scope:<nil>, "
  607. } else {
  608. ret += fmt.Sprintf("Scope:%v, ", *o.Scope)
  609. }
  610. if o.Type == nil {
  611. ret += "Type:<nil>, "
  612. } else {
  613. ret += fmt.Sprintf("Type:%v, ", *o.Type)
  614. }
  615. if o.Amount == nil {
  616. ret += "Amount:<nil>, "
  617. } else {
  618. ret += fmt.Sprintf("Amount:%v, ", *o.Amount)
  619. }
  620. if o.RefundAmount == nil {
  621. ret += "RefundAmount:<nil>, "
  622. } else {
  623. ret += fmt.Sprintf("RefundAmount:%v, ", *o.RefundAmount)
  624. }
  625. ret += fmt.Sprintf("GoodsDetail:%v", o.GoodsDetail)
  626. return fmt.Sprintf("Promotion{%s}", ret)
  627. }
  628. func (o Promotion) Clone() *Promotion {
  629. ret := Promotion{}
  630. if o.PromotionId != nil {
  631. ret.PromotionId = new(string)
  632. *ret.PromotionId = *o.PromotionId
  633. }
  634. if o.Scope != nil {
  635. ret.Scope = new(Scope)
  636. *ret.Scope = *o.Scope
  637. }
  638. if o.Type != nil {
  639. ret.Type = new(Type)
  640. *ret.Type = *o.Type
  641. }
  642. if o.Amount != nil {
  643. ret.Amount = new(int64)
  644. *ret.Amount = *o.Amount
  645. }
  646. if o.RefundAmount != nil {
  647. ret.RefundAmount = new(int64)
  648. *ret.RefundAmount = *o.RefundAmount
  649. }
  650. if o.GoodsDetail != nil {
  651. ret.GoodsDetail = make([]GoodsDetail, len(o.GoodsDetail))
  652. for i, item := range o.GoodsDetail {
  653. ret.GoodsDetail[i] = *item.Clone()
  654. }
  655. }
  656. return &ret
  657. }
  658. // QueryByOutRefundNoRequest
  659. type QueryByOutRefundNoRequest struct {
  660. // 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
  661. OutRefundNo *string `json:"out_refund_no"`
  662. // 子商户的商户号,由微信支付生成并下发。服务商模式下必须传递此参数
  663. SubMchid *string `json:"sub_mchid,omitempty"`
  664. }
  665. func (o QueryByOutRefundNoRequest) MarshalJSON() ([]byte, error) {
  666. toSerialize := map[string]interface{}{}
  667. if o.OutRefundNo == nil {
  668. return nil, fmt.Errorf("field `OutRefundNo` is required and must be specified in QueryByOutRefundNoRequest")
  669. }
  670. toSerialize["out_refund_no"] = o.OutRefundNo
  671. if o.SubMchid != nil {
  672. toSerialize["sub_mchid"] = o.SubMchid
  673. }
  674. return json.Marshal(toSerialize)
  675. }
  676. func (o QueryByOutRefundNoRequest) String() string {
  677. var ret string
  678. if o.OutRefundNo == nil {
  679. ret += "OutRefundNo:<nil>, "
  680. } else {
  681. ret += fmt.Sprintf("OutRefundNo:%v, ", *o.OutRefundNo)
  682. }
  683. if o.SubMchid == nil {
  684. ret += "SubMchid:<nil>"
  685. } else {
  686. ret += fmt.Sprintf("SubMchid:%v", *o.SubMchid)
  687. }
  688. return fmt.Sprintf("QueryByOutRefundNoRequest{%s}", ret)
  689. }
  690. func (o QueryByOutRefundNoRequest) Clone() *QueryByOutRefundNoRequest {
  691. ret := QueryByOutRefundNoRequest{}
  692. if o.OutRefundNo != nil {
  693. ret.OutRefundNo = new(string)
  694. *ret.OutRefundNo = *o.OutRefundNo
  695. }
  696. if o.SubMchid != nil {
  697. ret.SubMchid = new(string)
  698. *ret.SubMchid = *o.SubMchid
  699. }
  700. return &ret
  701. }
  702. // Refund
  703. type Refund struct {
  704. // 微信支付退款号
  705. RefundId *string `json:"refund_id"`
  706. // 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
  707. OutRefundNo *string `json:"out_refund_no"`
  708. // 微信支付交易订单号
  709. TransactionId *string `json:"transaction_id"`
  710. // 原支付交易对应的商户订单号
  711. OutTradeNo *string `json:"out_trade_no"`
  712. // 枚举值: - ORIGINAL—原路退款 - BALANCE—退回到余额 - OTHER_BALANCE—原账户异常退到其他余额账户 - OTHER_BANKCARD—原银行卡异常退到其他银行卡 * `ORIGINAL` - 原路退款 * `BALANCE` - 退回到余额 * `OTHER_BALANCE` - 原账户异常退到其他余额账户 * `OTHER_BANKCARD` - 原银行卡异常退到其他银行卡
  713. Channel *Channel `json:"channel"`
  714. // 取当前退款单的退款入账方,有以下几种情况: 1)退回银行卡:{银行名称}{卡类型}{卡尾号} 2)退回支付用户零钱:支付用户零钱 3)退还商户:商户基本账户商户结算银行账户 4)退回支付用户零钱通:支付用户零钱通
  715. UserReceivedAccount *string `json:"user_received_account"`
  716. // 退款成功时间,退款状态status为SUCCESS(退款成功)时,返回该字段。遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
  717. SuccessTime *time.Time `json:"success_time,omitempty"`
  718. // 退款受理时间,遵循rfc3339标准格式,格式为YYYY-MM-DDTHH:mm:ss+TIMEZONE,YYYY-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒。
  719. CreateTime *time.Time `json:"create_time"`
  720. // 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台(pay.weixin.qq.com)-交易中心,手动处理此笔退款。 枚举值: - SUCCESS—退款成功 - CLOSED—退款关闭 - PROCESSING—退款处理中 - ABNORMAL—退款异常 * `SUCCESS` - 退款成功 * `CLOSED` - 退款关闭 * `PROCESSING` - 退款处理中 * `ABNORMAL` - 退款异常
  721. Status *Status `json:"status"`
  722. // 退款所使用资金对应的资金账户类型 枚举值: - UNSETTLED : 未结算资金 - AVAILABLE : 可用余额 - UNAVAILABLE : 不可用余额 - OPERATION : 运营户 - BASIC : 基本账户(含可用余额和不可用余额) * `UNSETTLED` - 未结算资金 * `AVAILABLE` - 可用余额 * `UNAVAILABLE` - 不可用余额 * `OPERATION` - 运营户 * `BASIC` - 基本账户(含可用余额和不可用余额)
  723. FundsAccount *FundsAccount `json:"funds_account,omitempty"`
  724. // 金额详细信息
  725. Amount *Amount `json:"amount"`
  726. // 优惠退款信息
  727. PromotionDetail []Promotion `json:"promotion_detail,omitempty"`
  728. }
  729. func (o Refund) MarshalJSON() ([]byte, error) {
  730. toSerialize := map[string]interface{}{}
  731. if o.RefundId == nil {
  732. return nil, fmt.Errorf("field `RefundId` is required and must be specified in Refund")
  733. }
  734. toSerialize["refund_id"] = o.RefundId
  735. if o.OutRefundNo == nil {
  736. return nil, fmt.Errorf("field `OutRefundNo` is required and must be specified in Refund")
  737. }
  738. toSerialize["out_refund_no"] = o.OutRefundNo
  739. if o.TransactionId == nil {
  740. return nil, fmt.Errorf("field `TransactionId` is required and must be specified in Refund")
  741. }
  742. toSerialize["transaction_id"] = o.TransactionId
  743. if o.OutTradeNo == nil {
  744. return nil, fmt.Errorf("field `OutTradeNo` is required and must be specified in Refund")
  745. }
  746. toSerialize["out_trade_no"] = o.OutTradeNo
  747. if o.Channel == nil {
  748. return nil, fmt.Errorf("field `Channel` is required and must be specified in Refund")
  749. }
  750. toSerialize["channel"] = o.Channel
  751. if o.UserReceivedAccount == nil {
  752. return nil, fmt.Errorf("field `UserReceivedAccount` is required and must be specified in Refund")
  753. }
  754. toSerialize["user_received_account"] = o.UserReceivedAccount
  755. if o.SuccessTime != nil {
  756. toSerialize["success_time"] = o.SuccessTime.Format(time.RFC3339)
  757. }
  758. if o.CreateTime == nil {
  759. return nil, fmt.Errorf("field `CreateTime` is required and must be specified in Refund")
  760. }
  761. toSerialize["create_time"] = o.CreateTime.Format(time.RFC3339)
  762. if o.Status == nil {
  763. return nil, fmt.Errorf("field `Status` is required and must be specified in Refund")
  764. }
  765. toSerialize["status"] = o.Status
  766. if o.FundsAccount != nil {
  767. toSerialize["funds_account"] = o.FundsAccount
  768. }
  769. if o.Amount == nil {
  770. return nil, fmt.Errorf("field `Amount` is required and must be specified in Refund")
  771. }
  772. toSerialize["amount"] = o.Amount
  773. if o.PromotionDetail != nil {
  774. toSerialize["promotion_detail"] = o.PromotionDetail
  775. }
  776. return json.Marshal(toSerialize)
  777. }
  778. func (o Refund) String() string {
  779. var ret string
  780. if o.RefundId == nil {
  781. ret += "RefundId:<nil>, "
  782. } else {
  783. ret += fmt.Sprintf("RefundId:%v, ", *o.RefundId)
  784. }
  785. if o.OutRefundNo == nil {
  786. ret += "OutRefundNo:<nil>, "
  787. } else {
  788. ret += fmt.Sprintf("OutRefundNo:%v, ", *o.OutRefundNo)
  789. }
  790. if o.TransactionId == nil {
  791. ret += "TransactionId:<nil>, "
  792. } else {
  793. ret += fmt.Sprintf("TransactionId:%v, ", *o.TransactionId)
  794. }
  795. if o.OutTradeNo == nil {
  796. ret += "OutTradeNo:<nil>, "
  797. } else {
  798. ret += fmt.Sprintf("OutTradeNo:%v, ", *o.OutTradeNo)
  799. }
  800. if o.Channel == nil {
  801. ret += "Channel:<nil>, "
  802. } else {
  803. ret += fmt.Sprintf("Channel:%v, ", *o.Channel)
  804. }
  805. if o.UserReceivedAccount == nil {
  806. ret += "UserReceivedAccount:<nil>, "
  807. } else {
  808. ret += fmt.Sprintf("UserReceivedAccount:%v, ", *o.UserReceivedAccount)
  809. }
  810. if o.SuccessTime == nil {
  811. ret += "SuccessTime:<nil>, "
  812. } else {
  813. ret += fmt.Sprintf("SuccessTime:%v, ", *o.SuccessTime)
  814. }
  815. if o.CreateTime == nil {
  816. ret += "CreateTime:<nil>, "
  817. } else {
  818. ret += fmt.Sprintf("CreateTime:%v, ", *o.CreateTime)
  819. }
  820. if o.Status == nil {
  821. ret += "Status:<nil>, "
  822. } else {
  823. ret += fmt.Sprintf("Status:%v, ", *o.Status)
  824. }
  825. if o.FundsAccount == nil {
  826. ret += "FundsAccount:<nil>, "
  827. } else {
  828. ret += fmt.Sprintf("FundsAccount:%v, ", *o.FundsAccount)
  829. }
  830. ret += fmt.Sprintf("Amount:%v, ", o.Amount)
  831. ret += fmt.Sprintf("PromotionDetail:%v", o.PromotionDetail)
  832. return fmt.Sprintf("Refund{%s}", ret)
  833. }
  834. func (o Refund) Clone() *Refund {
  835. ret := Refund{}
  836. if o.RefundId != nil {
  837. ret.RefundId = new(string)
  838. *ret.RefundId = *o.RefundId
  839. }
  840. if o.OutRefundNo != nil {
  841. ret.OutRefundNo = new(string)
  842. *ret.OutRefundNo = *o.OutRefundNo
  843. }
  844. if o.TransactionId != nil {
  845. ret.TransactionId = new(string)
  846. *ret.TransactionId = *o.TransactionId
  847. }
  848. if o.OutTradeNo != nil {
  849. ret.OutTradeNo = new(string)
  850. *ret.OutTradeNo = *o.OutTradeNo
  851. }
  852. if o.Channel != nil {
  853. ret.Channel = new(Channel)
  854. *ret.Channel = *o.Channel
  855. }
  856. if o.UserReceivedAccount != nil {
  857. ret.UserReceivedAccount = new(string)
  858. *ret.UserReceivedAccount = *o.UserReceivedAccount
  859. }
  860. if o.SuccessTime != nil {
  861. ret.SuccessTime = new(time.Time)
  862. *ret.SuccessTime = *o.SuccessTime
  863. }
  864. if o.CreateTime != nil {
  865. ret.CreateTime = new(time.Time)
  866. *ret.CreateTime = *o.CreateTime
  867. }
  868. if o.Status != nil {
  869. ret.Status = new(Status)
  870. *ret.Status = *o.Status
  871. }
  872. if o.FundsAccount != nil {
  873. ret.FundsAccount = new(FundsAccount)
  874. *ret.FundsAccount = *o.FundsAccount
  875. }
  876. if o.Amount != nil {
  877. ret.Amount = o.Amount.Clone()
  878. }
  879. if o.PromotionDetail != nil {
  880. ret.PromotionDetail = make([]Promotion, len(o.PromotionDetail))
  881. for i, item := range o.PromotionDetail {
  882. ret.PromotionDetail[i] = *item.Clone()
  883. }
  884. }
  885. return &ret
  886. }
  887. // ReqFundsAccount * `AVAILABLE` - 可用余额, 仅对老资金流商户适用,指定从可用余额账户出资
  888. type ReqFundsAccount string
  889. func (e ReqFundsAccount) Ptr() *ReqFundsAccount {
  890. return &e
  891. }
  892. // Enums of ReqFundsAccount
  893. const (
  894. REQFUNDSACCOUNT_AVAILABLE ReqFundsAccount = "AVAILABLE"
  895. )
  896. // Scope * `GLOBAL` - 全场代金券, 全场优惠类型 * `SINGLE` - 单品优惠, 单品优惠类型
  897. type Scope string
  898. func (e Scope) Ptr() *Scope {
  899. return &e
  900. }
  901. // Enums of Scope
  902. const (
  903. SCOPE_GLOBAL Scope = "GLOBAL"
  904. SCOPE_SINGLE Scope = "SINGLE"
  905. )
  906. // Status * `SUCCESS` - 退款成功, 退款状态 * `CLOSED` - 退款关闭, 退款状态 * `PROCESSING` - 退款处理中, 退款状态 * `ABNORMAL` - 退款异常, 退款状态
  907. type Status string
  908. func (e Status) Ptr() *Status {
  909. return &e
  910. }
  911. // Enums of Status
  912. const (
  913. STATUS_SUCCESS Status = "SUCCESS"
  914. STATUS_CLOSED Status = "CLOSED"
  915. STATUS_PROCESSING Status = "PROCESSING"
  916. STATUS_ABNORMAL Status = "ABNORMAL"
  917. )
  918. // Type * `COUPON` - 代金券, 代金券类型,需要走结算资金的充值型代金券 * `DISCOUNT` - 优惠券, 优惠券类型,不走结算资金的免充值型优惠券
  919. type Type string
  920. func (e Type) Ptr() *Type {
  921. return &e
  922. }
  923. // Enums of Type
  924. const (
  925. TYPE_COUPON Type = "COUPON"
  926. TYPE_DISCOUNT Type = "DISCOUNT"
  927. )