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


