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