View Javadoc
1   package com.foxinmy.weixin4j.pay.payment.coupon;
2   
3   import com.alibaba.fastjson.annotation.JSONField;
4   import com.foxinmy.weixin4j.pay.type.mch.CouponType;
5   
6   import javax.xml.bind.annotation.XmlAccessType;
7   import javax.xml.bind.annotation.XmlAccessorType;
8   import javax.xml.bind.annotation.XmlElement;
9   import javax.xml.bind.annotation.XmlRootElement;
10  import java.io.Serializable;
11  
12  /**
13   * 订单代金券信息
14   * 
15   * @className OrderCouponInfo
16   * @author jinyu(foxinmy@gmail.com)
17   * @date 2015年3月24日
18   * @since JDK 1.6
19   * @see
20   */
21  @XmlRootElement
22  @XmlAccessorType(XmlAccessType.FIELD)
23  public class OrderCouponInfo implements Serializable {
24  
25  	private static final long serialVersionUID = -8744999305258786901L;
26  
27  	/**
28  	 * 代金券或立减优惠批次ID
29  	 */
30  	@XmlElement(name = "coupon_batch_id")
31  	@JSONField(name = "coupon_batch_id")
32  	private String couponBatchId;
33  	/**
34  	 * 代金券类型
35  	 * 
36  	 * @see CouponType
37  	 */
38  	@XmlElement(name = "coupon_type")
39  	@JSONField(name = "coupon_type")
40  	private String couponType;
41  	/**
42  	 * 代金券或立减优惠ID
43  	 */
44  	@XmlElement(name = "coupon_id")
45  	@JSONField(name = "coupon_id")
46  	private String couponId;
47  	/**
48  	 * 单个代金券或立减优惠支付金额
49  	 */
50  	@XmlElement(name = "coupon_fee")
51  	@JSONField(name = "coupon_fee")
52  	private Integer couponFee;
53  
54  	protected OrderCouponInfo() {
55  		// jaxb requried
56  	}
57  
58  	public String getCouponBatchId() {
59  		return couponBatchId;
60  	}
61  
62  	public void setCouponBatchId(String couponBatchId) {
63  		this.couponBatchId = couponBatchId;
64  	}
65  
66  	public String getCouponType() {
67  		return couponType;
68  	}
69  
70  	public void setCouponType(String couponType) {
71  		this.couponType = couponType;
72  	}
73  
74  	@JSONField(serialize = false)
75  	public CouponType getFormatCouponType() {
76  		return couponType != null ? CouponType
77  				.valueOf(couponType.toUpperCase()) : null;
78  	}
79  
80  	public String getCouponId() {
81  		return couponId;
82  	}
83  
84  	public void setCouponId(String couponId) {
85  		this.couponId = couponId;
86  	}
87  
88  	public Integer getCouponFee() {
89  		return couponFee;
90  	}
91  
92  	public void setCouponFee(Integer couponFee) {
93  		this.couponFee = couponFee;
94  	}
95  
96  	/**
97  	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
98  	 * 
99  	 * @return 元单位
100 	 */
101 	@JSONField(serialize = false)
102 	public double getFormatCouponFee() {
103 		return couponFee != null ? couponFee.doubleValue() / 100d : 0d;
104 	}
105 
106 	@Override
107 	public String toString() {
108 		return "couponBatchId=" + couponBatchId + ", couponType=" + couponType
109 				+ ", couponId=" + couponId + ", couponFee=" + couponFee;
110 	}
111 }