View Javadoc
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   * @className CouponStock
20   * @author jinyu(foxinmy@gmail.com)
21   * @date 2015年3月27日
22   * @since JDK 1.6
23   * @see
24   * @deprecated 迁移到子模块weixin4j-pay
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  	 * 代金券批次ID
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  	 * 代金券类型:1-代金券无门槛,2-代金券有门槛互斥,3-代金券有门槛叠加
59  	 */
60  	@XmlElement(name = "coupon_type")
61  	@JSONField(name = "coupon_type")
62  	private int couponType;
63  	/**
64  	 * 批次状态: 1-未激活;2-审批中;4-已激活;8-已作废;16-中止发放;
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  	 * 代金券每个人最多能领取的数量, 如果为0,则表示没有限制
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 	 * 生效开始时间 格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
101 	 */
102 	@XmlElement(name = "begin_time")
103 	@JSONField(name = "begin_time")
104 	private String beginTime;
105 	/**
106 	 * 生效结束时间 格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
107 	 */
108 	@XmlElement(name = "end_time")
109 	@JSONField(name = "end_time")
110 	private String endTime;
111 	/**
112 	 * 创建时间 格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
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 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
142 	 * 
143 	 * @return 元单位
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 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
156 	 * 
157 	 * @return 元单位
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 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
202 	 * 
203 	 * @return 元单位
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 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
216 	 * 
217 	 * @return 元单位
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 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
230 	 * 
231 	 * @return 元单位
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 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
244 	 * 
245 	 * @return 元单位
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 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
287 	 * 
288 	 * @return 元单位
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 }