View Javadoc
1   package com.foxinmy.weixin4j.model.card;
2   
3   import com.alibaba.fastjson.annotation.JSONField;
4   import com.foxinmy.weixin4j.type.card.CardType;
5   import com.foxinmy.weixin4j.type.card.SubCardType;
6   
7   /**
8    * 单品类型礼品卡
9    * 指该礼品卡用于兑换指定单品,如汉堡礼品卡
10   *
11   * @className VoucherCardCoupon
12   * @author kit(kit.li@qq.com)
13   * @date 2018年10月23日
14   */
15  public class VoucherCard extends CardCoupon {
16  
17      /**
18       * 子卡券类型
19       */
20      @JSONField(name = "sub_card_type")
21      private final String subCardType;
22      /**
23       * 礼品卡背景图片,非必需
24       */
25      @JSONField(name = "background_pic_url")
26      private String backgroundPicUrl;
27      /**
28       * 是否支持积分,填写true或者false。默认为false
29       */
30      @JSONField(name = "supply_bonus")
31      private boolean supplyBonus;
32      /**
33       * 是否支持余额,填写true或者false。默认为false
34       */
35      @JSONField(name = "supply_balance")
36      private boolean supplyBalance;
37      /**
38       * 自定义会员信息类目,会员卡激活后显示,包含name和url字段
39       */
40      @JSONField(name = "custom_field1")
41      private MemCardCustomField customField1;
42      /**
43       * 自定义会员信息类目,会员卡激活后显示,包含name和url字段
44       */
45      @JSONField(name = "custom_field2")
46      private MemCardCustomField customField2;
47      /**
48       * 自定义会员信息类目,会员卡激活后显示,包含name和url字段
49       */
50      @JSONField(name = "custom_field3")
51      private MemCardCustomField customField3;
52      /**
53       * 是否自动激活,若开发者不需要额外激活流程则填写true。
54       */
55      @JSONField(name = "auto_activate")
56      private boolean autoActivate;
57  
58      public String getSubCardType() {
59          return subCardType;
60      }
61  
62      public String getBackgroundPicUrl() {
63          return backgroundPicUrl;
64      }
65  
66      public boolean isSupplyBonus() {
67          return supplyBonus;
68      }
69  
70      public boolean isSupplyBalance() {
71          return supplyBalance;
72      }
73  
74      public MemCardCustomField getCustomField1() {
75          return customField1;
76      }
77  
78      public MemCardCustomField getCustomField2() {
79          return customField2;
80      }
81  
82      public MemCardCustomField getCustomField3() {
83          return customField3;
84      }
85  
86      public boolean isAutoActivate() {
87          return autoActivate;
88      }
89  
90      public VoucherCard(CouponBaseInfo baseInfo, GiftCard.Builder builder){
91          super(baseInfo);
92          this.subCardType = SubCardType.VOUCHER.name();
93          this.autoActivate = builder.isAutoActivate();
94          this.backgroundPicUrl = builder.getBackgroundPicUrl();
95          this.customField1 = builder.getCustomField1();
96          this.customField2 = builder.getCustomField2();
97          this.customField3 = builder.getCustomField3();
98          this.supplyBalance = false;
99          this.supplyBonus = builder.isSupplyBonus();;
100     }
101 
102     @JSONField(serialize = false)
103     @Override
104     public CardType getCardType() {
105         return CardType.GENERAL_CARD;
106     }
107 
108     @Override
109     public String toString() {
110         return "VoucherCardCoupon [" +
111                 "subCardType='" + subCardType + '\'' +
112                 ", backgroundPicUrl='" + backgroundPicUrl + '\'' +
113                 ", supplyBonus=" + supplyBonus +
114                 ", supplyBalance=" + supplyBalance +
115                 ", customField1=" + customField1 +
116                 ", customField2=" + customField2 +
117                 ", customField3=" + customField3 +
118                 ", autoActivate=" + autoActivate +
119                 ", " + super.toString() +
120                 ']';
121     }
122 }