Skip to content

Commit 61be67f

Browse files
committed
优化代码
1 parent 07ad931 commit 61be67f

File tree

3 files changed

+534
-564
lines changed

3 files changed

+534
-564
lines changed

.editorconfig

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
14+
15+
[Makefile]
16+
indent_style = tab
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,127 @@
1-
package com.github.binarywang.demo.wx.pay.controller;
2-
3-
import org.springframework.beans.factory.annotation.Autowired;
4-
import org.springframework.web.bind.annotation.GetMapping;
5-
import org.springframework.web.bind.annotation.PathVariable;
6-
import org.springframework.web.bind.annotation.PostMapping;
7-
import org.springframework.web.bind.annotation.RequestBody;
8-
import org.springframework.web.bind.annotation.RequestMapping;
9-
import org.springframework.web.bind.annotation.RestController;
10-
11-
import com.github.binarywang.wxpay.bean.entpay.EntPayBankQueryResult;
12-
import com.github.binarywang.wxpay.bean.entpay.EntPayBankRequest;
13-
import com.github.binarywang.wxpay.bean.entpay.EntPayBankResult;
14-
import com.github.binarywang.wxpay.bean.entpay.EntPayQueryResult;
15-
import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
16-
import com.github.binarywang.wxpay.bean.entpay.EntPayResult;
17-
import com.github.binarywang.wxpay.exception.WxPayException;
18-
import com.github.binarywang.wxpay.service.WxPayService;
19-
import io.swagger.annotations.Api;
20-
import io.swagger.annotations.ApiOperation;
21-
22-
/**
23-
* <pre>
24-
* 企业付款相关接口
25-
* Created by Binary Wang on 2018/9/27.
26-
* </pre>
27-
*
28-
* @author <a href="https://github.com/binarywang">Binary Wang</a>
29-
*/
30-
@Api("企业付款")
31-
@RequestMapping("/pay")
32-
@RestController
33-
public class EntPayController {
34-
private WxPayService wxService;
35-
36-
@Autowired
37-
public EntPayController(WxPayService wxService) {
38-
this.wxService = wxService;
39-
}
40-
41-
/**
42-
* <pre>
43-
* 企业付款业务是基于微信支付商户平台的资金管理能力,为了协助商户方便地实现企业向个人付款,针对部分有开发能力的商户,提供通过API完成企业付款的功能。
44-
* 比如目前的保险行业向客户退保、给付、理赔。
45-
* 企业付款将使用商户的可用余额,需确保可用余额充足。查看可用余额、充值、提现请登录商户平台“资金管理”https://pay.weixin.qq.com/进行操作。
46-
* 注意:与商户微信支付收款资金并非同一账户,需要单独充值。
47-
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
48-
* 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers
49-
* </pre>
50-
*
51-
* @param request 请求对象
52-
*/
53-
@ApiOperation(value = "企业付款到零钱")
54-
@PostMapping("/entPay")
55-
public EntPayResult entPay(@RequestBody EntPayRequest request) throws WxPayException {
56-
return this.wxService.getEntPayService().entPay(request);
57-
}
58-
59-
/**
60-
* <pre>
61-
* 查询企业付款API
62-
* 用于商户的企业付款操作进行结果查询,返回付款操作详细结果。
63-
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3
64-
* 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo
65-
* </pre>
66-
*
67-
* @param partnerTradeNo 商户订单号
68-
*/
69-
@ApiOperation(value = "查询企业付款到零钱的结果")
70-
@GetMapping("/queryEntPay/{partnerTradeNo}")
71-
public EntPayQueryResult queryEntPay(@PathVariable String partnerTradeNo) throws WxPayException {
72-
return this.wxService.getEntPayService().queryEntPay(partnerTradeNo);
73-
}
74-
75-
76-
/**
77-
* <pre>
78-
* 获取RSA加密公钥API.
79-
* RSA算法使用说明(非对称加密算法,算法采用RSA/ECB/OAEPPadding模式)
80-
* 1、 调用获取RSA公钥API获取RSA公钥,落地成本地文件,假设为public.pem
81-
* 2、 确定public.pem文件的存放路径,同时修改代码中文件的输入路径,加载RSA公钥
82-
* 3、 用标准的RSA加密库对敏感信息进行加密,选择RSA_PKCS1_OAEP_PADDING填充模式
83-
* (eg:Java的填充方式要选 " RSA/ECB/OAEPWITHSHA-1ANDMGF1PADDING")
84-
* 4、 得到进行rsa加密并转base64之后的密文
85-
* 5、 将密文传给微信侧相应字段,如付款接口(enc_bank_no/enc_true_name)
86-
*
87-
* 接口默认输出PKCS#1格式的公钥,商户需根据自己开发的语言选择公钥格式
88-
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_7&index=4
89-
* 接口链接:https://fraud.mch.weixin.qq.com/risk/getpublickey
90-
* </pre>
91-
*
92-
* @return the public key
93-
* @throws WxPayException the wx pay exception
94-
*/
95-
@ApiOperation(value = "获取RSA加密公钥")
96-
@GetMapping("/getPublicKey")
97-
public String getPublicKey() throws WxPayException {
98-
return this.wxService.getEntPayService().getPublicKey();
99-
}
100-
101-
/**
102-
* 企业付款到银行卡.
103-
* <pre>
104-
* 用于企业向微信用户银行卡付款
105-
* 目前支持接口API的方式向指定微信用户的银行卡付款。
106-
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_2
107-
* 接口链接:https://api.mch.weixin.qq.com/mmpaysptrans/pay_bank
108-
* </pre>
109-
*
110-
* @param request 请求对象
111-
* @return the ent pay bank result
112-
* @throws WxPayException the wx pay exception
113-
*/
114-
@ApiOperation(value = "企业付款到银行卡")
115-
@PostMapping("/payBank")
116-
public EntPayBankResult payBank(EntPayBankRequest request) throws WxPayException {
117-
return this.wxService.getEntPayService().payBank(request);
118-
}
119-
120-
/**
121-
* 企业付款到银行卡查询.
122-
* <pre>
123-
* 用于对商户企业付款到银行卡操作进行结果查询,返回付款操作详细结果。
124-
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_3
125-
* 接口链接:https://api.mch.weixin.qq.com/mmpaysptrans/query_bank
126-
* </pre>
127-
*
128-
* @param partnerTradeNo 商户订单号
129-
* @return the ent pay bank query result
130-
* @throws WxPayException the wx pay exception
131-
*/
132-
@ApiOperation(value = "查询企业付款到银行卡的结果")
133-
@GetMapping("/queryPayBank/{partnerTradeNo}")
134-
public EntPayBankQueryResult queryPayBank(@PathVariable String partnerTradeNo) throws WxPayException {
135-
return this.wxService.getEntPayService().queryPayBank(partnerTradeNo);
136-
}
137-
138-
}
1+
package com.github.binarywang.demo.wx.pay.controller;
2+
3+
import com.github.binarywang.wxpay.bean.entpay.*;
4+
import com.github.binarywang.wxpay.exception.WxPayException;
5+
import com.github.binarywang.wxpay.service.WxPayService;
6+
import io.swagger.annotations.Api;
7+
import io.swagger.annotations.ApiOperation;
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.web.bind.annotation.*;
10+
11+
/**
12+
* <pre>
13+
* 企业付款相关接口
14+
* Created by Binary Wang on 2018/9/27.
15+
* </pre>
16+
*
17+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
18+
*/
19+
@Api("企业付款")
20+
@RequestMapping("/pay")
21+
@RestController
22+
public class EntPayController {
23+
private WxPayService wxService;
24+
25+
@Autowired
26+
public EntPayController(WxPayService wxService) {
27+
this.wxService = wxService;
28+
}
29+
30+
/**
31+
* <pre>
32+
* 企业付款业务是基于微信支付商户平台的资金管理能力,为了协助商户方便地实现企业向个人付款,针对部分有开发能力的商户,提供通过API完成企业付款的功能。
33+
* 比如目前的保险行业向客户退保、给付、理赔。
34+
* 企业付款将使用商户的可用余额,需确保可用余额充足。查看可用余额、充值、提现请登录商户平台“资金管理”https://pay.weixin.qq.com/进行操作。
35+
* 注意:与商户微信支付收款资金并非同一账户,需要单独充值。
36+
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_2
37+
* 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers
38+
* </pre>
39+
*
40+
* @param request 请求对象
41+
*/
42+
@ApiOperation(value = "企业付款到零钱")
43+
@PostMapping("/entPay")
44+
public EntPayResult entPay(@RequestBody EntPayRequest request) throws WxPayException {
45+
return this.wxService.getEntPayService().entPay(request);
46+
}
47+
48+
/**
49+
* <pre>
50+
* 查询企业付款API
51+
* 用于商户的企业付款操作进行结果查询,返回付款操作详细结果。
52+
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=14_3
53+
* 接口链接:https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo
54+
* </pre>
55+
*
56+
* @param partnerTradeNo 商户订单号
57+
*/
58+
@ApiOperation(value = "查询企业付款到零钱的结果")
59+
@GetMapping("/queryEntPay/{partnerTradeNo}")
60+
public EntPayQueryResult queryEntPay(@PathVariable String partnerTradeNo) throws WxPayException {
61+
return this.wxService.getEntPayService().queryEntPay(partnerTradeNo);
62+
}
63+
64+
65+
/**
66+
* <pre>
67+
* 获取RSA加密公钥API.
68+
* RSA算法使用说明(非对称加密算法,算法采用RSA/ECB/OAEPPadding模式)
69+
* 1、 调用获取RSA公钥API获取RSA公钥,落地成本地文件,假设为public.pem
70+
* 2、 确定public.pem文件的存放路径,同时修改代码中文件的输入路径,加载RSA公钥
71+
* 3、 用标准的RSA加密库对敏感信息进行加密,选择RSA_PKCS1_OAEP_PADDING填充模式
72+
* (eg:Java的填充方式要选 " RSA/ECB/OAEPWITHSHA-1ANDMGF1PADDING")
73+
* 4、 得到进行rsa加密并转base64之后的密文
74+
* 5、 将密文传给微信侧相应字段,如付款接口(enc_bank_no/enc_true_name)
75+
*
76+
* 接口默认输出PKCS#1格式的公钥,商户需根据自己开发的语言选择公钥格式
77+
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_7&index=4
78+
* 接口链接:https://fraud.mch.weixin.qq.com/risk/getpublickey
79+
* </pre>
80+
*
81+
* @return the public key
82+
* @throws WxPayException the wx pay exception
83+
*/
84+
@ApiOperation(value = "获取RSA加密公钥")
85+
@GetMapping("/getPublicKey")
86+
public String getPublicKey() throws WxPayException {
87+
return this.wxService.getEntPayService().getPublicKey();
88+
}
89+
90+
/**
91+
* 企业付款到银行卡.
92+
* <pre>
93+
* 用于企业向微信用户银行卡付款
94+
* 目前支持接口API的方式向指定微信用户的银行卡付款。
95+
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_2
96+
* 接口链接:https://api.mch.weixin.qq.com/mmpaysptrans/pay_bank
97+
* </pre>
98+
*
99+
* @param request 请求对象
100+
* @return the ent pay bank result
101+
* @throws WxPayException the wx pay exception
102+
*/
103+
@ApiOperation(value = "企业付款到银行卡")
104+
@PostMapping("/payBank")
105+
public EntPayBankResult payBank(EntPayBankRequest request) throws WxPayException {
106+
return this.wxService.getEntPayService().payBank(request);
107+
}
108+
109+
/**
110+
* 企业付款到银行卡查询.
111+
* <pre>
112+
* 用于对商户企业付款到银行卡操作进行结果查询,返回付款操作详细结果。
113+
* 文档详见:https://pay.weixin.qq.com/wiki/doc/api/tools/mch_pay.php?chapter=24_3
114+
* 接口链接:https://api.mch.weixin.qq.com/mmpaysptrans/query_bank
115+
* </pre>
116+
*
117+
* @param partnerTradeNo 商户订单号
118+
* @return the ent pay bank query result
119+
* @throws WxPayException the wx pay exception
120+
*/
121+
@ApiOperation(value = "查询企业付款到银行卡的结果")
122+
@GetMapping("/queryPayBank/{partnerTradeNo}")
123+
public EntPayBankQueryResult queryPayBank(@PathVariable String partnerTradeNo) throws WxPayException {
124+
return this.wxService.getEntPayService().queryPayBank(partnerTradeNo);
125+
}
126+
127+
}

0 commit comments

Comments
 (0)