
1package main
2
3import (
4 "bytes"
5 "demo/wxpay_utility"
6 "encoding/json"
7 "fmt"
8 "net/http"
9 "net/url"
10 "time"
11)
12
13func main() {
14
15 config, err := wxpay_utility.CreateMchConfig(
16 "19xxxxxxxx",
17 "1DDE55AD98Exxxxxxxxxx",
18 "/path/to/apiclient_key.pem",
19 "PUB_KEY_ID_xxxxxxxxxxxxx",
20 "/path/to/wxp_pub.pem",
21 )
22 if err != nil {
23 fmt.Println(err)
24 return
25 }
26
27 request := &CreateProductCouponRequest{
28 OutRequestNo: wxpay_utility.String("12345_20250101_A3489"),
29 Scope: PRODUCTCOUPONSCOPE_ALL.Ptr(),
30 Type: PRODUCTCOUPONTYPE_DISCOUNT.Ptr(),
31 UsageMode: USAGEMODE_PROGRESSIVE_BUNDLE.Ptr(),
32
33 ProgressiveBundleUsageInfo: &ProgressiveBundleUsageInfo{
34 Count: wxpay_utility.Int64(3),
35 IntervalDays: wxpay_utility.Int64(1),
36 },
37
38 DisplayInfo: &ProductCouponDisplayInfo{
39 Name: wxpay_utility.String("全场多次折扣券"),
40 ImageUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"),
41 BackgroundUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"),
42 DetailImageUrlList: []string{
43 "https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx",
44 },
45 },
46 OutProductNo: wxpay_utility.String("Product_1234567890"),
47
48 StockBundle: &StockBundleForCreate{
49 Remark: wxpay_utility.String("8月工作日有效批次"),
50 CouponCodeMode: COUPONCODEMODE_UPLOAD.Ptr(),
51 StockSendRule: &StockSendRuleForBundle{
52 MaxCount: wxpay_utility.Int64(10000000),
53 MaxCountPerUser: wxpay_utility.Int64(1),
54 },
55
56 ProgressiveBundleUsageRule: &StockBundleUsageRule{
57 CouponAvailablePeriod: &CouponAvailablePeriod{
58 AvailableBeginTime: wxpay_utility.String("2025-08-01T00:00:00+08:00"),
59 AvailableEndTime: wxpay_utility.String("2025-08-31T23:59:59+08:00"),
60 AvailableDays: wxpay_utility.Int64(30),
61 WeeklyAvailablePeriod: &FixedWeekPeriod{
62 DayList: []WeekEnum{
63 WEEKENUM_MONDAY,
64 WEEKENUM_TUESDAY,
65 WEEKENUM_WEDNESDAY,
66 WEEKENUM_THURSDAY,
67 WEEKENUM_FRIDAY,
68 },
69 },
70 },
71
72 DiscountCouponList: []DiscountCouponUsageRule{
73 {
74 Threshold: wxpay_utility.Int64(10000),
75 PercentOff: wxpay_utility.Int64(50),
76 },
77 {
78 Threshold: wxpay_utility.Int64(10000),
79 PercentOff: wxpay_utility.Int64(20),
80 },
81 {
82 Threshold: wxpay_utility.Int64(10000),
83 PercentOff: wxpay_utility.Int64(30),
84 },
85 },
86 },
87
88 UsageRuleDisplayInfo: &UsageRuleDisplayInfo{
89 CouponUsageMethodList: []CouponUsageMethod{
90 COUPONUSAGEMETHOD_OFFLINE,
91 COUPONUSAGEMETHOD_MINI_PROGRAM,
92 COUPONUSAGEMETHOD_PAYMENT_CODE,
93 },
94 MiniProgramAppid: wxpay_utility.String("wx1234567890"),
95 MiniProgramPath: wxpay_utility.String("/pages/index/product"),
96 UsageDescription: wxpay_utility.String("工作日可用"),
97 CouponAvailableStoreInfo: &CouponAvailableStoreInfo{
98 Description: wxpay_utility.String("所有门店可用,可使用小程序查看门店列表"),
99 MiniProgramAppid: wxpay_utility.String("wx1234567890"),
100 MiniProgramPath: wxpay_utility.String("/pages/index/store-list"),
101 },
102 },
103
104 CouponDisplayInfo: &CouponDisplayInfo{
105 CodeDisplayMode: COUPONCODEDISPLAYMODE_QRCODE.Ptr(),
106 BackgroundColor: wxpay_utility.String("Color010"),
107 EntranceMiniProgram: &EntranceMiniProgram{
108 Appid: wxpay_utility.String("wx1234567890"),
109 Path: wxpay_utility.String("/pages/index/product"),
110 EntranceWording: wxpay_utility.String("欢迎选购"),
111 GuidanceWording: wxpay_utility.String("获取更多优惠"),
112 },
113 EntranceOfficialAccount: &EntranceOfficialAccount{
114 Appid: wxpay_utility.String("wx1234567890"),
115 },
116 EntranceFinder: &EntranceFinder{
117 FinderId: wxpay_utility.String("gh_12345678"),
118 FinderVideoId: wxpay_utility.String("UDFsdf24df34dD456Hdf34"),
119 FinderVideoCoverImageUrl: wxpay_utility.String("https://wxpaylogo.qpic.cn/wxpaylogo/xxxxx/xxx"),
120 },
121 },
122 StoreScope: STOCKSTORESCOPE_NONE.Ptr(),
123 NotifyConfig: &NotifyConfig{
124 NotifyAppid: wxpay_utility.String("wx4fd12345678"),
125 },
126 },
127 BrandId: wxpay_utility.String("120344"),
128 }
129
130 response, err := CreateProductCoupon(config, request)
131 if err != nil {
132 fmt.Printf("请求失败: %+v\n", err)
133
134 return
135 }
136
137
138 fmt.Printf("请求成功: %+v\n", response)
139}
140
141func CreateProductCoupon(config *wxpay_utility.MchConfig, request *CreateProductCouponRequest) (response *CreateProductCouponResponse, err error) {
142 const (
143 host = "https://api.mch.weixin.qq.com"
144 method = "POST"
145 path = "/v3/marketing/partner/product-coupon/product-coupons"
146 )
147
148 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path))
149 if err != nil {
150 return nil, err
151 }
152 reqBody, err := json.Marshal(request)
153 if err != nil {
154 return nil, err
155 }
156 httpRequest, err := http.NewRequest(method, reqUrl.String(), bytes.NewReader(reqBody))
157 if err != nil {
158 return nil, err
159 }
160 httpRequest.Header.Set("Accept", "application/json")
161 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId())
162 httpRequest.Header.Set("Content-Type", "application/json")
163 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), reqBody)
164 if err != nil {
165 return nil, err
166 }
167 httpRequest.Header.Set("Authorization", authorization)
168
169 client := &http.Client{}
170 httpResponse, err := client.Do(httpRequest)
171 if err != nil {
172 return nil, err
173 }
174 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse)
175 if err != nil {
176 return nil, err
177 }
178 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 {
179
180 err = wxpay_utility.ValidateResponse(
181 config.WechatPayPublicKeyId(),
182 config.WechatPayPublicKey(),
183 &httpResponse.Header,
184 respBody,
185 )
186 if err != nil {
187 return nil, err
188 }
189 response := &CreateProductCouponResponse{}
190 if err := json.Unmarshal(respBody, response); err != nil {
191 return nil, err
192 }
193
194 return response, nil
195 } else {
196 return nil, wxpay_utility.NewApiException(
197 httpResponse.StatusCode,
198 httpResponse.Header,
199 respBody,
200 )
201 }
202}
203
204type CreateProductCouponRequest struct {
205 OutRequestNo *string `json:"out_request_no,omitempty"`
206 Scope *ProductCouponScope `json:"scope,omitempty"`
207 Type *ProductCouponType `json:"type,omitempty"`
208 UsageMode *UsageMode `json:"usage_mode,omitempty"`
209 SingleUsageInfo *SingleUsageInfo `json:"single_usage_info,omitempty"`
210 ProgressiveBundleUsageInfo *ProgressiveBundleUsageInfo `json:"progressive_bundle_usage_info,omitempty"`
211 DisplayInfo *ProductCouponDisplayInfoForCreate `json:"display_info,omitempty"`
212 OutProductNo *string `json:"out_product_no,omitempty"`
213 Stock *StockForCreate `json:"stock,omitempty"`
214 StockBundle *StockBundleForCreate `json:"stock_bundle,omitempty"`
215 BrandId *string `json:"brand_id,omitempty"`
216 ShowAsExchange *bool `json:"show_as_exchange,omitempty"`
217 AvailableProductNoList []string `json:"available_product_no_list,omitempty"`
218 BusinessMode *ProductCouponBusinessMode `json:"business_mode,omitempty"`
219}
220
221type CreateProductCouponResponse struct {
222 ProductCouponId *string `json:"product_coupon_id,omitempty"`
223 Scope *ProductCouponScope `json:"scope,omitempty"`
224 Type *ProductCouponType `json:"type,omitempty"`
225 UsageMode *UsageMode `json:"usage_mode,omitempty"`
226 SingleUsageInfo *SingleUsageInfo `json:"single_usage_info,omitempty"`
227 ProgressiveBundleUsageInfo *ProgressiveBundleUsageInfo `json:"progressive_bundle_usage_info,omitempty"`
228 DisplayInfo *ProductCouponDisplayInfo `json:"display_info,omitempty"`
229 OutProductNo *string `json:"out_product_no,omitempty"`
230 State *ProductCouponState `json:"state,omitempty"`
231 Stock *StockEntity `json:"stock,omitempty"`
232 StockBundle *StockBundleEntity `json:"stock_bundle,omitempty"`
233 BrandId *string `json:"brand_id,omitempty"`
234 ShowAsExchange *bool `json:"show_as_exchange,omitempty"`
235 AvailableProductNoList []string `json:"available_product_no_list,omitempty"`
236 BusinessMode *ProductCouponBusinessMode `json:"business_mode,omitempty"`
237}
238
239type ProductCouponScope string
240
241func (e ProductCouponScope) Ptr() *ProductCouponScope {
242 return &e
243}
244
245const (
246 PRODUCTCOUPONSCOPE_ALL ProductCouponScope = "ALL"
247 PRODUCTCOUPONSCOPE_SINGLE ProductCouponScope = "SINGLE"
248 PRODUCTCOUPONSCOPE_CATEGORY ProductCouponScope = "CATEGORY"
249)
250
251type ProductCouponType string
252
253func (e ProductCouponType) Ptr() *ProductCouponType {
254 return &e
255}
256
257const (
258 PRODUCTCOUPONTYPE_NORMAL ProductCouponType = "NORMAL"
259 PRODUCTCOUPONTYPE_DISCOUNT ProductCouponType = "DISCOUNT"
260 PRODUCTCOUPONTYPE_EXCHANGE ProductCouponType = "EXCHANGE"
261)
262
263type UsageMode string
264
265func (e UsageMode) Ptr() *UsageMode {
266 return &e
267}
268
269const (
270 USAGEMODE_SINGLE UsageMode = "SINGLE"
271 USAGEMODE_PROGRESSIVE_BUNDLE UsageMode = "PROGRESSIVE_BUNDLE"
272)
273
274type SingleUsageInfo struct {
275 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"`
276 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"`
277}
278
279type ProgressiveBundleUsageInfo struct {
280 Count *int64 `json:"count,omitempty"`
281 IntervalDays *int64 `json:"interval_days,omitempty"`
282}
283
284type ProductCouponDisplayInfoForCreate struct {
285 Name *string `json:"name,omitempty"`
286 ImageUrl *string `json:"image_url,omitempty"`
287 BackgroundUrl *string `json:"background_url,omitempty"`
288 DetailImageUrlList []string `json:"detail_image_url_list,omitempty"`
289 OriginalPrice *int64 `json:"original_price,omitempty"`
290 ComboPackageList []ComboPackage `json:"combo_package_list,omitempty"`
291}
292
293type StockForCreate struct {
294 Remark *string `json:"remark,omitempty"`
295 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"`
296 StockSendRule *StockSendRule `json:"stock_send_rule,omitempty"`
297 SingleUsageRule *SingleUsageRule `json:"single_usage_rule,omitempty"`
298 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"`
299 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"`
300 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"`
301 StoreScope *StockStoreScope `json:"store_scope,omitempty"`
302}
303
304type StockBundleForCreate struct {
305 Remark *string `json:"remark,omitempty"`
306 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"`
307 StockSendRule *StockSendRuleForBundle `json:"stock_send_rule,omitempty"`
308 ProgressiveBundleUsageRule *StockBundleUsageRule `json:"progressive_bundle_usage_rule,omitempty"`
309 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"`
310 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"`
311 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"`
312 StoreScope *StockStoreScope `json:"store_scope,omitempty"`
313}
314
315type ProductCouponBusinessMode string
316
317func (e ProductCouponBusinessMode) Ptr() *ProductCouponBusinessMode {
318 return &e
319}
320
321const (
322 PRODUCTCOUPONBUSINESSMODE_FREE ProductCouponBusinessMode = "FREE"
323)
324
325type ProductCouponDisplayInfo struct {
326 Name *string `json:"name,omitempty"`
327 ImageUrl *string `json:"image_url,omitempty"`
328 BackgroundUrl *string `json:"background_url,omitempty"`
329 DetailImageUrlList []string `json:"detail_image_url_list,omitempty"`
330 OriginalPrice *int64 `json:"original_price,omitempty"`
331 ComboPackageList []ComboPackage `json:"combo_package_list,omitempty"`
332}
333
334type ProductCouponState string
335
336func (e ProductCouponState) Ptr() *ProductCouponState {
337 return &e
338}
339
340const (
341 PRODUCTCOUPONSTATE_AUDITING ProductCouponState = "AUDITING"
342 PRODUCTCOUPONSTATE_EFFECTIVE ProductCouponState = "EFFECTIVE"
343 PRODUCTCOUPONSTATE_DEACTIVATED ProductCouponState = "DEACTIVATED"
344)
345
346type StockEntity struct {
347 ProductCouponId *string `json:"product_coupon_id,omitempty"`
348 StockId *string `json:"stock_id,omitempty"`
349 Remark *string `json:"remark,omitempty"`
350 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"`
351 CouponCodeCountInfo *CouponCodeCountInfo `json:"coupon_code_count_info,omitempty"`
352 StockSendRule *StockSendRule `json:"stock_send_rule,omitempty"`
353 SingleUsageRule *SingleUsageRule `json:"single_usage_rule,omitempty"`
354 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"`
355 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"`
356 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"`
357 StoreScope *StockStoreScope `json:"store_scope,omitempty"`
358 SentCountInfo *StockSentCountInfo `json:"sent_count_info,omitempty"`
359 State *StockState `json:"state,omitempty"`
360 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"`
361 DeactivateTime *time.Time `json:"deactivate_time,omitempty"`
362 DeactivateReason *string `json:"deactivate_reason,omitempty"`
363 BrandId *string `json:"brand_id,omitempty"`
364}
365
366type StockBundleEntity struct {
367 StockBundleId *string `json:"stock_bundle_id,omitempty"`
368 StockList []StockEntityInBundle `json:"stock_list,omitempty"`
369}
370
371type NormalCouponUsageRule struct {
372 Threshold *int64 `json:"threshold,omitempty"`
373 DiscountAmount *int64 `json:"discount_amount,omitempty"`
374}
375
376type DiscountCouponUsageRule struct {
377 Threshold *int64 `json:"threshold,omitempty"`
378 PercentOff *int64 `json:"percent_off,omitempty"`
379}
380
381type ComboPackage struct {
382 Name *string `json:"name,omitempty"`
383 PickCount *int64 `json:"pick_count,omitempty"`
384 ChoiceList []ComboPackageChoice `json:"choice_list,omitempty"`
385}
386
387type CouponCodeMode string
388
389func (e CouponCodeMode) Ptr() *CouponCodeMode {
390 return &e
391}
392
393const (
394 COUPONCODEMODE_WECHATPAY CouponCodeMode = "WECHATPAY"
395 COUPONCODEMODE_UPLOAD CouponCodeMode = "UPLOAD"
396 COUPONCODEMODE_API_ASSIGN CouponCodeMode = "API_ASSIGN"
397)
398
399type StockSendRule struct {
400 MaxCount *int64 `json:"max_count,omitempty"`
401 MaxCountPerDay *int64 `json:"max_count_per_day,omitempty"`
402 MaxCountPerUser *int64 `json:"max_count_per_user,omitempty"`
403}
404
405type SingleUsageRule struct {
406 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"`
407 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"`
408 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"`
409 ExchangeCoupon *ExchangeCouponUsageRule `json:"exchange_coupon,omitempty"`
410}
411
412type UsageRuleDisplayInfo struct {
413 CouponUsageMethodList []CouponUsageMethod `json:"coupon_usage_method_list,omitempty"`
414 MiniProgramAppid *string `json:"mini_program_appid,omitempty"`
415 MiniProgramPath *string `json:"mini_program_path,omitempty"`
416 AppPath *string `json:"app_path,omitempty"`
417 UsageDescription *string `json:"usage_description,omitempty"`
418 CouponAvailableStoreInfo *CouponAvailableStoreInfo `json:"coupon_available_store_info,omitempty"`
419 AppJumpType *AppJumpType `json:"app_jump_type,omitempty"`
420 PasscodeLink *string `json:"passcode_link,omitempty"`
421}
422
423type CouponDisplayInfo struct {
424 CodeDisplayMode *CouponCodeDisplayMode `json:"code_display_mode,omitempty"`
425 BackgroundColor *string `json:"background_color,omitempty"`
426 EntranceMiniProgram *EntranceMiniProgram `json:"entrance_mini_program,omitempty"`
427 EntranceOfficialAccount *EntranceOfficialAccount `json:"entrance_official_account,omitempty"`
428}
429
430type NotifyConfig struct {
431 NotifyAppid *string `json:"notify_appid,omitempty"`
432}
433
434type StockStoreScope string
435
436func (e StockStoreScope) Ptr() *StockStoreScope {
437 return &e
438}
439
440const (
441 STOCKSTORESCOPE_NONE StockStoreScope = "NONE"
442 STOCKSTORESCOPE_ALL StockStoreScope = "ALL"
443 STOCKSTORESCOPE_SPECIFIC StockStoreScope = "SPECIFIC"
444)
445
446type StockSendRuleForBundle struct {
447 MaxCount *int64 `json:"max_count,omitempty"`
448 MaxCountPerDay *int64 `json:"max_count_per_day,omitempty"`
449 MaxCountPerUser *int64 `json:"max_count_per_user,omitempty"`
450}
451
452type StockBundleUsageRule struct {
453 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"`
454 NormalCouponList []NormalCouponUsageRule `json:"normal_coupon_list,omitempty"`
455 DiscountCouponList []DiscountCouponUsageRule `json:"discount_coupon_list,omitempty"`
456 ExchangeCouponList []ExchangeCouponUsageRule `json:"exchange_coupon_list,omitempty"`
457}
458
459type CouponCodeCountInfo struct {
460 TotalCount *int64 `json:"total_count,omitempty"`
461 AvailableCount *int64 `json:"available_count,omitempty"`
462}
463
464type StockSentCountInfo struct {
465 TotalCount *int64 `json:"total_count,omitempty"`
466 TodayCount *int64 `json:"today_count,omitempty"`
467}
468
469type StockState string
470
471func (e StockState) Ptr() *StockState {
472 return &e
473}
474
475const (
476 STOCKSTATE_AUDITING StockState = "AUDITING"
477 STOCKSTATE_SENDING StockState = "SENDING"
478 STOCKSTATE_PAUSED StockState = "PAUSED"
479 STOCKSTATE_STOPPED StockState = "STOPPED"
480 STOCKSTATE_DEACTIVATED StockState = "DEACTIVATED"
481)
482
483type StockEntityInBundle struct {
484 ProductCouponId *string `json:"product_coupon_id,omitempty"`
485 StockId *string `json:"stock_id,omitempty"`
486 Remark *string `json:"remark,omitempty"`
487 CouponCodeMode *CouponCodeMode `json:"coupon_code_mode,omitempty"`
488 CouponCodeCountInfo *CouponCodeCountInfo `json:"coupon_code_count_info,omitempty"`
489 StockSendRule *StockSendRule `json:"stock_send_rule,omitempty"`
490 ProgressiveBundleUsageRule *StockUsageRule `json:"progressive_bundle_usage_rule,omitempty"`
491 StockBundleInfo *StockBundleInfo `json:"stock_bundle_info,omitempty"`
492 UsageRuleDisplayInfo *UsageRuleDisplayInfo `json:"usage_rule_display_info,omitempty"`
493 CouponDisplayInfo *CouponDisplayInfo `json:"coupon_display_info,omitempty"`
494 NotifyConfig *NotifyConfig `json:"notify_config,omitempty"`
495 StoreScope *StockStoreScope `json:"store_scope,omitempty"`
496 SentCountInfo *StockSentCountInfo `json:"sent_count_info,omitempty"`
497 State *StockState `json:"state,omitempty"`
498 DeactivateRequestNo *string `json:"deactivate_request_no,omitempty"`
499 DeactivateTime *time.Time `json:"deactivate_time,omitempty"`
500 DeactivateReason *string `json:"deactivate_reason,omitempty"`
501 BrandId *string `json:"brand_id,omitempty"`
502}
503
504type ComboPackageChoice struct {
505 Name *string `json:"name,omitempty"`
506 Price *int64 `json:"price,omitempty"`
507 Count *int64 `json:"count,omitempty"`
508 ImageUrl *string `json:"image_url,omitempty"`
509 MiniProgramAppid *string `json:"mini_program_appid,omitempty"`
510 MiniProgramPath *string `json:"mini_program_path,omitempty"`
511}
512
513type CouponAvailablePeriod struct {
514 AvailableBeginTime *string `json:"available_begin_time,omitempty"`
515 AvailableEndTime *string `json:"available_end_time,omitempty"`
516 AvailableDays *int64 `json:"available_days,omitempty"`
517 WaitDaysAfterReceive *int64 `json:"wait_days_after_receive,omitempty"`
518 WeeklyAvailablePeriod *FixedWeekPeriod `json:"weekly_available_period,omitempty"`
519 IrregularAvailablePeriodList []TimePeriod `json:"irregular_available_period_list,omitempty"`
520 AvailableSeconds *int64 `json:"available_seconds,omitempty"`
521}
522
523type ExchangeCouponUsageRule struct {
524 Threshold *int64 `json:"threshold,omitempty"`
525 ExchangePrice *int64 `json:"exchange_price,omitempty"`
526}
527
528type CouponUsageMethod string
529
530func (e CouponUsageMethod) Ptr() *CouponUsageMethod {
531 return &e
532}
533
534const (
535 COUPONUSAGEMETHOD_OFFLINE CouponUsageMethod = "OFFLINE"
536 COUPONUSAGEMETHOD_MINI_PROGRAM CouponUsageMethod = "MINI_PROGRAM"
537 COUPONUSAGEMETHOD_APP CouponUsageMethod = "APP"
538 COUPONUSAGEMETHOD_PAYMENT_CODE CouponUsageMethod = "PAYMENT_CODE"
539)
540
541type CouponAvailableStoreInfo struct {
542 Description *string `json:"description,omitempty"`
543 MiniProgramAppid *string `json:"mini_program_appid,omitempty"`
544 MiniProgramPath *string `json:"mini_program_path,omitempty"`
545}
546
547type AppJumpType string
548
549func (e AppJumpType) Ptr() *AppJumpType {
550 return &e
551}
552
553const (
554 APPJUMPTYPE_H5 AppJumpType = "H5"
555 APPJUMPTYPE_PASSCODE_LINK AppJumpType = "PASSCODE_LINK"
556 APPJUMPTYPE_USAGE_GUIDE AppJumpType = "USAGE_GUIDE"
557)
558
559type CouponCodeDisplayMode string
560
561func (e CouponCodeDisplayMode) Ptr() *CouponCodeDisplayMode {
562 return &e
563}
564
565const (
566 COUPONCODEDISPLAYMODE_INVISIBLE CouponCodeDisplayMode = "INVISIBLE"
567 COUPONCODEDISPLAYMODE_BARCODE CouponCodeDisplayMode = "BARCODE"
568 COUPONCODEDISPLAYMODE_QRCODE CouponCodeDisplayMode = "QRCODE"
569)
570
571type EntranceMiniProgram struct {
572 Appid *string `json:"appid,omitempty"`
573 Path *string `json:"path,omitempty"`
574 EntranceWording *string `json:"entrance_wording,omitempty"`
575 GuidanceWording *string `json:"guidance_wording,omitempty"`
576}
577
578type EntranceOfficialAccount struct {
579 Appid *string `json:"appid,omitempty"`
580}
581
582type StockUsageRule struct {
583 CouponAvailablePeriod *CouponAvailablePeriod `json:"coupon_available_period,omitempty"`
584 NormalCoupon *NormalCouponUsageRule `json:"normal_coupon,omitempty"`
585 DiscountCoupon *DiscountCouponUsageRule `json:"discount_coupon,omitempty"`
586 ExchangeCoupon *ExchangeCouponUsageRule `json:"exchange_coupon,omitempty"`
587}
588
589type StockBundleInfo struct {
590 StockBundleId *string `json:"stock_bundle_id,omitempty"`
591 StockBundleIndex *int64 `json:"stock_bundle_index,omitempty"`
592}
593
594type FixedWeekPeriod struct {
595 DayList []WeekEnum `json:"day_list,omitempty"`
596 DayPeriodList []PeriodOfTheDay `json:"day_period_list,omitempty"`
597}
598
599type TimePeriod struct {
600 BeginTime *string `json:"begin_time,omitempty"`
601 EndTime *string `json:"end_time,omitempty"`
602}
603
604type WeekEnum string
605
606func (e WeekEnum) Ptr() *WeekEnum {
607 return &e
608}
609
610const (
611 WEEKENUM_MONDAY WeekEnum = "MONDAY"
612 WEEKENUM_TUESDAY WeekEnum = "TUESDAY"
613 WEEKENUM_WEDNESDAY WeekEnum = "WEDNESDAY"
614 WEEKENUM_THURSDAY WeekEnum = "THURSDAY"
615 WEEKENUM_FRIDAY WeekEnum = "FRIDAY"
616 WEEKENUM_SATURDAY WeekEnum = "SATURDAY"
617 WEEKENUM_SUNDAY WeekEnum = "SUNDAY"
618)
619
620type PeriodOfTheDay struct {
621 BeginTime *int64 `json:"begin_time,omitempty"`
622 EndTime *int64 `json:"end_time,omitempty"`
623}