微信支付
This commit is contained in:
parent
7bc223ab26
commit
f2ed333de9
|
|
@ -73,7 +73,17 @@ public class WxDepartmentController {
|
||||||
try {
|
try {
|
||||||
WxCpDepartmentService departmentService = WxCpConfiguration.getCpService(999999).getDepartmentService();
|
WxCpDepartmentService departmentService = WxCpConfiguration.getCpService(999999).getDepartmentService();
|
||||||
for (WxCpDepart wxCpDepart : wxCpDeparts) {
|
for (WxCpDepart wxCpDepart : wxCpDeparts) {
|
||||||
Integer id = departmentService.create(wxCpDepart);
|
List<WxCpDepart> list =null;
|
||||||
|
try {
|
||||||
|
list = departmentService.list(wxCpDepart.getId());
|
||||||
|
} catch (WxErrorException e) {
|
||||||
|
this.logger.info( "组织机构不存在" );
|
||||||
|
}
|
||||||
|
if(list!=null&& list.size()>0){
|
||||||
|
departmentService.update(wxCpDepart);
|
||||||
|
}else{
|
||||||
|
Integer id = departmentService.create(wxCpDepart);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return AjaxResult.success(wxCpDeparts.size(),"全量新增组织机构成功");
|
return AjaxResult.success(wxCpDeparts.size(),"全量新增组织机构成功");
|
||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
package com.ruoyi.wx.pay;
|
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Binary Wang
|
|
||||||
*/
|
|
||||||
@SpringBootApplication
|
|
||||||
public class WxPayDemoApplication {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SpringApplication.run(WxPayDemoApplication.class, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -123,13 +123,48 @@ public class WxPayController {
|
||||||
* @param request 统一下单请求参数
|
* @param request 统一下单请求参数
|
||||||
* @param <T> 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类
|
* @param <T> 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类
|
||||||
* @return 返回 {@link com.github.binarywang.wxpay.bean.order}包下的类对象
|
* @return 返回 {@link com.github.binarywang.wxpay.bean.order}包下的类对象
|
||||||
|
*
|
||||||
|
* 示例参数
|
||||||
|
* {
|
||||||
|
"body":"测试商品",
|
||||||
|
"outTradeNo":"12344324242342342342554",
|
||||||
|
"totalFee":1.01,
|
||||||
|
"spbillCreateIp":"1.80.82.241",
|
||||||
|
"notifyUrl":"http://www.baidu.com",
|
||||||
|
"tradeType":"NATIVE",
|
||||||
|
"productId":"13652b4a71df2f49e3647c55c8e31a88"
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
@ApiOperation(value = "统一下单,并组装所需支付参数")
|
@ApiOperation(value = "统一下单,并组装所需支付参数")
|
||||||
@PostMapping("/createOrder")
|
@PostMapping("/createOrder")
|
||||||
public <T> T createOrder(@RequestBody WxPayUnifiedOrderRequest request) throws WxPayException {
|
public <T> T createOrder(@RequestBody WxPayUnifiedOrderRequest request) throws WxPayException {
|
||||||
return this.wxService.createOrder(request);
|
return this.wxService.createOrder(request);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* 调用统一下单接口,并组装生成支付所需参数对象.并返回二维码
|
||||||
|
*
|
||||||
|
* @param request 统一下单请求参数
|
||||||
|
* @param <T> 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类
|
||||||
|
* @return 返回二维码
|
||||||
|
*
|
||||||
|
* 示例参数
|
||||||
|
* {
|
||||||
|
"body":"测试商品",
|
||||||
|
"outTradeNo":"12344324242342342342554",
|
||||||
|
"totalFee":1.01,
|
||||||
|
"spbillCreateIp":"1.80.82.241",
|
||||||
|
"notifyUrl":"http://www.baidu.com",
|
||||||
|
"tradeType":"NATIVE",
|
||||||
|
"productId":"13652b4a71df2f49e3647c55c8e31a88"
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "统一下单,并组装所需支付参数,返回二维码")
|
||||||
|
@PostMapping("/createOrderQrcode")
|
||||||
|
public <T> T createOrderAndQrcode(@RequestBody WxPayUnifiedOrderRequest request) throws WxPayException {
|
||||||
|
Object order = this.wxService.createOrder(request);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 统一下单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
|
* 统一下单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
|
||||||
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
|
* 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
|
||||||
|
|
@ -298,6 +333,9 @@ public class WxPayController {
|
||||||
* @param sideLength 要生成的二维码的边长,如果为空,则取默认值400
|
* @param sideLength 要生成的二维码的边长,如果为空,则取默认值400
|
||||||
* @return 生成的二维码的字节数组
|
* @return 生成的二维码的字节数组
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ApiOperation(value = "生成二维码")
|
||||||
|
@GetMapping("/createQrcode")
|
||||||
public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) {
|
public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) {
|
||||||
return this.wxService.createScanPayQrcodeMode2(codeUrl, logoFile, sideLength);
|
return this.wxService.createScanPayQrcodeMode2(codeUrl, logoFile, sideLength);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
package com.ruoyi.wx.pay.error;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Controller;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 出错页面控制器
|
|
||||||
* Created by Binary Wang on 2018/8/25.
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
|
||||||
*/
|
|
||||||
@Controller
|
|
||||||
@RequestMapping("/error")
|
|
||||||
public class ErrorController {
|
|
||||||
|
|
||||||
@GetMapping(value = "/404")
|
|
||||||
public String error404() {
|
|
||||||
return "error";
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping(value = "/500")
|
|
||||||
public String error500() {
|
|
||||||
return "error";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
||||||
package com.ruoyi.wx.pay.error;
|
|
||||||
|
|
||||||
import org.springframework.boot.web.server.ErrorPage;
|
|
||||||
import org.springframework.boot.web.server.ErrorPageRegistrar;
|
|
||||||
import org.springframework.boot.web.server.ErrorPageRegistry;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <pre>
|
|
||||||
* 配置错误状态与对应访问路径
|
|
||||||
* Created by Binary Wang on 2018/8/25.
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @author <a href="https://github.com/binarywang">Binary Wang</a>
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class ErrorPageConfiguration implements ErrorPageRegistrar {
|
|
||||||
@Override
|
|
||||||
public void registerErrorPages(ErrorPageRegistry errorPageRegistry) {
|
|
||||||
errorPageRegistry.addErrorPages(
|
|
||||||
new ErrorPage(HttpStatus.NOT_FOUND, "/error/404"),
|
|
||||||
new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -11,9 +11,9 @@ wechat:
|
||||||
token: 111
|
token: 111
|
||||||
aesKey: 111
|
aesKey: 111
|
||||||
pay:
|
pay:
|
||||||
appId: #微信公众号或者小程序等的appid
|
appId: wxf9fcc68ce428cfb6 #wxd67baf702dad665c #微信公众号或者小程序等的appid #wx6b73f1161cbfd5f3
|
||||||
mchId: #微信支付商户号
|
mchId: 1518812711 #微信支付商户号 #1518466961
|
||||||
mchKey: #微信支付商户密钥
|
mchKey: nantongjunruanquanjishu888888888 #微信支付商户密钥 #nantonghanhaixinxijishuyouxian88
|
||||||
subAppId: #服务商模式下的子商户公众账号ID
|
subAppId: #服务商模式下的子商户公众账号ID
|
||||||
subMchId: #服务商模式下的子商户号
|
subMchId: #服务商模式下的子商户号
|
||||||
keyPath: # p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头)
|
keyPath: # p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头)
|
||||||
Loading…
Reference in New Issue