View Javadoc
1   package com.foxinmy.weixin4j.mp.oldpayment;
2   
3   import javax.xml.bind.annotation.XmlAccessType;
4   import javax.xml.bind.annotation.XmlAccessorType;
5   import javax.xml.bind.annotation.XmlElement;
6   import javax.xml.bind.annotation.XmlRootElement;
7   
8   import com.alibaba.fastjson.annotation.JSONField;
9   import com.foxinmy.weixin4j.type.mch.RefundChannel;
10  import com.foxinmy.weixin4j.type.mch.RefundStatus;
11  
12  /**
13   * V2退款详细
14   * 
15   * @className RefundDetailV2
16   * @author jinyu(foxinmy@gmail.com)
17   * @date 2014年11月6日
18   * @since JDK 1.6
19   * @see
20   */
21  @XmlRootElement
22  @XmlAccessorType(XmlAccessType.FIELD)
23  public class RefundDetailV2 extends ApiResultV2 {
24  
25  	private static final long serialVersionUID = -3687863914168618620L;
26  
27  	/**
28  	 * 商户退款单号
29  	 */
30  	@XmlElement(name = "out_refund_no")
31  	@JSONField(name = "out_refund_no")
32  	private String outRefundNo;
33  	/**
34  	 * 微信退款单号
35  	 */
36  	@XmlElement(name = "refund_id")
37  	@JSONField(name = "refund_id")
38  	private String refundId;
39  	/**
40  	 * 退款渠道 0:退到财付通、1:退到银行;
41  	 */
42  	@XmlElement(name = "refund_channel")
43  	@JSONField(name = "refund_channel")
44  	private int refundChannel;
45  	/**
46  	 * 退款总金额,单位为分,可以做部分退款
47  	 */
48  	@XmlElement(name = "refund_fee")
49  	@JSONField(name = "refund_fee")
50  	private int refundFee;
51  	/**
52  	 * 退款状态
53  	 */
54  	@XmlElement(name = "refund_status")
55  	@JSONField(name = "refund_status")
56  	private int refundStatus;
57  	/**
58  	 * 转账退款接收退款的财付通帐号
59  	 */
60  	@XmlElement(name = "recv_user_id")
61  	@JSONField(name = "recv_user_id")
62  	private String recvUserId;
63  	/**
64  	 * 转账退款接收退款的姓名(需与接收退款的财付通帐号绑定的姓名一致)
65  	 */
66  	@XmlElement(name = "reccv_user_name")
67  	@JSONField(name = "reccv_user_name")
68  	private String reccvUserName;
69  
70  	protected RefundDetailV2() {
71  		// jaxb required
72  	}
73  
74  	public String getOutRefundNo() {
75  		return outRefundNo;
76  	}
77  
78  	public String getRefundId() {
79  		return refundId;
80  	}
81  
82  	public int getRefundChannel() {
83  		return refundChannel;
84  	}
85  
86  	@JSONField(serialize = false)
87  	public RefundChannel getFormatRefundChannel() {
88  		if (refundChannel == 0) {
89  			return RefundChannel.TENPAY;
90  		} else if (refundChannel == 1) {
91  			return RefundChannel.BANK;
92  		} else {
93  			return null;
94  		}
95  	}
96  
97  	public int getRefundFee() {
98  		return refundFee;
99  	}
100 
101 	/**
102 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
103 	 * 
104 	 * @return 元单位
105 	 */
106 	@JSONField(serialize = false)
107 	public double getFormatRefundFee() {
108 		return refundFee / 100d;
109 	}
110 
111 	public int getRefundStatus() {
112 		return refundStatus;
113 	}
114 
115 	@JSONField(serialize = false)
116 	public RefundStatus getFormatRefundStatus() {
117 		String refundStatus_ = String.format(",%d,", refundStatus);
118 		if (",4,10,".contains(refundStatus_)) {
119 			return RefundStatus.SUCCESS;
120 		} else if (",3,5,6,".contains(refundStatus_)) {
121 			return RefundStatus.FAIL;
122 		} else if (",8,9,11,".contains(refundStatus_)) {
123 			return RefundStatus.PROCESSING;
124 		} else if (",1,2,".contains(refundStatus_)) {
125 			return RefundStatus.NOTSURE;
126 		} else if (",7,".contains(refundStatus_)) {
127 			return RefundStatus.CHANGE;
128 		} else {
129 			return null;
130 		}
131 	}
132 
133 	public String getRecvUserId() {
134 		return recvUserId;
135 	}
136 
137 	public String getReccvUserName() {
138 		return reccvUserName;
139 	}
140 
141 	@Override
142 	public String toString() {
143 		return "outRefundNo=" + outRefundNo + ", refundId=" + refundId
144 				+ ", refundChannel=" + refundChannel + ", refundFee="
145 				+ refundFee + ", refundStatus=" + refundStatus
146 				+ ", recvUserId=" + recvUserId + ", reccvUserName="
147 				+ reccvUserName + ", refundChannel=" + getFormatRefundChannel()
148 				+ ", refundFee=" + getFormatRefundFee() + ", refundStatus="
149 				+ getFormatRefundStatus();
150 	}
151 }