【多次优惠-单品-满减券】API请求示例
更新时间:2025.12.04||
curl
Java
Go
1## 场景4: 多次优惠-单品-满减券 2 3```bash 4curl -X POST \ 5 https://api.mch.weixin.qq.com/v3/marketing/partner/product-coupon/product-coupons \ 6 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 7 -H "Accept: application/json" \ 8 -H "Content-Type: application/json" \ 9 -d '{ 10 "out_request_no" : "MANY_SINGLE_NORMAL_20250101_004", # 必填,创建请求单号,品牌侧需保持唯一性,长度6-40个字符 11 "brand_id" : "120344", # 必填,品牌ID 12 "out_product_no" : "Product_1234567890", # 选填,外部商品ID 13 "scope" : "SINGLE", # 必填,优惠范围:SINGLE=单品券 14 "type" : "NORMAL", # 必填,商品券类型:NORMAL=满减券 15 "usage_mode" : "PROGRESSIVE_BUNDLE", # 必填,使用模式:PROGRESSIVE_BUNDLE=多次优惠模式(阶梯模式) 16 "progressive_bundle_usage_info" : { # 条件必填:当usage_mode="PROGRESSIVE_BUNDLE"时必填,多次优惠模式配置信息 17 "count" : 3, # 必填,可使用次数,最少3次,最多15次 18 "interval_days" : 2 # 选填,多次优惠使用间隔天数,2=使用后需等到第三天00:00:00才能使用下一次 19 }, 20 "display_info" : { # 必填,商品券展示信息 21 "name" : "指定商品立减15(可用3次)", # 必填,商品券名称 22 "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", # 必填,商品图片URL 23 "background_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", # 必填,背景图URL 24 "detail_image_url_list" : [ # 选填,详情图URL列表 25 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" 26 ], 27 "original_price" : 9900, # 条件必填:当scope="SINGLE"时,与combo_package_list二选一必填,商品原价,单位为分 28 "combo_package_list" : [ # 条件必填:当scope="SINGLE"时,与original_price二选一必填,套餐组合列表 29 { 30 "name" : "套餐A", # 条件必填:当配置combo_package_list数组时必填,套餐名称 31 "pick_count" : 2, # 条件必填:当配置combo_package_list数组时必填,可选单品数量 32 "choice_list" : [ # 条件必填:当配置combo_package_list数组时必填,单品列表 33 { "name" : "鸡腿饭", "price" : 2000, "count" : 1, "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/chicken" }, # name/price/count必填,image_url选填 34 { "name" : "牛肉饭", "price" : 2500, "count" : 1, "image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/beef" } 35 ] 36 } 37 ] 38 }, 39 "stock_bundle" : { # 条件必填:当usage_mode="PROGRESSIVE_BUNDLE"时必填,批次组信息 40 "remark" : "指定商品立减15批次", # 选填,批次备注 41 "coupon_code_mode" : "WECHATPAY", # 必填,券Code分配模式 42 "stock_send_rule" : { # 必填,发放规则 43 "max_count" : 10000000, # 必填,总发放次数上限 44 "max_count_per_user" : 1 # 必填,每用户领取上限 45 }, 46 "progressive_bundle_usage_rule" : { # 条件必填:当usage_mode="PROGRESSIVE_BUNDLE"时必填,多次优惠使用规则 47 "coupon_available_period" : { # 必填,券可核销时间 48 "available_begin_time" : "2025-08-01T00:00:00+08:00", # 必填,开始时间 49 "available_end_time" : "2025-08-31T23:59:59+08:00", # 必填,结束时间 50 "available_days" : 30, # 选填,生效后N天有效 51 "weekly_available_period" : { # 选填,每周可用时间。若配置此对象,则day_list必填 52 "day_list" : ["MONDAY","TUESDAY","WEDNESDAY","THURSDAY","FRIDAY"] # 条件必填:当配置weekly_available_period对象时必填 53 } 54 }, 55 "normal_coupon" : { # 条件必填:当type="NORMAL"时必填,满减券使用规则 56 "threshold" : 0, # 必填,门槛金额,单位为分,0表示无门槛 57 "discount_amount" : 1500 # 必填,固定减免金额,单位为分,减15元填1500 58 } 59 }, 60 "usage_rule_display_info" : { # 必填,使用规则展示信息 61 "coupon_usage_method_list" : ["OFFLINE","MINI_PROGRAM","PAYMENT_CODE"], # 必填,券使用方式列表 62 "mini_program_appid" : "wx1234567890", # 条件必填:当coupon_usage_method_list包含"MINI_PROGRAM"时必填 63 "mini_program_path" : "/pages/index/product", # 条件必填:当coupon_usage_method_list包含"MINI_PROGRAM"时必填 64 "usage_description" : "指定商品可用,立减15元", # 必填,使用说明 65 "coupon_available_store_info" : { # 选填,可用门店信息 66 "description" : "所有门店可用,可使用小程序查看门店列表", # 条件必填:当配置coupon_available_store_info对象时必填 67 "mini_program_appid" : "wx1234567890", # 选填 68 "mini_program_path" : "/pages/index/store-list" # 选填 69 } 70 }, 71 "coupon_display_info" : { # 必填,用户券展示信息 72 "code_display_mode" : "QRCODE", # 必填,Code展示模式 73 "background_color" : "Color010", # 选填,背景颜色 74 "entrance_mini_program" : { # 选填,小程序入口。若配置此对象,则appid/path/entrance_wording/guidance_wording均必填 75 "appid" : "wx1234567890", # 条件必填:当配置entrance_mini_program对象时必填 76 "path" : "/pages/index/product", # 条件必填:当配置entrance_mini_program对象时必填 77 "entrance_wording" : "欢迎选购", # 条件必填:当配置entrance_mini_program对象时必填 78 "guidance_wording" : "获取更多优惠" # 条件必填:当配置entrance_mini_program对象时必填 79 }, 80 "entrance_official_account" : { "appid" : "wx1234567890" }, # 选填 81 "entrance_finder" : { # 选填,视频号入口。若配置此对象,则finder_id/finder_video_id/finder_video_cover_image_url均必填 82 "finder_id" : "gh_12345678", # 条件必填:当配置entrance_finder对象时必填 83 "finder_video_id" : "UDFsdf24df34dD456Hdf34", # 条件必填:当配置entrance_finder对象时必填 84 "finder_video_cover_image_url" : "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx" # 条件必填:当配置entrance_finder对象时必填 85 } 86 }, 87 "store_scope" : "NONE", # 必填,可用门店范围 88 "notify_config" : { "notify_appid" : "wx4fd12345678" } # 必填,事件通知配置 89 } 90 }' 91```
需配合微信支付工具库 WXPayUtility 使用,请参考 Java
1package com.java.demo; 2 3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/partner/4014985777 4import com.google.gson.annotations.SerializedName; 5import okhttp3.MediaType; 6import okhttp3.OkHttpClient; 7import okhttp3.Request; 8import okhttp3.RequestBody; 9import okhttp3.Response; 10import java.io.IOException; 11import java.io.UncheckedIOException; 12import java.security.PrivateKey; 13import java.security.PublicKey; 14import java.util.ArrayList; 15import java.util.List; 16 17/** 18 * 创建商品券 - 场景4:多次优惠-单品-满减券 19 * 20 * 场景说明:单品券(适用于指定商品)+ 满减券(满足门槛后减固定金额)+ 阶梯模式(可多次使用) 21 * 22 * 关键参数: 23 * - scope = SINGLE(单品券) 24 * - type = NORMAL(满减券) 25 * - usage_mode = PROGRESSIVE_BUNDLE(阶梯模式) 26 */ 27public class SingleNormalManyJava { 28 private static String HOST = "https://api.mch.weixin.qq.com"; 29 private static String METHOD = "POST"; 30 private static String PATH = "/v3/marketing/partner/product-coupon/product-coupons"; 31 32 public static void main(String[] args) { 33 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 34 SingleNormalManyJava client = new SingleNormalManyJava( 35 "19xxxxxxxx", // 商户号 36 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号 37 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径 38 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID 39 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径 40 ); 41 42 CreateProductCouponRequest request = new CreateProductCouponRequest(); 43 // 必填,创建请求单号,6-40个字符,品牌侧需保持唯一性 44 request.outRequestNo = "MANY_SINGLE_NORMAL_20250101_004"; 45 // 必填,品牌ID,由微信支付分配 46 request.brandId = "120344"; 47 // 选填,商户侧商品券唯一标识 48 request.outProductNo = "Product_1234567890"; 49 // 必填,优惠范围:ALL-全场券(仅支持NORMAL/DISCOUNT), SINGLE-单品券(支持NORMAL/DISCOUNT/EXCHANGE) 50 request.scope = ProductCouponScope.SINGLE; 51 // 必填,商品券类型:NORMAL-满减券, DISCOUNT-折扣券, EXCHANGE-兑换券(仅单品券) 52 request.type = ProductCouponType.NORMAL; 53 // 必填,使用模式:SINGLE-单券, PROGRESSIVE_BUNDLE-多次优惠 54 request.usageMode = UsageMode.PROGRESSIVE_BUNDLE; 55 56 // 条件必填,多次优惠模式配置信息(当usage_mode=PROGRESSIVE_BUNDLE时必填) 57 request.progressiveBundleUsageInfo = new ProgressiveBundleUsageInfo(); 58 // 必填,可使用次数,最少3次,最多15次 59 request.progressiveBundleUsageInfo.count = 3L; 60 // 选填,多次优惠使用间隔天数(2表示使用后需等到第三天00:00:00才能使用下一次),最高7天,默认0 61 request.progressiveBundleUsageInfo.intervalDays = 2L; // 使用后需等到第三天00:00:00才能使用下一次 62 63 // 必填,商品券展示信息 64 request.displayInfo = new ProductCouponDisplayInfo(); 65 // 必填,商品券名称,最多12个字符 66 request.displayInfo.name = "指定商品立减15(可用3次)"; 67 // 必填,商品券图片URL 68 request.displayInfo.imageUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"; 69 // 选填,背景图URL 70 request.displayInfo.backgroundUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"; 71 // 选填,详情图URL列表,最多6张 72 request.displayInfo.detailImageUrlList = new ArrayList<>(); 73 request.displayInfo.detailImageUrlList.add("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"); 74 // 条件必填(单品券),商品原价(单位:分),与combo_package_list二选一 75 request.displayInfo.originalPrice = 9900L; 76 77 // 条件必填(单品券),套餐组合列表,与original_price二选一 78 request.displayInfo.comboPackageList = new ArrayList<>(); 79 ComboPackage combo = new ComboPackage(); 80 combo.name = "套餐A"; // 必填,套餐名称 81 combo.pickCount = 2L; // 必填,可选商品数量 82 combo.choiceList = new ArrayList<>(); // 必填,可选商品列表 83 ComboPackageChoice choice1 = new ComboPackageChoice(); 84 choice1.name = "鸡腿饭"; // 必填,商品名称 85 choice1.price = 2000L; // 必填,商品价格(单位:分) 86 choice1.count = 1L; // 必填,商品数量 87 choice1.imageUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/chicken"; // 必填,商品图片URL 88 combo.choiceList.add(choice1); 89 ComboPackageChoice choice2 = new ComboPackageChoice(); 90 choice2.name = "牛肉饭"; // 必填,商品名称 91 choice2.price = 2500L; // 必填,商品价格(单位:分) 92 choice2.count = 1L; // 必填,商品数量 93 choice2.imageUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/beef"; // 必填,商品图片URL 94 combo.choiceList.add(choice2); 95 request.displayInfo.comboPackageList.add(combo); 96 97 // 条件必填,批次信息(当usage_mode=PROGRESSIVE_BUNDLE时必填) 98 request.stockBundle = createStock("指定商品立减15批次", 0, 1500); 99 100 try { 101 CreateProductCouponResponse response = client.run(request); 102 System.out.println(response); 103 } catch (WXPayUtility.ApiException e) { 104 e.printStackTrace(); 105 } 106 } 107 108 /** 109 * 创建满减券批次 110 */ 111 private static StockForProgressiveBundle createStock(String remark, long threshold, long discountAmount) { 112 StockForProgressiveBundle stock = new StockForProgressiveBundle(); 113 stock.remark = remark; 114 stock.couponCodeMode = CouponCodeMode.WECHATPAY; 115 116 stock.stockSendRule = new StockSendRule(); 117 stock.stockSendRule.maxCount = 10000000L; 118 stock.stockSendRule.maxCountPerUser = 1L; 119 120 stock.progressiveBundleUsageRule = new ProgressiveBundleUsageRule(); 121 stock.progressiveBundleUsageRule.couponAvailablePeriod = new CouponAvailablePeriod(); 122 stock.progressiveBundleUsageRule.couponAvailablePeriod.availableBeginTime = "2025-08-01T00:00:00+08:00"; 123 stock.progressiveBundleUsageRule.couponAvailablePeriod.availableEndTime = "2025-08-31T23:59:59+08:00"; 124 stock.progressiveBundleUsageRule.couponAvailablePeriod.availableDays = 30L; 125 stock.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod = new FixedWeekPeriod(); 126 stock.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList = new ArrayList<>(); 127 stock.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.MONDAY); 128 stock.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.TUESDAY); 129 stock.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.WEDNESDAY); 130 stock.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.THURSDAY); 131 stock.progressiveBundleUsageRule.couponAvailablePeriod.weeklyAvailablePeriod.dayList.add(WeekEnum.FRIDAY); 132 133 // 满减券规则 134 stock.progressiveBundleUsageRule.normalCoupon = new NormalCouponUsageRule(); 135 stock.progressiveBundleUsageRule.normalCoupon.threshold = threshold; 136 stock.progressiveBundleUsageRule.normalCoupon.discountAmount = discountAmount; 137 138 stock.usageRuleDisplayInfo = new UsageRuleDisplayInfo(); 139 stock.usageRuleDisplayInfo.couponUsageMethodList = new ArrayList<>(); 140 stock.usageRuleDisplayInfo.couponUsageMethodList.add(CouponUsageMethod.OFFLINE); 141 stock.usageRuleDisplayInfo.couponUsageMethodList.add(CouponUsageMethod.MINI_PROGRAM); 142 stock.usageRuleDisplayInfo.couponUsageMethodList.add(CouponUsageMethod.PAYMENT_CODE); 143 stock.usageRuleDisplayInfo.miniProgramAppid = "wx1234567890"; 144 stock.usageRuleDisplayInfo.miniProgramPath = "/pages/index/product"; 145 stock.usageRuleDisplayInfo.usageDescription = "指定商品可用,立减15元"; 146 stock.usageRuleDisplayInfo.couponAvailableStoreInfo = new CouponAvailableStoreInfo(); 147 stock.usageRuleDisplayInfo.couponAvailableStoreInfo.description = "所有门店可用,可使用小程序查看门店列表"; 148 stock.usageRuleDisplayInfo.couponAvailableStoreInfo.miniProgramAppid = "wx1234567890"; 149 stock.usageRuleDisplayInfo.couponAvailableStoreInfo.miniProgramPath = "/pages/index/store-list"; 150 151 stock.couponDisplayInfo = new CouponDisplayInfo(); 152 stock.couponDisplayInfo.codeDisplayMode = CouponCodeDisplayMode.QRCODE; 153 stock.couponDisplayInfo.backgroundColor = "Color010"; 154 stock.couponDisplayInfo.entranceMiniProgram = new EntranceMiniProgram(); 155 stock.couponDisplayInfo.entranceMiniProgram.appid = "wx1234567890"; 156 stock.couponDisplayInfo.entranceMiniProgram.path = "/pages/index/product"; 157 stock.couponDisplayInfo.entranceMiniProgram.entranceWording = "欢迎选购"; 158 stock.couponDisplayInfo.entranceMiniProgram.guidanceWording = "获取更多优惠"; 159 stock.couponDisplayInfo.entranceOfficialAccount = new EntranceOfficialAccount(); 160 stock.couponDisplayInfo.entranceOfficialAccount.appid = "wx1234567890"; 161 stock.couponDisplayInfo.entranceFinder = new EntranceFinder(); 162 stock.couponDisplayInfo.entranceFinder.finderId = "gh_12345678"; 163 stock.couponDisplayInfo.entranceFinder.finderVideoId = "UDFsdf24df34dD456Hdf34"; 164 stock.couponDisplayInfo.entranceFinder.finderVideoCoverImageUrl = "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"; 165 166 stock.storeScope = StockStoreScope.NONE; 167 stock.notifyConfig = new NotifyConfig(); 168 stock.notifyConfig.notifyAppid = "wx4fd12345678"; 169 170 return stock; 171 } 172 173 public CreateProductCouponResponse run(CreateProductCouponRequest request) { 174 String uri = PATH; 175 String reqBody = WXPayUtility.toJson(request); 176 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 177 reqBuilder.addHeader("Accept", "application/json"); 178 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 179 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, reqBody)); 180 reqBuilder.addHeader("Content-Type", "application/json"); 181 RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), reqBody); 182 reqBuilder.method(METHOD, requestBody); 183 Request httpRequest = reqBuilder.build(); 184 185 OkHttpClient client = new OkHttpClient.Builder().build(); 186 try (Response httpResponse = client.newCall(httpRequest).execute()) { 187 String respBody = WXPayUtility.extractBody(httpResponse); 188 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 189 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 190 httpResponse.headers(), respBody); 191 return WXPayUtility.fromJson(respBody, CreateProductCouponResponse.class); 192 } else { 193 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 194 } 195 } catch (IOException e) { 196 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 197 } 198 } 199 200 private final String mchid; 201 private final String certificateSerialNo; 202 private final PrivateKey privateKey; 203 private final String wechatPayPublicKeyId; 204 private final PublicKey wechatPayPublicKey; 205 206 public SingleNormalManyJava(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 207 this.mchid = mchid; 208 this.certificateSerialNo = certificateSerialNo; 209 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 210 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 211 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 212 } 213 214 // ==================== 请求/响应类定义 ==================== 215 216 public static class CreateProductCouponRequest { 217 @SerializedName("out_request_no") 218 public String outRequestNo; 219 220 @SerializedName("brand_id") 221 public String brandId; 222 223 @SerializedName("out_product_no") 224 public String outProductNo; 225 226 @SerializedName("scope") 227 public ProductCouponScope scope; 228 229 @SerializedName("type") 230 public ProductCouponType type; 231 232 @SerializedName("usage_mode") 233 public UsageMode usageMode; 234 235 @SerializedName("progressive_bundle_usage_info") 236 public ProgressiveBundleUsageInfo progressiveBundleUsageInfo; 237 238 @SerializedName("display_info") 239 public ProductCouponDisplayInfo displayInfo; 240 241 @SerializedName("stock_bundle") 242 public StockForProgressiveBundle stockBundle; 243 } 244 245 public static class CreateProductCouponResponse { 246 @SerializedName("product_coupon_id") 247 public String productCouponId; 248 249 @SerializedName("scope") 250 public ProductCouponScope scope; 251 252 @SerializedName("type") 253 public ProductCouponType type; 254 255 @SerializedName("usage_mode") 256 public UsageMode usageMode; 257 258 @SerializedName("progressive_bundle_usage_info") 259 public ProgressiveBundleUsageInfo progressiveBundleUsageInfo; 260 261 @SerializedName("display_info") 262 public ProductCouponDisplayInfo displayInfo; 263 264 @SerializedName("out_product_no") 265 public String outProductNo; 266 267 @SerializedName("state") 268 public ProductCouponState state; 269 270 @SerializedName("stock_bundle") 271 public StockBundleEntity stockBundle; 272 273 @SerializedName("brand_id") 274 public String brandId; 275 } 276 277 // ==================== 枚举类型定义 ==================== 278 279 public enum ProductCouponScope { 280 @SerializedName("ALL") ALL, 281 @SerializedName("SINGLE") SINGLE 282 } 283 284 public enum ProductCouponType { 285 @SerializedName("NORMAL") NORMAL, 286 @SerializedName("DISCOUNT") DISCOUNT, 287 @SerializedName("EXCHANGE") EXCHANGE 288 } 289 290 public enum UsageMode { 291 @SerializedName("SINGLE") SINGLE, 292 @SerializedName("PROGRESSIVE_BUNDLE") PROGRESSIVE_BUNDLE 293 } 294 295 public enum ProductCouponState { 296 @SerializedName("AUDITING") AUDITING, 297 @SerializedName("EFFECTIVE") EFFECTIVE, 298 @SerializedName("DEACTIVATED") DEACTIVATED 299 } 300 301 public enum CouponCodeMode { 302 @SerializedName("WECHATPAY") WECHATPAY, 303 @SerializedName("UPLOAD") UPLOAD, 304 @SerializedName("API_ASSIGN") API_ASSIGN 305 } 306 307 public enum StockStoreScope { 308 @SerializedName("NONE") NONE, 309 @SerializedName("ALL") ALL, 310 @SerializedName("SPECIFIC") SPECIFIC 311 } 312 313 public enum CouponUsageMethod { 314 @SerializedName("OFFLINE") OFFLINE, 315 @SerializedName("MINI_PROGRAM") MINI_PROGRAM, 316 @SerializedName("APP") APP, 317 @SerializedName("PAYMENT_CODE") PAYMENT_CODE 318 } 319 320 public enum CouponCodeDisplayMode { 321 @SerializedName("INVISIBLE") INVISIBLE, 322 @SerializedName("BARCODE") BARCODE, 323 @SerializedName("QRCODE") QRCODE 324 } 325 326 public enum WeekEnum { 327 @SerializedName("MONDAY") MONDAY, 328 @SerializedName("TUESDAY") TUESDAY, 329 @SerializedName("WEDNESDAY") WEDNESDAY, 330 @SerializedName("THURSDAY") THURSDAY, 331 @SerializedName("FRIDAY") FRIDAY, 332 @SerializedName("SATURDAY") SATURDAY, 333 @SerializedName("SUNDAY") SUNDAY 334 } 335 336 // ==================== 模型类定义 ==================== 337 338 public static class ProgressiveBundleUsageInfo { 339 @SerializedName("count") 340 public Long count; 341 342 @SerializedName("interval_days") 343 public Long intervalDays; 344 } 345 346 public static class ProductCouponDisplayInfo { 347 @SerializedName("name") 348 public String name; 349 350 @SerializedName("image_url") 351 public String imageUrl; 352 353 @SerializedName("background_url") 354 public String backgroundUrl; 355 356 @SerializedName("detail_image_url_list") 357 public List<String> detailImageUrlList; 358 359 @SerializedName("original_price") 360 public Long originalPrice; 361 362 @SerializedName("combo_package_list") 363 public List<ComboPackage> comboPackageList; 364 } 365 366 public static class ComboPackage { 367 @SerializedName("name") 368 public String name; 369 370 @SerializedName("pick_count") 371 public Long pickCount; 372 373 @SerializedName("choice_list") 374 public List<ComboPackageChoice> choiceList; 375 } 376 377 public static class ComboPackageChoice { 378 @SerializedName("name") 379 public String name; 380 381 @SerializedName("price") 382 public Long price; 383 384 @SerializedName("count") 385 public Long count; 386 387 @SerializedName("image_url") 388 public String imageUrl; 389 390 @SerializedName("mini_program_appid") 391 public String miniProgramAppid; 392 393 @SerializedName("mini_program_path") 394 public String miniProgramPath; 395 } 396 397 public static class StockForProgressiveBundle { 398 @SerializedName("remark") 399 public String remark; 400 401 @SerializedName("coupon_code_mode") 402 public CouponCodeMode couponCodeMode; 403 404 @SerializedName("stock_send_rule") 405 public StockSendRule stockSendRule; 406 407 @SerializedName("progressive_bundle_usage_rule") 408 public ProgressiveBundleUsageRule progressiveBundleUsageRule; 409 410 @SerializedName("usage_rule_display_info") 411 public UsageRuleDisplayInfo usageRuleDisplayInfo; 412 413 @SerializedName("coupon_display_info") 414 public CouponDisplayInfo couponDisplayInfo; 415 416 @SerializedName("notify_config") 417 public NotifyConfig notifyConfig; 418 419 @SerializedName("store_scope") 420 public StockStoreScope storeScope; 421 } 422 423 public static class StockSendRule { 424 @SerializedName("max_count") 425 public Long maxCount; 426 427 @SerializedName("max_count_per_day") 428 public Long maxCountPerDay; 429 430 @SerializedName("max_count_per_user") 431 public Long maxCountPerUser; 432 } 433 434 public static class ProgressiveBundleUsageRule { 435 @SerializedName("coupon_available_period") 436 public CouponAvailablePeriod couponAvailablePeriod; 437 438 @SerializedName("normal_coupon") 439 public NormalCouponUsageRule normalCoupon; 440 441 @SerializedName("discount_coupon") 442 public DiscountCouponUsageRule discountCoupon; 443 444 @SerializedName("exchange_coupon") 445 public ExchangeCouponUsageRule exchangeCoupon; 446 } 447 448 public static class CouponAvailablePeriod { 449 @SerializedName("available_begin_time") 450 public String availableBeginTime; 451 452 @SerializedName("available_end_time") 453 public String availableEndTime; 454 455 @SerializedName("available_days") 456 public Long availableDays; 457 458 @SerializedName("wait_days_after_receive") 459 public Long waitDaysAfterReceive; 460 461 @SerializedName("weekly_available_period") 462 public FixedWeekPeriod weeklyAvailablePeriod; 463 } 464 465 public static class FixedWeekPeriod { 466 @SerializedName("day_list") 467 public List<WeekEnum> dayList; 468 } 469 470 public static class NormalCouponUsageRule { 471 @SerializedName("threshold") 472 public Long threshold; 473 474 @SerializedName("discount_amount") 475 public Long discountAmount; 476 } 477 478 public static class DiscountCouponUsageRule { 479 @SerializedName("threshold") 480 public Long threshold; 481 482 @SerializedName("percent_off") 483 public Long percentOff; 484 } 485 486 public static class ExchangeCouponUsageRule { 487 @SerializedName("threshold") 488 public Long threshold; 489 490 @SerializedName("exchange_price") 491 public Long exchangePrice; 492 } 493 494 public static class UsageRuleDisplayInfo { 495 @SerializedName("coupon_usage_method_list") 496 public List<CouponUsageMethod> couponUsageMethodList; 497 498 @SerializedName("mini_program_appid") 499 public String miniProgramAppid; 500 501 @SerializedName("mini_program_path") 502 public String miniProgramPath; 503 504 @SerializedName("app_path") 505 public String appPath; 506 507 @SerializedName("usage_description") 508 public String usageDescription; 509 510 @SerializedName("coupon_available_store_info") 511 public CouponAvailableStoreInfo couponAvailableStoreInfo; 512 } 513 514 public static class CouponAvailableStoreInfo { 515 @SerializedName("description") 516 public String description; 517 518 @SerializedName("mini_program_appid") 519 public String miniProgramAppid; 520 521 @SerializedName("mini_program_path") 522 public String miniProgramPath; 523 } 524 525 public static class CouponDisplayInfo { 526 @SerializedName("code_display_mode") 527 public CouponCodeDisplayMode codeDisplayMode; 528 529 @SerializedName("background_color") 530 public String backgroundColor; 531 532 @SerializedName("entrance_mini_program") 533 public EntranceMiniProgram entranceMiniProgram; 534 535 @SerializedName("entrance_official_account") 536 public EntranceOfficialAccount entranceOfficialAccount; 537 538 @SerializedName("entrance_finder") 539 public EntranceFinder entranceFinder; 540 } 541 542 public static class EntranceMiniProgram { 543 @SerializedName("appid") 544 public String appid; 545 546 @SerializedName("path") 547 public String path; 548 549 @SerializedName("entrance_wording") 550 public String entranceWording; 551 552 @SerializedName("guidance_wording") 553 public String guidanceWording; 554 } 555 556 public static class EntranceOfficialAccount { 557 @SerializedName("appid") 558 public String appid; 559 } 560 561 public static class EntranceFinder { 562 @SerializedName("finder_id") 563 public String finderId; 564 565 @SerializedName("finder_video_id") 566 public String finderVideoId; 567 568 @SerializedName("finder_video_cover_image_url") 569 public String finderVideoCoverImageUrl; 570 } 571 572 public static class NotifyConfig { 573 @SerializedName("notify_appid") 574 public String notifyAppid; 575 } 576 577 public static class StockBundleEntity { 578 @SerializedName("stock_bundle_id") 579 public String stockBundleId; 580 581 @SerializedName("stock_list") 582 public List<StockEntityInBundle> stockList; 583 } 584 585 public static class StockEntityInBundle { 586 @SerializedName("product_coupon_id") 587 public String productCouponId; 588 589 @SerializedName("stock_id") 590 public String stockId; 591 592 @SerializedName("remark") 593 public String remark; 594 } 595} 596 597
需配合微信支付工具库 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) 11 12// 创建商品券 - 场景4:多次优惠-单品-满减券 13// 14// 场景说明:单品券(适用于指定商品)+ 满减券(满足门槛后减固定金额)+ 阶梯模式(可多次使用) 15// 16// 关键参数: 17// - scope = SINGLE(单品券) 18// - type = NORMAL(满减券) 19// - usage_mode = PROGRESSIVE_BUNDLE(阶梯模式) 20 21func main() { 22 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/partner/4013080340 23 config, err := wxpay_utility.CreateMchConfig( 24 "19xxxxxxxx", // 商户号 25 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号 26 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径 27 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID 28 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径 29 ) 30 if err != nil { 31 fmt.Println(err) 32 return 33 } 34 35 request := &CreateProductCouponRequest{ 36 OutRequestNo: wxpay_utility.String("MANY_SINGLE_NORMAL_20250101_004"), // 必填,创建请求单号,6-40个字符,品牌侧需保持唯一性 37 BrandId: wxpay_utility.String("120344"), // 必填,品牌ID,由微信支付分配 38 OutProductNo: wxpay_utility.String("Product_1234567890"), // 选填,商户侧商品券唯一标识 39 Scope: PRODUCTCOUPONSCOPE_SINGLE.Ptr(), // 必填,优惠范围:ALL-全场券, SINGLE-单品券(支持NORMAL/DISCOUNT/EXCHANGE) 40 Type: PRODUCTCOUPONTYPE_NORMAL.Ptr(), // 必填,商品券类型:NORMAL-满减券, DISCOUNT-折扣券, EXCHANGE-兑换券(仅单品券) 41 UsageMode: USAGEMODE_PROGRESSIVE_BUNDLE.Ptr(), // 必填,使用模式:SINGLE-单券, PROGRESSIVE_BUNDLE-多次优惠 42 // 条件必填,多次优惠模式配置信息(当usage_mode=PROGRESSIVE_BUNDLE时必填) 43 ProgressiveBundleUsageInfo: &ProgressiveBundleUsageInfo{ 44 Count: wxpay_utility.Int64(3), // 必填,可使用次数,最少3次,最多15次 45 IntervalDays: wxpay_utility.Int64(2), // 选填,多次优惠使用间隔天数(2表示使用后需等到第三天00:00:00才能使用下一次),最高7天,默认0 46 }, 47 // 必填,商品券展示信息 48 DisplayInfo: &ProductCouponDisplayInfo{ 49 Name: wxpay_utility.String("指定商品立减15(可用3次)"), // 必填,商品券名称,最多12个字符 50 ImageUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), // 必填,商品券图片URL 51 BackgroundUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), // 选填,背景图URL 52 DetailImageUrlList: []string{ // 选填,详情图URL列表,最多6张 53 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx", 54 }, 55 OriginalPrice: wxpay_utility.Int64(9900), // 条件必填(单品券),商品原价(单位:分),与combo_package_list二选一 56 // 条件必填(单品券),套餐组合列表,与original_price二选一 57 ComboPackageList: []ComboPackage{ 58 { 59 Name: wxpay_utility.String("套餐A"), // 必填,套餐名称 60 PickCount: wxpay_utility.Int64(2), // 必填,可选商品数量 61 ChoiceList: []ComboPackageChoice{ // 必填,可选商品列表 62 { 63 Name: wxpay_utility.String("鸡腿饭"), // 必填,商品名称 64 Price: wxpay_utility.Int64(2000), // 必填,商品价格(单位:分) 65 Count: wxpay_utility.Int64(1), // 必填,商品数量 66 ImageUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/chicken"), // 必填,商品图片URL 67 }, 68 { 69 Name: wxpay_utility.String("牛肉饭"), // 必填,商品名称 70 Price: wxpay_utility.Int64(2500), // 必填,商品价格(单位:分) 71 Count: wxpay_utility.Int64(1), // 必填,商品数量 72 ImageUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/beef"), // 必填,商品图片URL 73 }, 74 }, 75 }, 76 }, 77 }, 78 // 条件必填,批次信息(当usage_mode=PROGRESSIVE_BUNDLE时必填) 79 Stock: createNormalStockPtr("指定商品立减15批次", 0, 1500), 80 } 81 82 response, err := CreateProductCoupon(config, request) 83 if err != nil { 84 fmt.Printf("请求失败: %+v\n", err) 85 return 86 } 87 fmt.Printf("请求成功: %+v\n", response) 88} 89 90// createNormalStockPtr 创建满减券批次(返回指针) 91func createNormalStockPtr(remark string, threshold, discountAmount int64) *StockForProgressiveBundle { 92 stock := createNormalStock(remark, threshold, discountAmount) 93 return &stock 94} 95 96// createNormalStock 创建满减券批次 97func createNormalStock(remark string, threshold, discountAmount int64) StockForProgressiveBundle { 98 return StockForProgressiveBundle{ 99 Remark: wxpay_utility.String(remark), 100 CouponCodeMode: COUPONCODEMODE_WECHATPAY.Ptr(), 101 StockSendRule: &StockSendRule{ 102 MaxCount: wxpay_utility.Int64(10000000), 103 MaxCountPerUser: wxpay_utility.Int64(1), 104 }, 105 ProgressiveBundleUsageRule: &ProgressiveBundleUsageRule{ 106 CouponAvailablePeriod: &CouponAvailablePeriod{ 107 AvailableBeginTime: wxpay_utility.String("2025-08-01T00:00:00+08:00"), 108 AvailableEndTime: wxpay_utility.String("2025-08-31T23:59:59+08:00"), 109 AvailableDays: wxpay_utility.Int64(30), 110 WeeklyAvailablePeriod: &FixedWeekPeriod{ 111 DayList: []WeekEnum{ 112 WEEKENUM_MONDAY, 113 WEEKENUM_TUESDAY, 114 WEEKENUM_WEDNESDAY, 115 WEEKENUM_THURSDAY, 116 WEEKENUM_FRIDAY, 117 }, 118 }, 119 }, 120 NormalCoupon: &NormalCouponUsageRule{ 121 Threshold: wxpay_utility.Int64(threshold), 122 DiscountAmount: wxpay_utility.Int64(discountAmount), 123 }, 124 }, 125 UsageRuleDisplayInfo: &UsageRuleDisplayInfo{ 126 CouponUsageMethodList: []CouponUsageMethod{ 127 COUPONUSAGEMETHOD_OFFLINE, 128 COUPONUSAGEMETHOD_MINI_PROGRAM, 129 COUPONUSAGEMETHOD_PAYMENT_CODE, 130 }, 131 MiniProgramAppid: wxpay_utility.String("wx1234567890"), 132 MiniProgramPath: wxpay_utility.String("/pages/index/product"), 133 UsageDescription: wxpay_utility.String("指定商品可用,立减15元"), 134 CouponAvailableStoreInfo: &CouponAvailableStoreInfo{ 135 Description: wxpay_utility.String("所有门店可用,可使用小程序查看门店列表"), 136 MiniProgramAppid: wxpay_utility.String("wx1234567890"), 137 MiniProgramPath: wxpay_utility.String("/pages/index/store-list"), 138 }, 139 }, 140 CouponDisplayInfo: &CouponDisplayInfo{ 141 CodeDisplayMode: COUPONCODEDISPLAYMODE_QRCODE.Ptr(), 142 BackgroundColor: wxpay_utility.String("Color010"), 143 EntranceMiniProgram: &EntranceMiniProgram{ 144 Appid: wxpay_utility.String("wx1234567890"), 145 Path: wxpay_utility.String("/pages/index/product"), 146 EntranceWording: wxpay_utility.String("欢迎选购"), 147 GuidanceWording: wxpay_utility.String("获取更多优惠"), 148 }, 149 EntranceOfficialAccount: &EntranceOfficialAccount{ 150 Appid: wxpay_utility.String("wx1234567890"), 151 }, 152 EntranceFinder: &EntranceFinder{ 153 FinderId: wxpay_utility.String("gh_12345678"), 154 FinderVideoId: wxpay_utility.String("UDFsdf24df34dD456Hdf34"), 155 FinderVideoCoverImageUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"), 156 }, 157 }, 158 StoreScope: STOCKSTORESCOPE_NONE.Ptr(), 159 NotifyConfig: &NotifyConfig{ 160 NotifyAppid: wxpay_utility.String("wx4fd12345678"), 161 }, 162 } 163} 164 165func CreateProductCoupon(config *wxpay_utility.MchConfig, request *CreateProductCouponRequest) (response *CreateProductCouponResponse, err error) { 166 const ( 167 host = "https://api.mch.weixin.qq.com" 168 method = "POST" 169 path = "/v3/marketing/partner/product-coupon/product-coupons" 170 ) 171 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 172 if err != nil { 173 return nil, err 174 } 175 reqBody, err := json.Marshal(request) 176 if err != nil { 177 return nil, err 178 } 179 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody)) 180 if err != nil { 181 return nil, err 182 } 183 httpRequest.Header.Set("Accept", "application/json") 184 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 185 httpRequest.Header.Set("Content-Type", "application/json") 186 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody) 187 if err != nil { 188 return nil, err 189 } 190 httpRequest.Header.Set("Authorization", authorization) 191 client := &http.Client{} 192 httpResponse, err := client.Do(httpRequest) 193 if err != nil { 194 return nil, err 195 } 196 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 197 if err != nil { 198 return nil, err 199 } 200 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 201 err = wxpay_utility.ValidateResponse( 202 config.WechatPayPublicKeyId(), 203 config.WechatPayPublicKey(), 204 &httpResponse.Header, 205 respBody, 206 ) 207 if err != nil { 208 return nil, err 209 } 210 response := &CreateProductCouponResponse{} 211 if err := json.Unmarshal(respBody, response); err != nil { 212 return nil, err 213 } 214 return response, nil 215 } else { 216 return nil, wxpay_utility.NewApiException( 217 httpResponse.StatusCode, 218 httpResponse.Header, 219 respBody, 220 ) 221 } 222} 223 224// ==================== 请求/响应结构体定义 ==================== 225 226type CreateProductCouponRequest struct { 227 OutRequestNo *string `json:"out_request_no,omitempty"` 228 BrandId *string `json:"brand_id,omitempty"` 229 OutProductNo *string `json:"out_product_no,omitempty"` 230 Scope *ProductCouponScope `json:"scope,omitempty"` 231 Type *ProductCouponType `json:"type,omitempty"` 232 UsageMode *UsageMode `json:"usage_mode,omitempty"` 233 ProgressiveBundleUsageInfo *ProgressiveBundleUsageInfo `json:"progressive_bundle_usage_info,omitempty"` 234 DisplayInfo *ProductCouponDisplayInfo `json:"display_info,omitempty"` 235 StockBundle *StockForProgressiveBundle `json:"stock_bundle,omitempty"` 236} 237 238type CreateProductCouponResponse struct { 239 ProductCouponId *string `json:"product_coupon_id,omitempty"` 240 Scope *ProductCouponScope `json:"scope,omitempty"` 241 Type *ProductCouponType `json:"type,omitempty"` 242 UsageMode *UsageMode `json:"usage_mode,omitempty"` 243 ProgressiveBundleUsageInfo *ProgressiveBundleUsageInfo `json:"progressive_bundle_usage_info,omitempty"` 244 DisplayInfo *ProductCouponDisplayInfo `json:"display_info,omitempty"` 245 OutProductNo *string `json:"out_product_no,omitempty"` 246 State *ProductCouponState `json:"state,omitempty"` 247 StockBundle *StockBundleEntity `json:"stock_bundle,omitempty"` 248 BrandId *string `json:"brand_id,omitempty"` 249} 250 251// ==================== 枚举类型定义 ==================== 252 253type ProductCouponScope string 254 255func (e ProductCouponScope) Ptr() *ProductCouponScope { return &e } 256 257const ( 258 PRODUCTCOUPONSCOPE_ALL ProductCouponScope = "ALL" 259 PRODUCTCOUPONSCOPE_SINGLE ProductCouponScope = "SINGLE" 260) 261 262type ProductCouponType string 263 264func (e ProductCouponType) Ptr() *ProductCouponType { return &e } 265 266const ( 267 PRODUCTCOUPONTYPE_NORMAL ProductCouponType = "NORMAL" 268 PRODUCTCOUPONTYPE_DISCOUNT ProductCouponType = "DISCOUNT" 269 PRODUCTCOUPONTYPE_EXCHANGE ProductCouponType = "EXCHANGE" 270) 271 272type UsageMode string 273 274func (e UsageMode) Ptr() *UsageMode { return &e } 275 276const ( 277 USAGEMODE_SINGLE UsageMode = "SINGLE" 278 USAGEMODE_PROGRESSIVE_BUNDLE UsageMode = "PROGRESSIVE_BUNDLE" 279) 280 281type ProductCouponState string 282 283func (e ProductCouponState) Ptr() *ProductCouponState { return &e } 284 285const ( 286 PRODUCTCOUPONSTATE_AUDITING ProductCouponState = "AUDITING" 287 PRODUCTCOUPONSTATE_EFFECTIVE ProductCouponState = "EFFECTIVE" 288 PRODUCTCOUPONSTATE_DEACTIVATED ProductCouponState = "DEACTIVATED" 289) 290 291type CouponCodeMode string 292 293func (e CouponCodeMode) Ptr() *CouponCodeMode { return &e } 294 295const ( 296 COUPONCODEMODE_WECHATPAY CouponCodeMode = "WECHATPAY" 297 COUPONCODEMODE_UPLOAD CouponCodeMode = "UPLOAD" 298 COUPONCODEMODE_API_ASSIGN CouponCodeMode = "API_ASSIGN" 299) 300 301type StockStoreScope string 302 303func (e StockStoreScope) Ptr() *StockStoreScope { return &e } 304 305const ( 306 STOCKSTORESCOPE_NONE StockStoreScope = "NONE" 307 STOCKSTORESCOPE_ALL StockStoreScope = "ALL" 308 STOCKSTORESCOPE_SPECIFIC StockStoreScope = "SPECIFIC" 309) 310 311type CouponUsageMethod string 312 313func (e CouponUsageMethod) Ptr() *CouponUsageMethod { return &e } 314 315const ( 316 COUPONUSAGEMETHOD_OFFLINE CouponUsageMethod = "OFFLINE" 317 COUPONUSAGEMETHOD_MINI_PROGRAM CouponUsageMethod = "MINI_PROGRAM" 318 COUPONUSAGEMETHOD_APP CouponUsageMethod = "APP" 319 COUPONUSAGEMETHOD_PAYMENT_CODE CouponUsageMethod = "PAYMENT_CODE" 320) 321 322type CouponCodeDisplayMode string 323 324func (e CouponCodeDisplayMode) Ptr() *CouponCodeDisplayMode { return &e } 325 326const ( 327 COUPONCODEDISPLAYMODE_INVISIBLE CouponCodeDisplayMode = "INVISIBLE" 328 COUPONCODEDISPLAYMODE_BARCODE CouponCodeDisplayMode = "BARCODE" 329 COUPONCODEDISPLAYMODE_QRCODE CouponCodeDisplayMode = "QRCODE" 330) 331 332type WeekEnum string 333 334func (e WeekEnum) Ptr() *WeekEnum { return &e } 335 336const ( 337 WEEKENUM_MONDAY WeekEnum = "MONDAY" 338 WEEKENUM_TUESDAY WeekEnum = "TUESDAY" 339 WEEKENUM_WEDNESDAY WeekEnum = "WEDNESDAY" 340 WEEKENUM_THURSDAY WeekEnum = "THURSDAY" 341 WEEKENUM_FRIDAY WeekEnum = "FRIDAY" 342 WEEKENUM_SATURDAY WeekEnum = "SATURDAY" 343 WEEKENUM_SUNDAY WeekEnum = "SUNDAY" 344) 345 346// ==================== 模型结构体定义 ==================== 347 348type ProgressiveBundleUsageInfo struct { 349 Count *int64 `json:"count,omitempty"` 350 IntervalDays *int64 `json:"interval_days,omitempty"` 351} 352 353type ProductCouponDisplayInfo struct { 354 Name *string `json:"name,omitempty"` 355 ImageUrl *string `json:"image_url,omitempty"` 356 BackgroundUrl *string `json:"background_url,omitempty"` 357 DetailImageUrlList []string `json:"detail_image_url_list,omitempty"` 358 OriginalPrice *int64 `json:"original_price,omitempty"` 359 ComboPackageList []ComboPackage `json:"combo_package_list,omitempty"` 360} 361 362type ComboPackage struct { 363 Name *string `json:"name,omitempty"` 364 PickCount *int64 `json:"pick_count,omitempty"` 365 ChoiceList []ComboPackageChoice `json:"choice_list,omitempty"` 366} 367 368type ComboPackageChoice struct { 369 Name *string `json:"name,omitempty"` 370 Price *int64 `json:"price,omitempty"` 371 Count *int64 `json:"count,omitempty"` 372 ImageUrl *string `json:"image_url,omitempty"` 373 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 374 MiniProgramPath *string `json:"mini_program_path,omitempty"` 375} 376 377type StockForProgressiveBundle struct { 378 Remark *string `json:"remark,omitempty"` 379 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"` 380 StockSendRule *StockSendRule `json:"stock_send_rule,omitempty"` 381 ProgressiveBundleUsageRule *ProgressiveBundleUsageRule `json:"progressive_bundle_usage_rule,omitempty"` 382 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"` 383 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"` 384 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"` 385 StoreScope *StockStoreScope `json:"store_scope,omitempty"` 386} 387 388type StockSendRule struct { 389 MaxCount *int64 `json:"max_count,omitempty"` 390 MaxCountPerDay *int64 `json:"max_count_per_day,omitempty"` 391 MaxCountPerUser *int64 `json:"max_count_per_user,omitempty"` 392} 393 394type ProgressiveBundleUsageRule struct { 395 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"` 396 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"` 397 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"` 398 ExchangeCoupon *ExchangeCouponUsageRule `json:"exchange_coupon,omitempty"` 399} 400 401type CouponAvailablePeriod struct { 402 AvailableBeginTime *string `json:"available_begin_time,omitempty"` 403 AvailableEndTime *string `json:"available_end_time,omitempty"` 404 AvailableDays *int64 `json:"available_days,omitempty"` 405 WaitDaysAfterReceive *int64 `json:"wait_days_after_receive,omitempty"` 406 WeeklyAvailablePeriod *FixedWeekPeriod `json:"weekly_available_period,omitempty"` 407} 408 409type FixedWeekPeriod struct { 410 DayList []WeekEnum `json:"day_list,omitempty"` 411} 412 413type NormalCouponUsageRule struct { 414 Threshold *int64 `json:"threshold,omitempty"` 415 DiscountAmount *int64 `json:"discount_amount,omitempty"` 416} 417 418type DiscountCouponUsageRule struct { 419 Threshold *int64 `json:"threshold,omitempty"` 420 PercentOff *int64 `json:"percent_off,omitempty"` 421} 422 423type ExchangeCouponUsageRule struct { 424 Threshold *int64 `json:"threshold,omitempty"` 425 ExchangePrice *int64 `json:"exchange_price,omitempty"` 426} 427 428type UsageRuleDisplayInfo struct { 429 CouponUsageMethodList []CouponUsageMethod `json:"coupon_usage_method_list,omitempty"` 430 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 431 MiniProgramPath *string `json:"mini_program_path,omitempty"` 432 AppPath *string `json:"app_path,omitempty"` 433 UsageDescription *string `json:"usage_description,omitempty"` 434 CouponAvailableStoreInfo *CouponAvailableStoreInfo `json:"coupon_available_store_info,omitempty"` 435} 436 437type CouponAvailableStoreInfo struct { 438 Description *string `json:"description,omitempty"` 439 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` 440 MiniProgramPath *string `json:"mini_program_path,omitempty"` 441} 442 443type CouponDisplayInfo struct { 444 CodeDisplayMode *CouponCodeDisplayMode `json:"code_display_mode,omitempty"` 445 BackgroundColor *string `json:"background_color,omitempty"` 446 EntranceMiniProgram *EntranceMiniProgram `json:"entrance_mini_program,omitempty"` 447 EntranceOfficialAccount *EntranceOfficialAccount `json:"entrance_official_account,omitempty"` 448 EntranceFinder *EntranceFinder `json:"entrance_finder,omitempty"` 449} 450 451type EntranceMiniProgram struct { 452 Appid *string `json:"appid,omitempty"` 453 Path *string `json:"path,omitempty"` 454 EntranceWording *string `json:"entrance_wording,omitempty"` 455 GuidanceWording *string `json:"guidance_wording,omitempty"` 456} 457 458type EntranceOfficialAccount struct { 459 Appid *string `json:"appid,omitempty"` 460} 461 462type EntranceFinder struct { 463 FinderId *string `json:"finder_id,omitempty"` 464 FinderVideoId *string `json:"finder_video_id,omitempty"` 465 FinderVideoCoverImageUrl *string `json:"finder_video_cover_image_url,omitempty"` 466} 467 468type NotifyConfig struct { 469 NotifyAppid *string `json:"notify_appid,omitempty"` 470} 471 472type StockBundleEntity struct { 473 StockBundleId *string `json:"stock_bundle_id,omitempty"` 474 StockList []StockEntityInBundle `json:"stock_list,omitempty"` 475} 476 477type StockEntityInBundle struct { 478 ProductCouponId *string `json:"product_coupon_id,omitempty"` 479 StockId *string `json:"stock_id,omitempty"` 480 Remark *string `json:"remark,omitempty"` 481} 482 483
文档是否有帮助

