创建商品券
更新时间:2025.12.31品牌方可以通过该接口为品牌创建商品券和批次组。微信支付创建成功后,会返回此次创建的商品券、批次组。品牌方可在【经营平台】上配置【活动】对商品券进行投放。
前置条件:品牌方已【设置商品券事件通知地址】
频率限制:20/s
接口说明
支持商户:【品牌商户】
请求方式:【POST】/brand/marketing/product-coupon/product-coupons
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
Content-Type 必填 string
请设置为application/json
Wechatpay-Serial 必填 string
【微信支付公钥ID】 请传入brand_id对应的微信支付公钥ID,接口将会校验两者的关联关系,参考微信支付公钥产品简介及使用说明获取微信支付公钥ID和相关的介绍。以下两种场景将使用到微信支付公钥: 1、接收到接口的返回内容,需要使用微信支付公钥进行验签; 2、调用含有敏感信息参数(如姓名、身份证号码)的接口时,需要使用微信支付公钥加密敏感信息后再传输参数,加密指引请参考微信支付公钥加密敏感信息指引。
body 包体参数
out_request_no 必填 string(40)
【创建请求单号】 品牌创建商品券的请求流水号,品牌侧需保持唯一性,可使用 数字、大小写字母、下划线_、短横线- 组成,长度在6-40个字符之间
scope 必填 string
【优惠范围】 商品券的优惠范围
可选取值
ALL: 全场商品可用券,此时券类型type仅可配置为NORMAL或DISCOUNTSINGLE: 部分商品可用券,此时券类型type配置不受限制,即可配置为NORMAL、DISCOUNT或EXCHANGE
type 必填 string
【商品券类型】 商品券的优惠类型
可选取值
NORMAL: 满减券DISCOUNT: 折扣券EXCHANGE: 兑换券,scope优惠范围为SINGLE时可选
usage_mode 必填 string
【使用模式】 商品券使用模式
PROGRESSIVE_BUNDLE: 多次优惠,由一组批次组成,每阶梯次序对应一个批次。用户按顺序使用,每次核销后发放下一张券,直到用完为止
progressive_bundle_usage_info 必填 object
【多次优惠模式信息】 多次优惠模式配置信息
| 属性 | |
count 必填 integer 【可使用次数】 多次优惠领取后用户可使用次数,最少3次,最多15次 interval_days 选填 integer 【多次优惠使用间隔天数】 多次优惠多次使用之间需要间隔的天数,最高7天。例如:
默认情况下为 |
display_info 必填 object
【展示信息】 商品券展示信息,展示结果可参考商品券示意图(多次优惠模式)
| 属性 | |||||||||
name 必填 string(15) 【商品券名称】 商品券名称,长度为3-15个UTF-8字符 image_url 必填 string 【商品券图片】 商品图片的链接地址,仅支持通过【图片上传API】获取的图片URL地址。
background_url 必填 string 【商品券背景图】 商品背景图片的URL地址,仅支持通过【图片上传API】获取的图片URL地址。
detail_image_url_list 选填 array[string] 【商品券详情图列表】 商品详情图URL地址列表,用于最多可上传8张图片,仅支持通过【图片上传API】获取的图片URL地址。
original_price 选填 integer 【商品原价】 单位为分, combo_package_list 选填 array[object] 【适用商品组合】 当
|
out_product_no 选填 string(40)
【外部商品ID】 品牌侧的商品标识,品牌可自行选择传入,长度不超过40个字符。
注:微信支付不校验此参数的唯一性,即允许多个商品券共享外部商品ID。
stock_bundle 必填 object
【批次组】 商品券批次组信息
| 属性 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
remark 选填 string(20) 【备注】 仅配置品牌方可见,用于自定义信息,最多20个UTF-8字符 coupon_code_mode 必填 string 【券Code分配模式】 决定发券时用户商品券Code如何产生,批次组内每一个批次都会设置为此值 可选取值
stock_send_rule 必填 object 【批次组发放规则】 批次组内的批次会继承此规则
progressive_bundle_usage_rule 必填 object 【多次优惠批次组使用规则】 包含组合内部每一个批次的优惠规则,会根据内部的优惠规则列表依次创建批次放入批次组
usage_rule_display_info 必填 object 【券使用规则展示信息】 券使用规则展示信息,批次组内每一个批次都会设置为此值
coupon_display_info 必填 object 【用户商品券展示信息】 用户商品券在卡包中的展示详情,包括引导用户的自定义入口,批次组内每一个批次都会设置为此值
notify_config 必填 object 【事件通知配置】 发生券相关事件时,微信支付会向品牌方发送通知,需要提供通知相关配置,批次组内每一个批次都会设置为此值
store_scope 必填 string 【可用门店范围】 控制该批次可以在品牌下哪些门店使用,批次组内每一个批次都会设置为此值 可选取值
|
请求示例
POST
创建全场折扣多次优惠券
1curl -X POST \ 2 https://api.mch.weixin.qq.com/brand/marketing/product-coupon/product-coupons \ 3 -H "Authorization: WECHATPAY-BRAND-SHA256-RSA2048 brand_id=\"XXXX\",..." \ 4 -H "Accept: application/json" \ 5 -H "Wechatpay-Serial: PUB_KEY_ID_XXXX" \ 6 -H "Content-Type: application/json" \ 7 -d '{ 8 "stock_bundle" : { 9 "remark" : "8月工作日有效批次", 10 "coupon_code_mode" : "UPLOAD", 11 "stock_send_rule" : { 12 "max_count" : 10000000, 13 "max_count_per_user" : 1 14 }, 15 "progressive_bundle_usage_rule" : { 16 "coupon_available_period" : { 17 "available_begin_time" : "2025-08-01T00:00:00+08:00", 18 "available_end_time" : "2025-08-31T23:59:59+08:00", 19 "available_days" : 30, 20 "weekly_available_period" : { 21 "day_list" : [ 22 "MONDAY", 23 "TUESDAY", 24 "WEDNESDAY", 25 "THURSDAY", 26 "FRIDAY" 27 ] 28 } 29 }, 30 "discount_coupon_list" : [ 31 { 32 "threshold" : 10000, 33 "percent_off" : 50 34 }, 35 { 36 "threshold" : 10000, 37 "percent_off" : 20 38 }, 39 { 40 "threshold" : 10000, 41 "percent_off" : 30 42 } 43 ] 44 }, 45 "usage_rule_display_info" : { 46 "coupon_usage_method_list" : [ 47 "OFFLINE", 48 "MINI_PROGRAM", 49 "PAYMENT_CODE" 50 ], 51 "mini_program_appid" : "wx1234567890", 52 "mini_program_path" : "/pages/index/product", 53 "usage_description" : "工作日可用", 54 "coupon_available_store_info" : { 55 "description" : "所有门店可用,可使用小程序查看门店列表", 56 "mini_program_appid" : "wx1234567890", 57 "mini_program_path" : "/pages/index/store-list" 58 } 59 }, 60 "coupon_display_info" : { 61 "code_display_mode" : "QRCODE", 62 "background_color" : "Color010", 63 "entrance_mini_program" : { 64 "appid" : "wx1234567890", 65 "path" : "/pages/index/product", 66 "entrance_wording" : "欢迎选购", 67 "guidance_wording" : "获取更多优惠" 68 }, 69 "entrance_official_account" : { 70 "appid" : "wx1234567890" 71 }, 72 "entrance_finder" : { 73 "finder_id" : "gh_12345678", 74 "finder_video_id" : "UDFsdf24df34dD456Hdf34", 75 "finder_video_cover_image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 76 } 77 }, 78 "store_scope" : "NONE", 79 "notify_config" : { 80 "notify_appid" : "wx4fd12345678" 81 } 82 }, 83 "out_product_no" : "Product_1234567890", 84 "scope" : "ALL", 85 "usage_mode" : "PROGRESSIVE_BUNDLE", 86 "display_info" : { 87 "name" : "全场多次折扣券", 88 "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 89 "background_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 90 "detail_image_url_list" : [ 91 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 92 ] 93 }, 94 "type" : "DISCOUNT", 95 "out_request_no" : "12345_20250101_A3489", 96 "progressive_bundle_usage_info" : { 97 "count" : 3, 98 "interval_days" : 1 99 } 100 }' 101
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayBrandUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/brand/4015826861 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 CreateProductCoupon { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "POST"; 28 private static String PATH = "/brand/marketing/product-coupon/product-coupons"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/brand/4015415289 32 CreateProductCoupon client = new CreateProductCoupon( 33 "xxxxxxxx", // 品牌ID,是由微信支付系统生成并分配给每个品牌方的唯一标识符,品牌ID获取方式参考 https://pay.weixin.qq.com/doc/brand/4015415289 34 "1DDE55AD98Exxxxxxxxxx", // 品牌API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015407570 35 "/path/to/apiclient_key.pem", // 品牌API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015453439 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 CreateProductCouponRequest request = new CreateProductCouponRequest(); 41 request.outRequestNo = "12345_20250101_A3489"; 42 request.scope = ProductCouponScope.ALL; 43 request.type = ProductCouponType.DISCOUNT; 44 request.usageMode = UsageMode.PROGRESSIVE_BUNDLE; 45 // 多次优惠信息 46 request.progressiveBundleUsageInfo = new ProgressiveBundleUsageInfo(); 47 request.progressiveBundleUsageInfo.count = 3L; 48 request.progressiveBundleUsageInfo.intervalDays = 1L; 49 // 展示信息 50 request.displayInfo = new ProductCouponDisplayInfo(); 51 request.displayInfo.name = "全场多次折扣券"; 52 request.displayInfo.imageUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"; 53 request.displayInfo.backgroundUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"; 54 request.displayInfo.detailImageUrlList = new ArrayList<>(); 55 request.displayInfo.detailImageUrlList.add("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"); 56 request.outProductNo = "Product_1234567890"; 57 // 批次包信息(多次优惠使用 stockBundle) 58 request.stockBundle = new StockBundleForCreate(); 59 request.stockBundle.remark = "8月工作日有效批次"; 60 request.stockBundle.couponCodeMode = CouponCodeMode.UPLOAD; 61 request.stockBundle.stockSendRule = new StockSendRuleForBundle(); 62 request.stockBundle.stockSendRule.maxCount = 10000000L; 63 request.stockBundle.stockSendRule.maxCountPerUser = 1L; 64 // 多次优惠使用规则 65 request.stockBundle.progressiveBundleUsageRule = new StockBundleUsageRule(); 66 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod = new CouponAvailablePeriod(); 67 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.availableBeginTime = "2025-08-01T00:00:00+08:00"; 68 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.availableEndTime = "2025-08-31T23:59:59+08:00"; 69 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.availableDays = 30L; 70 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod = new FixedWeekPeriod(); 71 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList = new ArrayList<>(); 72 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.MONDAY); 73 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.TUESDAY); 74 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.WEDNESDAY); 75 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.THURSDAY); 76 request.stockBundle.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.FRIDAY); 77 // 折扣券列表(3次优惠) 78 request.stockBundle.progressiveBundleUsageRule.discountCouponList = new ArrayList<>(); 79 { 80 DiscountCouponUsageRule discount1 = new DiscountCouponUsageRule(); 81 discount1.threshold = 10000L; 82 discount1.percentOff = 50L; 83 request.stockBundle.progressiveBundleUsageRule.discountCouponList.add(discount1); 84 DiscountCouponUsageRule discount2 = new DiscountCouponUsageRule(); 85 discount2.threshold = 10000L; 86 discount2.percentOff = 20L; 87 request.stockBundle.progressiveBundleUsageRule.discountCouponList.add(discount2); 88 DiscountCouponUsageRule discount3 = new DiscountCouponUsageRule(); 89 discount3.threshold = 10000L; 90 discount3.percentOff = 30L; 91 request.stockBundle.progressiveBundleUsageRule.discountCouponList.add(discount3); 92 } 93 // 使用规则展示信息 94 request.stockBundle.usageRuleDisplayInfo = new UsageRuleDisplayInfo(); 95 request.stockBundle.usageRuleDisplayInfo.couponUsageMethodList = new ArrayList<>(); 96 request.stockBundle.usageRuleDisplayInfo.couponUsageMethodList.add(CouponUsageMethod.OFFLINE); 97 request.stockBundle.usageRuleDisplayInfo.couponUsageMethodList.add(CouponUsageMethod.MINI_PROGRAM); 98 request.stockBundle.usageRuleDisplayInfo.couponUsageMethodList.add(CouponUsageMethod.PAYMENT_CODE); 99 request.stockBundle.usageRuleDisplayInfo.miniProgramAppid = "wx1234567890"; 100 request.stockBundle.usageRuleDisplayInfo.miniProgramPath = "/pages/index/product"; 101 request.stockBundle.usageRuleDisplayInfo.usageDescription = "工作日可用"; 102 request.stockBundle.usageRuleDisplayInfo.couponAvailableStoreInfo = new CouponAvailableStoreInfo(); 103 request.stockBundle.usageRuleDisplayInfo.couponAvailableStoreInfo.description = "所有门店可用,可使用小程序查看门店列表"; 104 request.stockBundle.usageRuleDisplayInfo.couponAvailableStoreInfo.miniProgramAppid = "wx1234567890"; 105 request.stockBundle.usageRuleDisplayInfo.couponAvailableStoreInfo.miniProgramPath = "/pages/index/store-list"; 106 // 券展示信息 107 request.stockBundle.couponDisplayInfo = new CouponDisplayInfo(); 108 request.stockBundle.couponDisplayInfo.codeDisplayMode = CouponCodeDisplayMode.QRCODE; 109 request.stockBundle.couponDisplayInfo.backgroundColor = "Color010"; 110 request.stockBundle.couponDisplayInfo.entranceMiniProgram = new EntranceMiniProgram(); 111 request.stockBundle.couponDisplayInfo.entranceMiniProgram.appid = "wx1234567890"; 112 request.stockBundle.couponDisplayInfo.entranceMiniProgram.path = "/pages/index/product"; 113 request.stockBundle.couponDisplayInfo.entranceMiniProgram.entranceWording = "欢迎选购"; 114 request.stockBundle.couponDisplayInfo.entranceMiniProgram.guidanceWording = "获取更多优惠"; 115 request.stockBundle.couponDisplayInfo.entranceOfficialAccount = new EntranceOfficialAccount(); 116 request.stockBundle.couponDisplayInfo.entranceOfficialAccount.appid = "wx1234567890"; 117 request.stockBundle.couponDisplayInfo.entranceFinder = new EntranceFinder(); 118 request.stockBundle.couponDisplayInfo.entranceFinder.finderId = "gh_12345678"; 119 request.stockBundle.couponDisplayInfo.entranceFinder.finderVideoId = "UDFsdf24df34dD456Hdf34"; 120 request.stockBundle.couponDisplayInfo.entranceFinder.finderVideoCoverImageUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"; 121 request.stockBundle.storeScope = StockStoreScope.NONE; 122 request.stockBundle.notifyConfig = new NotifyConfig(); 123 request.stockBundle.notifyConfig.notifyAppid = "wx4fd12345678"; 124 125 try { 126 CreateProductCouponResponse response = client.run(request); 127 // TODO: 请求成功,继续业务逻辑 128 System.out.println(response); 129 } catch (WXPayBrandUtility.ApiException e) { 130 // TODO: 请求失败,根据状态码执行不同的逻辑 131 e.printStackTrace(); 132 } 133 } 134 135 public CreateProductCouponResponse run(CreateProductCouponRequest request) { 136 String uri = PATH; 137 String reqBody = WXPayBrandUtility.toJson(request); 138 139 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 140 reqBuilder.addHeader("Accept", "application/json"); 141 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 142 reqBuilder.addHeader("Authorization", WXPayBrandUtility.buildAuthorization(brand_id, certificateSerialNo,privateKey, METHOD, uri, reqBody)); 143 reqBuilder.addHeader("Content-Type", "application/json"); 144 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 145 reqBuilder.method(METHOD, requestBody); 146 Request httpRequest = reqBuilder.build(); 147 148 // 发送HTTP请求 149 OkHttpClient client = new OkHttpClient.Builder().build(); 150 try (Response httpResponse = client.newCall(httpRequest).execute()) { 151 String respBody = WXPayBrandUtility.extractBody(httpResponse); 152 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 153 // 2XX 成功,验证应答签名 154 WXPayBrandUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 155 httpResponse.headers(), respBody); 156 157 // 从HTTP应答报文构建返回数据 158 return WXPayBrandUtility.fromJson(respBody, CreateProductCouponResponse.class); 159 } else { 160 throw new WXPayBrandUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 161 } 162 } catch (IOException e) { 163 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 164 } 165 } 166 167 private final String brand_id; 168 private final String certificateSerialNo; 169 private final PrivateKey privateKey; 170 private final String wechatPayPublicKeyId; 171 private final PublicKey wechatPayPublicKey; 172 173 public CreateProductCoupon(String brand_id, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 174 this.brand_id = brand_id; 175 this.certificateSerialNo = certificateSerialNo; 176 this.privateKey = WXPayBrandUtility.loadPrivateKeyFromPath(privateKeyFilePath); 177 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 178 this.wechatPayPublicKey = WXPayBrandUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 179 } 180 181 public static class CreateProductCouponRequest { 182 @SerializedName("out_request_no") 183 public String outRequestNo; 184 185 @SerializedName("scope") 186 public ProductCouponScope scope; 187 188 @SerializedName("type") 189 public ProductCouponType type; 190 191 @SerializedName("usage_mode") 192 public UsageMode usageMode; 193 194 @SerializedName("single_usage_info") 195 public SingleUsageInfo singleUsageInfo; 196 197 @SerializedName("progressive_bundle_usage_info") 198 public ProgressiveBundleUsageInfo progressiveBundleUsageInfo; 199 200 @SerializedName("display_info") 201 public ProductCouponDisplayInfo displayInfo; 202 203 @SerializedName("out_product_no") 204 public String outProductNo; 205 206 @SerializedName("stock") 207 public StockForCreate stock; 208 209 @SerializedName("stock_bundle") 210 public StockBundleForCreate stockBundle; 211 } 212 213 public static class CreateProductCouponResponse { 214 @SerializedName("product_coupon_id") 215 public String productCouponId; 216 217 @SerializedName("scope") 218 public ProductCouponScope scope; 219 220 @SerializedName("type") 221 public ProductCouponType type; 222 223 @SerializedName("usage_mode") 224 public UsageMode usageMode; 225 226 @SerializedName("single_usage_info") 227 public SingleUsageInfo singleUsageInfo; 228 229 @SerializedName("progressive_bundle_usage_info") 230 public ProgressiveBundleUsageInfo progressiveBundleUsageInfo; 231 232 @SerializedName("display_info") 233 public ProductCouponDisplayInfo displayInfo; 234 235 @SerializedName("out_product_no") 236 public String outProductNo; 237 238 @SerializedName("state") 239 public ProductCouponState state; 240 241 @SerializedName("stock") 242 public StockEntity stock; 243 244 @SerializedName("stock_bundle") 245 public StockBundleEntity stockBundle; 246 } 247 248 public enum ProductCouponScope { 249 @SerializedName("ALL") 250 ALL, 251 @SerializedName("SINGLE") 252 SINGLE 253 } 254 255 public enum ProductCouponType { 256 @SerializedName("NORMAL") 257 NORMAL, 258 @SerializedName("DISCOUNT") 259 DISCOUNT, 260 @SerializedName("EXCHANGE") 261 EXCHANGE 262 } 263 264 public enum UsageMode { 265 @SerializedName("SINGLE") 266 SINGLE, 267 @SerializedName("PROGRESSIVE_BUNDLE") 268 PROGRESSIVE_BUNDLE 269 } 270 271 public static class SingleUsageInfo { 272 @SerializedName("normal_coupon") 273 public NormalCouponUsageRule normalCoupon; 274 275 @SerializedName("discount_coupon") 276 public DiscountCouponUsageRule discountCoupon; 277 } 278 279 public static class ProgressiveBundleUsageInfo { 280 @SerializedName("count") 281 public Long count; 282 283 @SerializedName("interval_days") 284 public Long intervalDays; 285 } 286 287 public static class ProductCouponDisplayInfo { 288 @SerializedName("name") 289 public String name; 290 291 @SerializedName("image_url") 292 public String imageUrl; 293 294 @SerializedName("background_url") 295 public String backgroundUrl; 296 297 @SerializedName("detail_image_url_list") 298 public List<String> detailImageUrlList; 299 300 @SerializedName("original_price") 301 public Long originalPrice; 302 303 @SerializedName("combo_package_list") 304 public List<ComboPackage> comboPackageList; 305 } 306 307 public static class StockForCreate { 308 @SerializedName("remark") 309 public String remark; 310 311 @SerializedName("coupon_code_mode") 312 public CouponCodeMode couponCodeMode; 313 314 @SerializedName("stock_send_rule") 315 public StockSendRule stockSendRule; 316 317 @SerializedName("single_usage_rule") 318 public SingleUsageRule singleUsageRule; 319 320 @SerializedName("usage_rule_display_info") 321 public UsageRuleDisplayInfo usageRuleDisplayInfo; 322 323 @SerializedName("coupon_display_info") 324 public CouponDisplayInfo couponDisplayInfo; 325 326 @SerializedName("notify_config") 327 public NotifyConfig notifyConfig; 328 329 @SerializedName("store_scope") 330 public StockStoreScope storeScope; 331 } 332 333 public static class StockBundleForCreate { 334 @SerializedName("remark") 335 public String remark; 336 337 @SerializedName("coupon_code_mode") 338 public CouponCodeMode couponCodeMode; 339 340 @SerializedName("stock_send_rule") 341 public StockSendRuleForBundle stockSendRule; 342 343 @SerializedName("progressive_bundle_usage_rule") 344 public StockBundleUsageRule progressiveBundleUsageRule; 345 346 @SerializedName("usage_rule_display_info") 347 public UsageRuleDisplayInfo usageRuleDisplayInfo; 348 349 @SerializedName("coupon_display_info") 350 public CouponDisplayInfo couponDisplayInfo; 351 352 @SerializedName("notify_config") 353 public NotifyConfig notifyConfig; 354 355 @SerializedName("store_scope") 356 public StockStoreScope storeScope; 357 } 358 359 public enum ProductCouponState { 360 @SerializedName("AUDITING") 361 AUDITING, 362 @SerializedName("EFFECTIVE") 363 EFFECTIVE, 364 @SerializedName("DEACTIVATED") 365 DEACTIVATED 366 } 367 368 public static class StockEntity { 369 @SerializedName("product_coupon_id") 370 public String productCouponId; 371 372 @SerializedName("stock_id") 373 public String stockId; 374 375 @SerializedName("remark") 376 public String remark; 377 378 @SerializedName("coupon_code_mode") 379 public CouponCodeMode couponCodeMode; 380 381 @SerializedName("coupon_code_count_info") 382 public CouponCodeCountInfo couponCodeCountInfo; 383 384 @SerializedName("stock_send_rule") 385 public StockSendRule stockSendRule; 386 387 @SerializedName("single_usage_rule") 388 public SingleUsageRule singleUsageRule; 389 390 @SerializedName("usage_rule_display_info") 391 public UsageRuleDisplayInfo usageRuleDisplayInfo; 392 393 @SerializedName("coupon_display_info") 394 public CouponDisplayInfo couponDisplayInfo; 395 396 @SerializedName("notify_config") 397 public NotifyConfig notifyConfig; 398 399 @SerializedName("store_scope") 400 public StockStoreScope storeScope; 401 402 @SerializedName("sent_count_info") 403 public StockSentCountInfo sentCountInfo; 404 405 @SerializedName("state") 406 public StockState state; 407 408 @SerializedName("deactivate_request_no") 409 public String deactivateRequestNo; 410 411 @SerializedName("deactivate_time") 412 public String deactivateTime; 413 414 @SerializedName("deactivate_reason") 415 public String deactivateReason; 416 } 417 418 public static class StockBundleEntity { 419 @SerializedName("stock_bundle_id") 420 public String stockBundleId; 421 422 @SerializedName("stock_list") 423 public List<StockEntityInBundle> stockList = new ArrayList<StockEntityInBundle>(); 424 } 425 426 public static class NormalCouponUsageRule { 427 @SerializedName("threshold") 428 public Long threshold; 429 430 @SerializedName("discount_amount") 431 public Long discountAmount; 432 } 433 434 public static class DiscountCouponUsageRule { 435 @SerializedName("threshold") 436 public Long threshold; 437 438 @SerializedName("percent_off") 439 public Long percentOff; 440 } 441 442 public static class ComboPackage { 443 @SerializedName("name") 444 public String name; 445 446 @SerializedName("pick_count") 447 public Long pickCount; 448 449 @SerializedName("choice_list") 450 public List<ComboPackageChoice> choiceList = new ArrayList<ComboPackageChoice>(); 451 } 452 453 public enum CouponCodeMode { 454 @SerializedName("WECHATPAY") 455 WECHATPAY, 456 @SerializedName("UPLOAD") 457 UPLOAD, 458 @SerializedName("API_ASSIGN") 459 API_ASSIGN 460 } 461 462 public static class StockSendRule { 463 @SerializedName("max_count") 464 public Long maxCount; 465 466 @SerializedName("max_count_per_day") 467 public Long maxCountPerDay; 468 469 @SerializedName("max_count_per_user") 470 public Long maxCountPerUser; 471 } 472 473 public static class SingleUsageRule { 474 @SerializedName("coupon_available_period") 475 public CouponAvailablePeriod couponAvailablePeriod; 476 477 @SerializedName("normal_coupon") 478 public NormalCouponUsageRule normalCoupon; 479 480 @SerializedName("discount_coupon") 481 public DiscountCouponUsageRule discountCoupon; 482 483 @SerializedName("exchange_coupon") 484 public ExchangeCouponUsageRule exchangeCoupon; 485 } 486 487 public static class UsageRuleDisplayInfo { 488 @SerializedName("coupon_usage_method_list") 489 public List<CouponUsageMethod> couponUsageMethodList = new ArrayList<CouponUsageMethod>(); 490 491 @SerializedName("mini_program_appid") 492 public String miniProgramAppid; 493 494 @SerializedName("mini_program_path") 495 public String miniProgramPath; 496 497 @SerializedName("app_path") 498 public String appPath; 499 500 @SerializedName("usage_description") 501 public String usageDescription; 502 503 @SerializedName("coupon_available_store_info") 504 public CouponAvailableStoreInfo couponAvailableStoreInfo; 505 } 506 507 public static class CouponDisplayInfo { 508 @SerializedName("code_display_mode") 509 public CouponCodeDisplayMode codeDisplayMode; 510 511 @SerializedName("background_color") 512 public String backgroundColor; 513 514 @SerializedName("entrance_mini_program") 515 public EntranceMiniProgram entranceMiniProgram; 516 517 @SerializedName("entrance_official_account") 518 public EntranceOfficialAccount entranceOfficialAccount; 519 520 @SerializedName("entrance_finder") 521 public EntranceFinder entranceFinder; 522 } 523 524 public static class NotifyConfig { 525 @SerializedName("notify_appid") 526 public String notifyAppid; 527 } 528 529 public enum StockStoreScope { 530 @SerializedName("NONE") 531 NONE, 532 @SerializedName("ALL") 533 ALL, 534 @SerializedName("SPECIFIC") 535 SPECIFIC 536 } 537 538 public static class StockSendRuleForBundle { 539 @SerializedName("max_count") 540 public Long maxCount; 541 542 @SerializedName("max_count_per_day") 543 public Long maxCountPerDay; 544 545 @SerializedName("max_count_per_user") 546 public Long maxCountPerUser; 547 } 548 549 public static class StockBundleUsageRule { 550 @SerializedName("coupon_available_period") 551 public CouponAvailablePeriod couponAvailablePeriod; 552 553 @SerializedName("normal_coupon_list") 554 public List<NormalCouponUsageRule> normalCouponList; 555 556 @SerializedName("discount_coupon_list") 557 public List<DiscountCouponUsageRule> discountCouponList; 558 559 @SerializedName("exchange_coupon_list") 560 public List<ExchangeCouponUsageRule> exchangeCouponList; 561 } 562 563 public static class CouponCodeCountInfo { 564 @SerializedName("total_count") 565 public Long totalCount; 566 567 @SerializedName("available_count") 568 public Long availableCount; 569 } 570 571 public static class StockSentCountInfo { 572 @SerializedName("total_count") 573 public Long totalCount; 574 575 @SerializedName("today_count") 576 public Long todayCount; 577 } 578 579 public enum StockState { 580 @SerializedName("AUDITING") 581 AUDITING, 582 @SerializedName("SENDING") 583 SENDING, 584 @SerializedName("PAUSED") 585 PAUSED, 586 @SerializedName("STOPPED") 587 STOPPED, 588 @SerializedName("DEACTIVATED") 589 DEACTIVATED 590 } 591 592 public static class StockEntityInBundle { 593 @SerializedName("product_coupon_id") 594 public String productCouponId; 595 596 @SerializedName("stock_id") 597 public String stockId; 598 599 @SerializedName("remark") 600 public String remark; 601 602 @SerializedName("coupon_code_mode") 603 public CouponCodeMode couponCodeMode; 604 605 @SerializedName("coupon_code_count_info") 606 public CouponCodeCountInfo couponCodeCountInfo; 607 608 @SerializedName("stock_send_rule") 609 public StockSendRule stockSendRule; 610 611 @SerializedName("progressive_bundle_usage_rule") 612 public StockUsageRule progressiveBundleUsageRule; 613 614 @SerializedName("stock_bundle_info") 615 public StockBundleInfo stockBundleInfo; 616 617 @SerializedName("usage_rule_display_info") 618 public UsageRuleDisplayInfo usageRuleDisplayInfo; 619 620 @SerializedName("coupon_display_info") 621 public CouponDisplayInfo couponDisplayInfo; 622 623 @SerializedName("notify_config") 624 public NotifyConfig notifyConfig; 625 626 @SerializedName("store_scope") 627 public StockStoreScope storeScope; 628 629 @SerializedName("sent_count_info") 630 public StockSentCountInfo sentCountInfo; 631 632 @SerializedName("state") 633 public StockState state; 634 635 @SerializedName("deactivate_request_no") 636 public String deactivateRequestNo; 637 638 @SerializedName("deactivate_time") 639 public String deactivateTime; 640 641 @SerializedName("deactivate_reason") 642 public String deactivateReason; 643 } 644 645 public static class ComboPackageChoice { 646 @SerializedName("name") 647 public String name; 648 649 @SerializedName("price") 650 public Long price; 651 652 @SerializedName("count") 653 public Long count; 654 655 @SerializedName("image_url") 656 public String imageUrl; 657 658 @SerializedName("mini_program_appid") 659 public String miniProgramAppid; 660 661 @SerializedName("mini_program_path") 662 public String miniProgramPath; 663 } 664 665 public static class CouponAvailablePeriod { 666 @SerializedName("available_begin_time") 667 public String availableBeginTime; 668 669 @SerializedName("available_end_time") 670 public String availableEndTime; 671 672 @SerializedName("available_days") 673 public Long availableDays; 674 675 @SerializedName("wait_days_after_receive") 676 public Long waitDaysAfterReceive; 677 678 @SerializedName("weekly_available_period") 679 public FixedWeekPeriod weeklyAvailablePeriod; 680 681 @SerializedName("irregular_available_period_list") 682 public List<TimePeriod> irregularAvailablePeriodList; 683 } 684 685 public static class ExchangeCouponUsageRule { 686 @SerializedName("threshold") 687 public Long threshold; 688 689 @SerializedName("exchange_price") 690 public Long exchangePrice; 691 } 692 693 public enum CouponUsageMethod { 694 @SerializedName("OFFLINE") 695 OFFLINE, 696 @SerializedName("MINI_PROGRAM") 697 MINI_PROGRAM, 698 @SerializedName("APP") 699 APP, 700 @SerializedName("PAYMENT_CODE") 701 PAYMENT_CODE 702 } 703 704 public static class CouponAvailableStoreInfo { 705 @SerializedName("description") 706 public String description; 707 708 @SerializedName("mini_program_appid") 709 public String miniProgramAppid; 710 711 @SerializedName("mini_program_path") 712 public String miniProgramPath; 713 } 714 715 public enum CouponCodeDisplayMode { 716 @SerializedName("INVISIBLE") 717 INVISIBLE, 718 @SerializedName("BARCODE") 719 BARCODE, 720 @SerializedName("QRCODE") 721 QRCODE 722 } 723 724 public static class EntranceMiniProgram { 725 @SerializedName("appid") 726 public String appid; 727 728 @SerializedName("path") 729 public String path; 730 731 @SerializedName("entrance_wording") 732 public String entranceWording; 733 734 @SerializedName("guidance_wording") 735 public String guidanceWording; 736 } 737 738 public static class EntranceOfficialAccount { 739 @SerializedName("appid") 740 public String appid; 741 } 742 743 public static class EntranceFinder { 744 @SerializedName("finder_id") 745 public String finderId; 746 747 @SerializedName("finder_video_id") 748 public String finderVideoId; 749 750 @SerializedName("finder_video_cover_image_url") 751 public String finderVideoCoverImageUrl; 752 } 753 754 public static class StockUsageRule { 755 @SerializedName("coupon_available_period") 756 public CouponAvailablePeriod couponAvailablePeriod; 757 758 @SerializedName("normal_coupon") 759 public NormalCouponUsageRule normalCoupon; 760 761 @SerializedName("discount_coupon") 762 public DiscountCouponUsageRule discountCoupon; 763 764 @SerializedName("exchange_coupon") 765 public ExchangeCouponUsageRule exchangeCoupon; 766 } 767 768 public static class StockBundleInfo { 769 @SerializedName("stock_bundle_id") 770 public String stockBundleId; 771 772 @SerializedName("stock_bundle_index") 773 public Long stockBundleIndex; 774 } 775 776 public static class FixedWeekPeriod { 777 @SerializedName("day_list") 778 public List<WeekEnum> dayList; 779 780 @SerializedName("day_period_list") 781 public List<PeriodOfTheDay> dayPeriodList; 782 } 783 784 public static class TimePeriod { 785 @SerializedName("begin_time") 786 public String beginTime; 787 788 @SerializedName("end_time") 789 public String endTime; 790 } 791 792 public enum WeekEnum { 793 @SerializedName("MONDAY") 794 MONDAY, 795 @SerializedName("TUESDAY") 796 TUESDAY, 797 @SerializedName("WEDNESDAY") 798 WEDNESDAY, 799 @SerializedName("THURSDAY") 800 THURSDAY, 801 @SerializedName("FRIDAY") 802 FRIDAY, 803 @SerializedName("SATURDAY") 804 SATURDAY, 805 @SerializedName("SUNDAY") 806 SUNDAY 807 } 808 809 public static class PeriodOfTheDay { 810 @SerializedName("begin_time") 811 public Long beginTime; 812 813 @SerializedName("end_time") 814 public Long endTime; 815 } 816 817} 818
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "bytes" 5 "demo/wxpay_brand_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/brand/4015826866 6 "encoding/json" 7 "fmt" 8 "net/http" 9 "net/url" 10 "time" 11) 12 13func main() { 14 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/brand/4015415289 15 config, err := wxpay_brand_utility.CreateBrandConfig( 16 "xxxxxxxx", // 品牌ID,是由微信支付系统生成并分配给每个品牌方的唯一标识符,品牌ID获取方式参考 https://pay.weixin.qq.com/doc/brand/4015415289 17 "1DDE55AD98Exxxxxxxxxx", // 品牌API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015407570 18 "/path/to/apiclient_key.pem", // 品牌API证书私钥文件路径,本地文件路径 19 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/brand/4015453439 20 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 21 ) 22 if err != nil { 23 fmt.Println(err) 24 return 25 } 26 27 request := &CreateProductCouponRequest{ 28 OutRequestNo: wxpay_brand_utility.String("12345_20250101_A3489"), 29 Scope: PRODUCTCOUPONSCOPE_ALL.Ptr(), 30 Type: PRODUCTCOUPONTYPE_DISCOUNT.Ptr(), 31 UsageMode: USAGEMODE_PROGRESSIVE_BUNDLE.Ptr(), 32 // 多次优惠信息 33 ProgressiveBundleUsageInfo: &ProgressiveBundleUsageInfo{ 34 Count: wxpay_brand_utility.Int64(3), 35 IntervalDays: wxpay_brand_utility.Int64(1), 36 }, 37 // 展示信息 38 DisplayInfo: &ProductCouponDisplayInfo{ 39 Name: wxpay_brand_utility.String("全场多次折扣券"), 40 ImageUrl: wxpay_brand_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), 41 BackgroundUrl: wxpay_brand_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), 42 DetailImageUrlList: []string{ 43 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 44 }, 45 }, 46 OutProductNo: wxpay_brand_utility.String("Product_1234567890"), 47 // 批次包信息(多次优惠使用 StockBundle) 48 StockBundle: &StockBundleForCreate{ 49 Remark: wxpay_brand_utility.String("8月工作日有效批次"), 50 CouponCodeMode: COUPONCODEMODE_UPLOAD.Ptr(), 51 StockSendRule: &StockSendRuleForBundle{ 52 MaxCount: wxpay_brand_utility.Int64(10000000), 53 MaxCountPerUser: wxpay_brand_utility.Int64(1), 54 }, 55 // 多次优惠使用规则 56 ProgressiveBundleUsageRule: &StockBundleUsageRule{ 57 CouponAvailablePeriod: &CouponAvailablePeriod{ 58 AvailableBeginTime: wxpay_brand_utility.String("2025-08-01T00:00:00+08:00"), 59 AvailableEndTime: wxpay_brand_utility.String("2025-08-31T23:59:59+08:00"), 60 AvailableDays: wxpay_brand_utility.Int64(30), 61 WeeklyAvailablePeriod: &FixedWeekPeriod{ 62 DayList: []WeekEnum{ 63 WEEKENUM_MONDAY, 64 WEEKENUM_TUESDAY, 65 WEEKENUM_WEDNESDAY, 66 WEEKENUM_THURSDAY, 67 WEEKENUM_FRIDAY, 68 }, 69 }, 70 }, 71 // 折扣券列表(3次优惠) 72 DiscountCouponList: []DiscountCouponUsageRule{ 73 { 74 Threshold: wxpay_brand_utility.Int64(10000), 75 PercentOff: wxpay_brand_utility.Int64(50), 76 }, 77 { 78 Threshold: wxpay_brand_utility.Int64(10000), 79 PercentOff: wxpay_brand_utility.Int64(20), 80 }, 81 { 82 Threshold: wxpay_brand_utility.Int64(10000), 83 PercentOff: wxpay_brand_utility.Int64(30), 84 }, 85 }, 86 }, 87 // 使用规则展示信息 88 UsageRuleDisplayInfo: &UsageRuleDisplayInfo{ 89 CouponUsageMethodList: []CouponUsageMethod{ 90 COUPONUSAGEMETHOD_OFFLINE, 91 COUPONUSAGEMETHOD_MINI_PROGRAM, 92 COUPONUSAGEMETHOD_PAYMENT_CODE, 93 }, 94 MiniProgramAppid: wxpay_brand_utility.String("wx1234567890"), 95 MiniProgramPath: wxpay_brand_utility.String("/pages/index/product"), 96 UsageDescription: wxpay_brand_utility.String("工作日可用"), 97 CouponAvailableStoreInfo: &CouponAvailableStoreInfo{ 98 Description: wxpay_brand_utility.String("所有门店可用,可使用小程序查看门店列表"), 99 MiniProgramAppid: wxpay_brand_utility.String("wx1234567890"), 100 MiniProgramPath: wxpay_brand_utility.String("/pages/index/store-list"), 101 }, 102 }, 103 // 券展示信息 104 CouponDisplayInfo: &CouponDisplayInfo{ 105 CodeDisplayMode: COUPONCODEDISPLAYMODE_QRCODE.Ptr(), 106 BackgroundColor: wxpay_brand_utility.String("Color010"), 107 EntranceMiniProgram: &EntranceMiniProgram{ 108 Appid: wxpay_brand_utility.String("wx1234567890"), 109 Path: wxpay_brand_utility.String("/pages/index/product"), 110 EntranceWording: wxpay_brand_utility.String("欢迎选购"), 111 GuidanceWording: wxpay_brand_utility.String("获取更多优惠"), 112 }, 113 EntranceOfficialAccount: &EntranceOfficialAccount{ 114 Appid: wxpay_brand_utility.String("wx1234567890"), 115 }, 116 EntranceFinder: &EntranceFinder{ 117 FinderId: wxpay_brand_utility.String("gh_12345678"), 118 FinderVideoId: wxpay_brand_utility.String("UDFsdf24df34dD456Hdf34"), 119 FinderVideoCoverImageUrl: wxpay_brand_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), 120 }, 121 }, 122 StoreScope: STOCKSTORESCOPE_NONE.Ptr(), 123 NotifyConfig: &NotifyConfig{ 124 NotifyAppid: wxpay_brand_utility.String("wx4fd12345678"), 125 }, 126 }, 127 } 128 129 response, err := CreateProductCoupon(config, request) 130 if err != nil { 131 fmt.Printf("请求失败: %+v\n", err) 132 // TODO: 请求失败,根据状态码执行不同的处理 133 return 134 } 135 136 // TODO: 请求成功,继续业务逻辑 137 fmt.Printf("请求成功: %+v\n", response) 138} 139 140func CreateProductCoupon(config *wxpay_brand_utility.BrandConfig, request *CreateProductCouponRequest) (response *CreateProductCouponResponse, err error) { 141 const ( 142 host = "https://api.mch.weixin.qq.com" 143 method = "POST" 144 path = "/brand/marketing/product-coupon/product-coupons" 145 ) 146 147 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 148 if err != nil { 149 return nil, err 150 } 151 reqBody, err := json.Marshal(request) 152 if err != nil { 153 return nil, err 154 } 155 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 156 if err != nil { 157 return nil, err 158 } 159 httpRequest.Header.Set("Accept", "application/json") 160 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 161 httpRequest.Header.Set("Content-Type", "application/json") 162 authorization, err := wxpay_brand_utility.BuildAuthorization(config.BrandId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 163 if err != nil { 164 return nil, err 165 } 166 httpRequest.Header.Set("Authorization", authorization) 167 168 client := &http.Client{} 169 httpResponse, err := client.Do(httpRequest) 170 if err != nil { 171 return nil, err 172 } 173 respBody, err := wxpay_brand_utility.ExtractResponseBody(httpResponse) 174 if err != nil { 175 return nil, err 176 } 177 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 178 // 2XX 成功,验证应答签名 179 err = wxpay_brand_utility.ValidateResponse( 180 config.WechatPayPublicKeyId(), 181 config.WechatPayPublicKey(), 182 &httpResponse.Header, 183 respBody, 184 ) 185 if err != nil { 186 return nil, err 187 } 188 response := &CreateProductCouponResponse{} 189 if err := json.Unmarshal(respBody, response); err != nil { 190 return nil, err 191 } 192 193 return response, nil 194 } else { 195 return nil, wxpay_brand_utility.NewApiException( 196 httpResponse.StatusCode, 197 httpResponse.Header, 198 respBody, 199 ) 200 } 201} 202 203type CreateProductCouponRequest struct { 204 OutRequestNo *string `json:"out_request_no,omitempty"` 205 Scope *ProductCouponScope `json:"scope,omitempty"` 206 Type *ProductCouponType `json:"type,omitempty"` 207 UsageMode *UsageMode `json:"usage_mode,omitempty"` 208 SingleUsageInfo *SingleUsageInfo `json:"single_usage_info,omitempty"` 209 ProgressiveBundleUsageInfo *ProgressiveBundleUsageInfo `json:"progressive_bundle_usage_info,omitempty"` 210 DisplayInfo *ProductCouponDisplayInfo `json:"display_info,omitempty"` 211 OutProductNo *string `json:"out_product_no,omitempty"` 212 Stock *StockForCreate `json:"stock,omitempty"` 213 StockBundle *StockBundleForCreate `json:"stock_bundle,omitempty"` 214} 215 216type CreateProductCouponResponse struct { 217 ProductCouponId *string `json:"product_coupon_id,omitempty"` 218 Scope *ProductCouponScope `json:"scope,omitempty"` 219 Type *ProductCouponType `json:"type,omitempty"` 220 UsageMode *UsageMode `json:"usage_mode,omitempty"` 221 SingleUsageInfo *SingleUsageInfo `json:"single_usage_info,omitempty"` 222 ProgressiveBundleUsageInfo *ProgressiveBundleUsageInfo `json:"progressive_bundle_usage_info,omitempty"` 223 DisplayInfo *ProductCouponDisplayInfo `json:"display_info,omitempty"` 224 OutProductNo *string `json:"out_product_no,omitempty"` 225 State *ProductCouponState `json:"state,omitempty"` 226 Stock *StockEntity `json:"stock,omitempty"` 227 StockBundle *StockBundleEntity `json:"stock_bundle,omitempty"` 228} 229 230type ProductCouponScope string 231 232func (e ProductCouponScope) Ptr() *ProductCouponScope { 233 return &e 234} 235 236const ( 237 PRODUCTCOUPONSCOPE_ALL ProductCouponScope = "ALL" 238 PRODUCTCOUPONSCOPE_SINGLE ProductCouponScope = "SINGLE" 239) 240 241type ProductCouponType string 242 243func (e ProductCouponType) Ptr() *ProductCouponType { 244 return &e 245} 246 247const ( 248 PRODUCTCOUPONTYPE_NORMAL ProductCouponType = "NORMAL" 249 PRODUCTCOUPONTYPE_DISCOUNT ProductCouponType = "DISCOUNT" 250 PRODUCTCOUPONTYPE_EXCHANGE ProductCouponType = "EXCHANGE" 251) 252 253type UsageMode string 254 255func (e UsageMode) Ptr() *UsageMode { 256 return &e 257} 258 259const ( 260 USAGEMODE_SINGLE UsageMode = "SINGLE" 261 USAGEMODE_PROGRESSIVE_BUNDLE UsageMode = "PROGRESSIVE_BUNDLE" 262) 263 264type SingleUsageInfo struct { 265 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 266 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 267} 268 269type ProgressiveBundleUsageInfo struct { 270 Count *int64 `json:"count,omitempty"` 271 IntervalDays *int64 `json:"interval_days,omitempty"` 272} 273 274type ProductCouponDisplayInfo struct { 275 Name *string `json:"name,omitempty"` 276 ImageUrl *string `json:"image_url,omitempty"` 277 BackgroundUrl *string `json:"background_url,omitempty"` 278 DetailImageUrlList []string `json:"detail_image_url_list,omitempty"` 279 OriginalPrice *int64 `json:"original_price,omitempty"` 280 ComboPackageList []ComboPackage `json:"combo_package_list,omitempty"` 281} 282 283type StockForCreate struct { 284 Remark *string `json:"remark,omitempty"` 285 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"` 286 StockSendRule *StockSendRule `json:"stock_send_rule,omitempty"` 287 SingleUsageRule *SingleUsageRule `json:"single_usage_rule,omitempty"` 288 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"` 289 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"` 290 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"` 291 StoreScope *StockStoreScope `json:"store_scope,omitempty"` 292} 293 294type StockBundleForCreate struct { 295 Remark *string `json:"remark,omitempty"` 296 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"` 297 StockSendRule *StockSendRuleForBundle `json:"stock_send_rule,omitempty"` 298 ProgressiveBundleUsageRule *StockBundleUsageRule `json:"progressive_bundle_usage_rule,omitempty"` 299 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"` 300 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"` 301 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"` 302 StoreScope *StockStoreScope `json:"store_scope,omitempty"` 303} 304 305type ProductCouponState string 306 307func (e ProductCouponState) Ptr() *ProductCouponState { 308 return &e 309} 310 311const ( 312 PRODUCTCOUPONSTATE_AUDITING ProductCouponState = "AUDITING" 313 PRODUCTCOUPONSTATE_EFFECTIVE ProductCouponState = "EFFECTIVE" 314 PRODUCTCOUPONSTATE_DEACTIVATED ProductCouponState = "DEACTIVATED" 315) 316 317type StockEntity struct { 318 ProductCouponId *string `json:"product_coupon_id,omitempty"` 319 StockId *string `json:"stock_id,omitempty"` 320 Remark *string `json:"remark,omitempty"` 321 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"` 322 CouponCodeCountInfo *CouponCodeCountInfo `json:"coupon_code_count_info,omitempty"` 323 StockSendRule *StockSendRule `json:"stock_send_rule,omitempty"` 324 SingleUsageRule *SingleUsageRule `json:"single_usage_rule,omitempty"` 325 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"` 326 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"` 327 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"` 328 StoreScope *StockStoreScope `json:"store_scope,omitempty"` 329 SentCountInfo *StockSentCountInfo `json:"sent_count_info,omitempty"` 330 State *StockState `json:"state,omitempty"` 331 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"` 332 DeactivateTime *time.Time `json:"deactivate_time,omitempty"` 333 DeactivateReason *string `json:"deactivate_reason,omitempty"` 334} 335 336type StockBundleEntity struct { 337 StockBundleId *string `json:"stock_bundle_id,omitempty"` 338 StockList []StockEntityInBundle `json:"stock_list,omitempty"` 339} 340 341type NormalCouponUsageRule struct { 342 Threshold *int64 `json:"threshold,omitempty"` 343 DiscountAmount *int64 `json:"discount_amount,omitempty"` 344} 345 346type DiscountCouponUsageRule struct { 347 Threshold *int64 `json:"threshold,omitempty"` 348 PercentOff *int64 `json:"percent_off,omitempty"` 349} 350 351type ComboPackage struct { 352 Name *string `json:"name,omitempty"` 353 PickCount *int64 `json:"pick_count,omitempty"` 354 ChoiceList []ComboPackageChoice `json:"choice_list,omitempty"` 355} 356 357type CouponCodeMode string 358 359func (e CouponCodeMode) Ptr() *CouponCodeMode { 360 return &e 361} 362 363const ( 364 COUPONCODEMODE_WECHATPAY CouponCodeMode = "WECHATPAY" 365 COUPONCODEMODE_UPLOAD CouponCodeMode = "UPLOAD" 366 COUPONCODEMODE_API_ASSIGN CouponCodeMode = "API_ASSIGN" 367) 368 369type StockSendRule struct { 370 MaxCount *int64 `json:"max_count,omitempty"` 371 MaxCountPerDay *int64 `json:"max_count_per_day,omitempty"` 372 MaxCountPerUser *int64 `json:"max_count_per_user,omitempty"` 373} 374 375type SingleUsageRule struct { 376 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"` 377 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 378 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 379 ExchangeCoupon *ExchangeCouponUsageRule `json:"exchange_coupon,omitempty"` 380} 381 382type UsageRuleDisplayInfo struct { 383 CouponUsageMethodList []CouponUsageMethod `json:"coupon_usage_method_list,omitempty"` 384 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 385 MiniProgramPath *string `json:"mini_program_path,omitempty"` 386 AppPath *string `json:"app_path,omitempty"` 387 UsageDescription *string `json:"usage_description,omitempty"` 388 CouponAvailableStoreInfo *CouponAvailableStoreInfo `json:"coupon_available_store_info,omitempty"` 389} 390 391type CouponDisplayInfo struct { 392 CodeDisplayMode *CouponCodeDisplayMode `json:"code_display_mode,omitempty"` 393 BackgroundColor *string `json:"background_color,omitempty"` 394 EntranceMiniProgram *EntranceMiniProgram `json:"entrance_mini_program,omitempty"` 395 EntranceOfficialAccount *EntranceOfficialAccount `json:"entrance_official_account,omitempty"` 396 EntranceFinder *EntranceFinder `json:"entrance_finder,omitempty"` 397} 398 399type NotifyConfig struct { 400 NotifyAppid *string `json:"notify_appid,omitempty"` 401} 402 403type StockStoreScope string 404 405func (e StockStoreScope) Ptr() *StockStoreScope { 406 return &e 407} 408 409const ( 410 STOCKSTORESCOPE_NONE StockStoreScope = "NONE" 411 STOCKSTORESCOPE_ALL StockStoreScope = "ALL" 412 STOCKSTORESCOPE_SPECIFIC StockStoreScope = "SPECIFIC" 413) 414 415type StockSendRuleForBundle struct { 416 MaxCount *int64 `json:"max_count,omitempty"` 417 MaxCountPerDay *int64 `json:"max_count_per_day,omitempty"` 418 MaxCountPerUser *int64 `json:"max_count_per_user,omitempty"` 419} 420 421type StockBundleUsageRule struct { 422 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"` 423 NormalCouponList []NormalCouponUsageRule `json:"normal_coupon_list,omitempty"` 424 DiscountCouponList []DiscountCouponUsageRule `json:"discount_coupon_list,omitempty"` 425 ExchangeCouponList []ExchangeCouponUsageRule `json:"exchange_coupon_list,omitempty"` 426} 427 428type CouponCodeCountInfo struct { 429 TotalCount *int64 `json:"total_count,omitempty"` 430 AvailableCount *int64 `json:"available_count,omitempty"` 431} 432 433type StockSentCountInfo struct { 434 TotalCount *int64 `json:"total_count,omitempty"` 435 TodayCount *int64 `json:"today_count,omitempty"` 436} 437 438type StockState string 439 440func (e StockState) Ptr() *StockState { 441 return &e 442} 443 444const ( 445 STOCKSTATE_AUDITING StockState = "AUDITING" 446 STOCKSTATE_SENDING StockState = "SENDING" 447 STOCKSTATE_PAUSED StockState = "PAUSED" 448 STOCKSTATE_STOPPED StockState = "STOPPED" 449 STOCKSTATE_DEACTIVATED StockState = "DEACTIVATED" 450) 451 452type StockEntityInBundle struct { 453 ProductCouponId *string `json:"product_coupon_id,omitempty"` 454 StockId *string `json:"stock_id,omitempty"` 455 Remark *string `json:"remark,omitempty"` 456 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"` 457 CouponCodeCountInfo *CouponCodeCountInfo `json:"coupon_code_count_info,omitempty"` 458 StockSendRule *StockSendRule `json:"stock_send_rule,omitempty"` 459 ProgressiveBundleUsageRule *StockUsageRule `json:"progressive_bundle_usage_rule,omitempty"` 460 StockBundleInfo *StockBundleInfo `json:"stock_bundle_info,omitempty"` 461 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"` 462 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"` 463 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"` 464 StoreScope *StockStoreScope `json:"store_scope,omitempty"` 465 SentCountInfo *StockSentCountInfo `json:"sent_count_info,omitempty"` 466 State *StockState `json:"state,omitempty"` 467 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"` 468 DeactivateTime *time.Time `json:"deactivate_time,omitempty"` 469 DeactivateReason *string `json:"deactivate_reason,omitempty"` 470} 471 472type ComboPackageChoice struct { 473 Name *string `json:"name,omitempty"` 474 Price *int64 `json:"price,omitempty"` 475 Count *int64 `json:"count,omitempty"` 476 ImageUrl *string `json:"image_url,omitempty"` 477 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 478 MiniProgramPath *string `json:"mini_program_path,omitempty"` 479} 480 481type CouponAvailablePeriod struct { 482 AvailableBeginTime *string `json:"available_begin_time,omitempty"` 483 AvailableEndTime *string `json:"available_end_time,omitempty"` 484 AvailableDays *int64 `json:"available_days,omitempty"` 485 WaitDaysAfterReceive *int64 `json:"wait_days_after_receive,omitempty"` 486 WeeklyAvailablePeriod *FixedWeekPeriod `json:"weekly_available_period,omitempty"` 487 IrregularAvailablePeriodList []TimePeriod `json:"irregular_available_period_list,omitempty"` 488} 489 490type ExchangeCouponUsageRule struct { 491 Threshold *int64 `json:"threshold,omitempty"` 492 ExchangePrice *int64 `json:"exchange_price,omitempty"` 493} 494 495type CouponUsageMethod string 496 497func (e CouponUsageMethod) Ptr() *CouponUsageMethod { 498 return &e 499} 500 501const ( 502 COUPONUSAGEMETHOD_OFFLINE CouponUsageMethod = "OFFLINE" 503 COUPONUSAGEMETHOD_MINI_PROGRAM CouponUsageMethod = "MINI_PROGRAM" 504 COUPONUSAGEMETHOD_APP CouponUsageMethod = "APP" 505 COUPONUSAGEMETHOD_PAYMENT_CODE CouponUsageMethod = "PAYMENT_CODE" 506) 507 508type CouponAvailableStoreInfo struct { 509 Description *string `json:"description,omitempty"` 510 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 511 MiniProgramPath *string `json:"mini_program_path,omitempty"` 512} 513 514type CouponCodeDisplayMode string 515 516func (e CouponCodeDisplayMode) Ptr() *CouponCodeDisplayMode { 517 return &e 518} 519 520const ( 521 COUPONCODEDISPLAYMODE_INVISIBLE CouponCodeDisplayMode = "INVISIBLE" 522 COUPONCODEDISPLAYMODE_BARCODE CouponCodeDisplayMode = "BARCODE" 523 COUPONCODEDISPLAYMODE_QRCODE CouponCodeDisplayMode = "QRCODE" 524) 525 526type EntranceMiniProgram struct { 527 Appid *string `json:"appid,omitempty"` 528 Path *string `json:"path,omitempty"` 529 EntranceWording *string `json:"entrance_wording,omitempty"` 530 GuidanceWording *string `json:"guidance_wording,omitempty"` 531} 532 533type EntranceOfficialAccount struct { 534 Appid *string `json:"appid,omitempty"` 535} 536 537type EntranceFinder struct { 538 FinderId *string `json:"finder_id,omitempty"` 539 FinderVideoId *string `json:"finder_video_id,omitempty"` 540 FinderVideoCoverImageUrl *string `json:"finder_video_cover_image_url,omitempty"` 541} 542 543type StockUsageRule struct { 544 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"` 545 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 546 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 547 ExchangeCoupon *ExchangeCouponUsageRule `json:"exchange_coupon,omitempty"` 548} 549 550type StockBundleInfo struct { 551 StockBundleId *string `json:"stock_bundle_id,omitempty"` 552 StockBundleIndex *int64 `json:"stock_bundle_index,omitempty"` 553} 554 555type FixedWeekPeriod struct { 556 DayList []WeekEnum `json:"day_list,omitempty"` 557 DayPeriodList []PeriodOfTheDay `json:"day_period_list,omitempty"` 558} 559 560type TimePeriod struct { 561 BeginTime *string `json:"begin_time,omitempty"` 562 EndTime *string `json:"end_time,omitempty"` 563} 564 565type WeekEnum string 566 567func (e WeekEnum) Ptr() *WeekEnum { 568 return &e 569} 570 571const ( 572 WEEKENUM_MONDAY WeekEnum = "MONDAY" 573 WEEKENUM_TUESDAY WeekEnum = "TUESDAY" 574 WEEKENUM_WEDNESDAY WeekEnum = "WEDNESDAY" 575 WEEKENUM_THURSDAY WeekEnum = "THURSDAY" 576 WEEKENUM_FRIDAY WeekEnum = "FRIDAY" 577 WEEKENUM_SATURDAY WeekEnum = "SATURDAY" 578 WEEKENUM_SUNDAY WeekEnum = "SUNDAY" 579) 580 581type PeriodOfTheDay struct { 582 BeginTime *int64 `json:"begin_time,omitempty"` 583 EndTime *int64 `json:"end_time,omitempty"` 584} 585
应答参数
200 OK
product_coupon_id 必填 string(40)
【商品券ID】 商品券的唯一标识,本接口成功时由微信支付生成
scope 必填 string
【优惠范围】 商品券优惠范围
可选取值
ALL: 全场商品可用券,此时券类型type仅可配置为NORMAL或DISCOUNTSINGLE: 部分商品可用券,此时券类型type配置不受限制,即可配置为NORMAL、DISCOUNT或EXCHANGE
type 必填 string
【商品券类型】 商品券的优惠类型
可选取值
NORMAL: 满减券DISCOUNT: 折扣券EXCHANGE: 兑换券,仅在scope为SINGLE时可配置
usage_mode 必填 string
【使用模式】 商品券使用模式
PROGRESSIVE_BUNDLE: 多次优惠,由一组批次组成,每阶梯次序对应一个批次。用户按顺序使用,每次核销后发放下一张券,直到用完为止
progressive_bundle_usage_info 必填 object
【多次优惠模式信息】 多次优惠模式配置信息
| 属性 | |
count 必填 integer 【可使用次数】 多次优惠领取后用户可使用次数,最少3次,最多15次 interval_days 选填 integer 【多次优惠使用间隔天数】 多次优惠多次使用之间需要间隔的天数,最高7天。例如:
默认情况下为 |
display_info 必填 object
【展示信息】 商品券展示信息
| 属性 | |||||||||
name 必填 string(15) 【商品券名称】 商品券名称,长度为3-15个UTF-8字符 image_url 必填 string 【商品券图片】 商品图片的链接地址,仅支持通过【图片上传API】获取的图片URL地址。
background_url 必填 string 【商品券背景图】 商品背景图片的URL地址,仅支持通过【图片上传API】获取的图片URL地址。
detail_image_url_list 选填 array[string] 【商品券详情图列表】 商品详情图URL地址列表,用于最多可上传8张图片,仅支持通过【图片上传API】获取的图片URL地址。
original_price 选填 integer 【商品原价】 单位为分, combo_package_list 选填 array[object] 【适用商品组合】 当
|
out_product_no 选填 string
【外部商品ID】 商户创建商品券时主动传入的外部商品ID,原样返回
state 必填 string
【商品券状态】 商品券状态
可选取值
AUDITING: 审批中,审批完成前商品券不可用EFFECTIVE: 生效中,商品券已生效,可以正常使用DEACTIVATED: 已失效,品牌方主动调用失效接口使商品券失效
stock_bundle 必填 object
【批次组】 商品券批次组信息
| 属性 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
stock_bundle_id 必填 string(40) 【批次组ID】 商品券批次组的唯一标识,由微信支付生成 stock_list 必填 array[object] 【批次列表】 批次组内批次列表
|
应答示例
200 OK
创建全场折扣多次优惠券
1{ 2 "product_coupon_id" : "1000000014", 3 "scope" : "ALL", 4 "type" : "DISCOUNT", 5 "usage_mode" : "PROGRESSIVE_BUNDLE", 6 "progressive_bundle_usage_info" : { 7 "count" : 3, 8 "interval_days" : 1 9 }, 10 "display_info" : { 11 "name" : "全场满100立打8折", 12 "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 13 "background_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 14 "detail_image_url_list" : [ 15 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 16 ] 17 }, 18 "state" : "EFFECTIVE", 19 "out_product_no" : "Product_1234567890", 20 "stock_bundle" : { 21 "stock_bundle_id" : "712315129419284901", 22 "stock_list" : [ 23 { 24 "product_coupon_id" : "1000000014", 25 "stock_id" : "1000000014001", 26 "remark" : "8月工作日有效批次", 27 "coupon_code_mode" : "UPLOAD", 28 "coupon_code_count_info" : { 29 "total_count" : 0, 30 "available_count" : 0 31 }, 32 "stock_send_rule" : { 33 "max_count" : 10000000, 34 "max_count_per_user" : 1 35 }, 36 "progressive_bundle_usage_rule" : { 37 "coupon_available_period" : { 38 "available_begin_time" : "2025-08-01T00:00:00+08:00", 39 "available_end_time" : "2025-08-31T23:59:59+08:00", 40 "available_days" : 30, 41 "weekly_available_period" : { 42 "day_list" : [ 43 "MONDAY", 44 "TUESDAY", 45 "WEDNESDAY", 46 "THURSDAY", 47 "FRIDAY" 48 ] 49 } 50 }, 51 "discount_coupon" : { 52 "threshold" : 10000, 53 "percent_off" : 50 54 } 55 }, 56 "stock_bundle_info" : { 57 "stock_bundle_id" : "712315129419284901", 58 "stock_bundle_index" : 0 59 }, 60 "usage_rule_display_info" : { 61 "coupon_usage_method_list" : [ 62 "OFFLINE", 63 "MINI_PROGRAM", 64 "PAYMENT_CODE" 65 ], 66 "mini_program_appid" : "wx1234567890", 67 "mini_program_path" : "/pages/index/product", 68 "usage_description" : "工作日可用", 69 "coupon_available_store_info" : { 70 "description" : "所有门店可用,可使用小程序查看门店列表", 71 "mini_program_appid" : "wx1234567890", 72 "mini_program_path" : "/pages/index/store-list" 73 } 74 }, 75 "coupon_display_info" : { 76 "code_display_mode" : "QRCODE", 77 "background_color" : "Color010", 78 "entrance_mini_program" : { 79 "appid" : "wx1234567890", 80 "path" : "/pages/index/product", 81 "entrance_wording" : "欢迎选购", 82 "guidance_wording" : "获取更多优惠" 83 }, 84 "entrance_official_account" : { 85 "appid" : "wx1234567890" 86 }, 87 "entrance_finder" : { 88 "finder_id" : "gh_12345678", 89 "finder_video_id" : "UDFsdf24df34dD456Hdf34", 90 "finder_video_cover_image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 91 } 92 }, 93 "notify_config" : { 94 "notify_appid" : "wx4fd12345678" 95 }, 96 "store_scope" : "NONE", 97 "sent_count_info" : { 98 "total_count" : 0, 99 "today_count" : 0 100 }, 101 "state" : "SENDING" 102 }, 103 { 104 "product_coupon_id" : "1000000014", 105 "stock_id" : "1000000014002", 106 "remark" : "8月工作日有效批次", 107 "coupon_code_mode" : "UPLOAD", 108 "coupon_code_count_info" : { 109 "total_count" : 0, 110 "available_count" : 0 111 }, 112 "stock_send_rule" : { 113 "max_count" : 10000000, 114 "max_count_per_user" : 1 115 }, 116 "progressive_bundle_usage_rule" : { 117 "coupon_available_period" : { 118 "available_begin_time" : "2025-08-01T00:00:00+08:00", 119 "available_end_time" : "2025-08-31T23:59:59+08:00", 120 "available_days" : 30, 121 "weekly_available_period" : { 122 "day_list" : [ 123 "MONDAY", 124 "TUESDAY", 125 "WEDNESDAY", 126 "THURSDAY", 127 "FRIDAY" 128 ] 129 } 130 }, 131 "discount_coupon" : { 132 "threshold" : 10000, 133 "percent_off" : 20 134 } 135 }, 136 "stock_bundle_info" : { 137 "stock_bundle_id" : "712315129419284901", 138 "stock_bundle_index" : 1 139 }, 140 "usage_rule_display_info" : { 141 "coupon_usage_method_list" : [ 142 "OFFLINE", 143 "MINI_PROGRAM", 144 "PAYMENT_CODE" 145 ], 146 "mini_program_appid" : "wx1234567890", 147 "mini_program_path" : "/pages/index/product", 148 "usage_description" : "工作日可用", 149 "coupon_available_store_info" : { 150 "description" : "所有门店可用,可使用小程序查看门店列表", 151 "mini_program_appid" : "wx1234567890", 152 "mini_program_path" : "/pages/index/store-list" 153 } 154 }, 155 "coupon_display_info" : { 156 "code_display_mode" : "QRCODE", 157 "background_color" : "Color010", 158 "entrance_mini_program" : { 159 "appid" : "wx1234567890", 160 "path" : "/pages/index/product", 161 "entrance_wording" : "欢迎选购", 162 "guidance_wording" : "获取更多优惠" 163 }, 164 "entrance_official_account" : { 165 "appid" : "wx1234567890" 166 }, 167 "entrance_finder" : { 168 "finder_id" : "gh_12345678", 169 "finder_video_id" : "UDFsdf24df34dD456Hdf34", 170 "finder_video_cover_image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 171 } 172 }, 173 "notify_config" : { 174 "notify_appid" : "wx4fd12345678" 175 }, 176 "store_scope" : "NONE", 177 "sent_count_info" : { 178 "total_count" : 0, 179 "today_count" : 0 180 }, 181 "state" : "SENDING" 182 }, 183 { 184 "product_coupon_id" : "1000000014", 185 "stock_id" : "1000000014003", 186 "remark" : "8月工作日有效批次", 187 "coupon_code_mode" : "UPLOAD", 188 "coupon_code_count_info" : { 189 "total_count" : 0, 190 "available_count" : 0 191 }, 192 "stock_send_rule" : { 193 "max_count" : 10000000, 194 "max_count_per_user" : 1 195 }, 196 "progressive_bundle_usage_rule" : { 197 "coupon_available_period" : { 198 "available_begin_time" : "2025-08-01T00:00:00+08:00", 199 "available_end_time" : "2025-08-31T23:59:59+08:00", 200 "available_days" : 30, 201 "weekly_available_period" : { 202 "day_list" : [ 203 "MONDAY", 204 "TUESDAY", 205 "WEDNESDAY", 206 "THURSDAY", 207 "FRIDAY" 208 ] 209 } 210 }, 211 "discount_coupon" : { 212 "threshold" : 10000, 213 "percent_off" : 30 214 } 215 }, 216 "stock_bundle_info" : { 217 "stock_bundle_id" : "712315129419284901", 218 "stock_bundle_index" : 2 219 }, 220 "usage_rule_display_info" : { 221 "coupon_usage_method_list" : [ 222 "OFFLINE", 223 "MINI_PROGRAM", 224 "PAYMENT_CODE" 225 ], 226 "mini_program_appid" : "wx1234567890", 227 "mini_program_path" : "/pages/index/product", 228 "usage_description" : "工作日可用", 229 "coupon_available_store_info" : { 230 "description" : "所有门店可用,可使用小程序查看门店列表", 231 "mini_program_appid" : "wx1234567890", 232 "mini_program_path" : "/pages/index/store-list" 233 } 234 }, 235 "coupon_display_info" : { 236 "code_display_mode" : "QRCODE", 237 "background_color" : "Color010", 238 "entrance_mini_program" : { 239 "appid" : "wx1234567890", 240 "path" : "/pages/index/product", 241 "entrance_wording" : "欢迎选购", 242 "guidance_wording" : "获取更多优惠" 243 }, 244 "entrance_official_account" : { 245 "appid" : "wx1234567890" 246 }, 247 "entrance_finder" : { 248 "finder_id" : "gh_12345678", 249 "finder_video_id" : "UDFsdf24df34dD456Hdf34", 250 "finder_video_cover_image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 251 } 252 }, 253 "notify_config" : { 254 "notify_appid" : "wx4fd12345678" 255 }, 256 "store_scope" : "NONE", 257 "sent_count_info" : { 258 "total_count" : 0, 259 "today_count" : 0 260 }, 261 "state" : "SENDING" 262 } 263 ] 264 } 265} 266
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示
状态码 | 错误码 | 描述 | 解决方案 |
|---|---|---|---|
400 | PARAM_ERROR | 参数错误 | 请根据错误提示正确传入参数 |
400 | INVALID_REQUEST | HTTP 请求不符合微信支付 APIv3 接口规则 | 请参阅 接口规则 |
401 | SIGN_ERROR | 验证不通过 | 请参阅 签名常见问题 |
500 | SYSTEM_ERROR | 系统异常,请稍后重试 | 请稍后重试 |
400 | INVALID_REQUEST | 商品券使用模式(usage_mode)非法,不可以使此模式 | 请使用其他 usage_mode |
400 | INVALID_REQUEST | 多次优惠使用模式的商品券批次,应该在「多次优惠使用规则」中包含对应类型的优惠规则,且数量与多次优惠的优惠次数相等 | 在「多次优惠使用规则」中包含对应类型的优惠规则,且数量与多次优惠的优惠次数相等 |
400 | INVALID_REQUEST | 单品满减券或单品折扣券不应在商品券中设置「满减券使用规则」或「折扣券使用规则」,而是应该在商品券批次中设置 | 请删除商品券中的「满减券使用规则」或「折扣券使用规则」,并在商品券批次中设置对应的优惠规则 |
403 | NO_AUTH | 品牌没有此接口权限 | 品牌没有此接口权限 |
400 | INVALID_REQUEST | 全场券的券类型只能设置为 「满减券」和「折扣券」,不可以设置为「换购券」 | 请更换券类型为「满减券」或「折扣券」;或者更换券使用范围为「单品券』 |
400 | INVALID_REQUEST | 商品券支持APP核销时,必须提供「APP跳转路径」 | 请提供「APP跳转路径」参数 |
400 | PARAM_ERROR | 分页大小超出限制,请根据接口文档调整到允许的范围 | 请调整分页大小到规定范围 |
400 | INVALID_REQUEST | 商品券支持小程序核销时,必须提供「小程序AppID」 | 请提供「小程序AppID」 |
400 | INVALID_REQUEST | 单品券必须提供商品原价,请补充 | 请补充商品原价 |
400 | INVALID_REQUEST | 商品券支持小程序核销时,必须提供「小程序跳转路径」 | 请提供提供「小程序跳转路径」 |
400 | INVALID_REQUEST | 单品券必须提供商品券套餐组合信息,请补充 | 请提供商品券套餐组合信息 |
400 | PARAM_ERROR | 时间字符串格式错误,请使用 RFC3339 标准格式 | 请使用 RFC3339 标准格式 |
400 | INVALID_REQUEST | 每周固定可用时间(weekly_available_period)中提供当天可用时间段时(day_period_list),每周可用星期数(day_list)必填 | 请补充 每周可用星期数(day_list) |
400 | INVALID_REQUEST | 传入的OpenID不合法 | 请使用参数 AppID 对应的的OpenID |


