1 package com.foxinmy.weixin4j.pay.payment.coupon;
2
3 import com.alibaba.fastjson.annotation.JSONField;
4 import com.foxinmy.weixin4j.pay.payment.mch.MerchantResult;
5 import com.foxinmy.weixin4j.pay.type.mch.CouponStockStatus;
6 import com.foxinmy.weixin4j.pay.type.mch.CouponType;
7 import com.foxinmy.weixin4j.util.DateUtil;
8
9 import javax.xml.bind.annotation.XmlAccessType;
10 import javax.xml.bind.annotation.XmlAccessorType;
11 import javax.xml.bind.annotation.XmlElement;
12 import javax.xml.bind.annotation.XmlRootElement;
13 import java.util.Date;
14
15
16
17
18
19
20
21
22
23
24 @XmlRootElement
25 @XmlAccessorType(XmlAccessType.FIELD)
26 public class CouponStock extends MerchantResult {
27
28 private static final long serialVersionUID = -8627202879200080499L;
29
30
31
32
33 @XmlElement(name = "coupon_stock_id")
34 @JSONField(name = "coupon_stock_id")
35 private String couponStockId;
36
37
38
39 @XmlElement(name = "coupon_name")
40 @JSONField(name = "coupon_name")
41 private String couponName;
42
43
44
45 @XmlElement(name = "coupon_value")
46 @JSONField(name = "coupon_value")
47 private int couponValue;
48
49
50
51 @XmlElement(name = "coupon_mininumn")
52 @JSONField(name = "coupon_mininumn")
53 private Integer couponMininumn;
54
55
56
57 @XmlElement(name = "coupon_type")
58 @JSONField(name = "coupon_type")
59 private int couponType;
60
61
62
63 @XmlElement(name = "coupon_stock_status")
64 @JSONField(name = "coupon_stock_status")
65 private int couponStockStatus;
66
67
68
69 @XmlElement(name = "coupon_total")
70 @JSONField(name = "coupon_total")
71 private int couponTotal;
72
73
74
75 @XmlElement(name = "max_quota")
76 @JSONField(name = "max_quota")
77 private Integer maxQuota;
78
79
80
81 @XmlElement(name = "locked_num")
82 @JSONField(name = "locked_num")
83 private Integer lockedNum;
84
85
86
87 @XmlElement(name = "used_num")
88 @JSONField(name = "used_num")
89 private Integer usedNum;
90
91
92
93 @XmlElement(name = "is_send_num")
94 @JSONField(name = "is_send_num")
95 private Integer sendNum;
96
97
98
99 @XmlElement(name = "begin_time")
100 @JSONField(name = "begin_time")
101 private String beginTime;
102
103
104
105 @XmlElement(name = "end_time")
106 @JSONField(name = "end_time")
107 private String endTime;
108
109
110
111 @XmlElement(name = "create_time")
112 @JSONField(name = "create_time")
113 private String createTime;
114
115
116
117 @XmlElement(name = "coupon_budget")
118 @JSONField(name = "coupon_budget")
119 private Integer couponBudget;
120
121 public CouponStock() {
122
123 }
124
125 public String getCouponStockId() {
126 return couponStockId;
127 }
128
129 public void setCouponStockId(String couponStockId) {
130 this.couponStockId = couponStockId;
131 }
132
133 public String getCouponName() {
134 return couponName;
135 }
136
137 public void setCouponName(String couponName) {
138 this.couponName = couponName;
139 }
140
141 public int getCouponValue() {
142 return couponValue;
143 }
144
145 public void setCouponValue(int couponValue) {
146 this.couponValue = couponValue;
147 }
148
149
150
151
152
153
154 @JSONField(serialize = false)
155 public double getFormatCouponValue() {
156 return couponValue / 100d;
157 }
158
159 public Integer getCouponMininumn() {
160 return couponMininumn;
161 }
162
163 public void setCouponMininumn(Integer couponMininumn) {
164 this.couponMininumn = couponMininumn;
165 }
166
167
168
169
170
171
172 @JSONField(serialize = false)
173 public double getFormatCouponMininumn() {
174 return couponMininumn != null ? couponMininumn.intValue() / 100d : 0d;
175 }
176
177 public int getCouponType() {
178 return couponType;
179 }
180
181 @JSONField(serialize = false)
182 public CouponType getFormatCouponType() {
183 for (CouponType couponType : CouponType.values()) {
184 if (couponType.getVal() == this.couponType) {
185 return couponType;
186 }
187 }
188 return null;
189 }
190
191 public void setCouponType(int couponType) {
192 this.couponType = couponType;
193 }
194
195 public int getCouponStockStatus() {
196 return couponStockStatus;
197 }
198
199 @JSONField(serialize = false)
200 public CouponStockStatus getFormatCouponStockStatus() {
201 for (CouponStockStatus couponStockStatus : CouponStockStatus.values()) {
202 if (couponStockStatus.getVal() == this.couponStockStatus) {
203 return couponStockStatus;
204 }
205 }
206 return null;
207 }
208
209 public void setCouponStockStatus(int couponStockStatus) {
210 this.couponStockStatus = couponStockStatus;
211 }
212
213 public int getCouponTotal() {
214 return couponTotal;
215 }
216
217 public void setCouponTotal(int couponTotal) {
218 this.couponTotal = couponTotal;
219 }
220
221 public Integer getMaxQuota() {
222 return maxQuota;
223 }
224
225 public void setMaxQuota(Integer maxQuota) {
226 this.maxQuota = maxQuota;
227 }
228
229
230
231
232
233
234 @JSONField(serialize = false)
235 public double getFormatMaxQuota() {
236 return maxQuota != null ? maxQuota.intValue() / 100d : 0d;
237 }
238
239 public Integer getLockedNum() {
240 return lockedNum;
241 }
242
243 public void setLockedNum(Integer lockedNum) {
244 this.lockedNum = lockedNum;
245 }
246
247
248
249
250
251
252 @JSONField(serialize = false)
253 public double getFormatLockedNum() {
254 return lockedNum != null ? lockedNum.intValue() / 100d : 0d;
255 }
256
257 public Integer getUsedNum() {
258 return usedNum;
259 }
260
261 public void setUsedNum(Integer usedNum) {
262 this.usedNum = usedNum;
263 }
264
265
266
267
268
269
270 @JSONField(serialize = false)
271 public double getFormatUsedNum() {
272 return usedNum != null ? usedNum.intValue() / 100d : 0d;
273 }
274
275 public Integer getSendNum() {
276 return sendNum;
277 }
278
279 public void setSendNum(Integer sendNum) {
280 this.sendNum = sendNum;
281 }
282
283
284
285
286
287
288 @JSONField(serialize = false)
289 public double getFormatSendNum() {
290 return sendNum != null ? sendNum.intValue() / 100d : 0d;
291 }
292
293 public String getBeginTime() {
294 return beginTime;
295 }
296
297 public void setBeginTime(String beginTime) {
298 this.beginTime = beginTime;
299 }
300
301 @JSONField(serialize = false)
302 public Date getFormatBeginTime() {
303 return beginTime != null ? DateUtil.parse2yyyyMMddHHmmss(beginTime)
304 : null;
305 }
306
307 public String getEndTime() {
308 return endTime;
309 }
310
311 public void setEndTime(String endTime) {
312 this.endTime = endTime;
313 }
314
315 @JSONField(serialize = false)
316 public Date getFormatEndTime() {
317 return endTime != null ? DateUtil.parse2yyyyMMddHHmmss(endTime) : null;
318 }
319
320 public String getCreateTime() {
321 return createTime;
322 }
323
324 public void setCreateTime(String createTime) {
325 this.createTime = createTime;
326 }
327
328 @JSONField(serialize = false)
329 public Date getFormatCreateTime() {
330 return createTime != null ? DateUtil.parse2yyyyMMddHHmmss(createTime)
331 : null;
332 }
333
334 public Integer getCouponBudget() {
335 return couponBudget;
336 }
337
338 public void setCouponBudget(Integer couponBudget) {
339 this.couponBudget = couponBudget;
340 }
341
342
343
344
345
346
347 @JSONField(serialize = false)
348 public double getFormatCouponBudget() {
349 return couponBudget != null ? couponBudget.intValue() / 100d : 0d;
350 }
351
352 @Override
353 public String toString() {
354 return "CouponDetail [couponStockId=" + couponStockId + ", couponName="
355 + couponName + ", couponValue=" + getFormatCouponValue()
356 + ", couponMininumn=" + getFormatCouponMininumn()
357 + ", couponType=" + getFormatCouponType()
358 + ", couponStockStatus=" + getFormatCouponStockStatus()
359 + ", couponTotal=" + couponTotal + ", maxQuota="
360 + getFormatMaxQuota() + ", lockedNum=" + getFormatLockedNum()
361 + ", usedNum=" + getFormatUsedNum() + ", sendNum="
362 + getFormatSendNum() + ", beginTime=" + beginTime
363 + ", endTime=" + endTime + ", createTime=" + createTime
364 + ", couponBudget=" + getFormatCouponBudget() + ", "
365 + super.toString() + "]";
366 }
367 }