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

