models.go 32 KB

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