指定券状态查询用户商品券列表
更新时间:2025.11.07品牌方可以通过本接口查询已经发放给用户的特定状态的商品券
前置条件:已经给用户发券成功
接口说明
支持商户:【普通服务商】
请求方式:【GET】/v3/marketing/partner/product-coupon/users/{openid}/coupons
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
接口限频:500/秒(商户号维度)
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
path 路径参数
openid 必填 string
【用户OpenID】 OpenID信息,用户在AppID下的唯一标识,获取方式参考OpenID
query 查询参数
product_coupon_id 选填 string
【商品券ID】 商品券的唯一标识,创建商品券时由微信支付生成。查询指定商品券下的用户商品券列表,不传入时查询范围扩大至品牌下的所有商品券
stock_id 选填 string
【批次ID】 商品券批次的唯一标识,商品券批次创建时由微信支付生成(可使用【创建商品券API】或【添加商品券批次API】创建)。查询指定商品券批次下的用户商品券列表。
appid 必填 string
【公众账号ID】 公众账号ID也称AppID,是(微信开放平台、微信公众平台)为开发者提供的一个唯一标识,用于识别开发者的应用程序(APP、小程序、公众号)。 开发者需要先在微信开放平台或微信公众平台中申请ID,然后与品牌方或服务商绑定(详见服务商商户号与AppID账号关联管理)。
coupon_state 选填 string
【用户商品券状态】 查询指定状态的用户商品券
可选取值
CONFIRMING: 待确认,用户商品券发放需要品牌方调用【确认发放用户商品券API(单券)】或【确认发放用户商品券API(多次优惠)】后才能生效PENDING: 已发放待生效,用户商品券已发放成功但尚未到达可用开始时间EFFECTIVE: 已生效,用户商品券已成功发放且到达可用开始时间USED: 已核销,用户商品券已核销EXPIRED: 已过期,用户商品券已超过有效期,不再可用DELETED: 已删除,用户主动删除该券DEACTIVATED: 已失效,品牌方主动调用【失效用户商品券API】或【失效用户商品券组API】使用户商品券失效
user_coupon_bundle_id 选填 string
【用户券组ID】 用户券组的唯一标识,【向用户发放商品券批次组】时由微信支付生成,用于查询特定用户券组内的券
page_size 选填 integer
【分页大小】 单次拉取的数据条数上限,不填默认为20,最大值50
page_token 选填 string
【分页Token】 分页查询时,需要传入上一次调用返回的 next_page_token,首次调用不填
brand_id 必填 string
【品牌ID】 微信支付为品牌方分配的唯一标识,该品牌应与服务商存在授权关系
请求示例
GET
查询用户在某个批次下的券列表
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/marketing/partner/product-coupon/users/oh-394z-6CGkNoJrsDLTTUKiAnp4/coupons?product_coupon_id=1000000013&stock_id=1000000013001&appid=wx233544546545989&page_size=10&brand_id=120344 \ 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 ListUserProductCoupons { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/marketing/partner/product-coupon/users/{openid}/coupons"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 32 ListUserProductCoupons client = new ListUserProductCoupons( 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 ListUserProductCouponsRequest request = new ListUserProductCouponsRequest(); 41 request.productCouponId = "1000000013"; 42 request.stockId = "1000000013001"; 43 request.appid = "wx233544546545989"; 44 request.openid = "oh-394z-6CGkNoJrsDLTTUKiAnp4"; 45 request.pageSize = 10L; 46 request.brandId = "120344"; 47 try { 48 ListUserProductCouponsResponse 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 ListUserProductCouponsResponse run(ListUserProductCouponsRequest request) { 58 String uri = PATH; 59 uri = uri.replace("{openid}", WXPayUtility.urlEncode(request.openid)); 60 Map<String, Object> args = new HashMap<>(); 61 args.put("product_coupon_id", request.productCouponId); 62 args.put("stock_id", request.stockId); 63 args.put("appid", request.appid); 64 args.put("coupon_state", request.couponState); 65 args.put("user_coupon_bundle_id", request.userCouponBundleId); 66 args.put("page_size", request.pageSize); 67 args.put("page_token", request.pageToken); 68 args.put("brand_id", request.brandId); 69 String queryString = WXPayUtility.urlEncode(args); 70 if (!queryString.isEmpty()) { 71 uri = uri + "?" + queryString; 72 } 73 74 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 75 reqBuilder.addHeader("Accept", "application/json"); 76 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 77 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 78 reqBuilder.method(METHOD, null); 79 Request httpRequest = reqBuilder.build(); 80 81 // 发送HTTP请求 82 OkHttpClient client = new OkHttpClient.Builder().build(); 83 try (Response httpResponse = client.newCall(httpRequest).execute()) { 84 String respBody = WXPayUtility.extractBody(httpResponse); 85 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 86 // 2XX 成功,验证应答签名 87 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 88 httpResponse.headers(), respBody); 89 90 // 从HTTP应答报文构建返回数据 91 return WXPayUtility.fromJson(respBody, ListUserProductCouponsResponse.class); 92 } else { 93 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 94 } 95 } catch (IOException e) { 96 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 97 } 98 } 99 100 private final String mchid; 101 private final String certificateSerialNo; 102 private final PrivateKey privateKey; 103 private final String wechatPayPublicKeyId; 104 private final PublicKey wechatPayPublicKey; 105 106 public ListUserProductCoupons(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 107 this.mchid = mchid; 108 this.certificateSerialNo = certificateSerialNo; 109 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 110 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 111 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 112 } 113 114 public static class ListUserProductCouponsRequest { 115 @SerializedName("product_coupon_id") 116 @Expose(serialize = false) 117 public String productCouponId; 118 119 @SerializedName("stock_id") 120 @Expose(serialize = false) 121 public String stockId; 122 123 @SerializedName("appid") 124 @Expose(serialize = false) 125 public String appid; 126 127 @SerializedName("openid") 128 @Expose(serialize = false) 129 public String openid; 130 131 @SerializedName("user_coupon_bundle_id") 132 @Expose(serialize = false) 133 public String userCouponBundleId; 134 135 @SerializedName("page_size") 136 @Expose(serialize = false) 137 public Long pageSize; 138 139 @SerializedName("page_token") 140 @Expose(serialize = false) 141 public String pageToken; 142 143 @SerializedName("brand_id") 144 @Expose(serialize = false) 145 public String brandId; 146 147 @SerializedName("coupon_state") 148 @Expose(serialize = false) 149 public UserProductCouponState couponState; 150 } 151 152 public static class ListUserProductCouponsResponse { 153 @SerializedName("total_count") 154 public Long totalCount; 155 156 @SerializedName("user_coupon_list") 157 public List<UserProductCouponEntity> userCouponList; 158 159 @SerializedName("next_page_token") 160 public String nextPageToken; 161 } 162 163 public enum UserProductCouponState { 164 @SerializedName("CONFIRMING") 165 CONFIRMING, 166 @SerializedName("PENDING") 167 PENDING, 168 @SerializedName("EFFECTIVE") 169 EFFECTIVE, 170 @SerializedName("USED") 171 USED, 172 @SerializedName("EXPIRED") 173 EXPIRED, 174 @SerializedName("DELETED") 175 DELETED, 176 @SerializedName("DEACTIVATED") 177 DEACTIVATED 178 } 179 180 public static class UserProductCouponEntity { 181 @SerializedName("coupon_code") 182 public String couponCode; 183 184 @SerializedName("coupon_state") 185 public UserProductCouponState couponState; 186 187 @SerializedName("valid_begin_time") 188 public String validBeginTime; 189 190 @SerializedName("valid_end_time") 191 public String validEndTime; 192 193 @SerializedName("receive_time") 194 public String receiveTime; 195 196 @SerializedName("send_request_no") 197 public String sendRequestNo; 198 199 @SerializedName("send_channel") 200 public UserProductCouponSendChannel sendChannel; 201 202 @SerializedName("confirm_request_no") 203 public String confirmRequestNo; 204 205 @SerializedName("confirm_time") 206 public String confirmTime; 207 208 @SerializedName("deactivate_request_no") 209 public String deactivateRequestNo; 210 211 @SerializedName("deactivate_time") 212 public String deactivateTime; 213 214 @SerializedName("deactivate_reason") 215 public String deactivateReason; 216 217 @SerializedName("single_usage_detail") 218 public CouponUsageDetail singleUsageDetail; 219 220 @SerializedName("progressive_bundle_usage_detail") 221 public CouponUsageDetail progressiveBundleUsageDetail; 222 223 @SerializedName("user_product_coupon_bundle_info") 224 public UserProductCouponBundleInfo userProductCouponBundleInfo; 225 226 @SerializedName("product_coupon") 227 public ProductCouponEntity productCoupon; 228 229 @SerializedName("stock") 230 public StockEntity stock; 231 232 @SerializedName("attach") 233 public String attach; 234 235 @SerializedName("channel_custom_info") 236 public String channelCustomInfo; 237 238 @SerializedName("coupon_tag_info") 239 public CouponTagInfo couponTagInfo; 240 241 @SerializedName("brand_id") 242 public String brandId; 243 } 244 245 public enum UserProductCouponSendChannel { 246 @SerializedName("BRAND_MANAGE") 247 BRAND_MANAGE, 248 @SerializedName("API") 249 API, 250 @SerializedName("RECEIVE_COMPONENT") 251 RECEIVE_COMPONENT, 252 @SerializedName("MEMBER") 253 MEMBER, 254 @SerializedName("STICKER_GIFT") 255 STICKER_GIFT 256 } 257 258 public static class CouponUsageDetail { 259 @SerializedName("use_request_no") 260 public String useRequestNo; 261 262 @SerializedName("use_time") 263 public String useTime; 264 265 @SerializedName("return_request_no") 266 public String returnRequestNo; 267 268 @SerializedName("return_time") 269 public String returnTime; 270 271 @SerializedName("associated_order_info") 272 public UserProductCouponAssociatedOrderInfo associatedOrderInfo; 273 274 @SerializedName("associated_pay_score_order_info") 275 public UserProductCouponAssociatedPayScoreOrderInfo associatedPayScoreOrderInfo; 276 277 @SerializedName("saved_amount") 278 public Long savedAmount; 279 280 @SerializedName("use_product_no_list") 281 public List<String> useProductNoList; 282 } 283 284 public static class UserProductCouponBundleInfo { 285 @SerializedName("user_coupon_bundle_id") 286 public String userCouponBundleId; 287 288 @SerializedName("user_coupon_bundle_index") 289 public Long userCouponBundleIndex; 290 291 @SerializedName("total_count") 292 public Long totalCount; 293 294 @SerializedName("used_count") 295 public Long usedCount; 296 } 297 298 public static class ProductCouponEntity { 299 @SerializedName("product_coupon_id") 300 public String productCouponId; 301 302 @SerializedName("scope") 303 public ProductCouponScope scope; 304 305 @SerializedName("type") 306 public ProductCouponType type; 307 308 @SerializedName("usage_mode") 309 public UsageMode usageMode; 310 311 @SerializedName("single_usage_info") 312 public SingleUsageInfo singleUsageInfo; 313 314 @SerializedName("progressive_bundle_usage_info") 315 public ProgressiveBundleUsageInfo progressiveBundleUsageInfo; 316 317 @SerializedName("display_info") 318 public ProductCouponDisplayInfo displayInfo; 319 320 @SerializedName("out_product_no") 321 public String outProductNo; 322 323 @SerializedName("state") 324 public ProductCouponState state; 325 326 @SerializedName("deactivate_request_no") 327 public String deactivateRequestNo; 328 329 @SerializedName("deactivate_time") 330 public String deactivateTime; 331 332 @SerializedName("deactivate_reason") 333 public String deactivateReason; 334 335 @SerializedName("brand_id") 336 public String brandId; 337 338 @SerializedName("available_product_no_list") 339 public List<String> availableProductNoList; 340 341 @SerializedName("business_mode") 342 public ProductCouponBusinessMode businessMode; 343 } 344 345 public static class StockEntity { 346 @SerializedName("product_coupon_id") 347 public String productCouponId; 348 349 @SerializedName("stock_id") 350 public String stockId; 351 352 @SerializedName("remark") 353 public String remark; 354 355 @SerializedName("coupon_code_mode") 356 public CouponCodeMode couponCodeMode; 357 358 @SerializedName("coupon_code_count_info") 359 public CouponCodeCountInfo couponCodeCountInfo; 360 361 @SerializedName("stock_send_rule") 362 public StockSendRule stockSendRule; 363 364 @SerializedName("single_usage_rule") 365 public SingleUsageRule singleUsageRule; 366 367 @SerializedName("progressive_bundle_usage_rule") 368 public StockUsageRule progressiveBundleUsageRule; 369 370 @SerializedName("stock_bundle_info") 371 public StockBundleInfo stockBundleInfo; 372 373 @SerializedName("usage_rule_display_info") 374 public UsageRuleDisplayInfo usageRuleDisplayInfo; 375 376 @SerializedName("coupon_display_info") 377 public CouponDisplayInfo couponDisplayInfo; 378 379 @SerializedName("notify_config") 380 public NotifyConfig notifyConfig; 381 382 @SerializedName("store_scope") 383 public StockStoreScope storeScope; 384 385 @SerializedName("sent_count_info") 386 public StockSentCountInfo sentCountInfo; 387 388 @SerializedName("state") 389 public StockState state; 390 391 @SerializedName("deactivate_request_no") 392 public String deactivateRequestNo; 393 394 @SerializedName("deactivate_time") 395 public String deactivateTime; 396 397 @SerializedName("deactivate_reason") 398 public String deactivateReason; 399 400 @SerializedName("brand_id") 401 public String brandId; 402 } 403 404 public static class CouponTagInfo { 405 @SerializedName("coupon_tag_list") 406 public List<UserProductCouponTag> couponTagList; 407 408 @SerializedName("member_tag_info") 409 public MemberTagInfo memberTagInfo; 410 } 411 412 public static class UserProductCouponAssociatedOrderInfo { 413 @SerializedName("transaction_id") 414 public String transactionId; 415 416 @SerializedName("out_trade_no") 417 public String outTradeNo; 418 419 @SerializedName("mchid") 420 public String mchid; 421 422 @SerializedName("sub_mchid") 423 public String subMchid; 424 } 425 426 public static class UserProductCouponAssociatedPayScoreOrderInfo { 427 @SerializedName("order_id") 428 public String orderId; 429 430 @SerializedName("out_order_no") 431 public String outOrderNo; 432 433 @SerializedName("mchid") 434 public String mchid; 435 436 @SerializedName("sub_mchid") 437 public String subMchid; 438 } 439 440 public enum ProductCouponScope { 441 @SerializedName("ALL") 442 ALL, 443 @SerializedName("SINGLE") 444 SINGLE, 445 @SerializedName("CATEGORY") 446 CATEGORY 447 } 448 449 public enum ProductCouponType { 450 @SerializedName("NORMAL") 451 NORMAL, 452 @SerializedName("DISCOUNT") 453 DISCOUNT, 454 @SerializedName("EXCHANGE") 455 EXCHANGE 456 } 457 458 public enum UsageMode { 459 @SerializedName("SINGLE") 460 SINGLE, 461 @SerializedName("PROGRESSIVE_BUNDLE") 462 PROGRESSIVE_BUNDLE 463 } 464 465 public static class SingleUsageInfo { 466 @SerializedName("normal_coupon") 467 public NormalCouponUsageRule normalCoupon; 468 469 @SerializedName("discount_coupon") 470 public DiscountCouponUsageRule discountCoupon; 471 } 472 473 public static class ProgressiveBundleUsageInfo { 474 @SerializedName("count") 475 public Long count; 476 477 @SerializedName("interval_days") 478 public Long intervalDays; 479 } 480 481 public static class ProductCouponDisplayInfo { 482 @SerializedName("name") 483 public String name; 484 485 @SerializedName("image_url") 486 public String imageUrl; 487 488 @SerializedName("background_url") 489 public String backgroundUrl; 490 491 @SerializedName("detail_image_url_list") 492 public List<String> detailImageUrlList; 493 494 @SerializedName("original_price") 495 public Long originalPrice; 496 497 @SerializedName("combo_package_list") 498 public List<ComboPackage> comboPackageList; 499 } 500 501 public enum ProductCouponState { 502 @SerializedName("AUDITING") 503 AUDITING, 504 @SerializedName("EFFECTIVE") 505 EFFECTIVE, 506 @SerializedName("DEACTIVATED") 507 DEACTIVATED 508 } 509 510 public enum ProductCouponBusinessMode { 511 @SerializedName("FREE") 512 FREE 513 } 514 515 public enum CouponCodeMode { 516 @SerializedName("WECHATPAY") 517 WECHATPAY, 518 @SerializedName("UPLOAD") 519 UPLOAD, 520 @SerializedName("API_ASSIGN") 521 API_ASSIGN 522 } 523 524 public static class CouponCodeCountInfo { 525 @SerializedName("total_count") 526 public Long totalCount; 527 528 @SerializedName("available_count") 529 public Long availableCount; 530 } 531 532 public static class StockSendRule { 533 @SerializedName("max_count") 534 public Long maxCount; 535 536 @SerializedName("max_count_per_day") 537 public Long maxCountPerDay; 538 539 @SerializedName("max_count_per_user") 540 public Long maxCountPerUser; 541 } 542 543 public static class SingleUsageRule { 544 @SerializedName("coupon_available_period") 545 public CouponAvailablePeriod couponAvailablePeriod; 546 547 @SerializedName("normal_coupon") 548 public NormalCouponUsageRule normalCoupon; 549 550 @SerializedName("discount_coupon") 551 public DiscountCouponUsageRule discountCoupon; 552 553 @SerializedName("exchange_coupon") 554 public ExchangeCouponUsageRule exchangeCoupon; 555 } 556 557 public static class StockUsageRule { 558 @SerializedName("coupon_available_period") 559 public CouponAvailablePeriod couponAvailablePeriod; 560 561 @SerializedName("normal_coupon") 562 public NormalCouponUsageRule normalCoupon; 563 564 @SerializedName("discount_coupon") 565 public DiscountCouponUsageRule discountCoupon; 566 567 @SerializedName("exchange_coupon") 568 public ExchangeCouponUsageRule exchangeCoupon; 569 } 570 571 public static class StockBundleInfo { 572 @SerializedName("stock_bundle_id") 573 public String stockBundleId; 574 575 @SerializedName("stock_bundle_index") 576 public Long stockBundleIndex; 577 } 578 579 public static class UsageRuleDisplayInfo { 580 @SerializedName("coupon_usage_method_list") 581 public List<CouponUsageMethod> couponUsageMethodList = new ArrayList<CouponUsageMethod>(); 582 583 @SerializedName("mini_program_appid") 584 public String miniProgramAppid; 585 586 @SerializedName("mini_program_path") 587 public String miniProgramPath; 588 589 @SerializedName("app_path") 590 public String appPath; 591 592 @SerializedName("usage_description") 593 public String usageDescription; 594 595 @SerializedName("coupon_available_store_info") 596 public CouponAvailableStoreInfo couponAvailableStoreInfo; 597 598 @SerializedName("app_jump_type") 599 public AppJumpType appJumpType; 600 601 @SerializedName("passcode_link") 602 public String passcodeLink; 603 } 604 605 public static class CouponDisplayInfo { 606 @SerializedName("code_display_mode") 607 public CouponCodeDisplayMode codeDisplayMode; 608 609 @SerializedName("background_color") 610 public String backgroundColor; 611 612 @SerializedName("entrance_mini_program") 613 public EntranceMiniProgram entranceMiniProgram; 614 615 @SerializedName("entrance_official_account") 616 public EntranceOfficialAccount entranceOfficialAccount; 617 } 618 619 public static class NotifyConfig { 620 @SerializedName("notify_appid") 621 public String notifyAppid; 622 } 623 624 public enum StockStoreScope { 625 @SerializedName("NONE") 626 NONE, 627 @SerializedName("ALL") 628 ALL, 629 @SerializedName("SPECIFIC") 630 SPECIFIC 631 } 632 633 public static class StockSentCountInfo { 634 @SerializedName("total_count") 635 public Long totalCount; 636 637 @SerializedName("today_count") 638 public Long todayCount; 639 } 640 641 public enum StockState { 642 @SerializedName("AUDITING") 643 AUDITING, 644 @SerializedName("SENDING") 645 SENDING, 646 @SerializedName("PAUSED") 647 PAUSED, 648 @SerializedName("STOPPED") 649 STOPPED, 650 @SerializedName("DEACTIVATED") 651 DEACTIVATED 652 } 653 654 public enum UserProductCouponTag { 655 @SerializedName("MEMBER") 656 MEMBER, 657 @SerializedName("MEMBER_ACTIVITY") 658 MEMBER_ACTIVITY 659 } 660 661 public static class MemberTagInfo { 662 @SerializedName("member_card_id") 663 public String memberCardId; 664 } 665 666 public static class NormalCouponUsageRule { 667 @SerializedName("threshold") 668 public Long threshold; 669 670 @SerializedName("discount_amount") 671 public Long discountAmount; 672 } 673 674 public static class DiscountCouponUsageRule { 675 @SerializedName("threshold") 676 public Long threshold; 677 678 @SerializedName("percent_off") 679 public Long percentOff; 680 } 681 682 public static class ComboPackage { 683 @SerializedName("name") 684 public String name; 685 686 @SerializedName("pick_count") 687 public Long pickCount; 688 689 @SerializedName("choice_list") 690 public List<ComboPackageChoice> choiceList = new ArrayList<ComboPackageChoice>(); 691 } 692 693 public static class CouponAvailablePeriod { 694 @SerializedName("available_begin_time") 695 public String availableBeginTime; 696 697 @SerializedName("available_end_time") 698 public String availableEndTime; 699 700 @SerializedName("available_days") 701 public Long availableDays; 702 703 @SerializedName("wait_days_after_receive") 704 public Long waitDaysAfterReceive; 705 706 @SerializedName("weekly_available_period") 707 public FixedWeekPeriod weeklyAvailablePeriod; 708 709 @SerializedName("irregular_available_period_list") 710 public List<TimePeriod> irregularAvailablePeriodList; 711 712 @SerializedName("available_seconds") 713 public Long availableSeconds; 714 } 715 716 public static class ExchangeCouponUsageRule { 717 @SerializedName("threshold") 718 public Long threshold; 719 720 @SerializedName("exchange_price") 721 public Long exchangePrice; 722 } 723 724 public enum CouponUsageMethod { 725 @SerializedName("OFFLINE") 726 OFFLINE, 727 @SerializedName("MINI_PROGRAM") 728 MINI_PROGRAM, 729 @SerializedName("APP") 730 APP, 731 @SerializedName("PAYMENT_CODE") 732 PAYMENT_CODE 733 } 734 735 public static class CouponAvailableStoreInfo { 736 @SerializedName("description") 737 public String description; 738 739 @SerializedName("mini_program_appid") 740 public String miniProgramAppid; 741 742 @SerializedName("mini_program_path") 743 public String miniProgramPath; 744 } 745 746 public enum AppJumpType { 747 @SerializedName("H5") 748 H5, 749 @SerializedName("PASSCODE_LINK") 750 PASSCODE_LINK, 751 @SerializedName("USAGE_GUIDE") 752 USAGE_GUIDE 753 } 754 755 public enum CouponCodeDisplayMode { 756 @SerializedName("INVISIBLE") 757 INVISIBLE, 758 @SerializedName("BARCODE") 759 BARCODE, 760 @SerializedName("QRCODE") 761 QRCODE 762 } 763 764 public static class EntranceMiniProgram { 765 @SerializedName("appid") 766 public String appid; 767 768 @SerializedName("path") 769 public String path; 770 771 @SerializedName("entrance_wording") 772 public String entranceWording; 773 774 @SerializedName("guidance_wording") 775 public String guidanceWording; 776 } 777 778 public static class EntranceOfficialAccount { 779 @SerializedName("appid") 780 public String appid; 781 } 782 783 public static class ComboPackageChoice { 784 @SerializedName("name") 785 public String name; 786 787 @SerializedName("price") 788 public Long price; 789 790 @SerializedName("count") 791 public Long count; 792 793 @SerializedName("image_url") 794 public String imageUrl; 795 796 @SerializedName("mini_program_appid") 797 public String miniProgramAppid; 798 799 @SerializedName("mini_program_path") 800 public String miniProgramPath; 801 } 802 803 public static class FixedWeekPeriod { 804 @SerializedName("day_list") 805 public List<WeekEnum> dayList = new ArrayList<WeekEnum>(); 806 807 @SerializedName("day_period_list") 808 public List<PeriodOfTheDay> dayPeriodList; 809 } 810 811 public static class TimePeriod { 812 @SerializedName("begin_time") 813 public String beginTime; 814 815 @SerializedName("end_time") 816 public String endTime; 817 } 818 819 public enum WeekEnum { 820 @SerializedName("MONDAY") 821 MONDAY, 822 @SerializedName("TUESDAY") 823 TUESDAY, 824 @SerializedName("WEDNESDAY") 825 WEDNESDAY, 826 @SerializedName("THURSDAY") 827 THURSDAY, 828 @SerializedName("FRIDAY") 829 FRIDAY, 830 @SerializedName("SATURDAY") 831 SATURDAY, 832 @SerializedName("SUNDAY") 833 SUNDAY 834 } 835 836 public static class PeriodOfTheDay { 837 @SerializedName("begin_time") 838 public Long beginTime; 839 840 @SerializedName("end_time") 841 public Long endTime; 842 } 843 844} 845
需配合微信支付工具库 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 "strings" 10 "time" 11) 12 13func main() { 14 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 15 config, err := wxpay_utility.CreateMchConfig( 16 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/partner/4013080340 17 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013058924 18 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/partner/4013038589 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &ListUserProductCouponsRequest{ 28 ProductCouponId: wxpay_utility.String("1000000013"), 29 StockId: wxpay_utility.String("1000000013001"), 30 Appid: wxpay_utility.String("wx233544546545989"), 31 Openid: wxpay_utility.String("oh-394z-6CGkNoJrsDLTTUKiAnp4"), 32 PageSize: wxpay_utility.Int64(10), 33 BrandId: wxpay_utility.String("120344"), 34 } 35 36 response, err := ListUserProductCoupons(config, request) 37 if err != nil { 38 fmt.Printf("请求失败: %+v\n", err) 39 // TODO: 请求失败,根据状态码执行不同的处理 40 return 41 } 42 43 // TODO: 请求成功,继续业务逻辑 44 fmt.Printf("请求成功: %+v\n", response) 45} 46 47func ListUserProductCoupons(config *wxpay_utility.MchConfig, request *ListUserProductCouponsRequest) (response *ListUserProductCouponsResponse, err error) { 48 const ( 49 host = "https://api.mch.weixin.qq.com" 50 method = "GET" 51 path = "/v3/marketing/partner/product-coupon/users/{openid}/coupons" 52 ) 53 54 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 55 if err != nil { 56 return nil, err 57 } 58 reqUrl.Path = strings.Replace(reqUrl.Path, "{openid}", url.PathEscape(*request.Openid), -1) 59 query := reqUrl.Query() 60 if request.ProductCouponId != nil { 61 query.Add("product_coupon_id", *request.ProductCouponId) 62 } 63 if request.StockId != nil { 64 query.Add("stock_id", *request.StockId) 65 } 66 if request.Appid != nil { 67 query.Add("appid", *request.Appid) 68 } 69 if request.CouponState != nil { 70 query.Add("coupon_state", fmt.Sprintf("%v", *request.CouponState)) 71 } 72 if request.UserCouponBundleId != nil { 73 query.Add("user_coupon_bundle_id", *request.UserCouponBundleId) 74 } 75 if request.PageSize != nil { 76 query.Add("page_size", fmt.Sprintf("%v", *request.PageSize)) 77 } 78 if request.PageToken != nil { 79 query.Add("page_token", *request.PageToken) 80 } 81 if request.BrandId != nil { 82 query.Add("brand_id", *request.BrandId) 83 } 84 reqUrl.RawQuery = query.Encode() 85 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 86 if err != nil { 87 return nil, err 88 } 89 httpRequest.Header.Set("Accept", "application/json") 90 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 91 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 92 if err != nil { 93 return nil, err 94 } 95 httpRequest.Header.Set("Authorization", authorization) 96 97 client := &http.Client{} 98 httpResponse, err := client.Do(httpRequest) 99 if err != nil { 100 return nil, err 101 } 102 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 103 if err != nil { 104 return nil, err 105 } 106 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 107 // 2XX 成功,验证应答签名 108 err = wxpay_utility.ValidateResponse( 109 config.WechatPayPublicKeyId(), 110 config.WechatPayPublicKey(), 111 &httpResponse.Header, 112 respBody, 113 ) 114 if err != nil { 115 return nil, err 116 } 117 response := &ListUserProductCouponsResponse{} 118 if err := json.Unmarshal(respBody, response); err != nil { 119 return nil, err 120 } 121 122 return response, nil 123 } else { 124 return nil, wxpay_utility.NewApiException( 125 httpResponse.StatusCode, 126 httpResponse.Header, 127 respBody, 128 ) 129 } 130} 131 132type ListUserProductCouponsRequest struct { 133 ProductCouponId *string `json:"product_coupon_id,omitempty"` 134 StockId *string `json:"stock_id,omitempty"` 135 Appid *string `json:"appid,omitempty"` 136 Openid *string `json:"openid,omitempty"` 137 UserCouponBundleId *string `json:"user_coupon_bundle_id,omitempty"` 138 PageSize *int64 `json:"page_size,omitempty"` 139 PageToken *string `json:"page_token,omitempty"` 140 BrandId *string `json:"brand_id,omitempty"` 141 CouponState *UserProductCouponState `json:"coupon_state,omitempty"` 142} 143 144func (o *ListUserProductCouponsRequest) MarshalJSON() ([]byte, error) { 145 type Alias ListUserProductCouponsRequest 146 a := &struct { 147 ProductCouponId *string `json:"product_coupon_id,omitempty"` 148 StockId *string `json:"stock_id,omitempty"` 149 Appid *string `json:"appid,omitempty"` 150 Openid *string `json:"openid,omitempty"` 151 UserCouponBundleId *string `json:"user_coupon_bundle_id,omitempty"` 152 PageSize *int64 `json:"page_size,omitempty"` 153 PageToken *string `json:"page_token,omitempty"` 154 BrandId *string `json:"brand_id,omitempty"` 155 CouponState *UserProductCouponState `json:"coupon_state,omitempty"` 156 *Alias 157 }{ 158 // 序列化时移除非 Body 字段 159 ProductCouponId: nil, 160 StockId: nil, 161 Appid: nil, 162 Openid: nil, 163 UserCouponBundleId: nil, 164 PageSize: nil, 165 PageToken: nil, 166 BrandId: nil, 167 CouponState: nil, 168 Alias: (*Alias)(o), 169 } 170 return json.Marshal(a) 171} 172 173type ListUserProductCouponsResponse struct { 174 TotalCount *int64 `json:"total_count,omitempty"` 175 UserCouponList []UserProductCouponEntity `json:"user_coupon_list,omitempty"` 176 NextPageToken *string `json:"next_page_token,omitempty"` 177} 178 179type UserProductCouponState string 180 181func (e UserProductCouponState) Ptr() *UserProductCouponState { 182 return &e 183} 184 185const ( 186 USERPRODUCTCOUPONSTATE_CONFIRMING UserProductCouponState = "CONFIRMING" 187 USERPRODUCTCOUPONSTATE_PENDING UserProductCouponState = "PENDING" 188 USERPRODUCTCOUPONSTATE_EFFECTIVE UserProductCouponState = "EFFECTIVE" 189 USERPRODUCTCOUPONSTATE_USED UserProductCouponState = "USED" 190 USERPRODUCTCOUPONSTATE_EXPIRED UserProductCouponState = "EXPIRED" 191 USERPRODUCTCOUPONSTATE_DELETED UserProductCouponState = "DELETED" 192 USERPRODUCTCOUPONSTATE_DEACTIVATED UserProductCouponState = "DEACTIVATED" 193) 194 195type UserProductCouponEntity struct { 196 CouponCode *string `json:"coupon_code,omitempty"` 197 CouponState *UserProductCouponState `json:"coupon_state,omitempty"` 198 ValidBeginTime *time.Time `json:"valid_begin_time,omitempty"` 199 ValidEndTime *time.Time `json:"valid_end_time,omitempty"` 200 ReceiveTime *string `json:"receive_time,omitempty"` 201 SendRequestNo *string `json:"send_request_no,omitempty"` 202 SendChannel *UserProductCouponSendChannel `json:"send_channel,omitempty"` 203 ConfirmRequestNo *string `json:"confirm_request_no,omitempty"` 204 ConfirmTime *time.Time `json:"confirm_time,omitempty"` 205 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"` 206 DeactivateTime *string `json:"deactivate_time,omitempty"` 207 DeactivateReason *string `json:"deactivate_reason,omitempty"` 208 SingleUsageDetail *CouponUsageDetail `json:"single_usage_detail,omitempty"` 209 ProgressiveBundleUsageDetail *CouponUsageDetail `json:"progressive_bundle_usage_detail,omitempty"` 210 UserProductCouponBundleInfo *UserProductCouponBundleInfo `json:"user_product_coupon_bundle_info,omitempty"` 211 ProductCoupon *ProductCouponEntity `json:"product_coupon,omitempty"` 212 Stock *StockEntity `json:"stock,omitempty"` 213 Attach *string `json:"attach,omitempty"` 214 ChannelCustomInfo *string `json:"channel_custom_info,omitempty"` 215 CouponTagInfo *CouponTagInfo `json:"coupon_tag_info,omitempty"` 216 BrandId *string `json:"brand_id,omitempty"` 217} 218 219type UserProductCouponSendChannel string 220 221func (e UserProductCouponSendChannel) Ptr() *UserProductCouponSendChannel { 222 return &e 223} 224 225const ( 226 USERPRODUCTCOUPONSENDCHANNEL_BRAND_MANAGE UserProductCouponSendChannel = "BRAND_MANAGE" 227 USERPRODUCTCOUPONSENDCHANNEL_API UserProductCouponSendChannel = "API" 228 USERPRODUCTCOUPONSENDCHANNEL_RECEIVE_COMPONENT UserProductCouponSendChannel = "RECEIVE_COMPONENT" 229 USERPRODUCTCOUPONSENDCHANNEL_MEMBER UserProductCouponSendChannel = "MEMBER" 230 USERPRODUCTCOUPONSENDCHANNEL_STICKER_GIFT UserProductCouponSendChannel = "STICKER_GIFT" 231) 232 233type CouponUsageDetail struct { 234 UseRequestNo *string `json:"use_request_no,omitempty"` 235 UseTime *time.Time `json:"use_time,omitempty"` 236 ReturnRequestNo *string `json:"return_request_no,omitempty"` 237 ReturnTime *time.Time `json:"return_time,omitempty"` 238 AssociatedOrderInfo *UserProductCouponAssociatedOrderInfo `json:"associated_order_info,omitempty"` 239 AssociatedPayScoreOrderInfo *UserProductCouponAssociatedPayScoreOrderInfo `json:"associated_pay_score_order_info,omitempty"` 240 SavedAmount *int64 `json:"saved_amount,omitempty"` 241 UseProductNoList []string `json:"use_product_no_list,omitempty"` 242} 243 244type UserProductCouponBundleInfo struct { 245 UserCouponBundleId *string `json:"user_coupon_bundle_id,omitempty"` 246 UserCouponBundleIndex *int64 `json:"user_coupon_bundle_index,omitempty"` 247 TotalCount *int64 `json:"total_count,omitempty"` 248 UsedCount *int64 `json:"used_count,omitempty"` 249} 250 251type ProductCouponEntity struct { 252 ProductCouponId *string `json:"product_coupon_id,omitempty"` 253 Scope *ProductCouponScope `json:"scope,omitempty"` 254 Type *ProductCouponType `json:"type,omitempty"` 255 UsageMode *UsageMode `json:"usage_mode,omitempty"` 256 SingleUsageInfo *SingleUsageInfo `json:"single_usage_info,omitempty"` 257 ProgressiveBundleUsageInfo *ProgressiveBundleUsageInfo `json:"progressive_bundle_usage_info,omitempty"` 258 DisplayInfo *ProductCouponDisplayInfo `json:"display_info,omitempty"` 259 OutProductNo *string `json:"out_product_no,omitempty"` 260 State *ProductCouponState `json:"state,omitempty"` 261 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"` 262 DeactivateTime *string `json:"deactivate_time,omitempty"` 263 DeactivateReason *string `json:"deactivate_reason,omitempty"` 264 BrandId *string `json:"brand_id,omitempty"` 265 AvailableProductNoList []string `json:"available_product_no_list,omitempty"` 266 BusinessMode *ProductCouponBusinessMode `json:"business_mode,omitempty"` 267} 268 269type StockEntity struct { 270 ProductCouponId *string `json:"product_coupon_id,omitempty"` 271 StockId *string `json:"stock_id,omitempty"` 272 Remark *string `json:"remark,omitempty"` 273 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"` 274 CouponCodeCountInfo *CouponCodeCountInfo `json:"coupon_code_count_info,omitempty"` 275 StockSendRule *StockSendRule `json:"stock_send_rule,omitempty"` 276 SingleUsageRule *SingleUsageRule `json:"single_usage_rule,omitempty"` 277 ProgressiveBundleUsageRule *StockUsageRule `json:"progressive_bundle_usage_rule,omitempty"` 278 StockBundleInfo *StockBundleInfo `json:"stock_bundle_info,omitempty"` 279 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"` 280 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"` 281 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"` 282 StoreScope *StockStoreScope `json:"store_scope,omitempty"` 283 SentCountInfo *StockSentCountInfo `json:"sent_count_info,omitempty"` 284 State *StockState `json:"state,omitempty"` 285 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"` 286 DeactivateTime *time.Time `json:"deactivate_time,omitempty"` 287 DeactivateReason *string `json:"deactivate_reason,omitempty"` 288 BrandId *string `json:"brand_id,omitempty"` 289} 290 291type CouponTagInfo struct { 292 CouponTagList []UserProductCouponTag `json:"coupon_tag_list,omitempty"` 293 MemberTagInfo *MemberTagInfo `json:"member_tag_info,omitempty"` 294} 295 296type UserProductCouponAssociatedOrderInfo struct { 297 TransactionId *string `json:"transaction_id,omitempty"` 298 OutTradeNo *string `json:"out_trade_no,omitempty"` 299 Mchid *string `json:"mchid,omitempty"` 300 SubMchid *string `json:"sub_mchid,omitempty"` 301} 302 303type UserProductCouponAssociatedPayScoreOrderInfo struct { 304 OrderId *string `json:"order_id,omitempty"` 305 OutOrderNo *string `json:"out_order_no,omitempty"` 306 Mchid *string `json:"mchid,omitempty"` 307 SubMchid *string `json:"sub_mchid,omitempty"` 308} 309 310type ProductCouponScope string 311 312func (e ProductCouponScope) Ptr() *ProductCouponScope { 313 return &e 314} 315 316const ( 317 PRODUCTCOUPONSCOPE_ALL ProductCouponScope = "ALL" 318 PRODUCTCOUPONSCOPE_SINGLE ProductCouponScope = "SINGLE" 319 PRODUCTCOUPONSCOPE_CATEGORY ProductCouponScope = "CATEGORY" 320) 321 322type ProductCouponType string 323 324func (e ProductCouponType) Ptr() *ProductCouponType { 325 return &e 326} 327 328const ( 329 PRODUCTCOUPONTYPE_NORMAL ProductCouponType = "NORMAL" 330 PRODUCTCOUPONTYPE_DISCOUNT ProductCouponType = "DISCOUNT" 331 PRODUCTCOUPONTYPE_EXCHANGE ProductCouponType = "EXCHANGE" 332) 333 334type UsageMode string 335 336func (e UsageMode) Ptr() *UsageMode { 337 return &e 338} 339 340const ( 341 USAGEMODE_SINGLE UsageMode = "SINGLE" 342 USAGEMODE_PROGRESSIVE_BUNDLE UsageMode = "PROGRESSIVE_BUNDLE" 343) 344 345type SingleUsageInfo struct { 346 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 347 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 348} 349 350type ProgressiveBundleUsageInfo struct { 351 Count *int64 `json:"count,omitempty"` 352 IntervalDays *int64 `json:"interval_days,omitempty"` 353} 354 355type ProductCouponDisplayInfo struct { 356 Name *string `json:"name,omitempty"` 357 ImageUrl *string `json:"image_url,omitempty"` 358 BackgroundUrl *string `json:"background_url,omitempty"` 359 DetailImageUrlList []string `json:"detail_image_url_list,omitempty"` 360 OriginalPrice *int64 `json:"original_price,omitempty"` 361 ComboPackageList []ComboPackage `json:"combo_package_list,omitempty"` 362} 363 364type ProductCouponState string 365 366func (e ProductCouponState) Ptr() *ProductCouponState { 367 return &e 368} 369 370const ( 371 PRODUCTCOUPONSTATE_AUDITING ProductCouponState = "AUDITING" 372 PRODUCTCOUPONSTATE_EFFECTIVE ProductCouponState = "EFFECTIVE" 373 PRODUCTCOUPONSTATE_DEACTIVATED ProductCouponState = "DEACTIVATED" 374) 375 376type ProductCouponBusinessMode string 377 378func (e ProductCouponBusinessMode) Ptr() *ProductCouponBusinessMode { 379 return &e 380} 381 382const ( 383 PRODUCTCOUPONBUSINESSMODE_FREE ProductCouponBusinessMode = "FREE" 384) 385 386type CouponCodeMode string 387 388func (e CouponCodeMode) Ptr() *CouponCodeMode { 389 return &e 390} 391 392const ( 393 COUPONCODEMODE_WECHATPAY CouponCodeMode = "WECHATPAY" 394 COUPONCODEMODE_UPLOAD CouponCodeMode = "UPLOAD" 395 COUPONCODEMODE_API_ASSIGN CouponCodeMode = "API_ASSIGN" 396) 397 398type CouponCodeCountInfo struct { 399 TotalCount *int64 `json:"total_count,omitempty"` 400 AvailableCount *int64 `json:"available_count,omitempty"` 401} 402 403type StockSendRule struct { 404 MaxCount *int64 `json:"max_count,omitempty"` 405 MaxCountPerDay *int64 `json:"max_count_per_day,omitempty"` 406 MaxCountPerUser *int64 `json:"max_count_per_user,omitempty"` 407} 408 409type SingleUsageRule struct { 410 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"` 411 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 412 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 413 ExchangeCoupon *ExchangeCouponUsageRule `json:"exchange_coupon,omitempty"` 414} 415 416type StockUsageRule struct { 417 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"` 418 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 419 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 420 ExchangeCoupon *ExchangeCouponUsageRule `json:"exchange_coupon,omitempty"` 421} 422 423type StockBundleInfo struct { 424 StockBundleId *string `json:"stock_bundle_id,omitempty"` 425 StockBundleIndex *int64 `json:"stock_bundle_index,omitempty"` 426} 427 428type UsageRuleDisplayInfo struct { 429 CouponUsageMethodList []CouponUsageMethod `json:"coupon_usage_method_list,omitempty"` 430 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 431 MiniProgramPath *string `json:"mini_program_path,omitempty"` 432 AppPath *string `json:"app_path,omitempty"` 433 UsageDescription *string `json:"usage_description,omitempty"` 434 CouponAvailableStoreInfo *CouponAvailableStoreInfo `json:"coupon_available_store_info,omitempty"` 435 AppJumpType *AppJumpType `json:"app_jump_type,omitempty"` 436 PasscodeLink *string `json:"passcode_link,omitempty"` 437} 438 439type CouponDisplayInfo struct { 440 CodeDisplayMode *CouponCodeDisplayMode `json:"code_display_mode,omitempty"` 441 BackgroundColor *string `json:"background_color,omitempty"` 442 EntranceMiniProgram *EntranceMiniProgram `json:"entrance_mini_program,omitempty"` 443 EntranceOfficialAccount *EntranceOfficialAccount `json:"entrance_official_account,omitempty"` 444} 445 446type NotifyConfig struct { 447 NotifyAppid *string `json:"notify_appid,omitempty"` 448} 449 450type StockStoreScope string 451 452func (e StockStoreScope) Ptr() *StockStoreScope { 453 return &e 454} 455 456const ( 457 STOCKSTORESCOPE_NONE StockStoreScope = "NONE" 458 STOCKSTORESCOPE_ALL StockStoreScope = "ALL" 459 STOCKSTORESCOPE_SPECIFIC StockStoreScope = "SPECIFIC" 460) 461 462type StockSentCountInfo struct { 463 TotalCount *int64 `json:"total_count,omitempty"` 464 TodayCount *int64 `json:"today_count,omitempty"` 465} 466 467type StockState string 468 469func (e StockState) Ptr() *StockState { 470 return &e 471} 472 473const ( 474 STOCKSTATE_AUDITING StockState = "AUDITING" 475 STOCKSTATE_SENDING StockState = "SENDING" 476 STOCKSTATE_PAUSED StockState = "PAUSED" 477 STOCKSTATE_STOPPED StockState = "STOPPED" 478 STOCKSTATE_DEACTIVATED StockState = "DEACTIVATED" 479) 480 481type UserProductCouponTag string 482 483func (e UserProductCouponTag) Ptr() *UserProductCouponTag { 484 return &e 485} 486 487const ( 488 USERPRODUCTCOUPONTAG_MEMBER UserProductCouponTag = "MEMBER" 489 USERPRODUCTCOUPONTAG_MEMBER_ACTIVITY UserProductCouponTag = "MEMBER_ACTIVITY" 490) 491 492type MemberTagInfo struct { 493 MemberCardId *string `json:"member_card_id,omitempty"` 494} 495 496type NormalCouponUsageRule struct { 497 Threshold *int64 `json:"threshold,omitempty"` 498 DiscountAmount *int64 `json:"discount_amount,omitempty"` 499} 500 501type DiscountCouponUsageRule struct { 502 Threshold *int64 `json:"threshold,omitempty"` 503 PercentOff *int64 `json:"percent_off,omitempty"` 504} 505 506type ComboPackage struct { 507 Name *string `json:"name,omitempty"` 508 PickCount *int64 `json:"pick_count,omitempty"` 509 ChoiceList []ComboPackageChoice `json:"choice_list,omitempty"` 510} 511 512type CouponAvailablePeriod struct { 513 AvailableBeginTime *string `json:"available_begin_time,omitempty"` 514 AvailableEndTime *string `json:"available_end_time,omitempty"` 515 AvailableDays *int64 `json:"available_days,omitempty"` 516 WaitDaysAfterReceive *int64 `json:"wait_days_after_receive,omitempty"` 517 WeeklyAvailablePeriod *FixedWeekPeriod `json:"weekly_available_period,omitempty"` 518 IrregularAvailablePeriodList []TimePeriod `json:"irregular_available_period_list,omitempty"` 519 AvailableSeconds *int64 `json:"available_seconds,omitempty"` 520} 521 522type ExchangeCouponUsageRule struct { 523 Threshold *int64 `json:"threshold,omitempty"` 524 ExchangePrice *int64 `json:"exchange_price,omitempty"` 525} 526 527type CouponUsageMethod string 528 529func (e CouponUsageMethod) Ptr() *CouponUsageMethod { 530 return &e 531} 532 533const ( 534 COUPONUSAGEMETHOD_OFFLINE CouponUsageMethod = "OFFLINE" 535 COUPONUSAGEMETHOD_MINI_PROGRAM CouponUsageMethod = "MINI_PROGRAM" 536 COUPONUSAGEMETHOD_APP CouponUsageMethod = "APP" 537 COUPONUSAGEMETHOD_PAYMENT_CODE CouponUsageMethod = "PAYMENT_CODE" 538) 539 540type CouponAvailableStoreInfo struct { 541 Description *string `json:"description,omitempty"` 542 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 543 MiniProgramPath *string `json:"mini_program_path,omitempty"` 544} 545 546type AppJumpType string 547 548func (e AppJumpType) Ptr() *AppJumpType { 549 return &e 550} 551 552const ( 553 APPJUMPTYPE_H5 AppJumpType = "H5" 554 APPJUMPTYPE_PASSCODE_LINK AppJumpType = "PASSCODE_LINK" 555 APPJUMPTYPE_USAGE_GUIDE AppJumpType = "USAGE_GUIDE" 556) 557 558type CouponCodeDisplayMode string 559 560func (e CouponCodeDisplayMode) Ptr() *CouponCodeDisplayMode { 561 return &e 562} 563 564const ( 565 COUPONCODEDISPLAYMODE_INVISIBLE CouponCodeDisplayMode = "INVISIBLE" 566 COUPONCODEDISPLAYMODE_BARCODE CouponCodeDisplayMode = "BARCODE" 567 COUPONCODEDISPLAYMODE_QRCODE CouponCodeDisplayMode = "QRCODE" 568) 569 570type EntranceMiniProgram struct { 571 Appid *string `json:"appid,omitempty"` 572 Path *string `json:"path,omitempty"` 573 EntranceWording *string `json:"entrance_wording,omitempty"` 574 GuidanceWording *string `json:"guidance_wording,omitempty"` 575} 576 577type EntranceOfficialAccount struct { 578 Appid *string `json:"appid,omitempty"` 579} 580 581type ComboPackageChoice struct { 582 Name *string `json:"name,omitempty"` 583 Price *int64 `json:"price,omitempty"` 584 Count *int64 `json:"count,omitempty"` 585 ImageUrl *string `json:"image_url,omitempty"` 586 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 587 MiniProgramPath *string `json:"mini_program_path,omitempty"` 588} 589 590type FixedWeekPeriod struct { 591 DayList []WeekEnum `json:"day_list,omitempty"` 592 DayPeriodList []PeriodOfTheDay `json:"day_period_list,omitempty"` 593} 594 595type TimePeriod struct { 596 BeginTime *string `json:"begin_time,omitempty"` 597 EndTime *string `json:"end_time,omitempty"` 598} 599 600type WeekEnum string 601 602func (e WeekEnum) Ptr() *WeekEnum { 603 return &e 604} 605 606const ( 607 WEEKENUM_MONDAY WeekEnum = "MONDAY" 608 WEEKENUM_TUESDAY WeekEnum = "TUESDAY" 609 WEEKENUM_WEDNESDAY WeekEnum = "WEDNESDAY" 610 WEEKENUM_THURSDAY WeekEnum = "THURSDAY" 611 WEEKENUM_FRIDAY WeekEnum = "FRIDAY" 612 WEEKENUM_SATURDAY WeekEnum = "SATURDAY" 613 WEEKENUM_SUNDAY WeekEnum = "SUNDAY" 614) 615 616type PeriodOfTheDay struct { 617 BeginTime *int64 `json:"begin_time,omitempty"` 618 EndTime *int64 `json:"end_time,omitempty"` 619} 620
应答参数
折叠全部参数
200 OK
total_count 必填 integer
【总个数】 满足条件的数据总条数,当且仅当 page_token 为空时提供。
user_coupon_list 选填 array[object]
【用户商品券列表】 指定状态的用户商品券列表信息
coupon_code 必填 string(40)
【用户商品券Code】 用户商品券的唯一标识
coupon_state 必填 string
【用户商品券状态】
可选取值
CONFIRMING: 待确认,用户商品券发放需要品牌方调用【确认发放用户商品券API(单券)】或【确认发放用户商品券API(多次优惠)】后才能生效PENDING: 已发放待生效,用户商品券已发放成功但尚未到达可用开始时间EFFECTIVE: 已生效,用户商品券已成功发放且到达可用开始时间USED: 已核销,用户商品券已核销EXPIRED: 已过期,用户商品券已超过有效期,不再可用DELETED: 已删除,用户主动删除该券DEACTIVATED: 已失效,品牌方主动调用【失效用户商品券API】或【失效用户商品券组API】使用户商品券失效
valid_begin_time 必填 string
【有效期开始时间】 用户商品券可用开始时间,遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
valid_end_time 必填 string
【有效期结束时间】 用户商品券可用结束时间。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
receive_time 必填 string
【领券时间】 用户领券时间。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
send_request_no 必填 string(128)
【发券请求单号】 发券时传入的请求流水号
send_channel 必填 string
【发券渠道】 描述用户商品券是经由什么渠道发送的
可选取值
BRAND_MANAGE: 摇一摇有优惠,通过摇一摇有优惠渠道发放API: 服务商自主发券,服务商通过发券接口自主发券到商家名片RECEIVE_COMPONENT: 小程序领券组件,服务商通过小程序领券组件发券MEMBER: 会员,品牌方通过会员相关活动或渠道进行发券STICKER_GIFT: 贴图有礼,用户参与品牌贴图有礼活动后发放
confirm_request_no 选填 string
【确认请求单号】 品牌方确认发券请求时传入的的请求流水号。当且仅当 品牌方调用【确认发放用户商品券API】后提供。
confirm_time 选填 string
【确认发放时间】 品牌方确认发券时间,当且仅当 品牌方调用【确认发放用户商品券API】后提供。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
deactivate_request_no 选填 string(128)
【失效请求单号】 品牌方失效券请求时传入的的请求流水号。当且仅当 coupon_state 为 DEACTIVATED 时提供,返回品牌方调用【失效用户商品券API】或【失效用户商品券组API】时传入的请求流水号
deactivate_time 选填 string
【失效时间】 失效时间,当且仅当 coupon_state 为 DEACTIVATED 时提供。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
deactivate_reason 选填 string(150)
【失效原因】 失效券的原因,当且仅当 coupon_state 为 DEACTIVATED 时提供,返回品牌方调用【失效用户商品券API】或【失效用户商品券组API】时传入的失效原因
single_usage_detail 选填 object
【单券使用详情】 当且仅当 usage_mode 为 SINGLE 时提供
use_request_no 选填 string
【券核销请求单号】 券核销的请求流水号,当且仅当用户商品券状态 coupon_state 为 USED 时提供
use_time 选填 string
【券核销时间】 券被核销的时间,当且仅当用户商品券状态 coupon_state 为 USED 时提供。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
return_request_no 选填 string
【退券请求单号】 品牌退券时传入的请求流水号,当且仅当券发生了退回后提供此字段
return_time 选填 string
【退券时间】 券被退回的时间,当且仅当券发生了退回后提供此字段。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
associated_order_info 选填 object
【券核销的微信支付订单信息】 券核销对应的微信支付订单信息,当且仅当用户商品券状态 coupon_state 为 USED 时提供,
注:
1、associated_order_info与 associated_pay_score_order_info 会根据核销请求时的传入参数决定返回对应字段
2、订单信息必须至少传入 transaction_id 与 out_trade_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
transaction_id 选填 string
【微信支付单号】 由微信支付生成的支付单唯一标识,可以唯一定位到一笔微信支付单。
注:订单信息必须至少传入 transaction_id 与 out_trade_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
out_trade_no 选填 string
【商户订单号】 在微信支付支付时传入的商户订单号,在商户侧具有唯一性,因此提供此字段时应同时提供下单商户号:
如果此单为服务商模式下单,则需提供 父商户号
mchid以及 子商户号sub_mchid如果此单为直连商户模式下单,则需提供 直连商户号
mchid
注:订单信息必须至少传入 transaction_id 与 out_trade_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
mchid 选填 string
【商户号】 当提供 out_trade_no 时此字段必传,否则可以省略。参考如下规则传入:
若为服务商模式,则此字段为服务商商户号
若为直连商户模式,则此字段为商户号
sub_mchid 选填 string
【子商户号】 当提供 out_trade_no 时,参考如下规则传入:
若为服务商模式,则此字段必填,为子商户号
若为直连商户模式,则此字段为空
不提供 out_trade_no 时可忽略此字段
associated_pay_score_order_info 选填 object
【券核销的关联微信支付分订单信息】 券核销的关联微信支付分订单信息,当且仅当用户商品券状态 coupon_state 为 USED 时提供,
注:
1、associated_order_info与 associated_pay_score_order_info 会根据核销请求时的传入参数决定返回对应字段
2、订单信息必须至少传入 order_id 与 out_order_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
order_id 选填 string
【微信支付服务订单号】 支付分订单在微信侧的唯一标识。
注:订单信息必须至少传入 order_id 与 out_order_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
out_order_no 选填 string
【商户服务订单号】 商户系统内部服务订单号,要求32个字符内,只能是数字、大小写字母_-| 且在同一个商户号下唯一。:
如果此单为服务商模式下单,则需提供 父商户号
mchid以及 子商户号sub_mchid如果此单为直连商户模式下单,则需提供 直连商户号
mchid
注:订单信息必须至少传入 order_id 与 out_order_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付服务单。
mchid 选填 string
【商户号】 当提供 out_order_no 时此字段必传,否则可以省略。参考如下规则传入:
若为服务商模式,则此字段为服务商商户号
若为直连商户模式,则此字段为商户号
sub_mchid 选填 string
【子商户号】 当提供 out_order_no 时,参考如下规则传入:
若为服务商模式,则此字段必填,为子商户号
若为直连商户模式,则此字段为空
不提供 out_order_no 时可忽略此字段
saved_amount 选填 integer
【优惠金额】 使用本券的实际优惠金额,单位为分
注:
当本券为全场/品类折扣券(scope=
ALL或CATEGORY)时,提供的是传入的值
use_product_no_list 选填 array[string]
【核销商品编码列表】 核销商品编码列表
注:
当该券优惠范围为单品或品类且商户核销时传入的商品编码列表正确时提供
progressive_bundle_usage_detail 选填 object
【多次优惠使用详情】 当且仅当 usage_mode 为 PROGRESSIVE_BUNDLE 时提供
use_request_no 选填 string
【券核销请求单号】 券核销的请求流水号,当且仅当用户商品券状态 coupon_state 为 USED 时提供
use_time 选填 string
【券核销时间】 券被核销的时间,当且仅当用户商品券状态 coupon_state 为 USED 时提供。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
return_request_no 选填 string
【退券请求单号】 品牌退券时传入的请求流水号,当且仅当券发生了退回后提供此字段
return_time 选填 string
【退券时间】 券被退回的时间,当且仅当券发生了退回后提供此字段。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)
associated_order_info 选填 object
【券核销的微信支付订单信息】 券核销对应的微信支付订单信息,当且仅当用户商品券状态 coupon_state 为 USED 时提供,
注:
1、associated_order_info与 associated_pay_score_order_info 会根据核销请求时的传入参数决定返回对应字段
2、订单信息必须至少传入 transaction_id 与 out_trade_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
transaction_id 选填 string
【微信支付单号】 由微信支付生成的支付单唯一标识,可以唯一定位到一笔微信支付单。
注:订单信息必须至少传入 transaction_id 与 out_trade_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
out_trade_no 选填 string
【商户订单号】 在微信支付支付时传入的商户订单号,在商户侧具有唯一性,因此提供此字段时应同时提供下单商户号:
如果此单为服务商模式下单,则需提供 父商户号
mchid以及 子商户号sub_mchid如果此单为直连商户模式下单,则需提供 直连商户号
mchid
注:订单信息必须至少传入 transaction_id 与 out_trade_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
mchid 选填 string
【商户号】 当提供 out_trade_no 时此字段必传,否则可以省略。参考如下规则传入:
若为服务商模式,则此字段为服务商商户号
若为直连商户模式,则此字段为商户号
sub_mchid 选填 string
【子商户号】 当提供 out_trade_no 时,参考如下规则传入:
若为服务商模式,则此字段必填,为子商户号
若为直连商户模式,则此字段为空
不提供 out_trade_no 时可忽略此字段
associated_pay_score_order_info 选填 object
【券核销的关联微信支付分订单信息】 券核销的关联微信支付分订单信息,当且仅当用户商品券状态 coupon_state 为 USED 时提供,
注:
1、associated_order_info与 associated_pay_score_order_info 会根据核销请求时的传入参数决定返回对应字段
2、订单信息必须至少传入 order_id 与 out_order_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
order_id 选填 string
【微信支付服务订单号】 支付分订单在微信侧的唯一标识。
注:订单信息必须至少传入 order_id 与 out_order_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付单。
out_order_no 选填 string
【商户服务订单号】 商户系统内部服务订单号,要求32个字符内,只能是数字、大小写字母_-| 且在同一个商户号下唯一。:
如果此单为服务商模式下单,则需提供 父商户号
mchid以及 子商户号sub_mchid如果此单为直连商户模式下单,则需提供 直连商户号
mchid
注:订单信息必须至少传入 order_id 与 out_order_no 之一,亦可同时传入,同时传入时应保证二者指向同一笔微信支付服务单。
mchid 选填 string
【商户号】 当提供 out_order_no 时此字段必传,否则可以省略。参考如下规则传入:
若为服务商模式,则此字段为服务商商户号
若为直连商户模式,则此字段为商户号
sub_mchid 选填 string
【子商户号】 当提供 out_order_no 时,参考如下规则传入:
若为服务商模式,则此字段必填,为子商户号
若为直连商户模式,则此字段为空
不提供 out_order_no 时可忽略此字段
saved_amount 选填 integer
【优惠金额】 使用本券的实际优惠金额,单位为分
注:
当本券为全场/品类折扣券(scope=
ALL或CATEGORY)时,提供的是传入的值
use_product_no_list 选填 array[string]
【核销商品编码列表】 核销商品编码列表
注:
当该券优惠范围为单品或品类且商户核销时传入的商品编码列表正确时提供
user_product_coupon_bundle_info 选填 object
【用户券组信息】 当前用户券所属用户券组的信息,当且仅当 usage_mode 为 PROGRESSIVE_BUNDLE 时提供
user_coupon_bundle_id 必填 string
【用户券组ID】 本券所属的用户券组ID,【向用户发放商品券批次组】时由微信支付生成
user_coupon_bundle_index 必填 integer
【用户券组内索引】 本券在所属用户券组内的序号,从 0 开始编号
total_count 必填 integer
【总可使用次数】 所属用户券组总计可用次数
used_count 必填 integer
【已使用次数】 所属用户券组已使用次数
product_coupon 必填 object
【商品券信息】 该用户商品券对应的商品券详情
product_coupon_id 必填 string(40)
【商品券ID】 商品券的唯一标识,由微信支付生成
scope 必填 string
【优惠范围】 商品券优惠范围
可选取值
ALL: 全场商品可用券,此时券类型type仅可配置为NORMAL或DISCOUNTSINGLE: 部分商品可用券,此时券类型type配置不受限制,即可配置为NORMAL、DISCOUNT或EXCHANGECATEGORY: 品类券。适用于商户对某一品类商品提供优惠的场景;系统侧不维护商品/品类清单,具体可用商品范围由商户在display_info描述、图片等字段中向用户告知,并在核销时由商户自行判定。此时券类型type仅可配置为NORMAL或DISCOUNT
type 必填 string
【商品券类型】 商品券的优惠类型
可选取值
NORMAL: 满减券DISCOUNT: 折扣券EXCHANGE: 兑换券,仅在scope为SINGLE时可配置
usage_mode 必填 string
【使用模式】 商品券使用模式
可选取值
SINGLE: 单券,即用户只能使用一次,使用后券失效PROGRESSIVE_BUNDLE: 多次优惠,由一组批次组成,每阶梯次序对应一个批次。用户按顺序使用,每次核销后发放下一张券,直到用完为止
single_usage_info 选填 object
【单券模式信息】 单券模式配置信息,仅当 usage_mode 为 SINGLE 时提供,其他场景不提供。
normal_coupon 选填 object
【满减券使用规则】 本商品券内所有批次均以此规则提供满减优惠,当且仅当 type 为 NORMAL 且 scope 为 ALL 或 CATEGORY 时必填,其他类型不应填写。
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受满减优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
discount_amount 必填 integer
【固定减免金额】 固定减免金额,单位为分,必须大于0。
discount_coupon 选填 object
【折扣券使用规则】 本商品券内所有批次均以此规则提供折扣优惠,当且仅当 type 为 DISCOUNT 且 scope 为 ALL 或 CATEGORY 时必填,其他类型不应填写。
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受折扣优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
percent_off 必填 integer
【固定减免百分比】 表示减免金额为总金额的百分比,必须大于0。例如:填入 30 表示减免 30%,即打 7 折
progressive_bundle_usage_info 选填 object
【多次优惠模式信息】 多次优惠模式配置信息,当且仅当 usage_mode 为 PROGRESSIVE_BUNDLE 时提供,其他模式不提供。
count 必填 integer
【可使用次数】 多次优惠领取后用户可使用次数,最少3次,最多15次
interval_days 选填 integer
【多次优惠使用间隔天数】 多次优惠多次使用之间需要间隔的天数,最高7天。例如:
间隔
0天表示不限制,使用后当天仍然可以继续使用下一次优惠间隔
1天表示使用后当天不再可用,下一次优惠需要等到次日 00:00:00 才能使用间隔
2天表示使用后当天和次日不再可用,下一次优惠需要等到第三天 00:00:00 才能使用依此类推……
默认情况下为 0 天,即不限制,使用后当天仍然可以继续使用下一次优惠
display_info 必填 object
【展示信息】 商品券展示信息
name 必填 string(25)
【商品券名称】 商品券名称,长度为3-25个UTF-8字符
image_url 必填 string
【商品券图片】 商品图片的链接地址,仅支持通过【图片上传API】获取的图片URL地址。
请参考商品券图片设计规范进行设计
要求图片宽高比1:1,建议尺寸1080*1080
大小不超过2M
建议图片格式:透明PNG格式
需要注意保留透明边距(上下左右各120px)
background_url 必填 string
【商品券背景图】 商品背景图片的URL地址,仅支持通过【图片上传API】获取的图片URL地址。
要求图片宽高比65:77,建议尺寸1170*1326
大小不超过2M
建议图片格式:JPG/PNG格式
需要注意保留「商品名称」与「商品图」的安全区域
detail_image_url_list 选填 array[string]
【商品券详情图列表】 商品详情图URL地址列表,用于最多可上传8张图片,仅支持通过【图片上传API】获取的图片URL地址。
要求图片宽高比65:77,建议尺寸1170*1326
大小不超过2M
建议图片格式:JPG/PNG格式
original_price 选填 integer
【商品原价】 单位为分,用于对外展示,最大为 10000000。不填写时默认为 0
combo_package_list 选填 array[object]
【适用商品组合】 当 scope 为 SINGLE 必填,用于对外展示,其他优惠范围选填。最多配置 50 个组合
name 必填 string(25)
【适用商品名】 长度不超过25个UTF-8字符
pick_count 必填 integer
【可选单品数量】 用户可以从 choice_list 中选择的选项数量,例如 10 选 3,则这里填 3
choice_list 必填 array[object]
【单品列表】 套餐内包含的选项列表,记录每个单品的信息,最多99个单品,且不能少于设置的pick_count数量
name 必填 string(25)
【单品名称】 长度不超过25个UTF-8字符
price 必填 integer
【单品价格】 单位为分,必须大于0。
count 必填 integer
【单品数量】 最多99个
image_url 选填 string
【单品图片】 单品图片URL地址,仅支持通过【图片上传API】获取的图片URL地址,接入领券组件和核销组件的品牌方建议填写。
要求图片宽高比1:1,建议尺寸1080*1080
大小不超过2M
建议图片格式:透明PNG格式
需要注意保留透明边距(上下左右各120px)
mini_program_appid 选填 string
【单品跳转小程序AppID】 品牌方或服务商可展示单品的小程序AppID,小程序需与品牌方或服务商存在绑定关系,接入领券组件和核销组件的品牌方或服务商建议填写。需和 mini_program_path 一同填写。
mini_program_path 选填 string
【单品跳转小程序路径】 单品展示信息在小程序内的跳转路径,接入领券组件和核销组件的品牌方或服务商建议填写。需和 mini_program_appid 一同填写。
out_product_no 选填 string
【外部商品ID】 商户创建商品券时主动传入的外部商品ID,原样返回
state 必填 string
【商品券状态】 商品券状态
可选取值
AUDITING: 审批中,审批完成前商品券不可用EFFECTIVE: 生效中,商品券已生效,可以正常使用DEACTIVATED: 已失效,品牌方主动调用失效接口使商品券失效
deactivate_request_no 选填 string(128)
【失效请求单号】 当且仅当 state 为 DEACTIVATED 时提供,返回品牌方调用【失效商品券API】时传入的请求流水号
deactivate_time 选填 string
【失效时间】 当且仅当 state 为 DEACTIVATED 时提供,遵循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秒。
deactivate_reason 选填 string(150)
【失效原因】 当且仅当 state 为 DEACTIVATED 时提供,返回品牌方调用【失效商品券API】时传入的失效原因
brand_id 必填 string
【品牌ID】 微信支付为品牌方分配的唯一标识,该品牌应与服务商存在授权关系
available_product_no_list 选填 array[string]
【可用商品编码列表】 商户创建商品券时主动传入的可用商品编码,原样返回
business_mode 必填 string
【业务模式】 商品券的业务模式;本能力上线前创建的存量商品券统一返回 FREE
可选取值
FREE: 普通券,用户可直接领取。
stock 必填 object
【批次信息】 该用户商品券发券时使用的批次详情
product_coupon_id 必填 string(40)
【商品券ID】 商品券的唯一标识,由微信支付生成
stock_id 必填 string(40)
【批次ID】 商品券批次的唯一标识,由微信支付生成
remark 选填 string(20)
【备注】 仅配置品牌可见,用于自定义信息
coupon_code_mode 必填 string
【券Code分配模式】 决定发券时用户商品券Code如何产生
可选取值
WECHATPAY: 微信支付随机生成,发券时由微信支付系统自动随机生成券码,品牌方无需干预,微信支付随机生成的券Code长度限制为40个字符以内UPLOAD: 品牌方预上传Code,品牌方需先使用【预上传券Code API(单券)】或【预上传券Code API(多次优惠)】上传自定义Code,微信支付系统发券时从中随机选取,当预存Code不足时可能影响发券,品牌应及时补充API_ASSIGN: 品牌方自行指定,品牌方通过【向用户发放商品券API】自行发券时指定,微信支付系统不再进行自动分配。特别注意:这种模式的商品批次只可由品牌方自行发券,无法在摇一摇有优惠等微信支付渠道投放;商品券的usage_mode为PROGRESSIVE_BUNDLE时不可使用本模式
coupon_code_count_info 选填 object
【品牌方预上传的券Code数量信息】 当且仅当 coupon_code_mode 为 UPLOAD 时存在此字段
total_count 必填 integer
【已上传的Code总数】 品牌方为此批次已经上传过的券Code总数量
available_count 必填 integer
【当前可用的Code数】 品牌方为此批次已经上传过的券Code中,当前剩余可用的券Code数量
stock_send_rule 必填 object
【发放规则】 发放规则
max_count 必填 integer
【发放次数总上限】 批次在生命周期内总发放次数,最多 100,000,000 次
max_count_per_day 选填 integer
【每日发放次数上限】 批次在每天内发放次数上限,每日刷新,最多 100,000,000 次。默认不限制每日发放上限
max_count_per_user 必填 integer
【每个用户领取次数上限】 每个用户最多可领取本批次的次数,最多 100 次。
single_usage_rule 选填 object
【单券使用规则】 当且仅当 usage_mode 为 SINGLE 时提供,其他场景不提供
coupon_available_period 必填 object
【券可核销时间】 确定用户领券后在什么时间段内可以核销
available_begin_time 必填 string
【批次开始时间】 遵循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秒。
距离当前创建批次的时间不能超过90天,批次有效期最长不超过366天,摇优惠场景建议设置批次时间大于等于5天
available_end_time 必填 string
【批次结束时间】 遵循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秒。
批次有效期最长不超过366天
available_days 选填 integer
【券生效后N天内可用】 日期区间内,券生效后 N 天内有效,最多365天。例如:
生效当天内有效填 1
生效后2天内有效填 2
依此类推……
用户在有效期开始前领取商品券,则从有效期第1天开始计算天数,用户在有效期内领取商品券,则从领取当天开始计算天数,无论用户何时领取商品券,商品券在活动有效期结束后均不可用。
可配合 wait_days_after_receive 一同填写,也可单独填写。
注:不可与 irregular_available_period_list 同时配置
wait_days_after_receive 选填 integer
【领券后需等待N天才生效】 日期区间内,用户领券后需等待 N 天才开始生效,最多30天。例如:
领券后当天开始生效则无需填写
领券后第二天开始生效则填写 1
用户在有效期开始前领取商品券,则从有效期第1天开始计算天数,用户在有效期内领取商品券,则从领取当天开始计算天数。无论用户何时领取商品券,商品券在活动有效期结束后均不可用。
需配合 available_days 一同填写,不可单独填写。
注:不可与 irregular_available_period_list 同时配置
weekly_available_period 选填 object
【每周固定可用时间】 日期区间内,每周固定时间可以使用。可与 available_days 和 wait_days_after_receive 一同配置,一同配置时条件需同时满足券才可用(时间范围取交集)。
注:不可与 irregular_available_period_list 同时配置
day_list 必填 array[string]
【每周可用星期数】 每周特定星期X可用,在日期区间内每周循环有效。例如 配置 ["MONDAY", "FRIDAY"] 表示每周一和周五可用。
可选取值
MONDAY: 周一可用TUESDAY: 周二可用WEDNESDAY: 周三可用THURSDAY: 周四可用FRIDAY: 周五可用SATURDAY: 周六可用SUNDAY: 周日可用
day_period_list 选填 array[object]
【当天可用时间段】 生效当天特定时间段内有效,可以配置多个时间段。最多可以配置 3 个时间段。不配置则全天可用。
begin_time 必填 integer
【当天可用开始时间】 当天可用时间距离当天 00:00:00 的秒数,如 60 表示当天 00:01:00 开始可用。取值范围 [0,86399] 且必须小于 end_time
end_time 必填 integer
【当天可用结束时间】 当天结束可用时间距离当天 00:00:00 的秒数,如 86399 表示当天 23:59:59 结束可用。取值范围 [0,86399] 且必须大于 begin_time
irregular_available_period_list 选填 array[object]
【指定可用时间段】 可以配置多个无规律时间段,不同区间内请勿重叠,最多可配置2个区间。
注:不可与 available_days、wait_days_after_receive、weekly_available_period 同时配置
begin_time 必填 string
【开始时间】 区间开始时间,遵循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秒。
end_time 必填 string
【结束时间】 区间结束时间,遵循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秒。
available_seconds 选填 integer
【领取后N秒内有效】 日期区间内,用户领券后立即生效,自领取时刻起 N 秒内可用,不与自然日对齐。最大为86400(24小时),且仅支持 3600 的整数倍。
注:不可与 available_days、wait_days_after_receive、weekly_available_period、irregular_available_period_list 同时配置
normal_coupon 选填 object
【满减券使用规则】 当且仅当 type 为 NORMAL 且 scope 为 SINGLE 时必填,其他类型不应填写
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受满减优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
discount_amount 必填 integer
【固定减免金额】 固定减免金额,单位为分,必须大于0。
discount_coupon 选填 object
【折扣券使用规则】 当且仅当 type 为 DISCOUNT 且 scope 为 SINGLE 时必填,其他类型不应填写
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受折扣优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
percent_off 必填 integer
【固定减免百分比】 表示减免金额为总金额的百分比,必须大于0。例如:填入 30 表示减免 30%,即打 7 折
exchange_coupon 选填 object
【兑换券使用规则】 当且仅当 type 为 EXCHANGE 且 scope 为 SINGLE 时必填,其他类型不应填写
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可进行兑换。门槛可以为0,0元和0.01元都为无门槛兑换。例如:
满 100 元可用填
10000满 0.01 元可用填
1
exchange_price 必填 integer
【固定兑换价格】 单位为分,必须大于或等于0。
progressive_bundle_usage_rule 选填 object
【多次优惠使用规则】 当且仅当 usage_mode 为 PROGRESSIVE_BUNDLE 时提供,其他场景不提供
coupon_available_period 必填 object
【券可核销时间】 确定用户领券后在什么时间段内可以核销
available_begin_time 必填 string
【批次开始时间】 遵循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秒。
距离当前创建批次的时间不能超过90天,批次有效期最长不超过366天,摇优惠场景建议设置批次时间大于等于5天
available_end_time 必填 string
【批次结束时间】 遵循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秒。
批次有效期最长不超过366天
available_days 选填 integer
【券生效后N天内可用】 日期区间内,券生效后 N 天内有效,最多365天。例如:
生效当天内有效填 1
生效后2天内有效填 2
依此类推……
用户在有效期开始前领取商品券,则从有效期第1天开始计算天数,用户在有效期内领取商品券,则从领取当天开始计算天数,无论用户何时领取商品券,商品券在活动有效期结束后均不可用。
可配合 wait_days_after_receive 一同填写,也可单独填写。
注:不可与 irregular_available_period_list 同时配置
wait_days_after_receive 选填 integer
【领券后需等待N天才生效】 日期区间内,用户领券后需等待 N 天才开始生效,最多30天。例如:
领券后当天开始生效则无需填写
领券后第二天开始生效则填写 1
用户在有效期开始前领取商品券,则从有效期第1天开始计算天数,用户在有效期内领取商品券,则从领取当天开始计算天数。无论用户何时领取商品券,商品券在活动有效期结束后均不可用。
需配合 available_days 一同填写,不可单独填写。
注:不可与 irregular_available_period_list 同时配置
weekly_available_period 选填 object
【每周固定可用时间】 日期区间内,每周固定时间可以使用。可与 available_days 和 wait_days_after_receive 一同配置,一同配置时条件需同时满足券才可用(时间范围取交集)。
注:不可与 irregular_available_period_list 同时配置
day_list 必填 array[string]
【每周可用星期数】 每周特定星期X可用,在日期区间内每周循环有效。例如 配置 ["MONDAY", "FRIDAY"] 表示每周一和周五可用。
可选取值
MONDAY: 周一可用TUESDAY: 周二可用WEDNESDAY: 周三可用THURSDAY: 周四可用FRIDAY: 周五可用SATURDAY: 周六可用SUNDAY: 周日可用
day_period_list 选填 array[object]
【当天可用时间段】 生效当天特定时间段内有效,可以配置多个时间段。最多可以配置 3 个时间段。不配置则全天可用。
begin_time 必填 integer
【当天可用开始时间】 当天可用时间距离当天 00:00:00 的秒数,如 60 表示当天 00:01:00 开始可用。取值范围 [0,86399] 且必须小于 end_time
end_time 必填 integer
【当天可用结束时间】 当天结束可用时间距离当天 00:00:00 的秒数,如 86399 表示当天 23:59:59 结束可用。取值范围 [0,86399] 且必须大于 begin_time
irregular_available_period_list 选填 array[object]
【指定可用时间段】 可以配置多个无规律时间段,不同区间内请勿重叠,最多可配置2个区间。
注:不可与 available_days、wait_days_after_receive、weekly_available_period 同时配置
begin_time 必填 string
【开始时间】 区间开始时间,遵循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秒。
end_time 必填 string
【结束时间】 区间结束时间,遵循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秒。
available_seconds 选填 integer
【领取后N秒内有效】 日期区间内,用户领券后立即生效,自领取时刻起 N 秒内可用,不与自然日对齐。最大为86400(24小时),且仅支持 3600 的整数倍。
注:不可与 available_days、wait_days_after_receive、weekly_available_period、irregular_available_period_list 同时配置
normal_coupon 选填 object
【满减券使用规则】 当且仅当 type 为 NORMAL 时必填,其他类型不应填写
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受满减优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
discount_amount 必填 integer
【固定减免金额】 固定减免金额,单位为分,必须大于0。
discount_coupon 选填 object
【折扣券使用规则】 当且仅当 type 为 DISCOUNT 时必填,其他类型不应填写`
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可享受折扣优惠。门槛可以为0,0元和0.01元都为无门槛。例如:
满 100 元可用填
10000满 0.01 元可用填
1
percent_off 必填 integer
【固定减免百分比】 表示减免金额为总金额的百分比,必须大于0。例如:填入 30 表示减免 30%,即打 7 折
exchange_coupon 选填 object
【兑换券使用规则】 当且仅当 type 为 EXCHANGE 时必填,其他类型不应填写
threshold 必填 integer
【门槛金额】 使用门槛金额,单位为分,达到该门槛后可进行兑换。门槛可以为0,0元和0.01元都为无门槛兑换。例如:
满 100 元可用填
10000满 0.01 元可用填
1
exchange_price 必填 integer
【固定兑换价格】 单位为分,必须大于或等于0。
stock_bundle_info 选填 object
【批次组信息】 批次所在批次组信息,当且仅当 usage_mode 为 PROGRESSIVE_BUNDLE 时提供
stock_bundle_id 必填 string(40)
【批次所属批次组ID】 商品券批次组的唯一标识,【创建商品券(多次优惠)】或【添加商品券批次组】时由微信支付生成
stock_bundle_index 必填 integer
【批次在批次组内的次序】 本批次在批次组内的次序,从0开始
usage_rule_display_info 必填 object
【券使用规则展示信息】 券使用规则展示信息
coupon_usage_method_list 必填 array[string]
【券使用方式列表】 可以配置多种使用方式
可选取值
OFFLINE: 线下滴码核销,点击券“立即使用”跳转展示券二维码详情(投放计划暂不支持此核销方式)MINI_PROGRAM: 线上小程序核销,点击券“立即使用”跳转至配置的商家小程序(需要添加小程序AppID和Path)APP: APP核销,在商家APP内核销PAYMENT_CODE: 微信支付付款码核销,用户点击券“立即使用”将跳转至微信支付钱包付款码,服务商扫描付款码后可通过付款码获取到用户openid,通过openid查询并核销用户券,核销后再发起下单,适合线下支付场景
mini_program_appid 选填 string
【小程序AppID】 品牌方或服务商小程序AppID,可在微信公众平台查看,该小程序与品牌或服务商存在绑定关系。
在 coupon_usage_method_list 中包含 MINI_PROGRAM 时必填,需和 mini_program_path 一同填写。
mini_program_path 选填 string
【小程序跳转路径】 品牌方或服务商小程序内部跳转路径。
在 coupon_usage_method_list 中包含 MINI_PROGRAM 时必填,需和 mini_program_appid 一同填写。
app_path 选填 string
【APP的H5跳转路径】 品牌方或服务商APP的H5跳转路径。在 app_jump_type 为 H5 时必填。
usage_description 必填 string(1000)
【券使用说明】 用于说明详细的券规则,长度不超过1000个UTF-8字符
coupon_available_store_info 选填 object
【券可用门店信息】 用于描述全部可用门店信息,可配置小程序跳转地址进行展示
description 必填 string(1000)
【券可用门店描述】 告知用户本券可在哪些门店使用,长度不超过1000个UTF-8字符
mini_program_appid 选填 string
【小程序AppID】 品牌方或服务商小程序AppID,用于展示可用门店列表的详细信息,可在微信公众平台查看,该小程序与品牌或服务商存在绑定关系。需和 mini_program_path 一同填写。
mini_program_path 选填 string
【小程序跳转路径】 品牌方或服务商小程序内部展示可用门店列表的详细信息的页面跳转路径,需和 mini_program_appid 一同填写。
app_jump_type 选填 string
【APP跳转类型】 APP跳转类型,在 coupon_usage_method_list 中包含 APP 时必填。
可选取值
H5: 跳转H5,点击券立即使用跳转至配置的H5页面PASSCODE_LINK: 口令链接,点击券立即使用展示口令链接供用户复制使用USAGE_GUIDE: 展示使用指引,引导前往APP核销
passcode_link 选填 string
【口令链接】 口令链接。在 app_jump_type 为 PASSCODE_LINK 时必填。
coupon_display_info 必填 object
【用户商品券展示信息】 用户商品券在卡包中的展示详情,包括引导用户的自定义入口
code_display_mode 必填 string
【用户商品券Code展示模式】 决定用户商品券Code在卡包中的展示形态
可选取值
INVISIBLE: 不展示CodeBARCODE: 条形码QRCODE: 二维码
background_color 选填 string
【背景颜色】 券的背景颜色,可设置10种颜色,色值请参考下方说明。颜色取值为颜色图中的颜色名称,不填默认为 Color020 。

entrance_mini_program 选填 object
【小程序入口】 展示跳转小程序的入口
appid 必填 string
【小程序AppID】 品牌方或服务商小程序的AppID,可在微信公众平台查看,该小程序与品牌或服务商存在绑定关系
path 必填 string
【小程序跳转路径】 品牌方小程序内部跳转路径
entrance_wording 必填 string(5)
【入口文案】 小程序入口文案,长度不超过5个UTF-8字符
guidance_wording 必填 string(6)
【引导文案】 小程序入口引导文案,长度不超过6个UTF-8字符
entrance_official_account 选填 object
【公众号入口】 展示跳转公众号的入口
appid 必填 string
【公众号AppID】 微信公众号唯一标识,可在微信公众平台查看,该公众号应与品牌方或服务商存在绑定关系
notify_config 必填 object
【事件通知配置】 发生券相关事件时,微信支付会向服务商发送通知,需要提供通知相关配置
notify_appid 必填 string
【事件通知AppID】 服务商或者品牌的AppID,支持小程序、服务号、公众号、APP类型的AppID,可在微信公众平台查看,用于券事件通知时计算用户的OpenID,需要与服务商或者品牌存在绑定关系
store_scope 必填 string
【可用门店范围】 控制该批次可以在品牌下哪些门店使用
可选取值
NONE: 无关联门店,该批次对外不展示可用门店信息ALL: 所有门店可用,该批次在品牌下的所有门店可用,品牌无需为该批次关联门店列表SPECIFIC: 特定门店可用,品牌需调用关联门店接口关联门店,关联后该批次在关联的门店可用
sent_count_info 必填 object
【已发放次数】 本批次已发放次数
total_count 必填 integer
【已发放总次数】 批次在生命周期内已发放次数
today_count 必填 integer
【当天已发放次数】 批次在当天已发放次数
state 必填 string
【批次状态】 商品券批次状态
可选取值
AUDITING: 审批中SENDING: 发放中PAUSED: 已暂停STOPPED: 已停止,当前已到达结束时间DEACTIVATED: 已失效,品牌方主动调用失效接口使批次失效
deactivate_request_no 选填 string(128)
【失效请求单号】 当且仅当 state 为 DEACTIVATED 时提供,返回品牌方调用失效接口时传入的请求流水号
deactivate_time 选填 string
【失效时间】 当且仅当 state 为 DEACTIVATED 时提供,遵循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秒。
deactivate_reason 选填 string(150)
【失效原因】 当且仅当 state 为 DEACTIVATED 时提供,返回品牌方调用【失效商品券批次API】时传入的失效原因
brand_id 必填 string
【品牌ID】 微信支付为品牌方分配的唯一标识,该品牌应与服务商存在授权关系
attach 选填 string
【自定义附加信息】 调用发券接口时品牌方使用 attach 字段主动设置的附加信息。微信支付不会解析该信息,仅在查询用户商品券和回调中原样返回。
注: 发券渠道多样,只有品牌方通过发券接口发放的券才会在查询和回调中携带此字段,其他渠道发放的券 attach 为空。
channel_custom_info 选填 string(1000)
【渠道自定义信息】 使用微信支付提供的其他渠道(比如「摇一摇有优惠」)发放商品券时,渠道可能会设置该渠道特定的自定义信息,请根据 send_channel 字段判断如何解析本字段。不同渠道的自定义信息格式不同,请根据对应渠道的文档解析。
coupon_tag_info 选填 object
【用户商品券标签信息】 用户商品券标签信息
coupon_tag_list 选填 array[string]
【用户商品券标签列表】 用户商品券标签列表
可选取值
MEMBER: 会员标签,标识该用户商品券为会员券MEMBER_ACTIVITY: 会员活动标签,标识该用户券为会员活动券
member_tag_info 选填 object
【会员标签信息】 当用户商品券标签列表中有MEMBER时,该字段必填
member_card_id 选填 string
【会员卡模板ID】 通过商家名片会员API创建会员卡模板成功后,获得的会员卡模板ID
brand_id 必填 string
【品牌ID】 微信支付为品牌方分配的唯一标识,该品牌应与服务商存在授权关系
next_page_token 选填 string(100)
【下一页Token】 分页查询时,如果还有更多数据,会返回下一页的Token,请在下一次查询时设置在 page_token 中;如果已无更多数据,则不返回此字段。
应答示例
200 OK
查询用户在某个批次下的券列表
1{ 2 "total_count" : 1, 3 "user_coupon_list" : [ 4 { 5 "coupon_code" : "Code_123456", 6 "coupon_state" : "EFFECTIVE", 7 "valid_begin_time" : "2025-08-02T00:00:00+08:00", 8 "valid_end_time" : "2025-08-31T23:59:59+08:00", 9 "receive_time" : "2025-08-02T00:00:00+08:00", 10 "send_request_no" : "MCHSEND202003101234", 11 "send_channel" : "API", 12 "confirm_request_no" : "MCHCONFIRM202003101234", 13 "confirm_time" : "2025-08-02T00:00:05+08:00", 14 "single_usage_detail" : { }, 15 "product_coupon" : { 16 "product_coupon_id" : "1000000013", 17 "scope" : "ALL", 18 "type" : "DISCOUNT", 19 "usage_mode" : "SINGLE", 20 "business_mode" : "FREE", 21 "single_usage_info" : { 22 "discount_coupon" : { 23 "threshold" : 10000, 24 "percent_off" : 20 25 } 26 }, 27 "display_info" : { 28 "name" : "全场满100立打8折-新名字", 29 "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 30 "background_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 31 "detail_image_url_list" : [ 32 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 33 ] 34 }, 35 "state" : "EFFECTIVE", 36 "out_product_no" : "Product_1234567890", 37 "brand_id" : "120344" 38 }, 39 "stock" : { 40 "product_coupon_id" : "1000000013", 41 "stock_id" : "1000000013001", 42 "remark" : "8月工作日有效批次", 43 "coupon_code_mode" : "UPLOAD", 44 "coupon_code_count_info" : { 45 "total_count" : 0, 46 "available_count" : 0 47 }, 48 "stock_send_rule" : { 49 "max_count" : 10000000, 50 "max_count_per_user" : 1 51 }, 52 "single_usage_rule" : { 53 "coupon_available_period" : { 54 "available_begin_time" : "2025-08-01T00:00:00+08:00", 55 "available_end_time" : "2025-08-31T23:59:59+08:00", 56 "available_days" : 30, 57 "weekly_available_period" : { 58 "day_list" : [ 59 "MONDAY", 60 "TUESDAY", 61 "WEDNESDAY", 62 "THURSDAY", 63 "FRIDAY" 64 ] 65 } 66 } 67 }, 68 "usage_rule_display_info" : { 69 "coupon_usage_method_list" : [ 70 "OFFLINE", 71 "MINI_PROGRAM", 72 "PAYMENT_CODE" 73 ], 74 "mini_program_appid" : "wx1234567890", 75 "mini_program_path" : "/pages/index/product", 76 "usage_description" : "工作日可用", 77 "coupon_available_store_info" : { 78 "description" : "所有门店可用,可使用小程序查看门店列表", 79 "mini_program_appid" : "wx1234567890", 80 "mini_program_path" : "/pages/index/store-list" 81 } 82 }, 83 "coupon_display_info" : { 84 "code_display_mode" : "QRCODE", 85 "background_color" : "Color010", 86 "entrance_mini_program" : { 87 "appid" : "wx1234567890", 88 "path" : "/pages/index/product", 89 "entrance_wording" : "欢迎选购", 90 "guidance_wording" : "获取更多优惠" 91 }, 92 "entrance_official_account" : { 93 "appid" : "wx1234567890" 94 } 95 }, 96 "notify_config" : { 97 "notify_appid" : "wx4fd12345678" 98 }, 99 "store_scope" : "NONE", 100 "sent_count_info" : { 101 "total_count" : 0, 102 "today_count" : 0 103 }, 104 "state" : "SENDING", 105 "brand_id" : "120344" 106 }, 107 "attach" : "any attach content", 108 "brand_id" : "120344" 109 } 110 ] 111} 112
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
400 | INVALID_REQUEST | 传入参数不符合业务规则 | 请参考文档中对每个字段的要求以及组合要求,确认请求参数是否满足 |
404 | NOT_FOUND | 未找到 product_coupon_id 对应的商品券 | 请确认 product_coupon_id 存在且属于当前品牌 |
404 | NOT_FOUND | 未找到 stock_id 对应的商品券批次 | 请确认 stock_id 存在且属于当前商品券 |
429 | RATELIMIT_EXCEEDED | 请求超过接口频率限制 | 请稍后使用原参数重试 |
