models.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  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. )
  14. // Account * `AVAILABLE` - 可用余额, 多账户资金准备退款可用余额出资账户类型 * `UNAVAILABLE` - 不可用余额, 多账户资金准备退款不可用余额出资账户类型
  15. type Account string
  16. func (e Account) Ptr() *Account {
  17. return &e
  18. }
  19. // Enums of Account
  20. const (
  21. ACCOUNT_AVAILABLE Account = "AVAILABLE"
  22. ACCOUNT_UNAVAILABLE Account = "UNAVAILABLE"
  23. )
  24. // Amount
  25. type Amount struct {
  26. // 订单总金额,单位为分
  27. Total *int64 `json:"total"`
  28. // 退款标价金额,单位为分,可以做部分退款
  29. Refund *int64 `json:"refund"`
  30. // 退款出资的账户类型及金额信息
  31. From []FundsFromItem `json:"from,omitempty"`
  32. // 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY。
  33. Currency *string `json:"currency"`
  34. }
  35. func (o Amount) MarshalJSON() ([]byte, error) {
  36. toSerialize := map[string]interface{}{}
  37. if o.Total == nil {
  38. return nil, fmt.Errorf("field `Total` is required and must be specified in Amount")
  39. }
  40. toSerialize["total"] = o.Total
  41. if o.Refund == nil {
  42. return nil, fmt.Errorf("field `Refund` is required and must be specified in Amount")
  43. }
  44. toSerialize["refund"] = o.Refund
  45. if o.From != nil {
  46. toSerialize["from"] = o.From
  47. }
  48. if o.Currency == nil {
  49. return nil, fmt.Errorf("field `Currency` is required and must be specified in Amount")
  50. }
  51. toSerialize["currency"] = o.Currency
  52. return json.Marshal(toSerialize)
  53. }
  54. func (o Amount) String() string {
  55. var ret string
  56. if o.Total == nil {
  57. ret += "Total:<nil>, "
  58. } else {
  59. ret += fmt.Sprintf("Total:%v, ", *o.Total)
  60. }
  61. if o.Refund == nil {
  62. ret += "Refund:<nil>, "
  63. } else {
  64. ret += fmt.Sprintf("Refund:%v, ", *o.Refund)
  65. }
  66. ret += fmt.Sprintf("From:%v, ", o.From)
  67. if o.Currency == nil {
  68. ret += "Currency:<nil>"
  69. } else {
  70. ret += fmt.Sprintf("Currency:%v", *o.Currency)
  71. }
  72. return fmt.Sprintf("Amount{%s}", ret)
  73. }
  74. func (o Amount) Clone() *Amount {
  75. ret := Amount{}
  76. if o.Total != nil {
  77. ret.Total = new(int64)
  78. *ret.Total = *o.Total
  79. }
  80. if o.Refund != nil {
  81. ret.Refund = new(int64)
  82. *ret.Refund = *o.Refund
  83. }
  84. if o.From != nil {
  85. ret.From = make([]FundsFromItem, len(o.From))
  86. for i, item := range o.From {
  87. ret.From[i] = *item.Clone()
  88. }
  89. }
  90. if o.Currency != nil {
  91. ret.Currency = new(string)
  92. *ret.Currency = *o.Currency
  93. }
  94. return &ret
  95. }
  96. // AmountReq
  97. type AmountReq struct {
  98. // 退款金额,币种的最小单位,只能为整数,不能超过原订单支付金额。
  99. Refund *int64 `json:"refund"`
  100. // 退款需要从指定账户出资时,传递此参数指定出资金额(币种的最小单位,只能为整数)。 同时指定多个账户出资退款的使用场景需要满足以下条件:1、未开通退款支出分离产品功能;2、订单属于分账订单,且分账处于待分账或分账中状态。 参数传递需要满足条件:1、基本账户可用余额出资金额与基本账户不可用余额出资金额之和等于退款金额;2、账户类型不能重复。 上述任一条件不满足将返回错误
  101. From []FundsFromItem `json:"from,omitempty"`
  102. // 原支付交易的订单总金额,币种的最小单位,只能为整数。
  103. Total *int64 `json:"total"`
  104. // 符合ISO 4217标准的三位字母代码,目前只支持人民币:CNY。
  105. Currency *string `json:"currency"`
  106. }
  107. func (o AmountReq) MarshalJSON() ([]byte, error) {
  108. toSerialize := map[string]interface{}{}
  109. if o.Refund == nil {
  110. return nil, fmt.Errorf("field `Refund` is required and must be specified in AmountReq")
  111. }
  112. toSerialize["refund"] = o.Refund
  113. if o.From != nil {
  114. toSerialize["from"] = o.From
  115. }
  116. if o.Total == nil {
  117. return nil, fmt.Errorf("field `Total` is required and must be specified in AmountReq")
  118. }
  119. toSerialize["total"] = o.Total
  120. if o.Currency == nil {
  121. return nil, fmt.Errorf("field `Currency` is required and must be specified in AmountReq")
  122. }
  123. toSerialize["currency"] = o.Currency
  124. return json.Marshal(toSerialize)
  125. }
  126. func (o AmountReq) String() string {
  127. var ret string
  128. if o.Refund == nil {
  129. ret += "Refund:<nil>, "
  130. } else {
  131. ret += fmt.Sprintf("Refund:%v, ", *o.Refund)
  132. }
  133. ret += fmt.Sprintf("From:%v, ", o.From)
  134. if o.Total == nil {
  135. ret += "Total:<nil>, "
  136. } else {
  137. ret += fmt.Sprintf("Total:%v, ", *o.Total)
  138. }
  139. if o.Currency == nil {
  140. ret += "Currency:<nil>"
  141. } else {
  142. ret += fmt.Sprintf("Currency:%v", *o.Currency)
  143. }
  144. return fmt.Sprintf("AmountReq{%s}", ret)
  145. }
  146. func (o AmountReq) Clone() *AmountReq {
  147. ret := AmountReq{}
  148. if o.Refund != nil {
  149. ret.Refund = new(int64)
  150. *ret.Refund = *o.Refund
  151. }
  152. if o.From != nil {
  153. ret.From = make([]FundsFromItem, len(o.From))
  154. for i, item := range o.From {
  155. ret.From[i] = *item.Clone()
  156. }
  157. }
  158. if o.Total != nil {
  159. ret.Total = new(int64)
  160. *ret.Total = *o.Total
  161. }
  162. if o.Currency != nil {
  163. ret.Currency = new(string)
  164. *ret.Currency = *o.Currency
  165. }
  166. return &ret
  167. }
  168. // Channel * `ORIGINAL` - 原路退款, 退款渠道 * `BALANCE` - 退回到余额, 退款渠道 * `OTHER_BALANCE` - 原账户异常退到其他余额账户, 退款渠道 * `OTHER_BANKCARD` - 原银行卡异常退到其他银行卡, 退款渠道
  169. type Channel string
  170. func (e Channel) Ptr() *Channel {
  171. return &e
  172. }
  173. // Enums of Channel
  174. const (
  175. CHANNEL_ORIGINAL Channel = "ORIGINAL"
  176. CHANNEL_BALANCE Channel = "BALANCE"
  177. CHANNEL_OTHER_BALANCE Channel = "OTHER_BALANCE"
  178. CHANNEL_OTHER_BANKCARD Channel = "OTHER_BANKCARD"
  179. )
  180. // CreateRequest
  181. type CreateRequest struct {
  182. // 子商户的商户号,由微信支付生成并下发。服务商模式下必须传递此参数
  183. SubMchid *string `json:"sub_mchid,omitempty"`
  184. // 原支付交易对应的微信订单号
  185. TransactionId *string `json:"transaction_id,omitempty"`
  186. // 原支付交易对应的商户订单号
  187. OutTradeNo *string `json:"out_trade_no,omitempty"`
  188. // 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
  189. OutRefundNo *string `json:"out_refund_no"`
  190. // 若商户传入,会在下发给用户的退款消息中体现退款原因
  191. Reason *string `json:"reason,omitempty"`
  192. // 异步接收微信支付退款结果通知的回调地址,通知url必须为外网可访问的url,不能携带参数。 如果参数中传了notify_url,则商户平台上配置的回调地址将不会生效,优先回调当前传的这个地址。
  193. NotifyUrl *string `json:"notify_url,omitempty"`
  194. // 若传递此参数则使用对应的资金账户退款,否则默认使用未结算资金退款(仅对老资金流商户适用) 枚举值: - AVAILABLE:可用余额账户 * `AVAILABLE` - 可用余额
  195. FundsAccount *ReqFundsAccount `json:"funds_account,omitempty"`
  196. // 订单金额信息
  197. Amount *AmountReq `json:"amount"`
  198. // 指定商品退款需要传此参数,其他场景无需传递
  199. GoodsDetail []GoodsDetail `json:"goods_detail,omitempty"`
  200. }
  201. func (o CreateRequest) MarshalJSON() ([]byte, error) {
  202. toSerialize := map[string]interface{}{}
  203. if o.SubMchid != nil {
  204. toSerialize["sub_mchid"] = o.SubMchid
  205. }
  206. if o.TransactionId != nil {
  207. toSerialize["transaction_id"] = o.TransactionId
  208. }
  209. if o.OutTradeNo != nil {
  210. toSerialize["out_trade_no"] = o.OutTradeNo
  211. }
  212. if o.OutRefundNo == nil {
  213. return nil, fmt.Errorf("field `OutRefundNo` is required and must be specified in CreateRequest")
  214. }
  215. toSerialize["out_refund_no"] = o.OutRefundNo
  216. if o.Reason != nil {
  217. toSerialize["reason"] = o.Reason
  218. }
  219. if o.NotifyUrl != nil {
  220. toSerialize["notify_url"] = o.NotifyUrl
  221. }
  222. if o.FundsAccount != nil {
  223. toSerialize["funds_account"] = o.FundsAccount
  224. }
  225. if o.Amount == nil {
  226. return nil, fmt.Errorf("field `Amount` is required and must be specified in CreateRequest")
  227. }
  228. toSerialize["amount"] = o.Amount
  229. if o.GoodsDetail != nil {
  230. toSerialize["goods_detail"] = o.GoodsDetail
  231. }
  232. return json.Marshal(toSerialize)
  233. }
  234. func (o CreateRequest) String() string {
  235. var ret string
  236. if o.SubMchid == nil {
  237. ret += "SubMchid:<nil>, "
  238. } else {
  239. ret += fmt.Sprintf("SubMchid:%v, ", *o.SubMchid)
  240. }
  241. if o.TransactionId == nil {
  242. ret += "TransactionId:<nil>, "
  243. } else {
  244. ret += fmt.Sprintf("TransactionId:%v, ", *o.TransactionId)
  245. }
  246. if o.OutTradeNo == nil {
  247. ret += "OutTradeNo:<nil>, "
  248. } else {
  249. ret += fmt.Sprintf("OutTradeNo:%v, ", *o.OutTradeNo)
  250. }
  251. if o.OutRefundNo == nil {
  252. ret += "OutRefundNo:<nil>, "
  253. } else {
  254. ret += fmt.Sprintf("OutRefundNo:%v, ", *o.OutRefundNo)
  255. }
  256. if o.Reason == nil {
  257. ret += "Reason:<nil>, "
  258. } else {
  259. ret += fmt.Sprintf("Reason:%v, ", *o.Reason)
  260. }
  261. if o.NotifyUrl == nil {
  262. ret += "NotifyUrl:<nil>, "
  263. } else {
  264. ret += fmt.Sprintf("NotifyUrl:%v, ", *o.NotifyUrl)
  265. }
  266. if o.FundsAccount == nil {
  267. ret += "FundsAccount:<nil>, "
  268. } else {
  269. ret += fmt.Sprintf("FundsAccount:%v, ", *o.FundsAccount)
  270. }
  271. ret += fmt.Sprintf("Amount:%v, ", o.Amount)
  272. ret += fmt.Sprintf("GoodsDetail:%v", o.GoodsDetail)
  273. return fmt.Sprintf("CreateRequest{%s}", ret)
  274. }
  275. func (o CreateRequest) Clone() *CreateRequest {
  276. ret := CreateRequest{}
  277. if o.SubMchid != nil {
  278. ret.SubMchid = new(string)
  279. *ret.SubMchid = *o.SubMchid
  280. }
  281. if o.TransactionId != nil {
  282. ret.TransactionId = new(string)
  283. *ret.TransactionId = *o.TransactionId
  284. }
  285. if o.OutTradeNo != nil {
  286. ret.OutTradeNo = new(string)
  287. *ret.OutTradeNo = *o.OutTradeNo
  288. }
  289. if o.OutRefundNo != nil {
  290. ret.OutRefundNo = new(string)
  291. *ret.OutRefundNo = *o.OutRefundNo
  292. }
  293. if o.Reason != nil {
  294. ret.Reason = new(string)
  295. *ret.Reason = *o.Reason
  296. }
  297. if o.NotifyUrl != nil {
  298. ret.NotifyUrl = new(string)
  299. *ret.NotifyUrl = *o.NotifyUrl
  300. }
  301. if o.FundsAccount != nil {
  302. ret.FundsAccount = new(ReqFundsAccount)
  303. *ret.FundsAccount = *o.FundsAccount
  304. }
  305. if o.Amount != nil {
  306. ret.Amount = o.Amount.Clone()
  307. }
  308. if o.GoodsDetail != nil {
  309. ret.GoodsDetail = make([]GoodsDetail, len(o.GoodsDetail))
  310. for i, item := range o.GoodsDetail {
  311. ret.GoodsDetail[i] = *item.Clone()
  312. }
  313. }
  314. return &ret
  315. }
  316. // FundsAccount * `UNSETTLED` - 未结算资金, 退款所使用资金对应的资金账户类型 * `AVAILABLE` - 可用余额, 退款所使用资金对应的资金账户类型 * `UNAVAILABLE` - 不可用余额, 退款所使用资金对应的资金账户类型 * `OPERATION` - 运营户, 退款所使用资金对应的资金账户类型 * `BASIC` - 基本账户(含可用余额和不可用余额), 退款所使用资金对应的资金账户类型
  317. type FundsAccount string
  318. func (e FundsAccount) Ptr() *FundsAccount {
  319. return &e
  320. }
  321. // Enums of FundsAccount
  322. const (
  323. FUNDSACCOUNT_UNSETTLED FundsAccount = "UNSETTLED"
  324. FUNDSACCOUNT_AVAILABLE FundsAccount = "AVAILABLE"
  325. FUNDSACCOUNT_UNAVAILABLE FundsAccount = "UNAVAILABLE"
  326. FUNDSACCOUNT_OPERATION FundsAccount = "OPERATION"
  327. FUNDSACCOUNT_BASIC FundsAccount = "BASIC"
  328. )
  329. // FundsFromItem
  330. type FundsFromItem struct {
  331. FundSource *string `json:"funds_source"`
  332. Amount *int64 `json:"amount"`
  333. }
  334. func (o FundsFromItem) MarshalJSON() ([]byte, error) {
  335. toSerialize := map[string]interface{}{}
  336. if o.FundSource == nil {
  337. return nil, fmt.Errorf("field `FundSource` is required and must be specified in FundsFromItem")
  338. }
  339. toSerialize["funds_source"] = o.FundSource
  340. if o.Amount == nil {
  341. return nil, fmt.Errorf("field `Amount` is required and must be specified in FundsFromItem")
  342. }
  343. toSerialize["amount"] = o.Amount
  344. return json.Marshal(toSerialize)
  345. }
  346. func (o FundsFromItem) String() string {
  347. var ret string
  348. if o.FundSource == nil {
  349. ret += "FundSource:<nil>, "
  350. } else {
  351. ret += fmt.Sprintf("FundSource:%v, ", *o.FundSource)
  352. }
  353. if o.Amount == nil {
  354. ret += "Amount:<nil>"
  355. } else {
  356. ret += fmt.Sprintf("Amount:%v", *o.Amount)
  357. }
  358. return fmt.Sprintf("FundsFromItem{%s}", ret)
  359. }
  360. func (o FundsFromItem) Clone() *FundsFromItem {
  361. ret := FundsFromItem{}
  362. if o.Amount != nil {
  363. ret.Amount = new(int64)
  364. *ret.Amount = *o.Amount
  365. }
  366. return &ret
  367. }
  368. // GoodsDetail
  369. type GoodsDetail struct {
  370. // 由半角的大小写字母、数字、中划线、下划线中的一种或几种组成
  371. MerchantGoodsId *string `json:"merchant_goods_id"`
  372. // 微信支付定义的统一商品编号(没有可不传)
  373. WechatpayGoodsId *string `json:"wechatpay_goods_id,omitempty"`
  374. // 商品的实际名称
  375. GoodsName *string `json:"goods_name,omitempty"`
  376. // 商品单价金额,单位为分
  377. UnitPrice *int64 `json:"unit_price"`
  378. // 商品退款金额,单位为分
  379. RefundAmount *int64 `json:"refund_amount"`
  380. // 对应商品的退货数量
  381. RefundQuantity *int64 `json:"refund_quantity"`
  382. }
  383. func (o GoodsDetail) MarshalJSON() ([]byte, error) {
  384. toSerialize := map[string]interface{}{}
  385. if o.MerchantGoodsId == nil {
  386. return nil, fmt.Errorf("field `MerchantGoodsId` is required and must be specified in GoodsDetail")
  387. }
  388. toSerialize["merchant_goods_id"] = o.MerchantGoodsId
  389. if o.WechatpayGoodsId != nil {
  390. toSerialize["wechatpay_goods_id"] = o.WechatpayGoodsId
  391. }
  392. if o.GoodsName != nil {
  393. toSerialize["goods_name"] = o.GoodsName
  394. }
  395. if o.UnitPrice == nil {
  396. return nil, fmt.Errorf("field `UnitPrice` is required and must be specified in GoodsDetail")
  397. }
  398. toSerialize["unit_price"] = o.UnitPrice
  399. if o.RefundAmount == nil {
  400. return nil, fmt.Errorf("field `RefundAmount` is required and must be specified in GoodsDetail")
  401. }
  402. toSerialize["refund_amount"] = o.RefundAmount
  403. if o.RefundQuantity == nil {
  404. return nil, fmt.Errorf("field `RefundQuantity` is required and must be specified in GoodsDetail")
  405. }
  406. toSerialize["refund_quantity"] = o.RefundQuantity
  407. return json.Marshal(toSerialize)
  408. }
  409. func (o GoodsDetail) String() string {
  410. var ret string
  411. if o.MerchantGoodsId == nil {
  412. ret += "MerchantGoodsId:<nil>, "
  413. } else {
  414. ret += fmt.Sprintf("MerchantGoodsId:%v, ", *o.MerchantGoodsId)
  415. }
  416. if o.WechatpayGoodsId == nil {
  417. ret += "WechatpayGoodsId:<nil>, "
  418. } else {
  419. ret += fmt.Sprintf("WechatpayGoodsId:%v, ", *o.WechatpayGoodsId)
  420. }
  421. if o.GoodsName == nil {
  422. ret += "GoodsName:<nil>, "
  423. } else {
  424. ret += fmt.Sprintf("GoodsName:%v, ", *o.GoodsName)
  425. }
  426. if o.UnitPrice == nil {
  427. ret += "UnitPrice:<nil>, "
  428. } else {
  429. ret += fmt.Sprintf("UnitPrice:%v, ", *o.UnitPrice)
  430. }
  431. if o.RefundAmount == nil {
  432. ret += "RefundAmount:<nil>, "
  433. } else {
  434. ret += fmt.Sprintf("RefundAmount:%v, ", *o.RefundAmount)
  435. }
  436. if o.RefundQuantity == nil {
  437. ret += "RefundQuantity:<nil>"
  438. } else {
  439. ret += fmt.Sprintf("RefundQuantity:%v", *o.RefundQuantity)
  440. }
  441. return fmt.Sprintf("GoodsDetail{%s}", ret)
  442. }
  443. func (o GoodsDetail) Clone() *GoodsDetail {
  444. ret := GoodsDetail{}
  445. if o.MerchantGoodsId != nil {
  446. ret.MerchantGoodsId = new(string)
  447. *ret.MerchantGoodsId = *o.MerchantGoodsId
  448. }
  449. if o.WechatpayGoodsId != nil {
  450. ret.WechatpayGoodsId = new(string)
  451. *ret.WechatpayGoodsId = *o.WechatpayGoodsId
  452. }
  453. if o.GoodsName != nil {
  454. ret.GoodsName = new(string)
  455. *ret.GoodsName = *o.GoodsName
  456. }
  457. if o.UnitPrice != nil {
  458. ret.UnitPrice = new(int64)
  459. *ret.UnitPrice = *o.UnitPrice
  460. }
  461. if o.RefundAmount != nil {
  462. ret.RefundAmount = new(int64)
  463. *ret.RefundAmount = *o.RefundAmount
  464. }
  465. if o.RefundQuantity != nil {
  466. ret.RefundQuantity = new(int64)
  467. *ret.RefundQuantity = *o.RefundQuantity
  468. }
  469. return &ret
  470. }
  471. // Promotion
  472. type Promotion struct {
  473. // 券或者立减优惠id
  474. PromotionId *string `json:"promotion_id"`
  475. // 枚举值: - GLOBAL- 全场代金券 - SINGLE- 单品优惠 * `GLOBAL` - 全场代金券 * `SINGLE` - 单品优惠
  476. Scope *Scope `json:"scope"`
  477. // 枚举值: - COUPON- 代金券,需要走结算资金的充值型代金券 - DISCOUNT- 优惠券,不走结算资金的免充值型优惠券 * `COUPON` - 代金券 * `DISCOUNT` - 优惠券
  478. Type *Type `json:"type"`
  479. // 用户享受优惠的金额(优惠券面额=微信出资金额+商家出资金额+其他出资方金额 ),单位为分
  480. Amount *int64 `json:"amount"`
  481. // 优惠退款金额<=退款金额,退款金额-代金券或立减优惠退款金额为用户支付的现金,说明详见代金券或立减优惠,单位为分
  482. RefundAmount *int64 `json:"refund_amount"`
  483. // 优惠商品发生退款时返回商品信息
  484. GoodsDetail []GoodsDetail `json:"goods_detail,omitempty"`
  485. }
  486. func (o Promotion) MarshalJSON() ([]byte, error) {
  487. toSerialize := map[string]interface{}{}
  488. if o.PromotionId == nil {
  489. return nil, fmt.Errorf("field `PromotionId` is required and must be specified in Promotion")
  490. }
  491. toSerialize["promotion_id"] = o.PromotionId
  492. if o.Scope == nil {
  493. return nil, fmt.Errorf("field `Scope` is required and must be specified in Promotion")
  494. }
  495. toSerialize["scope"] = o.Scope
  496. if o.Type == nil {
  497. return nil, fmt.Errorf("field `Type` is required and must be specified in Promotion")
  498. }
  499. toSerialize["type"] = o.Type
  500. if o.Amount == nil {
  501. return nil, fmt.Errorf("field `Amount` is required and must be specified in Promotion")
  502. }
  503. toSerialize["amount"] = o.Amount
  504. if o.RefundAmount == nil {
  505. return nil, fmt.Errorf("field `RefundAmount` is required and must be specified in Promotion")
  506. }
  507. toSerialize["refund_amount"] = o.RefundAmount
  508. if o.GoodsDetail != nil {
  509. toSerialize["goods_detail"] = o.GoodsDetail
  510. }
  511. return json.Marshal(toSerialize)
  512. }
  513. func (o Promotion) String() string {
  514. var ret string
  515. if o.PromotionId == nil {
  516. ret += "PromotionId:<nil>, "
  517. } else {
  518. ret += fmt.Sprintf("PromotionId:%v, ", *o.PromotionId)
  519. }
  520. if o.Scope == nil {
  521. ret += "Scope:<nil>, "
  522. } else {
  523. ret += fmt.Sprintf("Scope:%v, ", *o.Scope)
  524. }
  525. if o.Type == nil {
  526. ret += "Type:<nil>, "
  527. } else {
  528. ret += fmt.Sprintf("Type:%v, ", *o.Type)
  529. }
  530. if o.Amount == nil {
  531. ret += "Amount:<nil>, "
  532. } else {
  533. ret += fmt.Sprintf("Amount:%v, ", *o.Amount)
  534. }
  535. if o.RefundAmount == nil {
  536. ret += "RefundAmount:<nil>, "
  537. } else {
  538. ret += fmt.Sprintf("RefundAmount:%v, ", *o.RefundAmount)
  539. }
  540. ret += fmt.Sprintf("GoodsDetail:%v", o.GoodsDetail)
  541. return fmt.Sprintf("Promotion{%s}", ret)
  542. }
  543. func (o Promotion) Clone() *Promotion {
  544. ret := Promotion{}
  545. if o.PromotionId != nil {
  546. ret.PromotionId = new(string)
  547. *ret.PromotionId = *o.PromotionId
  548. }
  549. if o.Scope != nil {
  550. ret.Scope = new(Scope)
  551. *ret.Scope = *o.Scope
  552. }
  553. if o.Type != nil {
  554. ret.Type = new(Type)
  555. *ret.Type = *o.Type
  556. }
  557. if o.Amount != nil {
  558. ret.Amount = new(int64)
  559. *ret.Amount = *o.Amount
  560. }
  561. if o.RefundAmount != nil {
  562. ret.RefundAmount = new(int64)
  563. *ret.RefundAmount = *o.RefundAmount
  564. }
  565. if o.GoodsDetail != nil {
  566. ret.GoodsDetail = make([]GoodsDetail, len(o.GoodsDetail))
  567. for i, item := range o.GoodsDetail {
  568. ret.GoodsDetail[i] = *item.Clone()
  569. }
  570. }
  571. return &ret
  572. }
  573. // QueryByOutRefundNoRequest
  574. type QueryByOutRefundNoRequest struct {
  575. // 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
  576. OutRefundNo *string `json:"out_refund_no"`
  577. // 子商户的商户号,由微信支付生成并下发。服务商模式下必须传递此参数
  578. SubMchid *string `json:"sub_mchid,omitempty"`
  579. }
  580. func (o QueryByOutRefundNoRequest) MarshalJSON() ([]byte, error) {
  581. toSerialize := map[string]interface{}{}
  582. if o.OutRefundNo == nil {
  583. return nil, fmt.Errorf("field `OutRefundNo` is required and must be specified in QueryByOutRefundNoRequest")
  584. }
  585. toSerialize["out_refund_no"] = o.OutRefundNo
  586. if o.SubMchid != nil {
  587. toSerialize["sub_mchid"] = o.SubMchid
  588. }
  589. return json.Marshal(toSerialize)
  590. }
  591. func (o QueryByOutRefundNoRequest) String() string {
  592. var ret string
  593. if o.OutRefundNo == nil {
  594. ret += "OutRefundNo:<nil>, "
  595. } else {
  596. ret += fmt.Sprintf("OutRefundNo:%v, ", *o.OutRefundNo)
  597. }
  598. if o.SubMchid == nil {
  599. ret += "SubMchid:<nil>"
  600. } else {
  601. ret += fmt.Sprintf("SubMchid:%v", *o.SubMchid)
  602. }
  603. return fmt.Sprintf("QueryByOutRefundNoRequest{%s}", ret)
  604. }
  605. func (o QueryByOutRefundNoRequest) Clone() *QueryByOutRefundNoRequest {
  606. ret := QueryByOutRefundNoRequest{}
  607. if o.OutRefundNo != nil {
  608. ret.OutRefundNo = new(string)
  609. *ret.OutRefundNo = *o.OutRefundNo
  610. }
  611. if o.SubMchid != nil {
  612. ret.SubMchid = new(string)
  613. *ret.SubMchid = *o.SubMchid
  614. }
  615. return &ret
  616. }
  617. // Refund
  618. type Refund struct {
  619. // 微信支付退款号
  620. RefundId *string `json:"refund_id"`
  621. // 商户系统内部的退款单号,商户系统内部唯一,只能是数字、大小写字母_-|*@ ,同一退款单号多次请求只退一笔。
  622. OutRefundNo *string `json:"out_refund_no"`
  623. // 微信支付交易订单号
  624. TransactionId *string `json:"transaction_id"`
  625. // 原支付交易对应的商户订单号
  626. OutTradeNo *string `json:"out_trade_no"`
  627. Reason *string `json:"reason,omitempty"`
  628. Source *string `json:"source,omitempty"`
  629. FundsAccount *FundsAccount `json:"funds_account,omitempty"`
  630. // 金额详细信息
  631. Amount *Amount `json:"amount"`
  632. // 优惠退款信息
  633. PromotionDetail []Promotion `json:"promotion_detail,omitempty"`
  634. MchId *string `json:"mch_id,omitempty"`
  635. AppId *string `json:"app_id,omitempty"`
  636. }
  637. func (o Refund) MarshalJSON() ([]byte, error) {
  638. toSerialize := map[string]interface{}{}
  639. if o.RefundId == nil {
  640. return nil, fmt.Errorf("field `RefundId` is required and must be specified in Refund")
  641. }
  642. toSerialize["refund_id"] = o.RefundId
  643. if o.OutRefundNo == nil {
  644. return nil, fmt.Errorf("field `OutRefundNo` is required and must be specified in Refund")
  645. }
  646. toSerialize["out_refund_no"] = o.OutRefundNo
  647. if o.TransactionId == nil {
  648. return nil, fmt.Errorf("field `TransactionId` is required and must be specified in Refund")
  649. }
  650. toSerialize["transaction_id"] = o.TransactionId
  651. if o.OutTradeNo == nil {
  652. return nil, fmt.Errorf("field `OutTradeNo` is required and must be specified in Refund")
  653. }
  654. toSerialize["out_trade_no"] = o.OutTradeNo
  655. if o.FundsAccount != nil {
  656. toSerialize["funds_account"] = o.FundsAccount
  657. }
  658. if o.Amount == nil {
  659. return nil, fmt.Errorf("field `Amount` is required and must be specified in Refund")
  660. }
  661. toSerialize["amount"] = o.Amount
  662. if o.PromotionDetail != nil {
  663. toSerialize["promotion_detail"] = o.PromotionDetail
  664. }
  665. return json.Marshal(toSerialize)
  666. }
  667. func (o Refund) String() string {
  668. var ret string
  669. if o.RefundId == nil {
  670. ret += "RefundId:<nil>, "
  671. } else {
  672. ret += fmt.Sprintf("RefundId:%v, ", *o.RefundId)
  673. }
  674. if o.OutRefundNo == nil {
  675. ret += "OutRefundNo:<nil>, "
  676. } else {
  677. ret += fmt.Sprintf("OutRefundNo:%v, ", *o.OutRefundNo)
  678. }
  679. if o.TransactionId == nil {
  680. ret += "TransactionId:<nil>, "
  681. } else {
  682. ret += fmt.Sprintf("TransactionId:%v, ", *o.TransactionId)
  683. }
  684. if o.OutTradeNo == nil {
  685. ret += "OutTradeNo:<nil>, "
  686. } else {
  687. ret += fmt.Sprintf("OutTradeNo:%v, ", *o.OutTradeNo)
  688. }
  689. if o.FundsAccount == nil {
  690. ret += "FundsAccount:<nil>, "
  691. } else {
  692. ret += fmt.Sprintf("FundsAccount:%v, ", *o.FundsAccount)
  693. }
  694. ret += fmt.Sprintf("Amount:%v, ", o.Amount)
  695. ret += fmt.Sprintf("PromotionDetail:%v", o.PromotionDetail)
  696. return fmt.Sprintf("Refund{%s}", ret)
  697. }
  698. func (o Refund) Clone() *Refund {
  699. ret := Refund{}
  700. if o.RefundId != nil {
  701. ret.RefundId = new(string)
  702. *ret.RefundId = *o.RefundId
  703. }
  704. if o.OutRefundNo != nil {
  705. ret.OutRefundNo = new(string)
  706. *ret.OutRefundNo = *o.OutRefundNo
  707. }
  708. if o.TransactionId != nil {
  709. ret.TransactionId = new(string)
  710. *ret.TransactionId = *o.TransactionId
  711. }
  712. if o.OutTradeNo != nil {
  713. ret.OutTradeNo = new(string)
  714. *ret.OutTradeNo = *o.OutTradeNo
  715. }
  716. if o.FundsAccount != nil {
  717. ret.FundsAccount = new(FundsAccount)
  718. *ret.FundsAccount = *o.FundsAccount
  719. }
  720. if o.Amount != nil {
  721. ret.Amount = o.Amount.Clone()
  722. }
  723. if o.PromotionDetail != nil {
  724. ret.PromotionDetail = make([]Promotion, len(o.PromotionDetail))
  725. for i, item := range o.PromotionDetail {
  726. ret.PromotionDetail[i] = *item.Clone()
  727. }
  728. }
  729. return &ret
  730. }
  731. // ReqFundsAccount * `AVAILABLE` - 可用余额, 仅对老资金流商户适用,指定从可用余额账户出资
  732. type ReqFundsAccount string
  733. func (e ReqFundsAccount) Ptr() *ReqFundsAccount {
  734. return &e
  735. }
  736. // Enums of ReqFundsAccount
  737. const (
  738. REQFUNDSACCOUNT_AVAILABLE ReqFundsAccount = "AVAILABLE"
  739. )
  740. // Scope * `GLOBAL` - 全场代金券, 全场优惠类型 * `SINGLE` - 单品优惠, 单品优惠类型
  741. type Scope string
  742. func (e Scope) Ptr() *Scope {
  743. return &e
  744. }
  745. // Enums of Scope
  746. const (
  747. SCOPE_GLOBAL Scope = "GLOBAL"
  748. SCOPE_SINGLE Scope = "SINGLE"
  749. )
  750. // Status * `SUCCESS` - 退款成功, 退款状态 * `CLOSED` - 退款关闭, 退款状态 * `PROCESSING` - 退款处理中, 退款状态 * `ABNORMAL` - 退款异常, 退款状态
  751. type Status string
  752. func (e Status) Ptr() *Status {
  753. return &e
  754. }
  755. // Enums of Status
  756. const (
  757. STATUS_SUCCESS Status = "SUCCESS"
  758. STATUS_CLOSED Status = "CLOSED"
  759. STATUS_PROCESSING Status = "PROCESSING"
  760. STATUS_ABNORMAL Status = "ABNORMAL"
  761. )
  762. // Type * `COUPON` - 代金券, 代金券类型,需要走结算资金的充值型代金券 * `DISCOUNT` - 优惠券, 优惠券类型,不走结算资金的免充值型优惠券
  763. type Type string
  764. func (e Type) Ptr() *Type {
  765. return &e
  766. }
  767. // Enums of Type
  768. const (
  769. TYPE_COUPON Type = "COUPON"
  770. TYPE_DISCOUNT Type = "DISCOUNT"
  771. )