View Javadoc
1   package com.foxinmy.weixin4j.pay.payment.mch;
2   
3   import com.alibaba.fastjson.annotation.JSONField;
4   import com.foxinmy.weixin4j.pay.type.mch.CorpPaymentCheckNameType;
5   import com.foxinmy.weixin4j.util.DateUtil;
6   
7   import javax.xml.bind.annotation.XmlAccessType;
8   import javax.xml.bind.annotation.XmlAccessorType;
9   import javax.xml.bind.annotation.XmlElement;
10  import javax.xml.bind.annotation.XmlRootElement;
11  import java.util.Date;
12  
13  /**
14   * 企业付款记录
15   * 
16   * @className CorpPaymentRecord
17   * @author jinyu(foxinmy@gmail.com)
18   * @date 2015年6月23日
19   * @since JDK 1.6
20   * @see
21   */
22  @XmlRootElement
23  @XmlAccessorType(XmlAccessType.FIELD)
24  public class CorpPaymentRecord extends MerchantResult {
25  
26  	private static final long serialVersionUID = -1926873539419750498L;
27  
28  	/**
29  	 * 微信订单订单号
30  	 */
31  	@JSONField(name = "detail_id")
32  	@XmlElement(name = "detail_id")
33  	private String transactionId;
34  	/**
35  	 * 商户订单号
36  	 */
37  	@JSONField(name = "partner_trade_no")
38  	@XmlElement(name = "partner_trade_no")
39  	private String outTradeNo;
40  	/**
41  	 * 交易状态 SUCCESS:转账成功 FAILED:转账失败
42  	 */
43  	@JSONField(name = "status")
44  	@XmlElement(name = "status")
45  	private String transactionStatus;
46  	/**
47  	 * 如果失败则应该有原因
48  	 */
49  	@JSONField(name = "reason")
50  	@XmlElement(name = "reason")
51  	private String failureReason;
52  	/**
53  	 * 收款用户openid
54  	 */
55  	@JSONField(name = "openid")
56  	@XmlElement(name = "openid")
57  	private String openId;
58  	/**
59  	 * 收款用户姓名
60  	 */
61  	@JSONField(name = "transfer_name")
62  	@XmlElement(name = "transfer_name")
63  	private String transferName;
64  	/**
65  	 * 付款金额(单位为分)
66  	 */
67  	@JSONField(name = "payment_amount")
68  	@XmlElement(name = "payment_amount")
69  	private int paymentAmount;
70  	/**
71  	 * 转账时间
72  	 */
73  	@JSONField(name = "transfer_time")
74  	@XmlElement(name = "transfer_time")
75  	private String transferTime;
76  	/**
77  	 * 校验用户姓名选项
78  	 * 
79  	 * @see CorpPaymentCheckNameType
80  	 */
81  	@XmlElement(name = "check_name")
82  	@JSONField(name = "check_name")
83  	private String checkNameType;
84  	/**
85  	 * 企业付款描述信息
86  	 */
87  	@XmlElement(name = "desc")
88  	private String desc;
89  	/**
90  	 * 实名验证结果 PASS:通过 FAILED:不通过
91  	 */
92  	@JSONField(name = "check_name_result")
93  	@XmlElement(name = "check_name_result")
94  	private String checkNameResult;
95  
96  	protected CorpPaymentRecord() {
97  		// jaxb required
98  	}
99  
100 	public String getTransactionId() {
101 		return transactionId;
102 	}
103 
104 	public void setTransactionId(String transactionId) {
105 		this.transactionId = transactionId;
106 	}
107 
108 	public String getOutTradeNo() {
109 		return outTradeNo;
110 	}
111 
112 	public void setOutTradeNo(String outTradeNo) {
113 		this.outTradeNo = outTradeNo;
114 	}
115 
116 	public String getTransactionStatus() {
117 		return transactionStatus;
118 	}
119 
120 	public void setTransactionStatus(String transactionStatus) {
121 		this.transactionStatus = transactionStatus;
122 	}
123 
124 	/**
125 	 * 格式化交易状态
126 	 * 
127 	 * @return
128 	 */
129 	@JSONField(serialize = false)
130 	public boolean getFormatTransactionStatus() {
131 		return "success".equalsIgnoreCase(transactionStatus);
132 	}
133 
134 	public String getFailureReason() {
135 		return failureReason;
136 	}
137 
138 	public void setFailureReason(String failureReason) {
139 		this.failureReason = failureReason;
140 	}
141 
142 	public String getOpenId() {
143 		return openId;
144 	}
145 
146 	public void setOpenId(String openId) {
147 		this.openId = openId;
148 	}
149 
150 	public String getTransferName() {
151 		return transferName;
152 	}
153 
154 	public void setTransferName(String transferName) {
155 		this.transferName = transferName;
156 	}
157 
158 	public int getPaymentAmount() {
159 		return paymentAmount;
160 	}
161 
162 	public void setPaymentAmount(int paymentAmount) {
163 		this.paymentAmount = paymentAmount;
164 	}
165 
166 	/**
167 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
168 	 * 
169 	 * @return 元单位
170 	 */
171 	@JSONField(serialize = false)
172 	public double getFormatPaymentAmount() {
173 		return paymentAmount / 100d;
174 	}
175 
176 	public String getTransferTime() {
177 		return transferTime;
178 	}
179 
180 	public void setTransferTime(String transferTime) {
181 		this.transferTime = transferTime;
182 	}
183 
184 	/**
185 	 * 格式化转账时间
186 	 * 
187 	 * @return
188 	 */
189 	@JSONField(serialize = false)
190 	public Date getFormatTransferTime() {
191 		return transferTime != null ? DateUtil
192 				.parse2yyyyMMddHHmmss(transferTime) : null;
193 	}
194 
195 	public String getCheckNameType() {
196 		return checkNameType;
197 	}
198 
199 	public void setCheckNameType(String checkNameType) {
200 		this.checkNameType = checkNameType;
201 	}
202 
203 	@JSONField(serialize = false)
204 	public CorpPaymentCheckNameType getFormatCheckNameType() {
205 		return checkNameType != null ? CorpPaymentCheckNameType
206 				.valueOf(checkNameType) : null;
207 	}
208 
209 	public String getDesc() {
210 		return desc;
211 	}
212 
213 	public void setDesc(String desc) {
214 		this.desc = desc;
215 	}
216 
217 	public String getCheckNameResult() {
218 		return checkNameResult;
219 	}
220 
221 	public void setCheckNameResult(String checkNameResult) {
222 		this.checkNameResult = checkNameResult;
223 	}
224 
225 	/**
226 	 * 格式化交易状态
227 	 * 
228 	 * @return
229 	 */
230 	@JSONField(serialize = false)
231 	public boolean getFormatCheckNameResult() {
232 		return "pass".equalsIgnoreCase(checkNameResult);
233 	}
234 
235 	@Override
236 	public String toString() {
237 		return "CorpPaymentRecord [transactionId=" + transactionId
238 				+ ", outTradeNo=" + outTradeNo + ", transactionStatus="
239 				+ getFormatTransactionStatus() + ", failureReason="
240 				+ failureReason + ", openId=" + openId + ", transferName="
241 				+ transferName + ", paymentAmount=" + getFormatPaymentAmount()
242 				+ ", transferTime=" + transferTime + ", checkNameType="
243 				+ checkNameType + ", desc=" + desc + ", checkNameResult="
244 				+ getFormatCheckNameResult() + ", " + super.toString() + "]";
245 	}
246 }