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
12
13 public class GiftCard extends CardCoupon {
14
15
16
17
18 @JSONField(name = "sub_card_type")
19 private final String subCardType;
20
21
22
23 @JSONField(name = "background_pic_url")
24 private String backgroundPicUrl;
25
26
27
28 @JSONField(name = "supply_bonus")
29 private boolean supplyBonus;
30
31
32
33 @JSONField(name = "supply_balance")
34 private boolean supplyBalance;
35
36
37
38 @JSONField(name = "custom_field1")
39 private MemCardCustomField customField1;
40
41
42
43 @JSONField(name = "custom_field2")
44 private MemCardCustomField customField2;
45
46
47
48 @JSONField(name = "custom_field3")
49 private MemCardCustomField customField3;
50
51
52
53 @JSONField(name = "auto_activate")
54 private boolean autoActivate;
55
56
57
58 @JSONField(name = "init_balance")
59 private Integer initBalance;
60
61 public GiftCard(CouponBaseInfo baseInfo, GiftCard.Builder builder){
62 super(baseInfo);
63 this.subCardType = SubCardType.VOUCHER.name();
64 this.autoActivate = builder.isAutoActivate();
65 this.backgroundPicUrl = builder.getBackgroundPicUrl();
66 this.customField1 = builder.getCustomField1();
67 this.customField2 = builder.getCustomField2();
68 this.customField3 = builder.getCustomField3();
69 this.supplyBalance = builder.isSupplyBalance();
70 this.supplyBonus = builder.isSupplyBonus();
71 this.initBalance = builder.getInitBalance();
72 }
73
74 @JSONField(serialize = false)
75 @Override
76 public CardType getCardType() {
77 return CardType.GENERAL_COUPON;
78 }
79
80 public static final class Builder {
81 private String backgroundPicUrl;
82 private boolean supplyBonus;
83 private boolean supplyBalance;
84 private boolean autoActivate;
85 private Integer initBalance;
86 private MemCardCustomField customField1;
87 private MemCardCustomField customField2;
88 private MemCardCustomField customField3;
89
90 public Builder(){
91 this.autoActivate = true;
92 this.supplyBalance = false;
93 this.supplyBonus = false;
94 }
95
96 public String getBackgroundPicUrl() {
97 return backgroundPicUrl;
98 }
99
100 public boolean isSupplyBonus() {
101 return supplyBonus;
102 }
103
104 public boolean isSupplyBalance() {
105 return supplyBalance;
106 }
107
108 public boolean isAutoActivate() {
109 return autoActivate;
110 }
111
112 public Integer getInitBalance() {
113 return initBalance;
114 }
115
116 public MemCardCustomField getCustomField1() {
117 return customField1;
118 }
119
120 public MemCardCustomField getCustomField2() {
121 return customField2;
122 }
123
124 public MemCardCustomField getCustomField3() {
125 return customField3;
126 }
127
128
129
130
131
132
133 public Builder backgroundPicUrl(String url){
134 this.backgroundPicUrl = url;
135 return this;
136 }
137
138
139
140
141
142
143 public Builder supplyBonus(boolean supplyBonus){
144 this.supplyBonus = supplyBonus;
145 return this;
146 }
147
148
149
150
151
152
153
154 public Builder supplyBalance(boolean supplyBalance){
155 this.supplyBalance = supplyBalance;
156 return this;
157 }
158
159
160
161
162
163
164 public Builder autoActivate(boolean autoActivate){
165 this.autoActivate = autoActivate;
166 return this;
167 }
168
169
170
171
172
173
174 public Builder initBalance(Integer initBalance){
175 this.initBalance = initBalance;
176 return this;
177 }
178
179
180
181
182
183
184
185
186 public Builder customField1(String name, String url){
187 MemCardCustomField field = new MemCardCustomField(name, url, null);
188 this.customField1 = field;
189 return this;
190 }
191
192
193
194
195
196
197
198
199 public Builder customField2(String name, String url){
200 MemCardCustomField field = new MemCardCustomField(name, url, null);
201 this.customField2 = field;
202 return this;
203 }
204
205
206
207
208
209
210
211
212 public Builder customField3(String name, String url){
213 MemCardCustomField field = new MemCardCustomField(name, url, null);
214 this.customField3 = field;
215 return this;
216 }
217 }
218
219 }