api_stock.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. //
  3. // 微信支付营销系统开放API
  4. //
  5. // 新增立减金api
  6. //
  7. // API version: 3.4.0
  8. // Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
  9. package cashcoupons
  10. import (
  11. "context"
  12. "fmt"
  13. nethttp "net/http"
  14. neturl "net/url"
  15. "strings"
  16. "git.nanodreamtech.com/sg/wechatpay-go/core"
  17. "git.nanodreamtech.com/sg/wechatpay-go/core/consts"
  18. "git.nanodreamtech.com/sg/wechatpay-go/services"
  19. )
  20. type StockApiService services.Service
  21. // CreateCouponStock 创建代金券批次
  22. //
  23. // 商户通过这个接口创建代金券批次
  24. //
  25. // 前置条件:商户开通了代金券产品权限
  26. //
  27. // 是否支持幂等:是
  28. func (a *StockApiService) CreateCouponStock(ctx context.Context, req CreateCouponStockRequest) (resp *CreateCouponStockResponse, result *core.APIResult, err error) {
  29. var (
  30. localVarHTTPMethod = nethttp.MethodPost
  31. localVarPostBody interface{}
  32. localVarQueryParams neturl.Values
  33. localVarHeaderParams = nethttp.Header{}
  34. )
  35. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/coupon-stocks"
  36. // Make sure All Required Params are properly set
  37. // Setup Body Params
  38. localVarPostBody = req
  39. // Determine the Content-Type Header
  40. localVarHTTPContentTypes := []string{"application/json"}
  41. // Setup Content-Type
  42. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  43. // Perform Http Request
  44. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  45. if err != nil {
  46. return nil, result, err
  47. }
  48. // Extract CreateCouponStockResponse from Http Response
  49. resp = new(CreateCouponStockResponse)
  50. err = core.UnMarshalResponse(result.Response, resp)
  51. if err != nil {
  52. return nil, result, err
  53. }
  54. return resp, result, nil
  55. }
  56. // ListAvailableMerchants 查询代金券可用商户
  57. //
  58. // 查使用代金券业务的商户询代金券可用商户
  59. //
  60. // 接口频率:1000/min
  61. //
  62. // 前置条件:非制券方查询主批次信息以获取发券商户列表,调用方只能查询自己制的批次、自己可发的批次
  63. //
  64. // 是否支持幂等:是
  65. func (a *StockApiService) ListAvailableMerchants(ctx context.Context, req ListAvailableMerchantsRequest) (resp *AvailableMerchantCollection, result *core.APIResult, err error) {
  66. var (
  67. localVarHTTPMethod = nethttp.MethodGet
  68. localVarPostBody interface{}
  69. localVarQueryParams neturl.Values
  70. localVarHeaderParams = nethttp.Header{}
  71. )
  72. // Make sure Path Params are properly set
  73. if req.StockId == nil {
  74. return nil, nil, fmt.Errorf("field `StockId` is required and must be specified in ListAvailableMerchantsRequest")
  75. }
  76. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks/{stock_id}/merchants"
  77. // Build Path with Path Params
  78. localVarPath = strings.Replace(localVarPath, "{"+"stock_id"+"}", neturl.PathEscape(core.ParameterToString(*req.StockId, "")), -1)
  79. // Make sure All Required Params are properly set
  80. if req.Offset == nil {
  81. return nil, nil, fmt.Errorf("field `Offset` is required and must be specified in ListAvailableMerchantsRequest")
  82. }
  83. if req.Limit == nil {
  84. return nil, nil, fmt.Errorf("field `Limit` is required and must be specified in ListAvailableMerchantsRequest")
  85. }
  86. if req.StockCreatorMchid == nil {
  87. return nil, nil, fmt.Errorf("field `StockCreatorMchid` is required and must be specified in ListAvailableMerchantsRequest")
  88. }
  89. // Setup Query Params
  90. localVarQueryParams = neturl.Values{}
  91. localVarQueryParams.Add("offset", core.ParameterToString(*req.Offset, ""))
  92. localVarQueryParams.Add("limit", core.ParameterToString(*req.Limit, ""))
  93. localVarQueryParams.Add("stock_creator_mchid", core.ParameterToString(*req.StockCreatorMchid, ""))
  94. // Determine the Content-Type Header
  95. localVarHTTPContentTypes := []string{}
  96. // Setup Content-Type
  97. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  98. // Perform Http Request
  99. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  100. if err != nil {
  101. return nil, result, err
  102. }
  103. // Extract AvailableMerchantCollection from Http Response
  104. resp = new(AvailableMerchantCollection)
  105. err = core.UnMarshalResponse(result.Response, resp)
  106. if err != nil {
  107. return nil, result, err
  108. }
  109. return resp, result, nil
  110. }
  111. // ListAvailableSingleitems 查询可核销商品编码
  112. //
  113. // 查询可核销商品编码
  114. //
  115. // 接口频率:600/min
  116. //
  117. // 前置条件:调用方只能查询自己制的批次、自己可发的批次的可核销商品编码
  118. //
  119. // 是否支持幂等:是
  120. func (a *StockApiService) ListAvailableSingleitems(ctx context.Context, req ListAvailableSingleitemsRequest) (resp *AvailableSingleitemCollection, result *core.APIResult, err error) {
  121. var (
  122. localVarHTTPMethod = nethttp.MethodGet
  123. localVarPostBody interface{}
  124. localVarQueryParams neturl.Values
  125. localVarHeaderParams = nethttp.Header{}
  126. )
  127. // Make sure Path Params are properly set
  128. if req.StockId == nil {
  129. return nil, nil, fmt.Errorf("field `StockId` is required and must be specified in ListAvailableSingleitemsRequest")
  130. }
  131. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks/{stock_id}/items"
  132. // Build Path with Path Params
  133. localVarPath = strings.Replace(localVarPath, "{"+"stock_id"+"}", neturl.PathEscape(core.ParameterToString(*req.StockId, "")), -1)
  134. // Make sure All Required Params are properly set
  135. if req.Offset == nil {
  136. return nil, nil, fmt.Errorf("field `Offset` is required and must be specified in ListAvailableSingleitemsRequest")
  137. }
  138. if req.Limit == nil {
  139. return nil, nil, fmt.Errorf("field `Limit` is required and must be specified in ListAvailableSingleitemsRequest")
  140. }
  141. if req.StockCreatorMchid == nil {
  142. return nil, nil, fmt.Errorf("field `StockCreatorMchid` is required and must be specified in ListAvailableSingleitemsRequest")
  143. }
  144. // Setup Query Params
  145. localVarQueryParams = neturl.Values{}
  146. localVarQueryParams.Add("offset", core.ParameterToString(*req.Offset, ""))
  147. localVarQueryParams.Add("limit", core.ParameterToString(*req.Limit, ""))
  148. localVarQueryParams.Add("stock_creator_mchid", core.ParameterToString(*req.StockCreatorMchid, ""))
  149. // Determine the Content-Type Header
  150. localVarHTTPContentTypes := []string{}
  151. // Setup Content-Type
  152. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  153. // Perform Http Request
  154. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  155. if err != nil {
  156. return nil, result, err
  157. }
  158. // Extract AvailableSingleitemCollection from Http Response
  159. resp = new(AvailableSingleitemCollection)
  160. err = core.UnMarshalResponse(result.Response, resp)
  161. if err != nil {
  162. return nil, result, err
  163. }
  164. return resp, result, nil
  165. }
  166. // ListStocks 条件查询批次列表
  167. //
  168. // 商户通过这个接口可以查询创建的批次列表
  169. //
  170. // 接口频率:1000/s
  171. //
  172. // 前置条件:商户开通了代金券产品权限,并创建过代金券
  173. func (a *StockApiService) ListStocks(ctx context.Context, req ListStocksRequest) (resp *StockCollection, result *core.APIResult, err error) {
  174. var (
  175. localVarHTTPMethod = nethttp.MethodGet
  176. localVarPostBody interface{}
  177. localVarQueryParams neturl.Values
  178. localVarHeaderParams = nethttp.Header{}
  179. )
  180. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks"
  181. // Make sure All Required Params are properly set
  182. if req.Offset == nil {
  183. return nil, nil, fmt.Errorf("field `Offset` is required and must be specified in ListStocksRequest")
  184. }
  185. if req.Limit == nil {
  186. return nil, nil, fmt.Errorf("field `Limit` is required and must be specified in ListStocksRequest")
  187. }
  188. if req.StockCreatorMchid == nil {
  189. return nil, nil, fmt.Errorf("field `StockCreatorMchid` is required and must be specified in ListStocksRequest")
  190. }
  191. // Setup Query Params
  192. localVarQueryParams = neturl.Values{}
  193. localVarQueryParams.Add("offset", core.ParameterToString(*req.Offset, ""))
  194. localVarQueryParams.Add("limit", core.ParameterToString(*req.Limit, ""))
  195. localVarQueryParams.Add("stock_creator_mchid", core.ParameterToString(*req.StockCreatorMchid, ""))
  196. if req.CreateStartTime != nil {
  197. localVarQueryParams.Add("create_start_time", core.ParameterToString(*req.CreateStartTime, ""))
  198. }
  199. if req.CreateEndTime != nil {
  200. localVarQueryParams.Add("create_end_time", core.ParameterToString(*req.CreateEndTime, ""))
  201. }
  202. if req.Status != nil {
  203. localVarQueryParams.Add("status", core.ParameterToString(*req.Status, ""))
  204. }
  205. // Determine the Content-Type Header
  206. localVarHTTPContentTypes := []string{}
  207. // Setup Content-Type
  208. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  209. // Perform Http Request
  210. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  211. if err != nil {
  212. return nil, result, err
  213. }
  214. // Extract StockCollection from Http Response
  215. resp = new(StockCollection)
  216. err = core.UnMarshalResponse(result.Response, resp)
  217. if err != nil {
  218. return nil, result, err
  219. }
  220. return resp, result, nil
  221. }
  222. // PauseStock 暂停批次
  223. //
  224. // 通过此接口暂停代金券批次
  225. //
  226. // 接口频率:1000/min
  227. //
  228. // 前置条件:成功激活代金券批次
  229. //
  230. // 注意事项:
  231. //
  232. // 1. 暂停后,该代金券批次暂停发放,用户无法通过任何渠道再领取该批次的券
  233. func (a *StockApiService) PauseStock(ctx context.Context, req PauseStockRequest) (resp *PauseStockResponse, result *core.APIResult, err error) {
  234. var (
  235. localVarHTTPMethod = nethttp.MethodPost
  236. localVarPostBody interface{}
  237. localVarQueryParams neturl.Values
  238. localVarHeaderParams = nethttp.Header{}
  239. )
  240. // Make sure Path Params are properly set
  241. if req.StockId == nil {
  242. return nil, nil, fmt.Errorf("field `StockId` is required and must be specified in PauseStockRequest")
  243. }
  244. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks/{stock_id}/pause"
  245. // Build Path with Path Params
  246. localVarPath = strings.Replace(localVarPath, "{"+"stock_id"+"}", neturl.PathEscape(core.ParameterToString(*req.StockId, "")), -1)
  247. // Make sure All Required Params are properly set
  248. // Setup Body Params
  249. localVarPostBody = &PauseStockBody{
  250. StockCreatorMchid: req.StockCreatorMchid,
  251. }
  252. // Determine the Content-Type Header
  253. localVarHTTPContentTypes := []string{"application/json"}
  254. // Setup Content-Type
  255. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  256. // Perform Http Request
  257. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  258. if err != nil {
  259. return nil, result, err
  260. }
  261. // Extract PauseStockResponse from Http Response
  262. resp = new(PauseStockResponse)
  263. err = core.UnMarshalResponse(result.Response, resp)
  264. if err != nil {
  265. return nil, result, err
  266. }
  267. return resp, result, nil
  268. }
  269. // QueryStock 查询批次详情
  270. //
  271. // 查询代金券批次详情信息
  272. //
  273. // 接口频率:500qps
  274. //
  275. // 前置条件:已创建代金券批次
  276. //
  277. // 注意:
  278. //
  279. // 1. 该接口支持批次创建商户号与批次发放商户调用
  280. func (a *StockApiService) QueryStock(ctx context.Context, req QueryStockRequest) (resp *Stock, result *core.APIResult, err error) {
  281. var (
  282. localVarHTTPMethod = nethttp.MethodGet
  283. localVarPostBody interface{}
  284. localVarQueryParams neturl.Values
  285. localVarHeaderParams = nethttp.Header{}
  286. )
  287. // Make sure Path Params are properly set
  288. if req.StockId == nil {
  289. return nil, nil, fmt.Errorf("field `StockId` is required and must be specified in QueryStockRequest")
  290. }
  291. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks/{stock_id}"
  292. // Build Path with Path Params
  293. localVarPath = strings.Replace(localVarPath, "{"+"stock_id"+"}", neturl.PathEscape(core.ParameterToString(*req.StockId, "")), -1)
  294. // Make sure All Required Params are properly set
  295. if req.StockCreatorMchid == nil {
  296. return nil, nil, fmt.Errorf("field `StockCreatorMchid` is required and must be specified in QueryStockRequest")
  297. }
  298. // Setup Query Params
  299. localVarQueryParams = neturl.Values{}
  300. localVarQueryParams.Add("stock_creator_mchid", core.ParameterToString(*req.StockCreatorMchid, ""))
  301. // Determine the Content-Type Header
  302. localVarHTTPContentTypes := []string{}
  303. // Setup Content-Type
  304. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  305. // Perform Http Request
  306. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  307. if err != nil {
  308. return nil, result, err
  309. }
  310. // Extract Stock from Http Response
  311. resp = new(Stock)
  312. err = core.UnMarshalResponse(result.Response, resp)
  313. if err != nil {
  314. return nil, result, err
  315. }
  316. return resp, result, nil
  317. }
  318. // RefundFlow 下载批次退款明细
  319. //
  320. // 通过此接口获取指定批次的退款明细数据,包括订单号、单品信息、银行流水号等,用于对账/数据分析
  321. //
  322. // 接口频率:1000/min
  323. //
  324. // 前置条件:批次过期10小时
  325. //
  326. // 注意:
  327. //
  328. // 1. 账单文件的下载地址的有效时间为30s。
  329. // 2. 强烈建议商户将实际账单文件的哈希值和之前从接口获取到的哈希值进行比对,以确认数据的完整性。
  330. // 3. 该接口响应的信息请求头中不包含微信接口响应的签名值,因此需要跳过验签的流程
  331. // 4. 该接口需要活动结束后次日10点才可以下载
  332. // 5. 该接口只能使用创建活动方进行调用”
  333. func (a *StockApiService) RefundFlow(ctx context.Context, req RefundFlowRequest) (resp *RefundFlowResponse, result *core.APIResult, err error) {
  334. var (
  335. localVarHTTPMethod = nethttp.MethodGet
  336. localVarPostBody interface{}
  337. localVarQueryParams neturl.Values
  338. localVarHeaderParams = nethttp.Header{}
  339. )
  340. // Make sure Path Params are properly set
  341. if req.StockId == nil {
  342. return nil, nil, fmt.Errorf("field `StockId` is required and must be specified in RefundFlowRequest")
  343. }
  344. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks/{stock_id}/refund-flow"
  345. // Build Path with Path Params
  346. localVarPath = strings.Replace(localVarPath, "{"+"stock_id"+"}", neturl.PathEscape(core.ParameterToString(*req.StockId, "")), -1)
  347. // Make sure All Required Params are properly set
  348. // Determine the Content-Type Header
  349. localVarHTTPContentTypes := []string{}
  350. // Setup Content-Type
  351. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  352. // Perform Http Request
  353. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  354. if err != nil {
  355. return nil, result, err
  356. }
  357. // Extract RefundFlowResponse from Http Response
  358. resp = new(RefundFlowResponse)
  359. err = core.UnMarshalResponse(result.Response, resp)
  360. if err != nil {
  361. return nil, result, err
  362. }
  363. return resp, result, nil
  364. }
  365. // RestartStock 重启批次
  366. //
  367. // 商户通过这个接口重新激活已暂停的代金券批次
  368. //
  369. // 接口频率:1000/min
  370. //
  371. // 前置条件:商户开通了代金券产品权限,且批次处于暂停状态
  372. func (a *StockApiService) RestartStock(ctx context.Context, req RestartStockRequest) (resp *RestartStockResponse, result *core.APIResult, err error) {
  373. var (
  374. localVarHTTPMethod = nethttp.MethodPost
  375. localVarPostBody interface{}
  376. localVarQueryParams neturl.Values
  377. localVarHeaderParams = nethttp.Header{}
  378. )
  379. // Make sure Path Params are properly set
  380. if req.StockId == nil {
  381. return nil, nil, fmt.Errorf("field `StockId` is required and must be specified in RestartStockRequest")
  382. }
  383. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks/{stock_id}/restart"
  384. // Build Path with Path Params
  385. localVarPath = strings.Replace(localVarPath, "{"+"stock_id"+"}", neturl.PathEscape(core.ParameterToString(*req.StockId, "")), -1)
  386. // Make sure All Required Params are properly set
  387. // Setup Body Params
  388. localVarPostBody = &RestartStockBody{
  389. StockCreatorMchid: req.StockCreatorMchid,
  390. }
  391. // Determine the Content-Type Header
  392. localVarHTTPContentTypes := []string{"application/json"}
  393. // Setup Content-Type
  394. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  395. // Perform Http Request
  396. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  397. if err != nil {
  398. return nil, result, err
  399. }
  400. // Extract RestartStockResponse from Http Response
  401. resp = new(RestartStockResponse)
  402. err = core.UnMarshalResponse(result.Response, resp)
  403. if err != nil {
  404. return nil, result, err
  405. }
  406. return resp, result, nil
  407. }
  408. // StartStock 激活开启批次
  409. //
  410. // 通过此接口激活代金券批次
  411. //
  412. // 前置条件:成功创建代金券批次
  413. //
  414. // 注意事项:
  415. //
  416. // 1. 如果是预充值代金券,激活时会从商户账户余额中锁定本批次的营销资金
  417. func (a *StockApiService) StartStock(ctx context.Context, req StartStockRequest) (resp *StartStockResponse, result *core.APIResult, err error) {
  418. var (
  419. localVarHTTPMethod = nethttp.MethodPost
  420. localVarPostBody interface{}
  421. localVarQueryParams neturl.Values
  422. localVarHeaderParams = nethttp.Header{}
  423. )
  424. // Make sure Path Params are properly set
  425. if req.StockId == nil {
  426. return nil, nil, fmt.Errorf("field `StockId` is required and must be specified in StartStockRequest")
  427. }
  428. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks/{stock_id}/start"
  429. // Build Path with Path Params
  430. localVarPath = strings.Replace(localVarPath, "{"+"stock_id"+"}", neturl.PathEscape(core.ParameterToString(*req.StockId, "")), -1)
  431. // Make sure All Required Params are properly set
  432. // Setup Body Params
  433. localVarPostBody = &StartStockBody{
  434. StockCreatorMchid: req.StockCreatorMchid,
  435. }
  436. // Determine the Content-Type Header
  437. localVarHTTPContentTypes := []string{"application/json"}
  438. // Setup Content-Type
  439. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  440. // Perform Http Request
  441. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  442. if err != nil {
  443. return nil, result, err
  444. }
  445. // Extract StartStockResponse from Http Response
  446. resp = new(StartStockResponse)
  447. err = core.UnMarshalResponse(result.Response, resp)
  448. if err != nil {
  449. return nil, result, err
  450. }
  451. return resp, result, nil
  452. }
  453. // StopStock 终止批次
  454. //
  455. // 商户通过这个接口终止未激活的代金券批次
  456. //
  457. // 前置条件:商户开通了代金券产品权限,且批次未激活
  458. func (a *StockApiService) StopStock(ctx context.Context, req StopStockRequest) (resp *StopStockResponse, result *core.APIResult, err error) {
  459. var (
  460. localVarHTTPMethod = nethttp.MethodPost
  461. localVarPostBody interface{}
  462. localVarQueryParams neturl.Values
  463. localVarHeaderParams = nethttp.Header{}
  464. )
  465. // Make sure Path Params are properly set
  466. if req.StockId == nil {
  467. return nil, nil, fmt.Errorf("field `StockId` is required and must be specified in StopStockRequest")
  468. }
  469. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks/{stock_id}/stop"
  470. // Build Path with Path Params
  471. localVarPath = strings.Replace(localVarPath, "{"+"stock_id"+"}", neturl.PathEscape(core.ParameterToString(*req.StockId, "")), -1)
  472. // Make sure All Required Params are properly set
  473. // Setup Body Params
  474. localVarPostBody = &StopStockBody{
  475. StockCreatorMchid: req.StockCreatorMchid,
  476. }
  477. // Determine the Content-Type Header
  478. localVarHTTPContentTypes := []string{"application/json"}
  479. // Setup Content-Type
  480. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  481. // Perform Http Request
  482. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  483. if err != nil {
  484. return nil, result, err
  485. }
  486. // Extract StopStockResponse from Http Response
  487. resp = new(StopStockResponse)
  488. err = core.UnMarshalResponse(result.Response, resp)
  489. if err != nil {
  490. return nil, result, err
  491. }
  492. return resp, result, nil
  493. }
  494. // UseFlow 下载批次核销明细
  495. //
  496. // 通过此接口获取指定批次的核销明细数据,包括订单号、单品信息、银行流水号等,用于对账/数据分析
  497. //
  498. // 接口频率:1000/min
  499. //
  500. // 前置条件:批次过期10小时
  501. //
  502. // 注意:
  503. //
  504. // 1. 账单文件的下载地址的有效时间为30s。
  505. // 2. 强烈建议商户将实际账单文件的哈希值和之前从接口获取到的哈希值进行比对,以确认数据的完整性。
  506. // 3. 该接口响应的信息请求头中不包含微信接口响应的签名值,因此需要跳过验签的流程。
  507. // 4. 该接口需要活动结束后次日10点才可以下载。
  508. // 5. 该接口只能使用创建活动方进行调用。
  509. func (a *StockApiService) UseFlow(ctx context.Context, req UseFlowRequest) (resp *UseFlowResponse, result *core.APIResult, err error) {
  510. var (
  511. localVarHTTPMethod = nethttp.MethodGet
  512. localVarPostBody interface{}
  513. localVarQueryParams neturl.Values
  514. localVarHeaderParams = nethttp.Header{}
  515. )
  516. // Make sure Path Params are properly set
  517. if req.StockId == nil {
  518. return nil, nil, fmt.Errorf("field `StockId` is required and must be specified in UseFlowRequest")
  519. }
  520. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/favor/stocks/{stock_id}/use-flow"
  521. // Build Path with Path Params
  522. localVarPath = strings.Replace(localVarPath, "{"+"stock_id"+"}", neturl.PathEscape(core.ParameterToString(*req.StockId, "")), -1)
  523. // Make sure All Required Params are properly set
  524. // Determine the Content-Type Header
  525. localVarHTTPContentTypes := []string{}
  526. // Setup Content-Type
  527. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  528. // Perform Http Request
  529. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  530. if err != nil {
  531. return nil, result, err
  532. }
  533. // Extract UseFlowResponse from Http Response
  534. resp = new(UseFlowResponse)
  535. err = core.UnMarshalResponse(result.Response, resp)
  536. if err != nil {
  537. return nil, result, err
  538. }
  539. return resp, result, nil
  540. }