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  
12  /**
13   * 企业付款
14   * 
15   * @className CorpPayment
16   * @author jinyu(foxinmy@gmail.com)
17   * @date 2015年4月1日
18   * @since JDK 1.6
19   * @see
20   */
21  @XmlRootElement
22  @XmlAccessorType(XmlAccessType.FIELD)
23  public class CorpPayment extends MerchantResult {
24  
25  	private static final long serialVersionUID = 3734639674346425312L;
26  	/**
27  	 * 商户订单号
28  	 */
29  	@XmlElement(name = "partner_trade_no")
30  	@JSONField(name = "partner_trade_no")
31  	private String outTradeNo;
32  	/**
33  	 * 接收红包的用户的openid
34  	 */
35  	@JSONField(name = "openid")
36  	@XmlElement(name = "openid")
37  	private String openId;
38  	/**
39  	 * 校验用户姓名选项
40  	 * 
41  	 * @see CorpPaymentCheckNameType
42  	 */
43  	@XmlElement(name = "check_name")
44  	@JSONField(name = "check_name")
45  	private CorpPaymentCheckNameType checkNameType;
46  	/**
47  	 * 收款用户真实姓名。 如果check_name设置为FORCE_CHECK或OPTION_CHECK,则必填用户真实姓名 可选
48  	 */
49  	@XmlElement(name = "re_user_name")
50  	@JSONField(name = "re_user_name")
51  	private String userName;
52  	/**
53  	 * 企业付款描述信息
54  	 */
55  	private String desc;
56  	/**
57  	 * 付款金额 单位分
58  	 */
59  	private int amount;
60  	/**
61  	 * 调用接口的机器Ip地址
62  	 */
63  	@XmlElement(name = "spbill_create_ip")
64  	@JSONField(name = "spbill_create_ip")
65  	private String clientIp;
66  
67  	protected CorpPayment() {
68  		// jaxb required
69  	}
70  
71  	/**
72  	 * 企业付款
73  	 * 
74  	 * @param outTradeNo
75  	 *            商户的订单号
76  	 * @param openId
77  	 *            用户的openid
78  	 * @param checkNameType
79  	 *            校验用户姓名选项
80  	 * @param desc
81  	 *            描述
82  	 * @param amount
83  	 *            金额 单位元
84  	 * @param clientIp
85  	 *            调用接口IP
86  	 */
87  	public CorpPayment(String outTradeNo, String openId,
88  			CorpPaymentCheckNameType checkNameType, String desc, double amount,
89  			String clientIp) {
90  		this.outTradeNo = outTradeNo;
91  		this.openId = openId;
92  		this.checkNameType = checkNameType;
93  		this.desc = desc;
94  		this.amount = DateUtil.formatYuan2Fen(amount);
95  		this.clientIp = clientIp;
96  	}
97  
98  	public String getOutTradeNo() {
99  		return outTradeNo;
100 	}
101 
102 	public void setOutTradeNo(String outTradeNo) {
103 		this.outTradeNo = outTradeNo;
104 	}
105 
106 	public String getOpenId() {
107 		return openId;
108 	}
109 
110 	public void setOpenId(String openId) {
111 		this.openId = openId;
112 	}
113 
114 	public CorpPaymentCheckNameType getCheckNameType() {
115 		return checkNameType;
116 	}
117 
118 	public void setCheckNameType(CorpPaymentCheckNameType checkNameType) {
119 		this.checkNameType = checkNameType;
120 	}
121 
122 	public String getUserName() {
123 		return userName;
124 	}
125 
126 	public void setUserName(String userName) {
127 		this.userName = userName;
128 	}
129 
130 	public String getDesc() {
131 		return desc;
132 	}
133 
134 	public void setDesc(String desc) {
135 		this.desc = desc;
136 	}
137 
138 	public int getAmount() {
139 		return amount;
140 	}
141 
142 	public void setAmount(int amount) {
143 		this.amount = amount;
144 	}
145 	
146 	/**
147 	 * <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
148 	 * 
149 	 * @return 元单位
150 	 */
151 	@JSONField(serialize = false)
152 	public double getFormatAmount() {
153 		return amount / 100d;
154 	}
155 
156 	public String getClientIp() {
157 		return clientIp;
158 	}
159 
160 	public void setClientIp(String clientIp) {
161 		this.clientIp = clientIp;
162 	}
163 
164 	@Override
165 	public String toString() {
166 		return "CorpPayment [outTradeNo=" + outTradeNo + ", openId=" + openId
167 				+ ", checkNameType=" + checkNameType + ", userName=" + userName
168 				+ ", desc=" + desc + ", amount=" + amount + ", clientIp="
169 				+ clientIp + ", " + super.toString() + "]";
170 	}
171 }