View Javadoc
1   package com.foxinmy.weixin4j.model.card;
2   
3   import com.alibaba.fastjson.JSONArray;
4   import com.alibaba.fastjson.JSONObject;
5   import com.alibaba.fastjson.annotation.JSONField;
6   import com.foxinmy.weixin4j.type.card.ActivateCommonField;
7   import com.foxinmy.weixin4j.type.card.ActivateFormFieldType;
8   
9   import java.util.HashSet;
10  
11  /**
12   * 普通一键激活 中设置会员卡
13   *
14   * @auther: Feng Yapeng
15   * @since: 2016/12/20 16:25
16   */
17  public class MemberUserForm {
18  
19      /**
20       * 卡券ID。
21       */
22      @JSONField(name = "card_id")
23      private String cardId;
24  
25      /**
26       * 服务声明,用于放置商户会员卡守则
27       */
28      @JSONField(name = "service_statement")
29      private JSONObject serviceStatement;
30      /**
31       * 绑定老会员链接
32       */
33      @JSONField(name = "bind_old_card")
34      private JSONObject bindOldCard;
35  
36      /**
37       *设置必填的from
38       */
39      @JSONField(name = "required_form")
40      private FormBudiler requiredForm;
41  
42      /**
43       * 设置选填的form
44       */
45      @JSONField(name = "optional_form")
46      private FormBudiler optionalForm;
47  
48  
49      public String getCardId() {
50          return cardId;
51      }
52  
53      public void setCardId(String cardId) {
54          this.cardId = cardId;
55      }
56  
57      public JSONObject getServiceStatement() {
58          return serviceStatement;
59      }
60  
61      public void setServiceStatement(String name,String url) {
62          JSONObject serviceStatement = new JSONObject();
63          serviceStatement.put("name",name);
64          serviceStatement.put("url",url);
65          this.serviceStatement = serviceStatement;
66      }
67  
68      public JSONObject getBindOldCard() {
69          return bindOldCard;
70      }
71  
72      public void setBindOldCard(String name,String url) {
73          JSONObject bindOldCard = new JSONObject();
74          bindOldCard.put("name",name);
75          bindOldCard.put("url",url);
76          this.bindOldCard = bindOldCard;
77      }
78  
79      public void setRequiredForm(FormBudiler formBudiler) {
80          this.requiredForm = formBudiler;
81      }
82  
83      public void setOptionalForm(FormBudiler formBudiler) {
84          this.optionalForm = formBudiler;
85      }
86  
87      public FormBudiler getRequiredForm() {
88          return requiredForm;
89      }
90  
91      public FormBudiler getOptionalForm() {
92          return optionalForm;
93      }
94  
95      public final static class FormBudiler {
96  
97          /**
98           * 当前结构(required_form或者optional_form )内
99           * 的字段是否允许用户激活后再次修改,商户设置为true
100          * 时,需要接收相应事件通知处理修改事件
101          */
102         @JSONField(name = "can_modify")
103         private boolean   canModify;
104         /**
105          * 自定义富文本类型,包含以下三个字段
106          */
107         @JSONField(name = "rich_field_list")
108         private JSONArray richFieldList;
109 
110         /**
111          * 微信格式化的选项类型
112          */
113         @JSONField(name = "common_field_id_list")
114         private HashSet<ActivateCommonField> commonFieldIdList;
115 
116         /**
117          * 自定义选项名称。
118          */
119         @JSONField(name = "custom_field_list")
120         private HashSet<String> customFieldList;
121 
122         /**
123          * 自定义富文本类型
124          */
125         public FormBudiler addRichField(ActivateFormFieldType fieldType, String name, String... values) {
126             if (richFieldList == null) {
127                 richFieldList = new JSONArray();
128             }
129             JSONObject obj = new JSONObject();
130             obj.put("type", fieldType);
131             obj.put("name", name);
132             obj.put("values", values);
133             richFieldList.add(obj);
134             return this;
135         }
136 
137         public FormBudiler canModify(boolean modify){
138             this.canModify = modify;
139             return this;
140         }
141 
142 
143         /**
144          * 自定义公共字段
145          */
146         public FormBudiler addCommonField(ActivateCommonField... fields) {
147             if (commonFieldIdList == null) {
148                 commonFieldIdList = new HashSet<ActivateCommonField>();
149             }
150             for (ActivateCommonField field : fields) {
151                 commonFieldIdList.add(field);
152             }
153             return this;
154         }
155 
156         /**
157          * 增加自定义的内容
158          * @param names
159          */
160         public FormBudiler addCustomField(String... names) {
161             if (customFieldList == null) {
162                 customFieldList = new HashSet<String>();
163             }
164             for (String name : names) {
165                 customFieldList.add(name);
166             }
167             return this;
168         }
169 
170         public boolean isCanModify() {
171             return canModify;
172         }
173 
174         public JSONArray getRichFieldList() {
175             return richFieldList;
176         }
177 
178         public HashSet<ActivateCommonField> getCommonFieldIdList() {
179             return commonFieldIdList;
180         }
181 
182         public HashSet<String> getCustomFieldList() {
183             return customFieldList;
184         }
185     }
186 
187 }