models.go 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. //
  3. // 微信支付直连商户基础支付
  4. //
  5. // 微信支付 API v3 直连商户基础支付
  6. //
  7. // API version: 1.2.3
  8. // Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
  9. package payments
  10. import (
  11. "encoding/json"
  12. "fmt"
  13. )
  14. // PromotionDetail
  15. type PromotionDetail struct {
  16. // 券ID
  17. CouponId *string `json:"coupon_id,omitempty"`
  18. // 优惠名称
  19. Name *string `json:"name,omitempty"`
  20. // GLOBAL:全场代金券;SINGLE:单品优惠
  21. Scope *string `json:"scope,omitempty"`
  22. // CASH:充值;NOCASH:预充值。
  23. Type *string `json:"type,omitempty"`
  24. // 优惠券面额
  25. Amount *int64 `json:"amount,omitempty"`
  26. // 活动ID,批次ID
  27. StockId *string `json:"stock_id,omitempty"`
  28. // 单位为分
  29. WechatpayContribute *int64 `json:"wechatpay_contribute,omitempty"`
  30. // 单位为分
  31. MerchantContribute *int64 `json:"merchant_contribute,omitempty"`
  32. // 单位为分
  33. OtherContribute *int64 `json:"other_contribute,omitempty"`
  34. // CNY:人民币,境内商户号仅支持人民币。
  35. Currency *string `json:"currency,omitempty"`
  36. GoodsDetail []PromotionGoodsDetail `json:"goods_detail,omitempty"`
  37. }
  38. func (o PromotionDetail) MarshalJSON() ([]byte, error) {
  39. toSerialize := map[string]interface{}{}
  40. if o.CouponId != nil {
  41. toSerialize["coupon_id"] = o.CouponId
  42. }
  43. if o.Name != nil {
  44. toSerialize["name"] = o.Name
  45. }
  46. if o.Scope != nil {
  47. toSerialize["scope"] = o.Scope
  48. }
  49. if o.Type != nil {
  50. toSerialize["type"] = o.Type
  51. }
  52. if o.Amount != nil {
  53. toSerialize["amount"] = o.Amount
  54. }
  55. if o.StockId != nil {
  56. toSerialize["stock_id"] = o.StockId
  57. }
  58. if o.WechatpayContribute != nil {
  59. toSerialize["wechatpay_contribute"] = o.WechatpayContribute
  60. }
  61. if o.MerchantContribute != nil {
  62. toSerialize["merchant_contribute"] = o.MerchantContribute
  63. }
  64. if o.OtherContribute != nil {
  65. toSerialize["other_contribute"] = o.OtherContribute
  66. }
  67. if o.Currency != nil {
  68. toSerialize["currency"] = o.Currency
  69. }
  70. if o.GoodsDetail != nil {
  71. toSerialize["goods_detail"] = o.GoodsDetail
  72. }
  73. return json.Marshal(toSerialize)
  74. }
  75. func (o PromotionDetail) String() string {
  76. var ret string
  77. if o.CouponId == nil {
  78. ret += "CouponId:<nil>, "
  79. } else {
  80. ret += fmt.Sprintf("CouponId:%v, ", *o.CouponId)
  81. }
  82. if o.Name == nil {
  83. ret += "Name:<nil>, "
  84. } else {
  85. ret += fmt.Sprintf("Name:%v, ", *o.Name)
  86. }
  87. if o.Scope == nil {
  88. ret += "Scope:<nil>, "
  89. } else {
  90. ret += fmt.Sprintf("Scope:%v, ", *o.Scope)
  91. }
  92. if o.Type == nil {
  93. ret += "Type:<nil>, "
  94. } else {
  95. ret += fmt.Sprintf("Type:%v, ", *o.Type)
  96. }
  97. if o.Amount == nil {
  98. ret += "Amount:<nil>, "
  99. } else {
  100. ret += fmt.Sprintf("Amount:%v, ", *o.Amount)
  101. }
  102. if o.StockId == nil {
  103. ret += "StockId:<nil>, "
  104. } else {
  105. ret += fmt.Sprintf("StockId:%v, ", *o.StockId)
  106. }
  107. if o.WechatpayContribute == nil {
  108. ret += "WechatpayContribute:<nil>, "
  109. } else {
  110. ret += fmt.Sprintf("WechatpayContribute:%v, ", *o.WechatpayContribute)
  111. }
  112. if o.MerchantContribute == nil {
  113. ret += "MerchantContribute:<nil>, "
  114. } else {
  115. ret += fmt.Sprintf("MerchantContribute:%v, ", *o.MerchantContribute)
  116. }
  117. if o.OtherContribute == nil {
  118. ret += "OtherContribute:<nil>, "
  119. } else {
  120. ret += fmt.Sprintf("OtherContribute:%v, ", *o.OtherContribute)
  121. }
  122. if o.Currency == nil {
  123. ret += "Currency:<nil>, "
  124. } else {
  125. ret += fmt.Sprintf("Currency:%v, ", *o.Currency)
  126. }
  127. ret += fmt.Sprintf("GoodsDetail:%v", o.GoodsDetail)
  128. return fmt.Sprintf("PromotionDetail{%s}", ret)
  129. }
  130. func (o PromotionDetail) Clone() *PromotionDetail {
  131. ret := PromotionDetail{}
  132. if o.CouponId != nil {
  133. ret.CouponId = new(string)
  134. *ret.CouponId = *o.CouponId
  135. }
  136. if o.Name != nil {
  137. ret.Name = new(string)
  138. *ret.Name = *o.Name
  139. }
  140. if o.Scope != nil {
  141. ret.Scope = new(string)
  142. *ret.Scope = *o.Scope
  143. }
  144. if o.Type != nil {
  145. ret.Type = new(string)
  146. *ret.Type = *o.Type
  147. }
  148. if o.Amount != nil {
  149. ret.Amount = new(int64)
  150. *ret.Amount = *o.Amount
  151. }
  152. if o.StockId != nil {
  153. ret.StockId = new(string)
  154. *ret.StockId = *o.StockId
  155. }
  156. if o.WechatpayContribute != nil {
  157. ret.WechatpayContribute = new(int64)
  158. *ret.WechatpayContribute = *o.WechatpayContribute
  159. }
  160. if o.MerchantContribute != nil {
  161. ret.MerchantContribute = new(int64)
  162. *ret.MerchantContribute = *o.MerchantContribute
  163. }
  164. if o.OtherContribute != nil {
  165. ret.OtherContribute = new(int64)
  166. *ret.OtherContribute = *o.OtherContribute
  167. }
  168. if o.Currency != nil {
  169. ret.Currency = new(string)
  170. *ret.Currency = *o.Currency
  171. }
  172. if o.GoodsDetail != nil {
  173. ret.GoodsDetail = make([]PromotionGoodsDetail, len(o.GoodsDetail))
  174. for i, item := range o.GoodsDetail {
  175. ret.GoodsDetail[i] = *item.Clone()
  176. }
  177. }
  178. return &ret
  179. }
  180. // PromotionGoodsDetail
  181. type PromotionGoodsDetail struct {
  182. // 商品编码
  183. GoodsId *string `json:"goods_id"`
  184. // 商品数量
  185. Quantity *int64 `json:"quantity"`
  186. // 商品价格
  187. UnitPrice *int64 `json:"unit_price"`
  188. // 商品优惠金额
  189. DiscountAmount *int64 `json:"discount_amount"`
  190. // 商品备注
  191. GoodsRemark *string `json:"goods_remark,omitempty"`
  192. }
  193. func (o PromotionGoodsDetail) MarshalJSON() ([]byte, error) {
  194. toSerialize := map[string]interface{}{}
  195. if o.GoodsId == nil {
  196. return nil, fmt.Errorf("field `GoodsId` is required and must be specified in PromotionGoodsDetail")
  197. }
  198. toSerialize["goods_id"] = o.GoodsId
  199. if o.Quantity == nil {
  200. return nil, fmt.Errorf("field `Quantity` is required and must be specified in PromotionGoodsDetail")
  201. }
  202. toSerialize["quantity"] = o.Quantity
  203. if o.UnitPrice == nil {
  204. return nil, fmt.Errorf("field `UnitPrice` is required and must be specified in PromotionGoodsDetail")
  205. }
  206. toSerialize["unit_price"] = o.UnitPrice
  207. if o.DiscountAmount == nil {
  208. return nil, fmt.Errorf("field `DiscountAmount` is required and must be specified in PromotionGoodsDetail")
  209. }
  210. toSerialize["discount_amount"] = o.DiscountAmount
  211. if o.GoodsRemark != nil {
  212. toSerialize["goods_remark"] = o.GoodsRemark
  213. }
  214. return json.Marshal(toSerialize)
  215. }
  216. func (o PromotionGoodsDetail) String() string {
  217. var ret string
  218. if o.GoodsId == nil {
  219. ret += "GoodsId:<nil>, "
  220. } else {
  221. ret += fmt.Sprintf("GoodsId:%v, ", *o.GoodsId)
  222. }
  223. if o.Quantity == nil {
  224. ret += "Quantity:<nil>, "
  225. } else {
  226. ret += fmt.Sprintf("Quantity:%v, ", *o.Quantity)
  227. }
  228. if o.UnitPrice == nil {
  229. ret += "UnitPrice:<nil>, "
  230. } else {
  231. ret += fmt.Sprintf("UnitPrice:%v, ", *o.UnitPrice)
  232. }
  233. if o.DiscountAmount == nil {
  234. ret += "DiscountAmount:<nil>, "
  235. } else {
  236. ret += fmt.Sprintf("DiscountAmount:%v, ", *o.DiscountAmount)
  237. }
  238. if o.GoodsRemark == nil {
  239. ret += "GoodsRemark:<nil>"
  240. } else {
  241. ret += fmt.Sprintf("GoodsRemark:%v", *o.GoodsRemark)
  242. }
  243. return fmt.Sprintf("PromotionGoodsDetail{%s}", ret)
  244. }
  245. func (o PromotionGoodsDetail) Clone() *PromotionGoodsDetail {
  246. ret := PromotionGoodsDetail{}
  247. if o.GoodsId != nil {
  248. ret.GoodsId = new(string)
  249. *ret.GoodsId = *o.GoodsId
  250. }
  251. if o.Quantity != nil {
  252. ret.Quantity = new(int64)
  253. *ret.Quantity = *o.Quantity
  254. }
  255. if o.UnitPrice != nil {
  256. ret.UnitPrice = new(int64)
  257. *ret.UnitPrice = *o.UnitPrice
  258. }
  259. if o.DiscountAmount != nil {
  260. ret.DiscountAmount = new(int64)
  261. *ret.DiscountAmount = *o.DiscountAmount
  262. }
  263. if o.GoodsRemark != nil {
  264. ret.GoodsRemark = new(string)
  265. *ret.GoodsRemark = *o.GoodsRemark
  266. }
  267. return &ret
  268. }
  269. // Transaction
  270. type Transaction struct {
  271. Amount *TransactionAmount `json:"amount,omitempty"`
  272. Appid *string `json:"appid,omitempty"`
  273. Attach *string `json:"attach,omitempty"`
  274. BankType *string `json:"bank_type,omitempty"`
  275. Mchid *string `json:"mchid,omitempty"`
  276. OutTradeNo *string `json:"out_trade_no,omitempty"`
  277. Payer *TransactionPayer `json:"payer,omitempty"`
  278. PromotionDetail []PromotionDetail `json:"promotion_detail,omitempty"`
  279. SuccessTime *string `json:"success_time,omitempty"`
  280. TradeState *string `json:"trade_state,omitempty"`
  281. TradeStateDesc *string `json:"trade_state_desc,omitempty"`
  282. TradeType *string `json:"trade_type,omitempty"`
  283. TransactionId *string `json:"transaction_id,omitempty"`
  284. }
  285. func (o Transaction) MarshalJSON() ([]byte, error) {
  286. toSerialize := map[string]interface{}{}
  287. if o.Amount != nil {
  288. toSerialize["amount"] = o.Amount
  289. }
  290. if o.Appid != nil {
  291. toSerialize["appid"] = o.Appid
  292. }
  293. if o.Attach != nil {
  294. toSerialize["attach"] = o.Attach
  295. }
  296. if o.BankType != nil {
  297. toSerialize["bank_type"] = o.BankType
  298. }
  299. if o.Mchid != nil {
  300. toSerialize["mchid"] = o.Mchid
  301. }
  302. if o.OutTradeNo != nil {
  303. toSerialize["out_trade_no"] = o.OutTradeNo
  304. }
  305. if o.Payer != nil {
  306. toSerialize["payer"] = o.Payer
  307. }
  308. if o.PromotionDetail != nil {
  309. toSerialize["promotion_detail"] = o.PromotionDetail
  310. }
  311. if o.SuccessTime != nil {
  312. toSerialize["success_time"] = o.SuccessTime
  313. }
  314. if o.TradeState != nil {
  315. toSerialize["trade_state"] = o.TradeState
  316. }
  317. if o.TradeStateDesc != nil {
  318. toSerialize["trade_state_desc"] = o.TradeStateDesc
  319. }
  320. if o.TradeType != nil {
  321. toSerialize["trade_type"] = o.TradeType
  322. }
  323. if o.TransactionId != nil {
  324. toSerialize["transaction_id"] = o.TransactionId
  325. }
  326. return json.Marshal(toSerialize)
  327. }
  328. func (o Transaction) String() string {
  329. var ret string
  330. ret += fmt.Sprintf("Amount:%v, ", o.Amount)
  331. if o.Appid == nil {
  332. ret += "Appid:<nil>, "
  333. } else {
  334. ret += fmt.Sprintf("Appid:%v, ", *o.Appid)
  335. }
  336. if o.Attach == nil {
  337. ret += "Attach:<nil>, "
  338. } else {
  339. ret += fmt.Sprintf("Attach:%v, ", *o.Attach)
  340. }
  341. if o.BankType == nil {
  342. ret += "BankType:<nil>, "
  343. } else {
  344. ret += fmt.Sprintf("BankType:%v, ", *o.BankType)
  345. }
  346. if o.Mchid == nil {
  347. ret += "Mchid:<nil>, "
  348. } else {
  349. ret += fmt.Sprintf("Mchid:%v, ", *o.Mchid)
  350. }
  351. if o.OutTradeNo == nil {
  352. ret += "OutTradeNo:<nil>, "
  353. } else {
  354. ret += fmt.Sprintf("OutTradeNo:%v, ", *o.OutTradeNo)
  355. }
  356. ret += fmt.Sprintf("Payer:%v, ", o.Payer)
  357. ret += fmt.Sprintf("PromotionDetail:%v, ", o.PromotionDetail)
  358. if o.SuccessTime == nil {
  359. ret += "SuccessTime:<nil>, "
  360. } else {
  361. ret += fmt.Sprintf("SuccessTime:%v, ", *o.SuccessTime)
  362. }
  363. if o.TradeState == nil {
  364. ret += "TradeState:<nil>, "
  365. } else {
  366. ret += fmt.Sprintf("TradeState:%v, ", *o.TradeState)
  367. }
  368. if o.TradeStateDesc == nil {
  369. ret += "TradeStateDesc:<nil>, "
  370. } else {
  371. ret += fmt.Sprintf("TradeStateDesc:%v, ", *o.TradeStateDesc)
  372. }
  373. if o.TradeType == nil {
  374. ret += "TradeType:<nil>, "
  375. } else {
  376. ret += fmt.Sprintf("TradeType:%v, ", *o.TradeType)
  377. }
  378. if o.TransactionId == nil {
  379. ret += "TransactionId:<nil>"
  380. } else {
  381. ret += fmt.Sprintf("TransactionId:%v", *o.TransactionId)
  382. }
  383. return fmt.Sprintf("Transaction{%s}", ret)
  384. }
  385. func (o Transaction) Clone() *Transaction {
  386. ret := Transaction{}
  387. if o.Amount != nil {
  388. ret.Amount = o.Amount.Clone()
  389. }
  390. if o.Appid != nil {
  391. ret.Appid = new(string)
  392. *ret.Appid = *o.Appid
  393. }
  394. if o.Attach != nil {
  395. ret.Attach = new(string)
  396. *ret.Attach = *o.Attach
  397. }
  398. if o.BankType != nil {
  399. ret.BankType = new(string)
  400. *ret.BankType = *o.BankType
  401. }
  402. if o.Mchid != nil {
  403. ret.Mchid = new(string)
  404. *ret.Mchid = *o.Mchid
  405. }
  406. if o.OutTradeNo != nil {
  407. ret.OutTradeNo = new(string)
  408. *ret.OutTradeNo = *o.OutTradeNo
  409. }
  410. if o.Payer != nil {
  411. ret.Payer = o.Payer.Clone()
  412. }
  413. if o.PromotionDetail != nil {
  414. ret.PromotionDetail = make([]PromotionDetail, len(o.PromotionDetail))
  415. for i, item := range o.PromotionDetail {
  416. ret.PromotionDetail[i] = *item.Clone()
  417. }
  418. }
  419. if o.SuccessTime != nil {
  420. ret.SuccessTime = new(string)
  421. *ret.SuccessTime = *o.SuccessTime
  422. }
  423. if o.TradeState != nil {
  424. ret.TradeState = new(string)
  425. *ret.TradeState = *o.TradeState
  426. }
  427. if o.TradeStateDesc != nil {
  428. ret.TradeStateDesc = new(string)
  429. *ret.TradeStateDesc = *o.TradeStateDesc
  430. }
  431. if o.TradeType != nil {
  432. ret.TradeType = new(string)
  433. *ret.TradeType = *o.TradeType
  434. }
  435. if o.TransactionId != nil {
  436. ret.TransactionId = new(string)
  437. *ret.TransactionId = *o.TransactionId
  438. }
  439. return &ret
  440. }
  441. // TransactionAmount
  442. type TransactionAmount struct {
  443. Currency *string `json:"currency,omitempty"`
  444. PayerCurrency *string `json:"payer_currency,omitempty"`
  445. PayerTotal *int64 `json:"payer_total,omitempty"`
  446. Total *int64 `json:"total,omitempty"`
  447. }
  448. func (o TransactionAmount) MarshalJSON() ([]byte, error) {
  449. toSerialize := map[string]interface{}{}
  450. if o.Currency != nil {
  451. toSerialize["currency"] = o.Currency
  452. }
  453. if o.PayerCurrency != nil {
  454. toSerialize["payer_currency"] = o.PayerCurrency
  455. }
  456. if o.PayerTotal != nil {
  457. toSerialize["payer_total"] = o.PayerTotal
  458. }
  459. if o.Total != nil {
  460. toSerialize["total"] = o.Total
  461. }
  462. return json.Marshal(toSerialize)
  463. }
  464. func (o TransactionAmount) String() string {
  465. var ret string
  466. if o.Currency == nil {
  467. ret += "Currency:<nil>, "
  468. } else {
  469. ret += fmt.Sprintf("Currency:%v, ", *o.Currency)
  470. }
  471. if o.PayerCurrency == nil {
  472. ret += "PayerCurrency:<nil>, "
  473. } else {
  474. ret += fmt.Sprintf("PayerCurrency:%v, ", *o.PayerCurrency)
  475. }
  476. if o.PayerTotal == nil {
  477. ret += "PayerTotal:<nil>, "
  478. } else {
  479. ret += fmt.Sprintf("PayerTotal:%v, ", *o.PayerTotal)
  480. }
  481. if o.Total == nil {
  482. ret += "Total:<nil>"
  483. } else {
  484. ret += fmt.Sprintf("Total:%v", *o.Total)
  485. }
  486. return fmt.Sprintf("TransactionAmount{%s}", ret)
  487. }
  488. func (o TransactionAmount) Clone() *TransactionAmount {
  489. ret := TransactionAmount{}
  490. if o.Currency != nil {
  491. ret.Currency = new(string)
  492. *ret.Currency = *o.Currency
  493. }
  494. if o.PayerCurrency != nil {
  495. ret.PayerCurrency = new(string)
  496. *ret.PayerCurrency = *o.PayerCurrency
  497. }
  498. if o.PayerTotal != nil {
  499. ret.PayerTotal = new(int64)
  500. *ret.PayerTotal = *o.PayerTotal
  501. }
  502. if o.Total != nil {
  503. ret.Total = new(int64)
  504. *ret.Total = *o.Total
  505. }
  506. return &ret
  507. }
  508. // TransactionPayer
  509. type TransactionPayer struct {
  510. Openid *string `json:"openid,omitempty"`
  511. }
  512. func (o TransactionPayer) MarshalJSON() ([]byte, error) {
  513. toSerialize := map[string]interface{}{}
  514. if o.Openid != nil {
  515. toSerialize["openid"] = o.Openid
  516. }
  517. return json.Marshal(toSerialize)
  518. }
  519. func (o TransactionPayer) String() string {
  520. var ret string
  521. if o.Openid == nil {
  522. ret += "Openid:<nil>"
  523. } else {
  524. ret += fmt.Sprintf("Openid:%v", *o.Openid)
  525. }
  526. return fmt.Sprintf("TransactionPayer{%s}", ret)
  527. }
  528. func (o TransactionPayer) Clone() *TransactionPayer {
  529. ret := TransactionPayer{}
  530. if o.Openid != nil {
  531. ret.Openid = new(string)
  532. *ret.Openid = *o.Openid
  533. }
  534. return &ret
  535. }