条件查询批次列表
更新时间:2025.03.25通过此接口可查询多个批次的信息,包括批次的配置信息以及批次概况数据。
接口频率:不区分来源 1000/s 单ip 500/s
接口耗时:1S
幂等规则:接口支持幂等重入
接口说明
支持商户:【普通服务商】 【从业机构(银行)】 【从业机构(支付机构)】 【渠道商】 【清算机构】
请求方式:【GET】/v3/marketing/favor/stocks
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
query 查询参数
offset 必填 integer
【分页页码】 页码从0开始,默认第0页
limit 必填 integer
【分页大小】 分页大小,最大10
stock_creator_mchid 必填 string(20)
【创建批次的商户号】 批次创建方商户号。
校验规则:接口传入的批次号需由stock_creator_mchid所创建。
create_start_time 选填 string(64)
【起始时间】 起始创建时间,遵循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秒。
校验规则:get请求,参数在 url中,需要进行 url 编码传递
create_end_time 选填 string(664)
【终止时间】 终止创建时间,遵循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秒。
校验规则:get请求,参数在 url中,需要进行 url 编码传递
status 选填 string(12)
【批次状态】 批次状态,枚举值:
unactivated:未激活
audit:审核中
running:运行中
stoped:已停止
paused:暂停发放
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/marketing/favor/stocks?offset=1&limit=8&stock_creator_mchid=9856888&create_start_time=2015-05-20T13:29:35.120+08:00&create_end_time=2015-05-20T13:29:35.120+08:00&status=paused \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" 5
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/partner/4014985777 4 5import com.google.gson.annotations.SerializedName; 6import com.google.gson.annotations.Expose; 7import okhttp3.MediaType; 8import okhttp3.OkHttpClient; 9import okhttp3.Request; 10import okhttp3.RequestBody; 11import okhttp3.Response; 12 13import java.io.IOException; 14import java.io.UncheckedIOException; 15import java.security.PrivateKey; 16import java.security.PublicKey; 17import java.util.ArrayList; 18import java.util.HashMap; 19import java.util.List; 20import java.util.Map; 21 22/** 23 * 条件查询批次列表 24 */ 25public class ListStocks { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/marketing/favor/stocks"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 ListStocks client = new ListStocks( 33 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 34 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 35 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 ListStocksRequest request = new ListStocksRequest(); 41 request.offset = 1L; 42 request.limit = 8L; 43 request.stockCreatorMchid = "9856888"; 44 request.createStartTime = "2015-05-20T13:29:35.120+08:00"; 45 request.createEndTime = "2015-05-20T13:29:35.120+08:00"; 46 request.status = "paused"; 47 try { 48 StockCollection response = client.run(request); 49 // TODO: 请求成功,继续业务逻辑 50 System.out.println(response); 51 } catch (WXPayUtility.ApiException e) { 52 // TODO: 请求失败,根据状态码执行不同的逻辑 53 e.printStackTrace(); 54 } 55 } 56 57 public StockCollection run(ListStocksRequest request) { 58 String uri = PATH; 59 Map<String, Object> args = new HashMap<>(); 60 args.put("offset", request.offset); 61 args.put("limit", request.limit); 62 args.put("stock_creator_mchid", request.stockCreatorMchid); 63 args.put("create_start_time", request.createStartTime); 64 args.put("create_end_time", request.createEndTime); 65 args.put("status", request.status); 66 String queryString = WXPayUtility.urlEncode(args); 67 if (!queryString.isEmpty()) { 68 uri = uri + "?" + queryString; 69 } 70 71 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 72 reqBuilder.addHeader("Accept", "application/json"); 73 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 74 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 75 reqBuilder.method(METHOD, null); 76 Request httpRequest = reqBuilder.build(); 77 78 // 发送HTTP请求 79 OkHttpClient client = new OkHttpClient.Builder().build(); 80 try (Response httpResponse = client.newCall(httpRequest).execute()) { 81 String respBody = WXPayUtility.extractBody(httpResponse); 82 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 83 // 2XX 成功,验证应答签名 84 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 85 httpResponse.headers(), respBody); 86 87 // 从HTTP应答报文构建返回数据 88 return WXPayUtility.fromJson(respBody, StockCollection.class); 89 } else { 90 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 91 } 92 } catch (IOException e) { 93 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 94 } 95 } 96 97 private final String mchid; 98 private final String certificateSerialNo; 99 private final PrivateKey privateKey; 100 private final String wechatPayPublicKeyId; 101 private final PublicKey wechatPayPublicKey; 102 103 public ListStocks(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 104 this.mchid = mchid; 105 this.certificateSerialNo = certificateSerialNo; 106 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 107 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 108 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 109 } 110 111 public static class ListStocksRequest { 112 @SerializedName("offset") 113 @Expose(serialize = false) 114 public Long offset; 115 116 @SerializedName("limit") 117 @Expose(serialize = false) 118 public Long limit; 119 120 @SerializedName("stock_creator_mchid") 121 @Expose(serialize = false) 122 public String stockCreatorMchid; 123 124 @SerializedName("create_start_time") 125 @Expose(serialize = false) 126 public String createStartTime; 127 128 @SerializedName("create_end_time") 129 @Expose(serialize = false) 130 public String createEndTime; 131 132 @SerializedName("status") 133 @Expose(serialize = false) 134 public String status; 135 } 136 137 public static class StockCollection { 138 @SerializedName("total_count") 139 public Long totalCount; 140 141 @SerializedName("data") 142 public List<Stock> data; 143 144 @SerializedName("limit") 145 public Long limit; 146 147 @SerializedName("offset") 148 public Long offset; 149 } 150 151 public static class Stock { 152 @SerializedName("stock_id") 153 public String stockId; 154 155 @SerializedName("stock_creator_mchid") 156 public String stockCreatorMchid; 157 158 @SerializedName("stock_name") 159 public String stockName; 160 161 @SerializedName("status") 162 public String status; 163 164 @SerializedName("create_time") 165 public String createTime; 166 167 @SerializedName("description") 168 public String description; 169 170 @SerializedName("stock_use_rule") 171 public StockUseRule stockUseRule; 172 173 @SerializedName("available_begin_time") 174 public String availableBeginTime; 175 176 @SerializedName("available_end_time") 177 public String availableEndTime; 178 179 @SerializedName("distributed_coupons") 180 public Long distributedCoupons; 181 182 @SerializedName("no_cash") 183 public Boolean noCash; 184 185 @SerializedName("start_time") 186 public String startTime; 187 188 @SerializedName("stop_time") 189 public String stopTime; 190 191 @SerializedName("cut_to_message") 192 public CutTypeMsg cutToMessage; 193 194 @SerializedName("singleitem") 195 public Boolean singleitem; 196 197 @SerializedName("stock_type") 198 public String stockType; 199 200 @SerializedName("card_id") 201 public String cardId; 202 203 @SerializedName("business_type") 204 public BusinessType businessType; 205 206 @SerializedName("available_region_list") 207 public List<RegionInfo> availableRegionList; 208 209 @SerializedName("available_industry_list") 210 public List<String> availableIndustryList; 211 } 212 213 public static class StockUseRule { 214 @SerializedName("max_coupons") 215 public Long maxCoupons; 216 217 @SerializedName("max_amount") 218 public Long maxAmount; 219 220 @SerializedName("max_amount_by_day") 221 public Long maxAmountByDay; 222 223 @SerializedName("fixed_normal_coupon") 224 public FixedValueStockMsg fixedNormalCoupon; 225 226 @SerializedName("max_coupons_per_user") 227 public Long maxCouponsPerUser; 228 229 @SerializedName("coupon_type") 230 public String couponType; 231 232 @SerializedName("goods_tag") 233 public List<String> goodsTag; 234 235 @SerializedName("trade_type") 236 public List<TradeType> tradeType; 237 238 @SerializedName("combine_use") 239 public Boolean combineUse; 240 241 @SerializedName("fixed_discount_coupon") 242 public DiscountMsg fixedDiscountCoupon; 243 } 244 245 public static class CutTypeMsg { 246 @SerializedName("single_price_max") 247 public Long singlePriceMax; 248 249 @SerializedName("cut_to_price") 250 public Long cutToPrice; 251 } 252 253 public enum BusinessType { 254 @SerializedName("MULTIUSE") 255 MULTIUSE 256 } 257 258 public static class RegionInfo { 259 @SerializedName("type") 260 public RegionType type; 261 262 @SerializedName("province") 263 public String province; 264 265 @SerializedName("city") 266 public String city; 267 268 @SerializedName("district") 269 public String district; 270 271 @SerializedName("country") 272 public String country; 273 } 274 275 public static class FixedValueStockMsg { 276 @SerializedName("coupon_amount") 277 public Long couponAmount; 278 279 @SerializedName("transaction_minimum") 280 public Long transactionMinimum; 281 } 282 283 public enum TradeType { 284 @SerializedName("MICROAPP") 285 MICROAPP, 286 @SerializedName("APPPAY") 287 APPPAY, 288 @SerializedName("PPAY") 289 PPAY, 290 @SerializedName("CARD") 291 CARD, 292 @SerializedName("FACE") 293 FACE, 294 @SerializedName("OTHER") 295 OTHER 296 } 297 298 public static class DiscountMsg { 299 @SerializedName("discount_amount_max") 300 public Long discountAmountMax; 301 302 @SerializedName("discount_percent") 303 public Long discountPercent; 304 305 @SerializedName("transaction_minimum") 306 public Long transactionMinimum; 307 } 308 309 public enum RegionType { 310 @SerializedName("PROVINCE") 311 PROVINCE, 312 @SerializedName("CITY") 313 CITY, 314 @SerializedName("DISTRICT") 315 DISTRICT, 316 @SerializedName("COUNTRY") 317 COUNTRY 318 } 319 320} 321
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/partner/4015119446 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "net/url" 9) 10 11func main() { 12 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 13 config, err := wxpay_utility.CreateMchConfig( 14 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 15 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 16 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 17 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 18 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 19 ) 20 if err != nil { 21 fmt.Println(err) 22 return 23 } 24 25 request := &ListStocksRequest{ 26 Offset: wxpay_utility.Int64(1), 27 Limit: wxpay_utility.Int64(8), 28 StockCreatorMchid: wxpay_utility.String("9856888"), 29 CreateStartTime: wxpay_utility.String("2015-05-20T13:29:35.120+08:00"), 30 CreateEndTime: wxpay_utility.String("2015-05-20T13:29:35.120+08:00"), 31 Status: wxpay_utility.String("paused"), 32 } 33 34 response, err := ListStocks(config, request) 35 if err != nil { 36 fmt.Printf("请求失败: %+v\n", err) 37 // TODO: 请求失败,根据状态码执行不同的处理 38 return 39 } 40 41 // TODO: 请求成功,继续业务逻辑 42 fmt.Printf("请求成功: %+v\n", response) 43} 44 45func ListStocks(config *wxpay_utility.MchConfig, request *ListStocksRequest) (response *StockCollection, err error) { 46 const ( 47 host = "https://api.mch.weixin.qq.com" 48 method = "GET" 49 path = "/v3/marketing/favor/stocks" 50 ) 51 52 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 53 if err != nil { 54 return nil, err 55 } 56 query := reqUrl.Query() 57 if request.Offset != nil { 58 query.Add("offset", fmt.Sprintf("%v", *request.Offset)) 59 } 60 if request.Limit != nil { 61 query.Add("limit", fmt.Sprintf("%v", *request.Limit)) 62 } 63 if request.StockCreatorMchid != nil { 64 query.Add("stock_creator_mchid", *request.StockCreatorMchid) 65 } 66 if request.CreateStartTime != nil { 67 query.Add("create_start_time", *request.CreateStartTime) 68 } 69 if request.CreateEndTime != nil { 70 query.Add("create_end_time", *request.CreateEndTime) 71 } 72 if request.Status != nil { 73 query.Add("status", *request.Status) 74 } 75 reqUrl.RawQuery = query.Encode() 76 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 77 if err != nil { 78 return nil, err 79 } 80 httpRequest.Header.Set("Accept", "application/json") 81 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 82 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 83 if err != nil { 84 return nil, err 85 } 86 httpRequest.Header.Set("Authorization", authorization) 87 88 client := &http.Client{} 89 httpResponse, err := client.Do(httpRequest) 90 if err != nil { 91 return nil, err 92 } 93 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 94 if err != nil { 95 return nil, err 96 } 97 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 98 // 2XX 成功,验证应答签名 99 err = wxpay_utility.ValidateResponse( 100 config.WechatPayPublicKeyId(), 101 config.WechatPayPublicKey(), 102 &httpResponse.Header, 103 respBody, 104 ) 105 if err != nil { 106 return nil, err 107 } 108 response := &StockCollection{} 109 if err := json.Unmarshal(respBody, response); err != nil { 110 return nil, err 111 } 112 113 return response, nil 114 } else { 115 return nil, wxpay_utility.NewApiException( 116 httpResponse.StatusCode, 117 httpResponse.Header, 118 respBody, 119 ) 120 } 121} 122 123type ListStocksRequest struct { 124 Offset *int64 `json:"offset,omitempty"` 125 Limit *int64 `json:"limit,omitempty"` 126 StockCreatorMchid *string `json:"stock_creator_mchid,omitempty"` 127 CreateStartTime *string `json:"create_start_time,omitempty"` 128 CreateEndTime *string `json:"create_end_time,omitempty"` 129 Status *string `json:"status,omitempty"` 130} 131 132func (o *ListStocksRequest) MarshalJSON() ([]byte, error) { 133 type Alias ListStocksRequest 134 a := &struct { 135 Offset *int64 `json:"offset,omitempty"` 136 Limit *int64 `json:"limit,omitempty"` 137 StockCreatorMchid *string `json:"stock_creator_mchid,omitempty"` 138 CreateStartTime *string `json:"create_start_time,omitempty"` 139 CreateEndTime *string `json:"create_end_time,omitempty"` 140 Status *string `json:"status,omitempty"` 141 *Alias 142 }{ 143 // 序列化时移除非 Body 字段 144 Offset: nil, 145 Limit: nil, 146 StockCreatorMchid: nil, 147 CreateStartTime: nil, 148 CreateEndTime: nil, 149 Status: nil, 150 Alias: (*Alias)(o), 151 } 152 return json.Marshal(a) 153} 154 155type StockCollection struct { 156 TotalCount *int64 `json:"total_count,omitempty"` 157 Data []Stock `json:"data,omitempty"` 158 Limit *int64 `json:"limit,omitempty"` 159 Offset *int64 `json:"offset,omitempty"` 160} 161 162type Stock struct { 163 StockId *string `json:"stock_id,omitempty"` 164 StockCreatorMchid *string `json:"stock_creator_mchid,omitempty"` 165 StockName *string `json:"stock_name,omitempty"` 166 Status *string `json:"status,omitempty"` 167 CreateTime *string `json:"create_time,omitempty"` 168 Description *string `json:"description,omitempty"` 169 StockUseRule *StockUseRule `json:"stock_use_rule,omitempty"` 170 AvailableBeginTime *string `json:"available_begin_time,omitempty"` 171 AvailableEndTime *string `json:"available_end_time,omitempty"` 172 DistributedCoupons *int64 `json:"distributed_coupons,omitempty"` 173 NoCash *bool `json:"no_cash,omitempty"` 174 StartTime *string `json:"start_time,omitempty"` 175 StopTime *string `json:"stop_time,omitempty"` 176 CutToMessage *CutTypeMsg `json:"cut_to_message,omitempty"` 177 Singleitem *bool `json:"singleitem,omitempty"` 178 StockType *string `json:"stock_type,omitempty"` 179 CardId *string `json:"card_id,omitempty"` 180 BusinessType *BusinessType `json:"business_type,omitempty"` 181 AvailableRegionList []RegionInfo `json:"available_region_list,omitempty"` 182 AvailableIndustryList []string `json:"available_industry_list,omitempty"` 183} 184 185type StockUseRule struct { 186 MaxCoupons *int64 `json:"max_coupons,omitempty"` 187 MaxAmount *int64 `json:"max_amount,omitempty"` 188 MaxAmountByDay *int64 `json:"max_amount_by_day,omitempty"` 189 FixedNormalCoupon *FixedValueStockMsg `json:"fixed_normal_coupon,omitempty"` 190 MaxCouponsPerUser *int64 `json:"max_coupons_per_user,omitempty"` 191 CouponType *string `json:"coupon_type,omitempty"` 192 GoodsTag []string `json:"goods_tag,omitempty"` 193 TradeType []TradeType `json:"trade_type,omitempty"` 194 CombineUse *bool `json:"combine_use,omitempty"` 195 FixedDiscountCoupon *DiscountMsg `json:"fixed_discount_coupon,omitempty"` 196} 197 198type CutTypeMsg struct { 199 SinglePriceMax *int64 `json:"single_price_max,omitempty"` 200 CutToPrice *int64 `json:"cut_to_price,omitempty"` 201} 202 203type BusinessType string 204 205func (e BusinessType) Ptr() *BusinessType { 206 return &e 207} 208 209const ( 210 BUSINESSTYPE_MULTIUSE BusinessType = "MULTIUSE" 211) 212 213type RegionInfo struct { 214 Type *RegionType `json:"type,omitempty"` 215 Province *string `json:"province,omitempty"` 216 City *string `json:"city,omitempty"` 217 District *string `json:"district,omitempty"` 218 Country *string `json:"country,omitempty"` 219} 220 221type FixedValueStockMsg struct { 222 CouponAmount *int64 `json:"coupon_amount,omitempty"` 223 TransactionMinimum *int64 `json:"transaction_minimum,omitempty"` 224} 225 226type TradeType string 227 228func (e TradeType) Ptr() *TradeType { 229 return &e 230} 231 232const ( 233 TRADETYPE_MICROAPP TradeType = "MICROAPP" 234 TRADETYPE_APPPAY TradeType = "APPPAY" 235 TRADETYPE_PPAY TradeType = "PPAY" 236 TRADETYPE_CARD TradeType = "CARD" 237 TRADETYPE_FACE TradeType = "FACE" 238 TRADETYPE_OTHER TradeType = "OTHER" 239) 240 241type DiscountMsg struct { 242 DiscountAmountMax *int64 `json:"discount_amount_max,omitempty"` 243 DiscountPercent *int64 `json:"discount_percent,omitempty"` 244 TransactionMinimum *int64 `json:"transaction_minimum,omitempty"` 245} 246 247type RegionType string 248 249func (e RegionType) Ptr() *RegionType { 250 return &e 251} 252 253const ( 254 REGIONTYPE_PROVINCE RegionType = "PROVINCE" 255 REGIONTYPE_CITY RegionType = "CITY" 256 REGIONTYPE_DISTRICT RegionType = "DISTRICT" 257 REGIONTYPE_COUNTRY RegionType = "COUNTRY" 258) 259
应答参数
200 OK
total_count 必填 integer
【批次总数】 经过条件筛选,查询到的批次总数量。
data 选填 array[object]
【批次详情】 批次详情
属性 | |||||||||||||||||||||
stock_id 必填 string 【批次号】 微信为每个代金券批次分配的唯一id。 stock_creator_mchid 必填 string 【批次创建方商户号】 微信为创建方商户分配的商户号 stock_name 必填 string 【批次名称】 批次名称 status 必填 string 【批次状态】 批次状态,枚举值: create_time 必填 string 【创建时间】 批次创建时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。 description 必填 string 【使用说明】 批次描述信息 stock_use_rule 选填 object 【满减券/消费金批次使用规则】 满减券或消费金批次特定信息。
available_begin_time 必填 string 【可用开始时间】 可用开始时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。 available_end_time 必填 string 【可用结束时间】 可用结束时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。 distributed_coupons 必填 integer 【已发券或消费金数量】 已发券或消费金数量 no_cash 必填 boolean 【是否无资金流】 是否无资金流。枚举值: start_time 选填 string 【激活批次的时间】 批次激活开启时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。 stop_time 选填 string 【终止批次的时间】 批次永久停止时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss.sss表示时分秒毫秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35.120+08:00表示,北京时间2015年5月20日 13点29分35秒。 cut_to_message 选填 object 【减至批次特定信息】 单品优惠特定信息
singleitem 必填 boolean 【是否单品优惠】 枚举值: stock_type 必填 string 【批次类型】 批次类型 card_id 选填 string 【卡包ID】 微信卡包ID business_type 选填 string 【业务类型】 细分业务类型,仅有当business_type=MULTIUSE时,才会返回,枚举值: 可选取值
available_region_list 选填 array[object] 【消费金可用地域】 消费金可用地域列表,仅有当business_type=MULTIUSE时,才会返回
available_industry_list 选填 array[string] 【消费金可用行业】 消费金可用行业列表,仅有当business_type=MULTIUSE时,才会返回 |
limit 必填 integer
【分页大小】 分页大小,最大10
offset 必填 integer
【分页页码】 页码从0开始,默认第0页
应答示例
200 OK
1{ 2 "total_count" : 10, 3 "data" : [ 4 { 5 "stock_id" : "9836588", 6 "stock_creator_mchid" : "123456", 7 "stock_name" : "微信支付批次", 8 "status" : "paused", 9 "create_time" : "2015-05-20T13:29:35.120+08:00", 10 "description" : "微信支付营销", 11 "stock_use_rule" : { 12 "max_coupons" : 100, 13 "max_amount" : 5000, 14 "max_amount_by_day" : 400, 15 "fixed_normal_coupon" : { 16 "coupon_amount" : 100, 17 "transaction_minimum" : 100 18 }, 19 "max_coupons_per_user" : 3, 20 "coupon_type" : "NORMAL", 21 "goods_tag" : [ 22 "123456" 23 ], 24 "trade_type" : [ 25 "MICROAPP" 26 ], 27 "combine_use" : true, 28 "fixed_discount_coupon" : { 29 "discount_amount_max" : 100, 30 "discount_percent" : 88, 31 "transaction_minimum" : 100 32 } 33 }, 34 "available_begin_time" : "2015-05-20T13:29:35.120+08:00", 35 "available_end_time" : "2015-05-20T13:29:35.120+08:00", 36 "distributed_coupons" : 100, 37 "no_cash" : true, 38 "start_time" : "2015-05-20T13:29:35.120+08:00", 39 "stop_time" : "2015-05-20T13:29:35.120+08:00", 40 "cut_to_message" : { 41 "single_price_max" : 100, 42 "cut_to_price" : 80 43 }, 44 "singleitem" : true, 45 "stock_type" : "NORMAL", 46 "card_id" : "pX2-vjoeC94Nn-r2g5GjDwkfFH7E", 47 "business_type" : "MULTIUSE", 48 "available_region_list" : [ 49 { 50 "type" : "PROVINCE", 51 "province" : "广东省", 52 "city" : "深圳市", 53 "district" : "南山区", 54 "country" : "中国大陆" 55 } 56 ], 57 "available_industry_list" : [ 58 "餐饮" 59 ] 60 } 61 ], 62 "limit" : 8, 63 "offset" : 1 64} 65
错误码
公共错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
业务错误码
状态码 | 错误码 | 描述 | 解决方案 |
---|---|---|---|
400 | APPID_MCHID_NOT_MATCH | 商户号与AppID不匹配 | 请绑定调用接口的商户号和AppID后重试 |
400 | INVALID_REQUEST | OpenID与AppID不匹配 | 请使用AppID下的OpenID |
400 | INVALID_REQUEST | 活动已结束或未激活 | 请检查批次状态 |
400 | INVALID_REQUEST | 非法的商户号 | 请检查商户号是否正确 |
400 | MCH_NOT_EXISTS | 商户号不合法 | 请输入正确的商户号 |
400 | PARAM_ERROR | 回调URL不能为空 | 请填写回调URL |
400 | PARAM_ERROR | 回调商户不能为空 | 请填写回调商户 |
400 | PARAM_ERROR | 券ID必填 | 请填写券ID |
400 | PARAM_ERROR | AppID必填 | 请输入AppID |
400 | PARAM_ERROR | OpenID必填 | 请输入OpenID |
400 | PARAM_ERROR | 页大小超过阈值 | 请不要超过最大的页大小 |
400 | PARAM_ERROR | 输入时间格式错误 | 请输入正确的时间格式 |
400 | PARAM_ERROR | 批次号必填 | 请输入批次号 |
400 | PARAM_ERROR | 商户号必填 | 请输入商户号 |
400 | PARAM_ERROR | 非法的批次状态 | 请检查批次状态 |
403 | NOT_ENOUGH | 批次预算不足 | 请补充预算 |
403 | REQUEST_BLOCKED | 调用商户无权限 | 请开通产品权限后再调用该接口 |
403 | REQUEST_BLOCKED | 商户无权发券 | 调用接口的商户号无权发券,请检查是否是自己的批次或是已授权的批次。 |
403 | REQUEST_BLOCKED | 批次不支持跨商户发券 | 该批次未做跨商户号的授权,请授权后再发放 |
403 | REQUEST_BLOCKED | 用户被限领拦截 | 用户领取已经达到上限,请调高上限或停止发放。 |
403 | USER_ACCOUNT_ABNORMAL | 用户非法 | 该用户账号异常,无法领券。商家可联系微信支付或让用户联系微信支付客服处理。 |
404 | RESOURCE_NOT_EXISTS | 批次不存在 | 请检查批次ID是否正确 |
429 | FREQUENCY_LIMITED | 请求过于频繁 | 稍后重试 |