提交 a8b99d14 作者: xiaowang

修复:文件找不到问题

上级 d0d12077
...@@ -40,4 +40,7 @@ public class UserSystemConstant { ...@@ -40,4 +40,7 @@ public class UserSystemConstant {
@Value("${wx.pay.notify-url}") @Value("${wx.pay.notify-url}")
private String notifyUrl; private String notifyUrl;
@Value("${data.file.url}")
private String privateKeyFromPath;
} }
...@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Map; import java.util.Map;
/** /**
...@@ -31,7 +32,7 @@ public class WechatPayController extends BaseController { ...@@ -31,7 +32,7 @@ public class WechatPayController extends BaseController {
@ApiOperation(value = "小程序调起支付API") @ApiOperation(value = "小程序调起支付API")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
@PostMapping("pay") @PostMapping("pay")
public ResultBody orderPay(@RequestBody OrderRequestParamsVO orderRequestParamsVO, HttpServletRequest request) { public ResultBody orderPay(@RequestBody OrderRequestParamsVO orderRequestParamsVO, HttpServletRequest request) throws IOException {
return ResultBody.success(wechatPayService.orderPay(orderRequestParamsVO, this.getUserLoginInfoFromRedis(request).getUserAccountId(), request)); return ResultBody.success(wechatPayService.orderPay(orderRequestParamsVO, this.getUserLoginInfoFromRedis(request).getUserAccountId(), request));
} }
......
...@@ -48,7 +48,7 @@ public class WechatPayServiceImpl implements WechatPayService { ...@@ -48,7 +48,7 @@ public class WechatPayServiceImpl implements WechatPayService {
WxConfigUtils wxConfigUtils; WxConfigUtils wxConfigUtils;
@Override @Override
public Map orderPay(OrderRequestParamsVO orderRequestParamsVO, Integer userAccountId, HttpServletRequest request) { public Map orderPay(OrderRequestParamsVO orderRequestParamsVO, Integer userAccountId, HttpServletRequest request) throws IOException {
UserAccountSimpleDTO userSimpleInfo = userAppApi.feignGetUserSimpleInfo(userAccountId, request.getHeader("token")); UserAccountSimpleDTO userSimpleInfo = userAppApi.feignGetUserSimpleInfo(userAccountId, request.getHeader("token"));
if (userSimpleInfo == null) { if (userSimpleInfo == null) {
throw new RuntimeException("服务器内部错误!"); throw new RuntimeException("服务器内部错误!");
......
...@@ -3,6 +3,7 @@ package com.mmc.payment.service; ...@@ -3,6 +3,7 @@ package com.mmc.payment.service;
import com.mmc.payment.model.vo.order.OrderRequestParamsVO; import com.mmc.payment.model.vo.order.OrderRequestParamsVO;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Map; import java.util.Map;
/** /**
...@@ -11,7 +12,7 @@ import java.util.Map; ...@@ -11,7 +12,7 @@ import java.util.Map;
* 概要: * 概要:
*/ */
public interface WechatPayService { public interface WechatPayService {
Map orderPay(OrderRequestParamsVO orderRequestParamsVO, Integer userAccountId, HttpServletRequest request); Map orderPay(OrderRequestParamsVO orderRequestParamsVO, Integer userAccountId, HttpServletRequest request) throws IOException;
Map payCallback(HttpServletRequest request); Map payCallback(HttpServletRequest request);
} }
...@@ -7,8 +7,6 @@ import com.wechat.pay.java.core.notification.NotificationConfig; ...@@ -7,8 +7,6 @@ import com.wechat.pay.java.core.notification.NotificationConfig;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.io.File;
import java.net.URL;
/** /**
* @Author LW * @Author LW
...@@ -26,7 +24,7 @@ public class WxConfigUtils { ...@@ -26,7 +24,7 @@ public class WxConfigUtils {
Config config = Config config =
new RSAAutoCertificateConfig.Builder() new RSAAutoCertificateConfig.Builder()
.merchantId(userSystemConstant.getMchid()) .merchantId(userSystemConstant.getMchid())
.privateKeyFromPath(this.getFilePath()) .privateKeyFromPath(userSystemConstant.getPrivateKeyFromPath())
.merchantSerialNumber(userSystemConstant.getMchNumber()) .merchantSerialNumber(userSystemConstant.getMchNumber())
.apiV3Key(userSystemConstant.getApiv3Key()) .apiV3Key(userSystemConstant.getApiv3Key())
.build(); .build();
...@@ -40,17 +38,11 @@ public class WxConfigUtils { ...@@ -40,17 +38,11 @@ public class WxConfigUtils {
NotificationConfig config = NotificationConfig config =
new RSAAutoCertificateConfig.Builder() new RSAAutoCertificateConfig.Builder()
.merchantId(userSystemConstant.getMchid()) .merchantId(userSystemConstant.getMchid())
.privateKeyFromPath(this.getFilePath()) .privateKeyFromPath(userSystemConstant.getPrivateKeyFromPath())
.merchantSerialNumber(userSystemConstant.getMchNumber()) .merchantSerialNumber(userSystemConstant.getMchNumber())
.apiV3Key(userSystemConstant.getApiv3Key()) .apiV3Key(userSystemConstant.getApiv3Key())
.build(); .build();
return config; return config;
} }
private String getFilePath() {
ClassLoader classLoader = getClass().getClassLoader();
URL resourceUrl = classLoader.getResource("apiclient_key.pem");
return new File(resourceUrl.getFile()).getAbsolutePath();
}
} }
...@@ -60,3 +60,7 @@ iuav: ...@@ -60,3 +60,7 @@ iuav:
userapp: userapp:
url: http://cms-svc:35150 url: http://cms-svc:35150
data:
file:
url: src/main/java/com/mmc/payment/file/apiclient_key.pem
...@@ -60,5 +60,9 @@ iuav: ...@@ -60,5 +60,9 @@ iuav:
oms: oms:
url: http://localhost:8077/oms/ url: http://localhost:8077/oms/
data:
file:
url: src/main/java/com/mmc/payment/file/apiclient_key.pem
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论