Skip to content

Commit bceabfb

Browse files
committed
完善优化调试企业付款接口
1 parent ab5f573 commit bceabfb

File tree

2 files changed

+200
-68
lines changed

2 files changed

+200
-68
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxEntPayRequest.java

Lines changed: 191 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
package com.github.binarywang.wxpay.bean.request;
22

33
import com.thoughtworks.xstream.annotations.XStreamAlias;
4+
import me.chanjar.weixin.common.annotation.Required;
45
import me.chanjar.weixin.common.util.ToStringUtils;
56

67
/**
78
* <pre>
89
* 企业付款请求对象
9-
* 注释中各行每个字段描述对应如下:
10-
* <li>字段名
11-
* <li>变量名
12-
* <li>是否必填
13-
* <li>类型
14-
* <li>示例值
15-
* <li>描述
1610
* </pre>
1711
* Created by Binary Wang on 2016/10/02.
1812
*
@@ -22,92 +16,95 @@
2216
public class WxEntPayRequest extends WxPayBaseRequest {
2317
/**
2418
* <pre>
25-
* 公众账号appid
26-
* mch_appid
27-
* 是
28-
* wx8888888888888888
29-
* String
30-
* 微信分配的公众账号ID(企业号corpid即为此appId)
19+
* 字段名:公众账号appid
20+
* 变量名:mch_appid
21+
* 是否必填:
22+
* 示例值:wx8888888888888888
23+
* 类型:String
24+
* 描述:微信分配的公众账号ID(企业号corpid即为此appId)
3125
* </pre>
3226
*/
3327
@XStreamAlias("mch_appid")
3428
private String mchAppid;
3529

3630
/**
3731
* <pre>
38-
* 商户号
39-
* mchid
40-
*
41-
* 1900000109
42-
* String(32)
43-
* 微信支付分配的商户号
32+
* 字段名:商户号
33+
* 变量名:mchid
34+
* 是否必填:
35+
* 示例值:1900000109
36+
* 类型:String(32)
37+
* 描述:微信支付分配的商户号
4438
* </pre>
4539
*/
4640
@XStreamAlias("mchid")
4741
private String mchId;
4842

4943
/**
5044
* <pre>
51-
* 设备号
52-
* device_info
53-
* 否
54-
* 13467007045764
55-
* String(32)
56-
* 微信支付分配的终端设备号
45+
* 字段名:设备号
46+
* 变量名:device_info
47+
* 是否必填:
48+
* 示例值:13467007045764
49+
* 类型:String(32)
50+
* 描述:微信支付分配的终端设备号
5751
* </pre>
5852
*/
5953
@XStreamAlias("device_info")
6054
private String deviceInfo;
6155

6256
/**
6357
* <pre>
64-
* 商户订单号
65-
* partner_trade_no
66-
* 是
67-
* 10000098201411111234567890
68-
* String
69-
* 商户订单号
58+
* 字段名:商户订单号
59+
* 变量名:partner_trade_no
60+
* 是否必填:
61+
* 示例值:10000098201411111234567890
62+
* 类型:String
63+
* 描述:商户订单号
7064
* </pre>
7165
*/
66+
@Required
7267
@XStreamAlias("partner_trade_no")
7368
private String partnerTradeNo;
7469

7570
/**
7671
* <pre>
77-
* 需保持唯一性 用户openid
78-
* openid
79-
* 是
80-
* oxTWIuGaIt6gTKsQRLau2M0yL16E
81-
* String
82-
* 商户appid下,某用户的openid
72+
* 字段名:需保持唯一性 用户openid
73+
* 变量名:openid
74+
* 是否必填:
75+
* 示例值:oxTWIuGaIt6gTKsQRLau2M0yL16E
76+
* 类型:String
77+
* 描述:商户appid下,某用户的openid
8378
* </pre>
8479
*/
80+
@Required
8581
@XStreamAlias("openid")
8682
private String openid;
8783

8884
/**
8985
* <pre>
90-
* 校验用户姓名选项
91-
* check_name
92-
* 是
93-
* OPTION_CHECK
94-
* String
95-
* NO_CHECK:不校验真实姓名 
86+
* 字段名:校验用户姓名选项
87+
* 变量名:check_name
88+
* 是否必填:
89+
* 示例值:OPTION_CHECK
90+
* 类型:String
91+
* 描述:NO_CHECK:不校验真实姓名 
9692
* FORCE_CHECK:强校验真实姓名(未实名认证的用户会校验失败,无法转账) 
9793
* OPTION_CHECK:针对已实名认证的用户才校验真实姓名(未实名认证用户不校验,可以转账成功)
9894
* </pre>
9995
*/
96+
@Required
10097
@XStreamAlias("check_name")
10198
private String checkName;
10299

