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


