View Javadoc
1   package com.foxinmy.weixin4j.mp.oldpayment;
2   
3   import java.util.Date;
4   
5   import com.alibaba.fastjson.annotation.JSONField;
6   import com.foxinmy.weixin4j.type.CurrencyType;
7   import com.foxinmy.weixin4j.type.TradeState;
8   import com.foxinmy.weixin4j.util.DateUtil;
9   
10  /**
11   * V2订单信息
12   * 
13   * @className OrderV2
14   * @author jinyu(foxinmy@gmail.com)
15   * @date 2014年11月2日
16   * @since JDK 1.6
17   * @see
18   */
19  public class OrderV2 extends ApiResultV2 {
20  
21  	private static final long serialVersionUID = 4543552984506609920L;
22  
23  	/**
24  	 * 是订单状态,0 为成功,其他为失败;
25  	 */
26  	@JSONField(name = "trade_state")
27  	private int tradeState;
28  	/**
29  	 * 是交易模式,1 为即时到帐,其他保留;
30  	 */
31  	@JSONField(name = "trade_mode")
32  	private int tradeMode;
33  	/**
34  	 * 是银行类型;
35  	 */
36  	@JSONField(name = "bank_type")
37  	private String bankType;
38  	/**
39  	 * 是银行订单号;
40  	 */
41  	@JSONField(name = "bank_billno")
42  	private String bankBillno;
43  	/**
44  	 * 是总金额,单位为分;
45  	 */
46  	@JSONField(name = "total_fee")
47  	private int totalFee;
48  	/**
49  	 * 是币种,1 为人民币;
50  	 */
51  	@JSONField(name = "fee_type")
52  	private int feeType;
53  	/**
54  	 * 是财付通订单号;
55  	 */
56  	@JSONField(name = "transaction_id")
57  	private String transactionId;
58  	/**
59  	 * 是第三方订单号;
60  	 */
61  	@JSONField(name = "out_trade_no")
62  	private String outTradeNo;
63  	/**
64  	 * 表明是否分账,false 为无分账,true 为有分账;
65  	 */
66  	@JSONField(name = "is_split")
67  	private boolean isSplit;
68  	/**
69  	 * 表明是否退款,false 为无退款,ture 为退款;
70  	 */
71  	@JSONField(name = "is_refund")
72  	private boolean isRefund;
73  	/**
74  	 * attach 是商户数据包,即生成订单package 时商户填入的 attach;
75  	 */
76  	private String attach;
77  	/**
78  	 * 支付完成时间;
79  	 */
80  	@JSONField(name = "time_end")
81  	private String timeEnd;
82  	/**
83  	 * 物流费用,单位为分;
84  	 */
85  	@JSONField(name = "transport_fee")
86  	private int transportFee;
87  	/**
88  	 * 物品费用,单位为分;
89  	 */
90  	@JSONField(name = "product_fee")
91  	private int productFee;
92  	/**
93  	 * 折扣价格,单位为分;
94  	 */
95  	private int discount;
96  	/**
97  	 * 换算成人民币之后的总金额,单位为分,一般看 total_fee 即可。
98  	 */
99  	@JSONField(name = "rmb_total_fee")
100 	private Integer rmbTotalFee;
101 
102 	public int getTradeState() {
103 		return tradeState;
104 	}
105 
106 	@JSONField(serialize = false)
107 	public TradeState getFormatTradeState() {
108 		return tradeState == 0 ? TradeState.SUCCESS : null;
109 	}
110 
111 	public void setTradeState(int tradeState) {
112 		this.tradeState = tradeState;
113 	}
114 
115 	public int getTradeMode() {
116 		return tradeMode;
117 	}
118 
119 	public void setTradeMode(int tradeMode) {
120 		this.tradeMode = tradeMode;
121 	}
122 
123 	public String getBankType() {
124 		return bankType;
125 	}
126 
127 	public void setBankType(String bankType) {
128 		this.bankType = bankType;
129 	}
130 
131 	public String getBankBillno() {
132 		return bankBillno;
133 	}
134 
135 	public void setBankBillno(String bankBillno) {
136 		this.bankBillno = bankBillno;
137 	}
138 
139 	public int getTotalFee() {
140 		return totalFee;
141 	}
142 
143 	/**
144 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
145 	 * 
146 	 * @return 元单位
147 	 */
148 	@JSONField(serialize = false)
149 	public double getFormatTotalFee() {
150 		return totalFee / 100d;
151 	}
152 
153 	public void setTotalFee(int totalFee) {
154 		this.totalFee = totalFee;
155 	}
156 
157 	public int getFeeType() {
158 		return feeType;
159 	}
160 
161 	@JSONField(serialize = false)
162 	public CurrencyType getFormatFeeType() {
163 		return feeType == 1 ? CurrencyType.CNY : null;
164 	}
165 
166 	public void setFeeType(int feeType) {
167 		this.feeType = feeType;
168 	}
169 
170 	public String getTransactionId() {
171 		return transactionId;
172 	}
173 
174 	public void setTransactionId(String transactionId) {
175 		this.transactionId = transactionId;
176 	}
177 
178 	public String getOutTradeNo() {
179 		return outTradeNo;
180 	}
181 
182 	public void setOutTradeNo(String outTradeNo) {
183 		this.outTradeNo = outTradeNo;
184 	}
185 
186 	public boolean isSplit() {
187 		return isSplit;
188 	}
189 
190 	public void setSplit(boolean isSplit) {
191 		this.isSplit = isSplit;
192 	}
193 
194 	public boolean isRefund() {
195 		return isRefund;
196 	}
197 
198 	public void setRefund(boolean isRefund) {
199 		this.isRefund = isRefund;
200 	}
201 
202 	public String getAttach() {
203 		return attach;
204 	}
205 
206 	public void setAttach(String attach) {
207 		this.attach = attach;
208 	}
209 
210 	public String getTimeEnd() {
211 		return timeEnd;
212 	}
213 
214 	@JSONField(serialize = false)
215 	public Date getFormatTimeEnd() {
216 		return timeEnd != null ? DateUtil.parse2yyyyMMddHHmmss(timeEnd) : null;
217 	}
218 
219 	public void setTimeEnd(String timeEnd) {
220 		this.timeEnd = timeEnd;
221 	}
222 
223 	public int getTransportFee() {
224 		return transportFee;
225 	}
226 
227 	/**
228 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
229 	 * 
230 	 * @return 元单位
231 	 */
232 	@JSONField(serialize = false)
233 	public double getFormatTransportFee() {
234 		return transportFee / 100d;
235 	}
236 
237 	public void setTransportFee(int transportFee) {
238 		this.transportFee = transportFee;
239 	}
240 
241 	public int getProductFee() {
242 		return productFee;
243 	}
244 
245 	/**
246 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
247 	 * 
248 	 * @return 元单位
249 	 */
250 	@JSONField(serialize = false)
251 	public double getFormatProductFee() {
252 		return productFee / 100d;
253 	}
254 
255 	public void setProductFee(int productFee) {
256 		this.productFee = productFee;
257 	}
258 
259 	public int getDiscount() {
260 		return discount;
261 	}
262 
263 	/**
264 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
265 	 * 
266 	 * @return 元单位
267 	 */
268 	@JSONField(serialize = false)
269 	public double getFormatDiscount() {
270 		return discount / 100d;
271 	}
272 
273 	public void setDiscount(int discount) {
274 		this.discount = discount;
275 	}
276 
277 	public Integer getRmbTotalFee() {
278 		return rmbTotalFee;
279 	}
280 
281 	/**
282 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
283 	 * 
284 	 * @return 元单位
285 	 */
286 	@JSONField(serialize = false)
287 	public double getFormatRmbTotalFee() {
288 		return rmbTotalFee != null ? rmbTotalFee.doubleValue() / 100d : 0d;
289 	}
290 
291 	public void setRmbTotalFee(int rmbTotalFee) {
292 		this.rmbTotalFee = rmbTotalFee;
293 	}
294 
295 	@Override
296 	public String toString() {
297 		return "Order [tradeState=" + tradeState + ", tradeMode=" + tradeMode
298 				+ ", bankType=" + bankType + ", bankBillno=" + bankBillno
299 				+ ", totalFee=" + totalFee + ", feeType=" + feeType
300 				+ ", transactionId=" + transactionId + ", outTradeNo="
301 				+ outTradeNo + ", isSplit=" + isSplit + ", isRefund="
302 				+ isRefund + ", attach=" + attach + ", timeEnd=" + timeEnd
303 				+ ", transportFee=" + transportFee + ", productFee="
304 				+ productFee + ", discount=" + discount + ", rmbTotalFee="
305 				+ rmbTotalFee + ", tradeState=" + getFormatTradeState()
306 				+ ", totalFee=" + getFormatTotalFee() + ", feeType="
307 				+ getFormatFeeType() + ", timeEnd=" + getFormatTimeEnd()
308 				+ ", transportFee=" + getFormatTransportFee() + ", productFee="
309 				+ getFormatProductFee() + ", discount=" + getFormatDiscount()
310 				+ ", rmbTotalFee=" + getFormatRmbTotalFee() + ", "
311 				+ super.toString() + "]";
312 	}
313 }