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.FieldNameType;
6   
7   /**
8    * 会员卡
9    * @auther: Feng Yapeng
10   * @since: 2016/12/15 10:09
11   */
12  public class MemberCard extends CardCoupon {
13  
14      /**
15       * 会员卡背景图 [商家自定义会员卡背景图,须先调用上传图片接口将背景图上传至CDN,否则报错,
16       * 卡面设计请遵循微信会员卡自定义背景设计规范  ,像素大小控制在1000像素*600像素以下]
17       */
18      @JSONField(name = "background_pic_url")
19      private String backgroundPicUrl;
20  
21      /**
22       * 会员卡特权说明。
23       */
24      @JSONField(name = "prerogative")
25      private String  prerogative;
26      /**
27       * 用户领取会员卡后系统自动将其激活,无需调用激活接口,详情见自动激活。
28       */
29      @JSONField(name = "auto_activate")
30      private boolean autoActivate;
31      /**
32       * 设置为true时会员卡支持一键开卡,不允许同时传入activate_url字段,否则设置wx_activate失效。
33       */
34      @JSONField(name = "wx_activate")
35      private boolean wxActivate;
36      /**
37       * 激活会员卡的url。
38       */
39      @JSONField(name = "activate_url")
40      private String  activateUrl;
41  
42      /**
43       * 显示积分 【true:积分相关字段均为必填】
44       */
45      @JSONField(name = "supply_bonus")
46      private boolean supplyBonus;
47      /**
48       * 设置跳转外链查看积分详情。仅适用于积分无法通过激活接口同步的情况下使用该字段
49       */
50      @JSONField(name = "bonus_url")
51      private String  bonusUrl;
52      /**
53       * 显示余额
54       */
55      @JSONField(name = "supply_balance")
56      private boolean  supplyBalance;
57      /**
58       * 设置跳转外链查看余额详情。仅适用于余额无法通过激活接口同步的情况下使用该字段。
59       */
60      @JSONField(name = "balance_url")
61      private String  balanceUrl;
62  
63      /**
64       * 自定义会员信息类目
65       */
66      @JSONField(name = "custom_field1")
67      private MemCardCustomField customField1;
68      /**
69       * 自定义会员信息类目
70       */
71      @JSONField(name = "custom_field2")
72      private MemCardCustomField customField2;
73      /**
74       * 自定义会员信息类目
75       */
76      @JSONField(name = "custom_field3")
77      private MemCardCustomField customField3;
78  
79      /**
80       * 积分规则说明
81       */
82      @JSONField(name = "bonus_rules")
83      private String             bonusRules;
84      /**
85       * 储值说明。
86       */
87      @JSONField(name = "balance_rules")
88      private String             balanceRules;
89      /**
90       * 积分清零规则
91       */
92      @JSONField(name = "bonus_cleared")
93      private String             bonusCleared;
94      /**
95       * 自定义会员信息类目,会员卡激活后显示
96       */
97      @JSONField(name = "custom_cell1")
98      private MemCardCustomField customCell1;
99  
100     /**
101      * 折扣【该会员卡享受的折扣优惠,填10就是九折。】
102      */
103     private int discount;
104 
105     @JSONField(name = "bonus_rule")
106     private MemCardBonusRule bonusRule;
107 
108 
109     /**
110      * 卡券
111      *
112      * @param couponBaseInfo 基础信息
113      */
114     protected MemberCard(CouponBaseInfo couponBaseInfo, Builder builder) {
115         super(couponBaseInfo);
116         this.activateUrl = builder.activateUrl;
117         this.backgroundPicUrl = builder.backgroundPicUrl;
118         this.prerogative = builder.prerogative;
119         this.autoActivate = builder.autoActivate;
120         this.wxActivate = builder.wxActivate;
121         this.activateUrl = builder.activateUrl;
122         this.supplyBonus = builder.supplyBonus;
123         this.bonusUrl = builder.bonusUrl;
124         this.supplyBalance = builder.supplyBalance;
125         this.balanceUrl = builder.balanceUrl;
126         this.customField1 = builder.customField1;
127         this.customField2 = builder.customField2;
128         this.customField3 = builder.customField3;
129         this.bonusRules = builder.bonusRules;
130         this.balanceRules = builder.balanceRules;
131         this.bonusCleared = builder.bonusCleared;
132         this.customCell1 = builder.customCell1;
133         this.discount = builder.discount;
134         this.bonusRule = builder.bonusRule;
135     }
136 
137     @JSONField(serialize = false)
138     @Override
139     public CardType getCardType() {
140         return CardType.MEMBER_CARD;
141     }
142 
143     public String getBackgroundPicUrl() {
144         return backgroundPicUrl;
145     }
146 
147     public String getPrerogative() {
148         return prerogative;
149     }
150 
151     public boolean isAutoActivate() {
152         return autoActivate;
153     }
154 
155     public boolean isWxActivate() {
156         return wxActivate;
157     }
158 
159     public String getActivateUrl() {
160         return activateUrl;
161     }
162 
163     public boolean isSupplyBonus() {
164         return supplyBonus;
165     }
166 
167     public String getBonusUrl() {
168         return bonusUrl;
169     }
170 
171     public boolean getSupplyBalance() {
172         return supplyBalance;
173     }
174 
175     public String getBalanceUrl() {
176         return balanceUrl;
177     }
178 
179     public MemCardCustomField getCustomField1() {
180         return customField1;
181     }
182 
183     public MemCardCustomField getCustomField2() {
184         return customField2;
185     }
186 
187     public MemCardCustomField getCustomField3() {
188         return customField3;
189     }
190 
191     public String getBonusRules() {
192         return bonusRules;
193     }
194 
195     public String getBalanceRules() {
196         return balanceRules;
197     }
198 
199     public String getBonusCleared() {
200         return bonusCleared;
201     }
202 
203     public MemCardCustomField getCustomCell1() {
204         return customCell1;
205     }
206 
207     public int getDiscount() {
208         return discount;
209     }
210 
211     public MemCardBonusRule getBonusRule() {
212         return bonusRule;
213     }
214 
215 
216     public static final class Builder {
217 
218         /**
219          * 会员卡背景图 [商家自定义会员卡背景图,须先调用上传图片接口将背景图上传至CDN,否则报错,
220          * 卡面设计请遵循微信会员卡自定义背景设计规范  ,像素大小控制在1000像素*600像素以下]
221          */
222         private String backgroundPicUrl;
223 
224         /**
225          * 会员卡特权说明。
226          */
227         private String  prerogative;
228         /**
229          * 用户领取会员卡后系统自动将其激活,无需调用激活接口,详情见自动激活。
230          */
231         private boolean autoActivate;
232         /**
233          * 设置为true时会员卡支持一键开卡,不允许同时传入activate_url字段,否则设置wx_activate失效。
234          */
235         private boolean wxActivate;
236         /**
237          * 激活会员卡的url。
238          */
239         private String  activateUrl;
240 
241         /**
242          * 显示积分 【true:积分相关字段均为必填】
243          */
244         private boolean            supplyBonus;
245         /**
246          * 设置跳转外链查看积分详情。仅适用于积分无法通过激活接口同步的情况下使用该字段
247          */
248         private String             bonusUrl;
249         /**
250          * 显示余额
251          */
252         private boolean             supplyBalance;
253         /**
254          * 设置跳转外链查看余额详情。仅适用于余额无法通过激活接口同步的情况下使用该字段。
255          */
256         private String             balanceUrl;
257         /**
258          * 自定义会员信息类目
259          */
260         private MemCardCustomField customField1;
261         /**
262          * 自定义会员信息类目
263          */
264         private MemCardCustomField customField2;
265         /**
266          * 自定义会员信息类目
267          */
268         private MemCardCustomField customField3;
269         /**
270          * 积分规则说明
271          */
272         private String             bonusRules;
273         /**
274          * 储值说明。
275          */
276         private String             balanceRules;
277         /**
278          * 积分清零规则
279          */
280         private String             bonusCleared;
281         /**
282          * 自定义会员信息类目,会员卡激活后显示
283          */
284         private MemCardCustomField customCell1;
285         /**
286          * 折扣【该会员卡享受的折扣优惠,填10就是九折。】
287          */
288         private int                discount;
289         /**
290          * 积分规则
291          */
292         private MemCardBonusRule   bonusRule;
293 
294 
295         public Builder backgroundPicUrl(String backgroundPicUrl) {
296             this.backgroundPicUrl = backgroundPicUrl;
297             return this;
298         }
299 
300         public Builder prerogative(String prerogative) {
301             this.prerogative = prerogative;
302             return this;
303         }
304 
305         public Builder activateWithAuto(boolean autoActivate) {
306             this.autoActivate = autoActivate;
307             this.activateUrl = null;
308             this.wxActivate = false;
309             return this;
310         }
311 
312         public Builder activateWithWx(boolean wxActivate) {
313             this.wxActivate = wxActivate;
314             this.autoActivate = false;
315             this.activateUrl = null;
316             return this;
317         }
318 
319         public Builder activateUrl(String activateUrl) {
320             this.activateUrl = activateUrl;
321             this.autoActivate  = false;
322             this.wxActivate = false;
323             return this;
324         }
325 
326         public Builder supplyBonus(boolean supplyBonus) {
327             this.supplyBonus = supplyBonus;
328             return this;
329         }
330 
331         public Builder bonusUrl(String bonusUrl) {
332             this.bonusUrl = bonusUrl;
333             return this;
334         }
335 
336         public Builder supplyBalance(boolean supplyBalance) {
337             this.supplyBalance = supplyBalance;
338             return this;
339         }
340 
341         public Builder balanceUrl(String balanceUrl) {
342             this.balanceUrl = balanceUrl;
343             return this;
344         }
345 
346         public Builder customField1(FieldNameType type, String name, String url) {
347             this.customField1 = new MemCardCustomField(type, name, url);
348             return this;
349         }
350 
351         public Builder customField2(FieldNameType type, String name, String url) {
352             this.customField2 = new MemCardCustomField(type, name, url);
353             return this;
354         }
355 
356         public Builder customField3(FieldNameType type, String name, String url) {
357             this.customField3 = new MemCardCustomField(type, name, url);
358             return this;
359         }
360 
361         public Builder bonusRules(String bonusRules) {
362             this.bonusRules = bonusRules;
363             return this;
364         }
365 
366         public Builder balanceRules(String balanceRules) {
367             this.balanceRules = balanceRules;
368             return this;
369         }
370 
371         public Builder bonusCleared(String bonusCleared) {
372             this.bonusCleared = bonusCleared;
373             return this;
374         }
375 
376         public Builder customCell1(String name, String url, String tips) {
377             this.customCell1 = new MemCardCustomField(name, url, tips);
378             return this;
379         }
380 
381         public Builder discount(int discount) {
382             this.discount = discount;
383             return this;
384         }
385 
386         public Builder bonusRule(MemCardBonusRule bonusRule) {
387             this.bonusRule = bonusRule;
388             return this;
389         }
390     }
391 }