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.CouponStatus;
13  import com.foxinmy.weixin4j.type.mch.CouponStockType;
14  import com.foxinmy.weixin4j.type.mch.CouponType;
15  import com.foxinmy.weixin4j.util.DateUtil;
16  
17  /**
18   * 代金券详细
19   * 
20   * @className CouponDetail
21   * @author jinyu(foxinmy@gmail.com)
22   * @date 2015年3月27日
23   * @since JDK 1.6
24   * @see
25   * @deprecated 迁移到子模块weixin4j-pay
26   */
27  @Deprecated
28  @XmlRootElement
29  @XmlAccessorType(XmlAccessType.FIELD)
30  public class CouponDetail extends MerchantResult {
31  
32  	private static final long serialVersionUID = -311265355895457070L;
33  
34  	/**
35  	 * 代金券批次Id
36  	 */
37  	@XmlElement(name = "coupon_stock_id")
38  	@JSONField(name = "coupon_stock_id")
39  	private String couponStockId;
40  
41  	/**
42  	 * 批次类型;1-批量型,2-触发型
43  	 */
44  	@XmlElement(name = "coupon_stock_type")
45  	@JSONField(name = "coupon_stock_type")
46  	private int couponStockType;
47  
48  	/**
49  	 * 代金券id
50  	 */
51  	@XmlElement(name = "coupon_id")
52  	@JSONField(name = "coupon_id")
53  	private String couponId;
54  	/**
55  	 * 代金券面值,单位是分
56  	 */
57  	@XmlElement(name = "coupon_value")
58  	@JSONField(name = "coupon_value")
59  	private int couponValue;
60  
61  	/**
62  	 * 代金券使用最低限额,单位是分
63  	 */
64  	@XmlElement(name = "coupon_mininum")
65  	@JSONField(name = "coupon_mininum")
66  	private int couponMininum;
67  	/**
68  	 * 代金券名称
69  	 */
70  	@XmlElement(name = "coupon_name")
71  	@JSONField(name = "coupon_name")
72  	private String couponName;
73  	/**
74  	 * 代金券状态:2-已激活,4-已锁定,8-已实扣
75  	 */
76  	@XmlElement(name = "coupon_state")
77  	@JSONField(name = "coupon_state")
78  	private int couponStatus;
79  	/**
80  	 * 代金券类型:1-代金券无门槛,2-代金券有门槛互斥,3-代金券有门槛叠加,
81  	 */
82  	@XmlElement(name = "coupon_type")
83  	@JSONField(name = "coupon_type")
84  	private int couponType;
85  	/**
86  	 * 代金券描述
87  	 */
88  	@XmlElement(name = "coupon_desc")
89  	@JSONField(name = "coupon_desc")
90  	private String couponDesc;
91  
92  	/**
93  	 * 代金券实际使用金额
94  	 */
95  	@XmlElement(name = "coupon_use_value")
96  	@JSONField(name = "coupon_use_value")
97  	private int couponUseValue;
98  
99  	/**
100 	 * 代金券剩余金额:部分使用情况下,可能会存在券剩余金额
101 	 */
102 	@XmlElement(name = "coupon_remain_value")
103 	@JSONField(name = "coupon_remain_value")
104 	private int couponRemainValue;
105 
106 	/**
107 	 * 生效开始时间:格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
108 	 */
109 	@XmlElement(name = "begin_time")
110 	@JSONField(name = "begin_time")
111 	private String beginTime;
112 
113 	/**
114 	 * 生效结束时间:格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
115 	 */
116 	@XmlElement(name = "end_time")
117 	@JSONField(name = "end_time")
118 	private String endTime;
119 
120 	/**
121 	 * 发放时间:格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
122 	 */
123 	@XmlElement(name = "send_time")
124 	@JSONField(name = "send_time")
125 	private String sendTime;
126 
127 	/**
128 	 * 使用时间:格式为yyyyMMddhhmmss,如2009年12月27日9点10分10秒表示为20091227091010。
129 	 */
130 	@XmlElement(name = "use_time")
131 	@JSONField(name = "use_time")
132 	private String useTime;
133 
134 	/**
135 	 * 使用单号:代金券使用后,关联的大单收单单号
136 	 */
137 	@XmlElement(name = "trade_no")
138 	@JSONField(name = "trade_no")
139 	private String tradeNo;
140 
141 	/**
142 	 * 消耗方商户id:代金券使用后,消耗方商户id
143 	 */
144 	@XmlElement(name = "consumer_mch_id")
145 	@JSONField(name = "consumer_mch_id")
146 	private String consumerMchId;
147 
148 	/**
149 	 * 消耗方商户名称:代金券使用后,消耗方商户名称
150 	 */
151 	@XmlElement(name = "consumer_mch_name")
152 	@JSONField(name = "consumer_mch_name")
153 	private String consumerMchName;
154 
155 	/**
156 	 * 消耗方商户appid:代金券使用后,消耗方商户appid
157 	 */
158 	@XmlElement(name = "consumer_mch_appid")
159 	@JSONField(name = "consumer_mch_appid")
160 	private String consumerMchAppid;
161 
162 	/**
163 	 * 发放来源:代金券发放来源
164 	 */
165 	@XmlElement(name = "send_source")
166 	@JSONField(name = "send_source")
167 	private String sendSource;
168 
169 	/**
170 	 * 是否允许部分使用:该代金券是否允许部分使用标识:1-表示支持部分使用
171 	 */
172 	@XmlElement(name = "is_partial_use")
173 	@JSONField(name = "is_partial_use")
174 	private int isPartialUse;
175 
176 	public CouponDetail() {
177 
178 	}
179 
180 	public String getCouponStockId() {
181 		return couponStockId;
182 	}
183 
184 	public int getCouponStockType() {
185 		return couponStockType;
186 	}
187 
188 	@JSONField(serialize = false)
189 	public CouponStockType getFormatCouponStockType() {
190 		for (CouponStockType couponStockType : CouponStockType.values()) {
191 			if (couponStockType.getVal() == this.couponStockType) {
192 				return couponStockType;
193 			}
194 		}
195 		return null;
196 	}
197 
198 	public String getCouponId() {
199 		return couponId;
200 	}
201 
202 	public int getCouponValue() {
203 		return couponValue;
204 	}
205 
206 	/**
207 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
208 	 * 
209 	 * @return 元单位
210 	 */
211 	@JSONField(serialize = false)
212 	public double getFormatCouponValue() {
213 		return couponValue / 100d;
214 	}
215 
216 	public int getCouponMininum() {
217 		return couponMininum;
218 	}
219 
220 	/**
221 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
222 	 * 
223 	 * @return 元单位
224 	 */
225 	@JSONField(serialize = false)
226 	public double getFormatCouponMininum() {
227 		return couponMininum / 100d;
228 	}
229 
230 	public String getCouponName() {
231 		return couponName;
232 	}
233 
234 	public int getCouponStatus() {
235 		return couponStatus;
236 	}
237 
238 	@JSONField(serialize = false)
239 	public CouponStatus getFormatCouponStatus() {
240 		for (CouponStatus couponStatus : CouponStatus.values()) {
241 			if (couponStatus.getVal() == this.couponStatus) {
242 				return couponStatus;
243 			}
244 		}
245 		return null;
246 	}
247 
248 	public int getCouponType() {
249 		return couponType;
250 	}
251 
252 	@JSONField(deserialize = false, serialize = false)
253 	public CouponType getFormatCouponType() {
254 		for (CouponType couponType : CouponType.values()) {
255 			if (couponType.getVal() == this.couponType) {
256 				return couponType;
257 			}
258 		}
259 		return null;
260 	}
261 
262 	public String getCouponDesc() {
263 		return couponDesc;
264 	}
265 
266 	public int getCouponUseValue() {
267 		return couponUseValue;
268 	}
269 
270 	/**
271 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
272 	 * 
273 	 * @return 元单位
274 	 */
275 	@JSONField(serialize = false)
276 	public double getFormatCouponUseValue() {
277 		return couponUseValue / 100d;
278 	}
279 
280 	public int getCouponRemainValue() {
281 		return couponRemainValue;
282 	}
283 
284 	/**
285 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
286 	 * 
287 	 * @return 元单位
288 	 */
289 	@JSONField(serialize = false)
290 	public double getFormatCouponRemainValue() {
291 		return couponRemainValue / 100d;
292 	}
293 
294 	public String getBeginTime() {
295 		return beginTime;
296 	}
297 
298 	@JSONField(serialize = false)
299 	public Date getFormatBeginTime() {
300 		return beginTime != null ? DateUtil.parse2yyyyMMddHHmmss(beginTime)
301 				: null;
302 	}
303 
304 	public String getEndTime() {
305 		return endTime;
306 	}
307 
308 	@JSONField(serialize = false)
309 	public Date getFormatEndTime() {
310 		return endTime != null ? DateUtil.parse2yyyyMMddHHmmss(endTime) : null;
311 	}
312 
313 	public String getSendTime() {
314 		return sendTime;
315 	}
316 
317 	@JSONField(serialize = false)
318 	public Date getFormatSendTime() {
319 		return sendTime != null ? DateUtil.parse2yyyyMMddHHmmss(sendTime)
320 				: null;
321 	}
322 
323 	public String getUseTime() {
324 		return useTime;
325 	}
326 
327 	@JSONField(serialize = false)
328 	public Date getFormatUseTime() {
329 		return useTime != null ? DateUtil.parse2yyyyMMddHHmmss(useTime) : null;
330 	}
331 
332 	public String getTradeNo() {
333 		return tradeNo;
334 	}
335 
336 	public String getConsumerMchId() {
337 		return consumerMchId;
338 	}
339 
340 	public String getConsumerMchName() {
341 		return consumerMchName;
342 	}
343 
344 	public String getConsumerMchAppid() {
345 		return consumerMchAppid;
346 	}
347 
348 	public String getSendSource() {
349 		return sendSource;
350 	}
351 
352 	public int getIsPartialUse() {
353 		return isPartialUse;
354 	}
355 
356 	@JSONField(serialize = false)
357 	public boolean getFormatIsPartialUse() {
358 		return isPartialUse == 1;
359 	}
360 
361 	@Override
362 	public String toString() {
363 		return "CouponDetail [couponStockId=" + couponStockId
364 				+ ", couponStockType=" + getFormatCouponStockType()
365 				+ ", couponId=" + couponId + ", couponValue="
366 				+ getFormatCouponValue() + ", couponMininum="
367 				+ getFormatCouponMininum() + ", couponName=" + couponName
368 				+ ", couponStatus=" + getCouponStatus() + ", couponType="
369 				+ getFormatCouponType() + ", couponDesc=" + couponDesc
370 				+ ", couponUseValue=" + getFormatCouponUseValue()
371 				+ ", couponRemainValue=" + getFormatCouponRemainValue()
372 				+ ", beginTime=" + getFormatBeginTime() + ", endTime="
373 				+ getFormatEndTime() + ", sendTime=" + getFormatSendTime()
374 				+ ", useTime=" + getFormatUseTime() + ", tradeNo=" + tradeNo
375 				+ ", consumerMchId=" + consumerMchId + ", consumerMchName="
376 				+ consumerMchName + ", consumerMchAppid=" + consumerMchAppid
377 				+ ", sendSource=" + sendSource + ", isPartialUse="
378 				+ getFormatIsPartialUse() + ", " + super.toString() + "]";
379 	}
380 }