103100
/**
104101
* <pre>
105-
* 收款用户姓名
106-
* re_user_name
107-
* 可选
108-
* 马花花
109-
* String
110-
* 收款用户真实姓名。
102+
* 字段名:收款用户姓名
103+
* 变量名:re_user_name
104+
* 是否必填:可选
105+
* 示例值:马花花
106+
* 类型:String
107+
* 描述:收款用户真实姓名。
111108
* 如果check_name设置为FORCE_CHECK或OPTION_CHECK, 则必填用户真实姓名
112109
* </pre>
113110
*/
@@ -116,43 +113,71 @@ public class WxEntPayRequest extends WxPayBaseRequest {
116113

117114
/**
118115
* <pre>
119-
* 金额
120-
* amount
121-
* 是
122-
* 10099
123-
* int
124-
* 企业付款金额, 单位为分
116+
* 字段名:金额
117+
* 变量名:amount
118+
* 是否必填:
119+
* 示例值:10099
120+
* 类型:int
121+
* 描述:企业付款金额, 单位为分
125122
* </pre>
126123
*/
124+
@Required
127125
@XStreamAlias("amount")
128126
private Integer amount;
129127

130128
/**
131129
* <pre>
132-
* 企业付款描述信息
133-
* desc
134-
* 是
135-
* 理赔
136-
* String
137-
* 企业付款操作说明信息。必填。
130+
* 字段名:企业付款描述信息
131+
* 变量名:desc
132+
* 是否必填:
133+
* 示例值:理赔
134+
* 类型:String
135+
* 描述:企业付款操作说明信息。必填。
138136
* </pre>
139137
*/
138+
@Required
140139
@XStreamAlias("desc")
141140
private String description;
142141

143142
/**
144143
* <pre>
145-
* Ip地址
146-
* spbill_create_ip
147-
* 是
148-
* 192.168.0.1
149-
* String(32)
150-
* 调用接口的机器Ip地址
144+
* 字段名:Ip地址
145+
* 变量名:spbill_create_ip
146+
* 是否必填:
147+
* 示例值:192.168.0.1
148+
* 类型:String(32)
149+
* 描述:调用接口的机器Ip地址
151150
* </pre>
152151
*/
152+
@Required
153153
@XStreamAlias("spbill_create_ip")
154154
private String spbillCreateIp;
155155

156+
public WxEntPayRequest() {
157+
}
158+
159+
private WxEntPayRequest(Builder builder) {
160+
setAppid(builder.appid);
161+
setMchId(builder.mchId);
162+
setSubAppId(builder.subAppId);
163+
setSubMchId(builder.subMchId);
164+
setNonceStr(builder.nonceStr);
165+
setSign(builder.sign);
166+
mchAppid = builder.mchAppid;
167+
setMchId(builder.mchId);
168+
setDeviceInfo(builder.deviceInfo);
169+
setPartnerTradeNo(builder.partnerTradeNo);
170+
setOpenid(builder.openid);
171+
setCheckName(builder.checkName);
172+
setReUserName(builder.reUserName);
173+
setAmount(builder.amount);
174+
setDescription(builder.description);
175+
setSpbillCreateIp(builder.spbillCreateIp);
176+
}
177+
178+
public static Builder newBuilder() {
179+
return new Builder();
180+
}
156181

157182
@Override
158183
protected void checkConstraints() {
@@ -248,4 +273,103 @@ public String toString() {
248273
return ToStringUtils.toSimpleString(this);
249274
}
250275

276+
public static final class Builder {
277+
private String appid;
278+
private String mchId;
279+
private String deviceInfo;
280+
private String partnerTradeNo;
281+
private String openid;
282+
private String checkName;
283+
private String reUserName;
284+
private Integer amount;
285+
private String description;
286+
private String spbillCreateIp;
287+
private String subAppId;
288+
private String subMchId;
289+
private String nonceStr;
290+
private String sign;
291+
private String mchAppid;
292+
293+
private Builder() {
294+
}
295+
296+
public Builder appid(String appid) {
297+
this.appid = appid;
298+
return this;
299+
}
300+
301+
public Builder mchId(String mchId) {
302+
this.mchId = mchId;
303+
return this;
304+
}
305+
306+
public Builder deviceInfo(String deviceInfo) {
307+
this.deviceInfo = deviceInfo;
308+
return this;
309+
}
310+
311+
public Builder partnerTradeNo(String partnerTradeNo) {
312+
this.partnerTradeNo = partnerTradeNo;
313+
return this;
314+
}
315+
316+
public Builder openid(String openid) {
317+
this.openid = openid;
318+
return this;
319+
}
320+
321+
public Builder checkName(String checkName) {
322+
this.checkName = checkName;
323+
return this;
324+
}
325+
326+
public Builder reUserName(String reUserName) {
327+
this.reUserName = reUserName;
328+
return this;
329+
}
330+
331+
public Builder amount(Integer amount) {
332+
this.amount = amount;
333+
return this;
334+
}
335+
336+
public Builder description(String description) {
337+
this.description = description;
338+
return this;
339+
}
340+
341+
public Builder spbillCreateIp(String spbillCreateIp) {
342+
this.spbillCreateIp = spbillCreateIp;
343+
return this;
344+
}
345+
346+
public WxEntPayRequest build() {
347+
return new WxEntPayRequest(this);
348+
}
349+
350+
public Builder subAppId(String subAppId) {
351+
this.subAppId = subAppId;
352+
return this;
353+
}
354+
355+
public Builder subMchId(String subMchId) {
356+
this.subMchId = subMchId;
357+
return this;
358+
}
359+
360+
public Builder nonceStr(String nonceStr) {
361+
this.nonceStr = nonceStr;
362+
return this;
363+
}
364+
365+
public Builder sign(String sign) {
366+
this.sign = sign;
367+
return this;
368+
}
369+
370+
public Builder mchAppid(String mchAppid) {
371+
this.mchAppid = mchAppid;
372+
return this;
373+
}
374+
}
251375
}

weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,15 @@ public void testCloseOrder() throws WxPayException {
170170
*/
171171
@Test
172172
public void testEntPay() throws WxPayException {
173-
WxEntPayRequest request = new WxEntPayRequest();
173+
WxEntPayRequest request = WxEntPayRequest.newBuilder()
174+
.partnerTradeNo("Eb6Aep7uVTdbkJqrP4")
175+
.openid("ojOQA0y9o-Eb6Aep7uVTdbkJqrP4")
176+
.amount(1)
177+
.spbillCreateIp("10.10.10.10")
178+
.checkName("NO_CHECK")
179+
.description("描述信息")
180+
.build();
181+
174182
this.logger.info(this.payService.entPay(request).toString());
175183
}
176184

0 commit comments

Comments
 (0)