models.go 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138
  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. func (o CreateRequest) MarshalJSON() ([]byte, error) {
  278. toSerialize := map[string]interface{}{}
  279. if o.SubMchid != nil {
  280. toSerialize["sub_mchid"] = o.SubMchid
  281. }
  282. if o.TransactionId != nil {
  283. toSerialize["transaction_id"] = o.TransactionId
  284. }
  285. if o.OutTradeNo != nil {
  286. toSerialize["out_trade_no"] = o.OutTradeNo
  287. }
  288. if o.OutRefundNo == nil {
  289. return nil, fmt.Errorf("field `OutRefundNo` is required and must be specified in CreateRequest")
  290. }
  291. toSerialize["out_refund_no"] = o.OutRefundNo
  292. if o.Reason != nil {
  293. toSerialize["reason"] = o.Reason
  294. }
  295. if o.NotifyUrl != nil {
  296. toSerialize["notify_url"] = o.NotifyUrl
  297. }
  298. if o.FundsAccount != nil {
  299. toSerialize["funds_account"] = o.FundsAccount
  300. }
  301. if o.Amount == nil {
  302. return nil, fmt.Errorf("field `Amount` is required and must be specified in CreateRequest")
  303. }
  304. toSerialize["amount"] = o.Amount
  305. if o.GoodsDetail != nil {
  306. toSerialize["goods_detail"] = o.GoodsDetail
  307. }
  308. return json.Marshal(toSerialize)
  309. }
  310. func (o CreateRequest) String() string {
  311. var ret string
  312. if o.SubMchid == nil {
  313. ret += "SubMchid:<nil>, "
  314. } else {
  315. ret += fmt.Sprintf("SubMchid:%v, ", *o.SubMchid)
  316. }
  317. if o.TransactionId == nil {
  318. ret += "TransactionId:<nil>, "
  319. } else {
  320. ret += fmt.Sprintf("TransactionId:%v, ", *o.TransactionId)
  321. }
  322. if o.OutTradeNo == nil {
  323. ret += "OutTradeNo:<nil>, "
  324. } else {
  325. ret += fmt.Sprintf("OutTradeNo:%v, ", *o.OutTradeNo)
  326. }
  327. if o.OutRefundNo == nil {
  328. ret += "OutRefundNo:<nil>, "
  329. } else {
  330. ret += fmt.Sprintf("OutRefundNo:%v, ", *o.OutRefundNo)
  331. }
  332. if o.Reason == nil {
  333. ret += "Reason:<nil>, "
  334. } else {
  335. ret += fmt.Sprintf("Reason:%v, ", *o.Reason)
  336. }
  337. if o.NotifyUrl == nil {
  338. ret += "NotifyUrl:<nil>, "
  339. } else {
  340. ret += fmt.Sprintf("NotifyUrl:%v, ", *o.NotifyUrl)
  341. }
  342. if o.FundsAccount == nil {
  343. ret += "FundsAccount:<nil>, "
  344. } else {
  345. ret += fmt.Sprintf("FundsAccount:%v, ", *o.FundsAccount)
  346. }
  347. ret += fmt.Sprintf("Amount:%v, ", o.Amount)
  348. ret += fmt.Sprintf("GoodsDetail:%v", o.GoodsDetail)
  349. return fmt.Sprintf("CreateRequest{%s}", ret)
  350. }
  351. func (o CreateRequest) Clone() *CreateRequest {
  352. ret := CreateRequest{}
  353. if o.SubMchid != nil {
  354. ret.SubMchid = new(string)
  355. *ret.SubMchid = *o.SubMchid
  356. }
  357. if o.TransactionId != nil {
  358. ret.TransactionId = new(string)
  359. *ret.TransactionId = *o.TransactionId
  360. }
  361. if o.OutTradeNo != nil {
  362. ret.OutTradeNo = new(string)
  363. *ret.OutTradeNo = *o.OutTradeNo
  364. }
  365. if o.OutRefundNo != nil {
  366. ret.OutRefundNo = new(string)
  367. *ret.OutRefundNo = *o.OutRefundNo
  368. }
  369. if o.Reason != nil {
  370. ret.Reason = new(string)
  371. *ret.Reason = *o.Reason
  372. }
  373. if o.NotifyUrl != nil {
  374. ret.NotifyUrl = new(string)
  375. *ret.NotifyUrl = *o.NotifyUrl
  376. }
  377. if o.FundsAccount != nil {
  378. ret.FundsAccount = new(ReqFundsAccount)
  379. *ret.FundsAccount = *o.FundsAccount
  380. }
  381. if o.Amount != nil {
  382. ret.Amount = o.Amount.Clone()
  383. }
  384. if o.GoodsDetail != nil {
  385. ret.GoodsDetail = make([]GoodsDetail, len(o.GoodsDetail))
  386. for i, item := range o.GoodsDetail {
  387. ret.GoodsDetail[i] = *item.Clone()
  388. }
  389. }
  390. return &ret
  391. }
  392. // FundsAccount * `UNSETTLED` - 未结算资金, 退款所使用资金对应的资金账户类型 * `AVAILABLE` - 可用余额, 退款所使用资金对应的资金账户类型 * `UNAVAILABLE` - 不可用余额, 退款所使用资金对应的资金账户类型 * `OPERATION` - 运营户, 退款所使用资金对应的资金账户类型 * `BASIC` - 基本账户(含可用余额和不可用余额), 退款所使用资金对应的资金账户类型
  393. type FundsAccount string
  394. func (e FundsAccount) Ptr() *FundsAccount {
  395. return &e
  396. }
  397. // Enums of FundsAccount
  398. const (
  399. FUNDSACCOUNT_UNSETTLED FundsAccount = "UNSETTLED"
  400. FUNDSACCOUNT_AVAILABLE FundsAccount = "AVAILABLE"
  401. FUNDSACCOUNT_UNAVAILABLE FundsAccount = "UNAVAILABLE"
  402. FUNDSACCOUNT_OPERATION FundsAccount = "OPERATION"
  403. FUNDSACCOUNT_BASIC FundsAccount = "BASIC"
  404. )
  405. // FundsFromItem
  406. type FundsFromItem struct {
  407. // 下面枚举值多选一。 枚举值: AVAILABLE : 可用余额 UNAVAILABLE : 不可用余额 * `AVAILABLE` - 可用余额 * `UNAVAILABLE` - 不可用余额
  408. Account *Account `json:"account"`
  409. // 对应账户出资金额
  410. Amount *int64 `json:"amount"`
  411. }
  412. func (o FundsFromItem) MarshalJSON() ([]byte, error) {
  413. toSerialize := map[string]interface{}{}
  414. if o.Account == nil {
  415. return nil, fmt.Errorf("field `Account` is required and must be specified in FundsFromItem")
  416. }
  417. toSerialize["account"] = o.Account
  418. if o.Amount == nil {
  419. return nil, fmt.Errorf("field `Amount` is required and must be specified in FundsFromItem")
  420. }
  421. toSerialize["amount"] = o.Amount
  422. return json.Marshal(toSerialize)
  423. }
  424. func (o FundsFromItem) String() string {
  425. var ret string
  426. if o.Account == nil {
  427. ret += "Account:<nil>, "
  428. } else {
  429. ret += fmt.Sprintf("Account:%v, ", *o.Account)
  430. }
  431. if o.Amount == nil {
  432. ret += "Amount:<nil>"
  433. } else {
  434. ret += fmt.Sprintf("Amount:%v", *o.Amount)
  435. }
  436. return fmt.Sprintf("FundsFromItem{%s}", ret)
  437. }
  438. func (o FundsFromItem) Clone() *FundsFromItem {
  439. ret := FundsFromItem{}
  440. if o.Account != nil {
  441. ret.Account = new(Account)
  442. *ret.Account = *o.Account
  443. }
  444. if o.Amount != nil {
  445. ret.Amount = new(int64)
  446. *ret.Amount = *o.Amount
  447. }
  448. return &ret
  449. }
  450. // GoodsDetail
  451. type GoodsDetail struct {
  452. // 由半角的大小写字母、数字、中划线、下划线中的一种或几种组成
  453. MerchantGoodsId *string `json:"merchant_goods_id"`
  454. // 微信支付定义的统一商品编号(没有可不传)
  455. WechatpayGoodsId *string `json:"wechatpay_goods_id,omitempty"`
  456. // 商品的实际名称
  457. GoodsName *string `json:"goods_name,omitempty"`
  458. // 商品单价金额,单位为分
  459. UnitPrice *int64 `json:"unit_price"`
  460. // 商品退款金额,单位为分
  461. RefundAmount *int64 `json:"refund_amount"`
  462. // 对应商品的退货数量
  463. RefundQuantity *int64 `json:"refund_quantity"`
  464. }
  465. func (o GoodsDetail) MarshalJSON() ([]byte, error) {
  466. toSerialize := map[string]interface{}{}
  467. if o.MerchantGoodsId == nil {
  468. return nil, fmt.Errorf("field `MerchantGoodsId` is required and must be specified in GoodsDetail")
  469. }
  470. toSerialize["merchant_goods_id"] = o.MerchantGoodsId
  471. if o.WechatpayGoodsId != nil {
  472. toSerialize["wechatpay_goods_id"] = o.WechatpayGoodsId
  473. }
  474. if o.GoodsName != nil {
  475. toSerialize["goods_name"] = o.GoodsName
  476. }
  477. if o.UnitPrice == nil {
  478. return nil, fmt.Errorf("field `UnitPrice` is required and must be specified in GoodsDetail")
  479. }
  480. toSerialize["unit_price"] = o.UnitPrice
  481. if o.RefundAmount == nil {
  482. return nil, fmt.Errorf("field `RefundAmount` is required and must be specified in GoodsDetail")
  483. }
  484. toSerialize["refund_amount"] = o.RefundAmount
  485. if o.RefundQuantity == nil {
  486. return nil, fmt.Errorf("field `RefundQuantity` is required and must be specified in GoodsDetail")
  487. }
  488. toSerialize["refund_quantity"] = o.RefundQuantity
  489. return json.Marshal(toSerialize)
  490. }
  491. func (o GoodsDetail) String() string {
  492. var ret string
  493. if o.MerchantGoodsId == nil {
  494. ret += "MerchantGoodsId:<nil>, "
  495. } else {
  496. ret += fmt.Sprintf("MerchantGoodsId:%v, ", *o.MerchantGoodsId)
  497. }
  498. if o.WechatpayGoodsId == nil {
  499. ret += "WechatpayGoodsId:<nil>, "
  500. } else {
  501. ret += fmt.Sprintf("WechatpayGoodsId:%v, ", *o.WechatpayGoodsId)
  502. }
  503. if o.GoodsName == nil {
  504. ret += "GoodsName:<nil>, "
  505. } else {
  506. ret += fmt.Sprintf("GoodsName:%v, ", *o.GoodsName)
  507. }
  508. if o.UnitPrice == nil {
  509. ret += "UnitPrice:<nil>, "
  510. } else {
  511. ret += fmt.Sprintf("UnitPrice:%v, ", *o.UnitPrice)
  512. }
  513. if o.RefundAmount == nil {
  514. ret += "RefundAmount:<nil>, "
  515. } else {
  516. ret += fmt.Sprintf("RefundAmount:%v, ", *o.RefundAmount)
  517. }
  518. if o.RefundQuantity == nil {
  519. ret += "RefundQuantity:<nil>"
  520. } else {
  521. ret += fmt.Sprintf("RefundQuantity:%v", *o.RefundQuantity)
  522. }
  523. return fmt.Sprintf("GoodsDetail{%s}", ret)
  524. }
  525. func (o GoodsDetail) Clone() *GoodsDetail {
  526. ret := GoodsDetail{}
  527. if o.MerchantGoodsId != nil {
  528. ret.MerchantGoodsId = new(string)
  529. *ret.MerchantGoodsId = *o.MerchantGoodsId
  530. }
  531. if o.WechatpayGoodsId != nil {
  532. ret.WechatpayGoodsId = new(string)
  533. *ret.WechatpayGoodsId = *o.WechatpayGoodsId
  534. }
  535. if o.GoodsName != nil {
  536. ret.GoodsName = new(string)
  537. *ret.GoodsName = *o.GoodsName
  538. }
  539. if o.UnitPrice != nil {
  540. ret.UnitPrice = new(int64)
  541. *ret.UnitPrice = *o.UnitPrice
  542. }
  543. if o.RefundAmount != nil {
  544. ret.RefundAmount = new(int64)
  545. *ret.RefundAmount = *o.RefundAmount
  546. }
  547. if o.RefundQuantity != nil {
  548. ret.RefundQuantity = new(int64)
  549. *ret.RefundQuantity = *o.RefundQuantity
  550. }
  551. return &ret
  552. }
  553. // Promotion
  554. type Promotion struct {
  555. // 券或者立减优惠id
  556. PromotionId *string `json:"promotion_id"`
  557. // 枚举值: - GLOBAL- 全场代金券 - SINGLE- 单品优惠 * `GLOBAL` - 全场代金券 * `SINGLE` - 单品优惠
  558. Scope *Scope `json:"scope"`
  559. // 枚举值: - COUPON- 代金券,需要走结算资金的充值型代金券 - DISCOUNT- 优惠券,不走结算资金的免充值型优惠券 * `COUPON` - 代金券 * `DISCOUNT` - 优惠券
  560. Type *Type `json:"type"`
  561. // 用户享受优惠的金额(优惠券面额=微信出资金额+商家出资金额+其他出资方金额 ),单位为分
  562. Amount *int64 `json:"amount"`
  563. // 优惠退款金额<=退款金额,退款金额-代金券或立减优惠退款金额为用户支付的现金,说明详见代金券或立减优惠,单位为分
  564. RefundAmount *int64 `json:"refund_amount"`
  565. // 优惠商品发生退款时返回商品信息
  566. GoodsDetail []GoodsDetail `json:"goods_detail,omitempty"`
  567. }
  568. func (o Promotion) MarshalJSON() ([]byte, error) {
  569. toSerialize := map[string]interface{}{}
  570. if o.PromotionId == nil {
  571. return nil, fmt.Errorf("field `PromotionId` is required and must be specified in Promotion")
  572. }
  573. toSerialize["promotion_id"] = o.PromotionId
  574. if o.Scope == nil {
  575. return nil, fmt.Errorf("field `Scope` is required and must be specified in Promotion")
  576. }
  577. toSerialize["scope"] = o.Scope
  578. if o.Type == nil {
  579. return nil, fmt.Errorf("field `Type` is required and must be specified in Promotion")
  580. }
  581. toSerialize["type"] = o.Type
  582. if o.Amount == nil {
  583. return nil, fmt.Errorf("field `Amount` is required and must be specified in Promotion")
  584. }
  585. toSerialize["amount"] = o.Amount
  586. if o.RefundAmount == nil {
  587. return nil, fmt.Errorf("field `RefundAmount` is required and must be specified in Promotion")
  588. }
  589. toSerialize["refund_amount"] = o.RefundAmount
  590. if o.GoodsDetail != nil {
  591. toSerialize["goods_detail"] = o.GoodsDetail
  592. }
  593. return json.Marshal(toSerialize)
  594. }
  595. func (o Promotion) String() string {
  596. var ret string
  597. if o.PromotionId == nil {
  598. ret += "PromotionId:<nil>, "
  599. } else {
  600. ret += fmt.Sprintf("PromotionId:%v, ", *o.PromotionId)
  601. }
  602. if o.Scope == nil {
  603. ret += "Scope:<nil>, "
  604. } else {
  605. ret += fmt.Sprintf("Scope:%v, ", *o.Scope)
  606. }
  607. if o.Type == nil {
  608. ret += "Type:<nil>, "
  609. } else {
  610. ret += fmt.Sprintf("Type:%v, ", *o.Type)
  611. }
  612. if o.Amount == nil {
  613. ret += "Amount:<nil>, "
  614. } else {
  615. ret += fmt.Sprintf("Amount:%v, ", *o.Amount)
  616. }
  617. if o.RefundAmount == nil {
  618. ret += "RefundAmount:<nil>, "
  619. } else {
  620. ret += fmt.Sprintf("RefundAmount:%v, ", *o.RefundAmount)
  621. }
  622. ret += fmt.Sprintf("GoodsDetail:%v", o.GoodsDetail)
  623. return fmt.Sprintf("Promotion{%s}", ret)
  624. }
  625. func (o Promotion) Clone() *Promotion {
  626. ret := Promotion{}
  627. if o.PromotionId != nil {
  628. ret.PromotionId = new(string)
  629. *ret.PromotionId = *o.PromotionId
  630. }
  631. if o.Scope != nil {
  632. ret.Scope = new(Scope)
  633. *ret.Scope = *o.Scope
  634. }
  635. if o.Type != nil {
  636. ret.Type = new(Type)
  637. *ret.Type = *o.Type
  638. }
  639. if o.Amount != nil {
  640. ret.Amount = new(int64)
  641. *ret.Amount = *o.Amount
  642. }
  643. if o.RefundAmount != nil {
  644. ret.RefundAmount = new(int64)
  645. *ret.RefundAmount = *o.RefundAmount
  646. }
  647. if o.GoodsDetail != nil {
  648. ret.GoodsDetail = make([]GoodsDetail, len(o.GoodsDetail))
  649. for i, item := range o.GoodsDetail {
  650. ret.GoodsDetail[i] = *item.Clone()
  651. }
  652. }
  653. return &ret
  654. }
  655. // QueryByOutRefundNoRequest
  656. type QueryByOutRefundNoRequest struct {
  657. // 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
  658. OutRefundNo *string `json:"out_refund_no"`
  659. // 子商户的商户号,由微信支付生成并下发。服务商模式下必须传递此参数
  660. SubMchid *string `json:"sub_mchid,omitempty"`
  661. }
  662. func (o QueryByOutRefundNoRequest) MarshalJSON() ([]byte, error) {
  663. toSerialize := map[string]interface{}{}
  664. if o.OutRefundNo == nil {
  665. return nil, fmt.Errorf("field `OutRefundNo` is required and must be specified in QueryByOutRefundNoRequest")
  666. }
  667. toSerialize["out_refund_no"] = o.OutRefundNo
  668. if o.SubMchid != nil {
  669. toSerialize["sub_mchid"] = o.SubMchid
  670. }
  671. return json.Marshal(toSerialize)
  672. }
  673. func (o QueryByOutRefundNoRequest) String() string {
  674. var ret string
  675. if o.OutRefundNo == nil {
  676. ret += "OutRefundNo:<nil>, "
  677. } else {
  678. ret += fmt.Sprintf("OutRefundNo:%v, ", *o.OutRefundNo)
  679. }
  680. if o.SubMchid == nil {
  681. ret += "SubMchid:<nil>"
  682. } else {
  683. ret += fmt.Sprintf("SubMchid:%v", *o.SubMchid)
  684. }
  685. return fmt.Sprintf("QueryByOutRefundNoRequest{%s}", ret)
  686. }
  687. func (o QueryByOutRefundNoRequest) Clone() *QueryByOutRefundNoRequest {
  688. ret := QueryByOutRefundNoRequest{}
  689. if o.OutRefundNo != nil {
  690. ret.OutRefundNo = new(string)
  691. *ret.OutRefundNo = *o.OutRefundNo
  692. }
  693. if o.SubMchid != nil {
  694. ret.SubMchid = new(string)
  695. *ret.SubMchid = *o.SubMchid
  696. }
  697. return &ret
  698. }
  699. // Refund
  700. type Refund struct {
  701. // 微信支付退款号
  702. RefundId *string `json:"refund_id"`
  703. // 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
  704. OutRefundNo *string `json:"out_refund_no"`
  705. // 微信支付交易订单号
  706. TransactionId *string `json:"transaction_id"`
  707. // 原支付交易对应的商户订单号
  708. OutTradeNo *string `json:"out_trade_no"`
  709. // 枚举值: - ORIGINAL—原路退款 - BALANCE—退回到余额 - OTHER_BALANCE—原账户异常退到其他余额账户 - OTHER_BANKCARD—原银行卡异常退到其他银行卡 * `ORIGINAL` - 原路退款 * `BALANCE` - 退回到余额 * `OTHER_BALANCE` - 原账户异常退到其他余额账户 * `OTHER_BANKCARD` - 原银行卡异常退到其他银行卡
  710. Channel *Channel `json:"channel"`
  711. // 取当前退款单的退款入账方,有以下几种情况: 1)退回银行卡:{银行名称}{卡类型}{卡尾号} 2)退回支付用户零钱:支付用户零钱 3)退还商户:商户基本账户商户结算银行账户 4)退回支付用户零钱通:支付用户零钱通
  712. UserReceivedAccount *string `json:"user_received_account"`
  713. // 退款成功时间,退款状态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秒。
  714. SuccessTime *time.Time `json:"success_time,omitempty"`
  715. // 退款受理时间,遵循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秒。
  716. CreateTime *time.Time `json:"create_time"`
  717. // 退款到银行发现用户的卡作废或者冻结了,导致原路退款银行卡失败,可前往商户平台(pay.weixin.qq.com)-交易中心,手动处理此笔退款。 枚举值: - SUCCESS—退款成功 - CLOSED—退款关闭 - PROCESSING—退款处理中 - ABNORMAL—退款异常 * `SUCCESS` - 退款成功 * `CLOSED` - 退款关闭 * `PROCESSING` - 退款处理中 * `ABNORMAL` - 退款异常
  718. Status *Status `json:"status"`
  719. // 退款所使用资金对应的资金账户类型 枚举值: - UNSETTLED : 未结算资金 - AVAILABLE : 可用余额 - UNAVAILABLE : 不可用余额 - OPERATION : 运营户 - BASIC : 基本账户(含可用余额和不可用余额) * `UNSETTLED` - 未结算资金 * `AVAILABLE` - 可用余额 * `UNAVAILABLE` - 不可用余额 * `OPERATION` - 运营户 * `BASIC` - 基本账户(含可用余额和不可用余额)
  720. FundsAccount *FundsAccount `json:"funds_account,omitempty"`
  721. // 金额详细信息
  722. Amount *Amount `json:"amount"`
  723. // 优惠退款信息
  724. PromotionDetail []Promotion `json:"promotion_detail,omitempty"`
  725. }
  726. func (o Refund) MarshalJSON() ([]byte, error) {
  727. toSerialize := map[string]interface{}{}
  728. if o.RefundId == nil {
  729. return nil, fmt.Errorf("field `RefundId` is required and must be specified in Refund")
  730. }
  731. toSerialize["refund_id"] = o.RefundId
  732. if o.OutRefundNo == nil {
  733. return nil, fmt.Errorf("field `OutRefundNo` is required and must be specified in Refund")
  734. }
  735. toSerialize["out_refund_no"] = o.OutRefundNo
  736. if o.TransactionId == nil {
  737. return nil, fmt.Errorf("field `TransactionId` is required and must be specified in Refund")
  738. }
  739. toSerialize["transaction_id"] = o.TransactionId
  740. if o.OutTradeNo == nil {
  741. return nil, fmt.Errorf("field `OutTradeNo` is required and must be specified in Refund")
  742. }
  743. toSerialize["out_trade_no"] = o.OutTradeNo
  744. if o.Channel == nil {
  745. return nil, fmt.Errorf("field `Channel` is required and must be specified in Refund")
  746. }
  747. toSerialize["channel"] = o.Channel
  748. if o.UserReceivedAccount == nil {
  749. return nil, fmt.Errorf("field `UserReceivedAccount` is required and must be specified in Refund")
  750. }
  751. toSerialize["user_received_account"] = o.UserReceivedAccount
  752. if o.SuccessTime != nil {
  753. toSerialize["success_time"] = o.SuccessTime.Format(time.RFC3339)
  754. }
  755. if o.CreateTime == nil {
  756. return nil, fmt.Errorf("field `CreateTime` is required and must be specified in Refund")
  757. }
  758. toSerialize["create_time"] = o.CreateTime.Format(time.RFC3339)
  759. if o.Status == nil {
  760. return nil, fmt.Errorf("field `Status` is required and must be specified in Refund")
  761. }
  762. toSerialize["status"] = o.Status
  763. if o.FundsAccount != nil {
  764. toSerialize["funds_account"] = o.FundsAccount
  765. }
  766. if o.Amount == nil {
  767. return nil, fmt.Errorf("field `Amount` is required and must be specified in Refund")
  768. }
  769. toSerialize["amount"] = o.Amount
  770. if o.PromotionDetail != nil {
  771. toSerialize["promotion_detail"] = o.PromotionDetail
  772. }
  773. return json.Marshal(toSerialize)
  774. }
  775. func (o Refund) String() string {
  776. var ret string
  777. if o.RefundId == nil {
  778. ret += "RefundId:<nil>, "
  779. } else {
  780. ret += fmt.Sprintf("RefundId:%v, ", *o.RefundId)
  781. }
  782. if o.OutRefundNo == nil {
  783. ret += "OutRefundNo:<nil>, "
  784. } else {
  785. ret += fmt.Sprintf("OutRefundNo:%v, ", *o.OutRefundNo)
  786. }
  787. if o.TransactionId == nil {
  788. ret += "TransactionId:<nil>, "
  789. } else {
  790. ret += fmt.Sprintf("TransactionId:%v, ", *o.TransactionId)
  791. }
  792. if o.OutTradeNo == nil {
  793. ret += "OutTradeNo:<nil>, "
  794. } else {
  795. ret += fmt.Sprintf("OutTradeNo:%v, ", *o.OutTradeNo)
  796. }
  797. if o.Channel == nil {
  798. ret += "Channel:<nil>, "
  799. } else {
  800. ret += fmt.Sprintf("Channel:%v, ", *o.Channel)
  801. }
  802. if o.UserReceivedAccount == nil {
  803. ret += "UserReceivedAccount:<nil>, "
  804. } else {
  805. ret += fmt.Sprintf("UserReceivedAccount:%v, ", *o.UserReceivedAccount)
  806. }
  807. if o.SuccessTime == nil {
  808. ret += "SuccessTime:<nil>, "
  809. } else {
  810. ret += fmt.Sprintf("SuccessTime:%v, ", *o.SuccessTime)
  811. }
  812. if o.CreateTime == nil {
  813. ret += "CreateTime:<nil>, "
  814. } else {
  815. ret += fmt.Sprintf("CreateTime:%v, ", *o.CreateTime)
  816. }
  817. if o.Status == nil {
  818. ret += "Status:<nil>, "
  819. } else {
  820. ret += fmt.Sprintf("Status:%v, ", *o.Status)
  821. }
  822. if o.FundsAccount == nil {
  823. ret += "FundsAccount:<nil>, "
  824. } else {
  825. ret += fmt.Sprintf("FundsAccount:%v, ", *o.FundsAccount)
  826. }
  827. ret += fmt.Sprintf("Amount:%v, ", o.Amount)
  828. ret += fmt.Sprintf("PromotionDetail:%v", o.PromotionDetail)
  829. return fmt.Sprintf("Refund{%s}", ret)
  830. }
  831. func (o Refund) Clone() *Refund {
  832. ret := Refund{}
  833. if o.RefundId != nil {
  834. ret.RefundId = new(string)
  835. *ret.RefundId = *o.RefundId
  836. }
  837. if o.OutRefundNo != nil {
  838. ret.OutRefundNo = new(string)
  839. *ret.OutRefundNo = *o.OutRefundNo
  840. }
  841. if o.TransactionId != nil {
  842. ret.TransactionId = new(string)
  843. *ret.TransactionId = *o.TransactionId
  844. }
  845. if o.OutTradeNo != nil {
  846. ret.OutTradeNo = new(string)
  847. *ret.OutTradeNo = *o.OutTradeNo
  848. }
  849. if o.Channel != nil {
  850. ret.Channel = new(Channel)
  851. *ret.Channel = *o.Channel
  852. }
  853. if o.UserReceivedAccount != nil {
  854. ret.UserReceivedAccount = new(string)
  855. *ret.UserReceivedAccount = *o.UserReceivedAccount
  856. }
  857. if o.SuccessTime != nil {
  858. ret.SuccessTime = new(time.Time)
  859. *ret.SuccessTime = *o.SuccessTime
  860. }
  861. if o.CreateTime != nil {
  862. ret.CreateTime = new(time.Time)
  863. *ret.CreateTime = *o.CreateTime
  864. }
  865. if o.Status != nil {
  866. ret.Status = new(Status)
  867. *ret.Status = *o.Status
  868. }
  869. if o.FundsAccount != nil {
  870. ret.FundsAccount = new(FundsAccount)
  871. *ret.FundsAccount = *o.FundsAccount
  872. }
  873. if o.Amount != nil {
  874. ret.Amount = o.Amount.Clone()
  875. }
  876. if o.PromotionDetail != nil {
  877. ret.PromotionDetail = make([]Promotion, len(o.PromotionDetail))
  878. for i, item := range o.PromotionDetail {
  879. ret.PromotionDetail[i] = *item.Clone()
  880. }
  881. }
  882. return &ret
  883. }
  884. // ReqFundsAccount * `AVAILABLE` - 可用余额, 仅对老资金流商户适用,指定从可用余额账户出资
  885. type ReqFundsAccount string
  886. func (e ReqFundsAccount) Ptr() *ReqFundsAccount {
  887. return &e
  888. }
  889. // Enums of ReqFundsAccount
  890. const (
  891. REQFUNDSACCOUNT_AVAILABLE ReqFundsAccount = "AVAILABLE"
  892. )
  893. // Scope * `GLOBAL` - 全场代金券, 全场优惠类型 * `SINGLE` - 单品优惠, 单品优惠类型
  894. type Scope string
  895. func (e Scope) Ptr() *Scope {
  896. return &e
  897. }
  898. // Enums of Scope
  899. const (
  900. SCOPE_GLOBAL Scope = "GLOBAL"
  901. SCOPE_SINGLE Scope = "SINGLE"
  902. )
  903. // Status * `SUCCESS` - 退款成功, 退款状态 * `CLOSED` - 退款关闭, 退款状态 * `PROCESSING` - 退款处理中, 退款状态 * `ABNORMAL` - 退款异常, 退款状态
  904. type Status string
  905. func (e Status) Ptr() *Status {
  906. return &e
  907. }
  908. // Enums of Status
  909. const (
  910. STATUS_SUCCESS Status = "SUCCESS"
  911. STATUS_CLOSED Status = "CLOSED"
  912. STATUS_PROCESSING Status = "PROCESSING"
  913. STATUS_ABNORMAL Status = "ABNORMAL"
  914. )
  915. // Type * `COUPON` - 代金券, 代金券类型,需要走结算资金的充值型代金券 * `DISCOUNT` - 优惠券, 优惠券类型,不走结算资金的免充值型优惠券
  916. type Type string
  917. func (e Type) Ptr() *Type {
  918. return &e
  919. }
  920. // Enums of Type
  921. const (
  922. TYPE_COUPON Type = "COUPON"
  923. TYPE_DISCOUNT Type = "DISCOUNT"
  924. )