Commit ca31cf06 authored by terrfly's avatar terrfly
Browse files

商户、应用、服务商配置信息支持直接数据库查询(第一卷);

parent 30b232b1
......@@ -17,6 +17,7 @@ package com.jeequan.jeepay.pay.channel;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.beans.RequestKitBean;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
......@@ -38,6 +39,7 @@ public abstract class AbstractChannelNoticeService implements IChannelNoticeServ
@Autowired private RequestKitBean requestKitBean;
@Autowired private ChannelCertConfigKitBean channelCertConfigKitBean;
@Autowired protected ConfigContextQueryService configContextQueryService;
@Override
public ResponseEntity doNotifyOrderNotExists(HttpServletRequest request) {
......
......@@ -17,6 +17,7 @@ package com.jeequan.jeepay.pay.channel;
import com.alibaba.fastjson.JSONObject;
import com.jeequan.jeepay.core.beans.RequestKitBean;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
......@@ -38,6 +39,7 @@ public abstract class AbstractChannelRefundNoticeService implements IChannelRefu
@Autowired private RequestKitBean requestKitBean;
@Autowired private ChannelCertConfigKitBean channelCertConfigKitBean;
@Autowired protected ConfigContextQueryService configContextQueryService;
@Override
public ResponseEntity doNotifyOrderNotExists(HttpServletRequest request) {
......
......@@ -17,10 +17,13 @@ package com.jeequan.jeepay.pay.channel;
import com.jeequan.jeepay.core.entity.PayOrder;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean;
import com.jeequan.jeepay.service.impl.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import javax.jws.Oneway;
/*
* 支付接口抽象类
*
......@@ -32,6 +35,7 @@ public abstract class AbstractPaymentService implements IPaymentService{
@Autowired protected SysConfigService sysConfigService;
@Autowired protected ChannelCertConfigKitBean channelCertConfigKitBean;
@Autowired protected ConfigContextQueryService configContextQueryService;
/** 订单分账(一般用作 如微信订单将在下单处做标记) */
protected boolean isDivisionOrder(PayOrder payOrder){
......
......@@ -16,6 +16,7 @@
package com.jeequan.jeepay.pay.channel;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean;
import com.jeequan.jeepay.service.impl.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -31,6 +32,7 @@ public abstract class AbstractRefundService implements IRefundService{
@Autowired protected SysConfigService sysConfigService;
@Autowired protected ChannelCertConfigKitBean channelCertConfigKitBean;
@Autowired protected ConfigContextQueryService configContextQueryService;
protected String getNotifyUrl(){
return sysConfigService.getDBApplicationConfig().getPaySiteUrl() + "/api/refund/notify/" + getIfCode();
......
......@@ -78,7 +78,7 @@ public class AlipayChannelNoticeService extends AbstractChannelNoticeService {
if(mchAppConfigContext.isIsvsubMch()){
// 获取支付参数
AlipayIsvParams alipayParams = mchAppConfigContext.getIsvConfigContext().getIsvParamsByIfCode(getIfCode(), AlipayIsvParams.class);
AlipayIsvParams alipayParams = (AlipayIsvParams)configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), getIfCode());
useCert = alipayParams.getUseCert();
alipaySignType = alipayParams.getSignType();
alipayPublicCert = alipayParams.getAlipayPublicCert();
......@@ -87,7 +87,8 @@ public class AlipayChannelNoticeService extends AbstractChannelNoticeService {
}else{
// 获取支付参数
AlipayNormalMchParams alipayParams = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), AlipayNormalMchParams.class);
AlipayNormalMchParams alipayParams = (AlipayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
useCert = alipayParams.getUseCert();
alipaySignType = alipayParams.getSignType();
alipayPublicCert = alipayParams.getAlipayPublicCert();
......
......@@ -25,9 +25,10 @@ import com.jeequan.jeepay.core.model.params.alipay.AlipayNormalMchParams;
import com.jeequan.jeepay.pay.channel.IChannelUserService;
import com.jeequan.jeepay.pay.exception.ChannelException;
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.BindException;
/*
* 支付宝: 获取用户ID实现类
......@@ -40,6 +41,7 @@ import org.springframework.validation.BindException;
@Slf4j
public class AlipayChannelUserService implements IChannelUserService {
@Autowired private ConfigContextQueryService configContextQueryService;
@Override
public String getIfCode() {
......@@ -53,14 +55,14 @@ public class AlipayChannelUserService implements IChannelUserService {
String appId = null;
if(mchAppConfigContext.isIsvsubMch()){
AlipayIsvParams isvParams = mchAppConfigContext.getIsvConfigContext().getIsvParamsByIfCode(getIfCode(), AlipayIsvParams.class);
AlipayIsvParams isvParams = (AlipayIsvParams) configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), getIfCode());
if(isvParams == null) {
throw new BizException("服务商支付宝接口没有配置!");
}
appId = isvParams.getAppId();
}else{
//获取商户配置信息
AlipayNormalMchParams normalMchParams = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), AlipayNormalMchParams.class);
AlipayNormalMchParams normalMchParams = (AlipayNormalMchParams) configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
if(normalMchParams == null) {
throw new BizException("商户支付宝接口没有配置!");
}
......@@ -83,7 +85,7 @@ public class AlipayChannelUserService implements IChannelUserService {
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
request.setCode(authCode); request.setGrantType("authorization_code");
try {
return mchAppConfigContext.getAlipayClientWrapper().execute(request).getUserId();
return configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(request).getUserId();
} catch (ChannelException e) {
e.printStackTrace();
return null;
......
......@@ -32,7 +32,9 @@ import com.jeequan.jeepay.pay.channel.IDivisionService;
import com.jeequan.jeepay.pay.exception.ChannelException;
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
......@@ -50,6 +52,8 @@ import java.util.List;
@Service
public class AlipayDivisionService implements IDivisionService {
@Autowired private ConfigContextQueryService configContextQueryService;
@Override
public String getIfCode() {
return CS.IF_CODE.ALIPAY;
......@@ -83,7 +87,7 @@ public class AlipayDivisionService implements IDivisionService {
royaltyEntity.setMemo(mchDivisionReceiver.getRelationTypeName()); //分账关系描述
model.setReceiverList(Arrays.asList(royaltyEntity));
AlipayTradeRoyaltyRelationBindResponse alipayResp = mchAppConfigContext.getAlipayClientWrapper().execute(request);
AlipayTradeRoyaltyRelationBindResponse alipayResp = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(request);
if(alipayResp.isSuccess()){
return ChannelRetMsg.confirmSuccess(null);
......@@ -174,7 +178,7 @@ public class AlipayDivisionService implements IDivisionService {
if(log.isInfoEnabled()){
log.info("订单:[{}], 支付宝分账请求:{}", payOrder.getPayOrderId(), JSON.toJSONString(model));
}
AlipayTradeOrderSettleResponse alipayResp = mchAppConfigContext.getAlipayClientWrapper().execute(request);
AlipayTradeOrderSettleResponse alipayResp = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(request);
log.info("订单:[{}], 支付宝分账响应:{}", payOrder.getPayOrderId(), alipayResp.getBody());
if(alipayResp.isSuccess()){
return ChannelRetMsg.confirmSuccess(alipayResp.getTradeNo());
......
......@@ -23,7 +23,9 @@ import com.alipay.api.request.*;
import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.model.params.alipay.AlipayIsvParams;
import com.jeequan.jeepay.core.model.params.alipay.AlipayIsvsubMchParams;
import com.jeequan.jeepay.core.utils.SpringBeansUtil;
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import org.apache.commons.lang3.StringUtils;
/*
......@@ -44,9 +46,11 @@ public class AlipayKit {
return ;
}
ConfigContextQueryService configContextQueryService = SpringBeansUtil.getBean(ConfigContextQueryService.class);
// 获取支付参数
AlipayIsvParams isvParams = mchAppConfigContext.getIsvConfigContext().getIsvParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayIsvParams.class);
AlipayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayIsvsubMchParams.class);
AlipayIsvParams isvParams = (AlipayIsvParams)configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), CS.IF_CODE.ALIPAY);
AlipayIsvsubMchParams isvsubMchParams = (AlipayIsvsubMchParams)configContextQueryService.queryIsvsubMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.ALIPAY);
// 子商户信息
if(req instanceof AlipayTradePayRequest) {
......
......@@ -23,6 +23,8 @@ import com.jeequan.jeepay.core.entity.PayOrder;
import com.jeequan.jeepay.pay.channel.IPayOrderQueryService;
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
......@@ -35,6 +37,8 @@ import org.springframework.stereotype.Service;
@Service
public class AlipayPayOrderQueryService implements IPayOrderQueryService {
@Autowired private ConfigContextQueryService configContextQueryService;
@Override
public String getIfCode() {
return CS.IF_CODE.ALIPAY;
......@@ -53,7 +57,7 @@ public class AlipayPayOrderQueryService implements IPayOrderQueryService {
//通用字段
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
AlipayTradeQueryResponse resp = mchAppConfigContext.getAlipayClientWrapper().execute(req);
AlipayTradeQueryResponse resp = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(req);
String result = resp.getTradeStatus();
if("TRADE_SUCCESS".equals(result)) {
......
......@@ -66,8 +66,7 @@ public class AlipayRefundService extends AbstractRefundService {
//统一放置 isv接口必传信息
AlipayKit.putApiIsvInfo(mchAppConfigContext, request, model);
AlipayTradeRefundResponse response = mchAppConfigContext.getAlipayClientWrapper().execute(request);
AlipayTradeRefundResponse response = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(request);
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
channelRetMsg.setChannelAttach(response.getBody());
......@@ -97,7 +96,7 @@ public class AlipayRefundService extends AbstractRefundService {
//统一放置 isv接口必传信息
AlipayKit.putApiIsvInfo(mchAppConfigContext, request, model);
AlipayTradeFastpayRefundQueryResponse response = mchAppConfigContext.getAlipayClientWrapper().execute(request);
AlipayTradeFastpayRefundQueryResponse response = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(request);
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
channelRetMsg.setChannelAttach(response.getBody());
......
......@@ -26,8 +26,10 @@ import com.jeequan.jeepay.pay.channel.ITransferService;
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
import com.jeequan.jeepay.pay.rqrs.transfer.TransferOrderRQ;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
......@@ -41,6 +43,8 @@ import org.springframework.stereotype.Service;
@Service
public class AlipayTransferService implements ITransferService {
@Autowired private ConfigContextQueryService configContextQueryService;
@Override
public String getIfCode() {
return CS.IF_CODE.ALIPAY;
......@@ -79,7 +83,7 @@ public class AlipayTransferService implements ITransferService {
AlipayKit.putApiIsvInfo(mchAppConfigContext, request, model);
// 调起支付宝接口
AlipayFundTransToaccountTransferResponse response = mchAppConfigContext.getAlipayClientWrapper().execute(request);
AlipayFundTransToaccountTransferResponse response = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(request);
ChannelRetMsg channelRetMsg = new ChannelRetMsg();
channelRetMsg.setChannelAttach(response.getBody());
......
......@@ -31,8 +31,8 @@ import com.jeequan.jeepay.core.model.params.alipay.AlipayConfig;
import com.jeequan.jeepay.core.model.params.alipay.AlipayIsvParams;
import com.jeequan.jeepay.pay.channel.alipay.AlipayKit;
import com.jeequan.jeepay.pay.model.AlipayClientWrapper;
import com.jeequan.jeepay.pay.model.IsvConfigContext;
import com.jeequan.jeepay.pay.service.ConfigContextService;
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import com.jeequan.jeepay.service.impl.MchAppService;
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
import com.jeequan.jeepay.service.impl.SysConfigService;
......@@ -58,7 +58,7 @@ import java.math.BigDecimal;
@RequestMapping("/api/channelbiz/alipay")
public class AlipayBizController extends AbstractCtrl {
@Autowired private ConfigContextService configContextService;
@Autowired private ConfigContextQueryService configContextQueryService;
@Autowired private SysConfigService sysConfigService;
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
@Autowired private MchAppService mchAppService;
......@@ -73,8 +73,7 @@ public class AlipayBizController extends AbstractCtrl {
String isvNo = isvAndMchAppId.split("_")[0];
IsvConfigContext isvConfigContext = configContextService.getIsvConfigContext(isvNo);
AlipayIsvParams alipayIsvParams = isvConfigContext.getIsvParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayIsvParams.class);
AlipayIsvParams alipayIsvParams = (AlipayIsvParams) configContextQueryService.queryIsvParams(isvNo, CS.IF_CODE.ALIPAY);
alipayIsvParams.getSandbox();
String oauthUrl = AlipayConfig.PROD_APP_TO_APP_AUTH_URL;
......@@ -102,7 +101,11 @@ public class AlipayBizController extends AbstractCtrl {
isAlipaySysAuth = false;
String isvNo = isvAndMchAppId.split("_")[0];
String mchAppId = isvAndMchAppId.split("_")[1];
AlipayClientWrapper alipayClientWrapper = configContextService.getIsvConfigContext(isvNo).getAlipayClientWrapper();
MchApp mchApp = mchAppService.getById(mchAppId);
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(mchApp.getMchNo(), mchAppId);
AlipayClientWrapper alipayClientWrapper = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext);
AlipayOpenAuthTokenAppRequest request = new AlipayOpenAuthTokenAppRequest();
AlipayOpenAuthTokenAppModel model = new AlipayOpenAuthTokenAppModel();
......@@ -141,8 +144,6 @@ public class AlipayBizController extends AbstractCtrl {
payInterfaceConfigService.save(dbRecord);
}
MchApp mchApp = mchAppService.getById(mchAppId);
// 更新应用配置信息
mqSender.send(ResetIsvMchAppInfoConfigMQ.build(ResetIsvMchAppInfoConfigMQ.RESET_TYPE_MCH_APP, null, mchApp.getMchNo(), mchApp.getAppId()));
......
......@@ -66,7 +66,7 @@ public class AliApp extends AlipayPaymentService {
// sdk方式需自行拦截接口异常信息
try {
payData = mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().sdkExecute(req).getBody();
payData = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).getAlipayClient().sdkExecute(req).getBody();
} catch (AlipayApiException e) {
throw ChannelException.sysError(e.getMessage());
}
......
......@@ -74,7 +74,7 @@ public class AliBar extends AlipayPaymentService {
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
//调起支付宝 (如果异常, 将直接跑出 ChannelException )
AlipayTradePayResponse alipayResp = mchAppConfigContext.getAlipayClientWrapper().execute(req);
AlipayTradePayResponse alipayResp = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(req);
// 构造函数响应数据
AliBarOrderRS res = ApiResBuilder.buildSuccess(AliBarOrderRS.class);
......
......@@ -73,7 +73,7 @@ public class AliJsapi extends AlipayPaymentService {
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
//调起支付宝 (如果异常, 将直接跑出 ChannelException )
AlipayTradeCreateResponse alipayResp = mchAppConfigContext.getAlipayClientWrapper().execute(req);
AlipayTradeCreateResponse alipayResp = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(req);
// 构造函数响应数据
AliJsapiOrderRS res = ApiResBuilder.buildSuccess(AliJsapiOrderRS.class);
......
......@@ -73,9 +73,9 @@ public class AliPc extends AlipayPaymentService {
try {
if(CS.PAY_DATA_TYPE.FORM.equals(bizRQ.getPayDataType())){
res.setFormContent(mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req).getBody());
res.setFormContent(configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).getAlipayClient().pageExecute(req).getBody());
}else{
res.setPayUrl(mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req, "GET").getBody());
res.setPayUrl(configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).getAlipayClient().pageExecute(req, "GET").getBody());
}
}catch (AlipayApiException e) {
throw ChannelException.sysError(e.getMessage());
......
......@@ -65,7 +65,7 @@ public class AliQr extends AlipayPaymentService {
AlipayKit.putApiIsvInfo(mchAppConfigContext, req, model);
//调起支付宝 (如果异常, 将直接跑出 ChannelException )
AlipayTradePrecreateResponse alipayResp = mchAppConfigContext.getAlipayClientWrapper().execute(req);
AlipayTradePrecreateResponse alipayResp = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).execute(req);
// 构造函数响应数据
AliQrOrderRS res = ApiResBuilder.buildSuccess(AliQrOrderRS.class);
......
......@@ -72,15 +72,15 @@ public class AliWap extends AlipayPaymentService {
try {
if(CS.PAY_DATA_TYPE.FORM.equals(bizRQ.getPayDataType())){ //表单方式
res.setFormContent(mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req).getBody());
res.setFormContent(configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).getAlipayClient().pageExecute(req).getBody());
}else if (CS.PAY_DATA_TYPE.CODE_IMG_URL.equals(bizRQ.getPayDataType())){ //二维码图片地址
String payUrl = mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req, "GET").getBody();
String payUrl = configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).getAlipayClient().pageExecute(req, "GET").getBody();
res.setCodeImgUrl(sysConfigService.getDBApplicationConfig().genScanImgUrl(payUrl));
}else{ // 默认都为 payUrl方式
res.setPayUrl(mchAppConfigContext.getAlipayClientWrapper().getAlipayClient().pageExecute(req, "GET").getBody());
res.setPayUrl(configContextQueryService.getAlipayClientWrapper(mchAppConfigContext).getAlipayClient().pageExecute(req, "GET").getBody());
}
}catch (AlipayApiException e) {
throw ChannelException.sysError(e.getMessage());
......
......@@ -33,8 +33,9 @@ import com.jeequan.jeepay.core.exception.BizException;
import com.jeequan.jeepay.core.exception.ResponseException;
import com.jeequan.jeepay.pay.channel.AbstractChannelNoticeService;
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
import com.jeequan.jeepay.pay.service.ConfigContextService;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import com.jeequan.jeepay.service.impl.PayOrderService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
......@@ -60,7 +61,7 @@ import java.security.PrivateKey;
@Slf4j
public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
@Autowired private ConfigContextService configContextService;
@Autowired private ConfigContextQueryService configContextQueryService;
@Autowired private PayOrderService payOrderService;
......@@ -82,7 +83,7 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
}
//获取支付参数 (缓存数据) 和 商户信息
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(payOrder.getMchNo(), payOrder.getAppId());
if(mchAppConfigContext == null){
throw new BizException("获取商户信息失败");
}
......@@ -114,11 +115,13 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
ChannelRetMsg channelResult = new ChannelRetMsg();
channelResult.setChannelState(ChannelRetMsg.ChannelState.WAITING); // 默认支付中
if (CS.PAY_IF_VERSION.WX_V2.equals(mchAppConfigContext.getWxServiceWrapper().getApiVersion())) { // V2
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
if (CS.PAY_IF_VERSION.WX_V2.equals(wxServiceWrapper.getApiVersion())) { // V2
// 获取回调参数
WxPayOrderNotifyResult result = (WxPayOrderNotifyResult) params;
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
// 验证参数
verifyWxPayParams(wxPayService, result, payOrder);
......@@ -128,7 +131,7 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
channelResult.setChannelState(ChannelRetMsg.ChannelState.CONFIRM_SUCCESS);
channelResult.setResponseEntity(textResp(WxPayNotifyResponse.successResp("OK")));
}else if (CS.PAY_IF_VERSION.WX_V3.equals(mchAppConfigContext.getWxServiceWrapper().getApiVersion())) { // V3
}else if (CS.PAY_IF_VERSION.WX_V3.equals(wxServiceWrapper.getApiVersion())) { // V3
// 获取回调参数
WxPayOrderNotifyV3Result.DecryptNotifyResult result = (WxPayOrderNotifyV3Result.DecryptNotifyResult) params;
......@@ -208,7 +211,7 @@ public class WxpayChannelNoticeService extends AbstractChannelNoticeService {
log.info("\n【请求头信息】:{}\n【加密数据】:{}", header.toString(), params);
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
WxPayService wxPayService = configContextQueryService.getWxServiceWrapper(mchAppConfigContext).getWxPayService();
WxPayConfig wxPayConfig = wxPayService.getConfig();
// 自动获取微信平台证书
PrivateKey privateKey = PemUtils.loadPrivateKey(new FileInputStream(wxPayConfig.getPrivateKeyPath()));
......
......@@ -22,9 +22,12 @@ import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvParams;
import com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams;
import com.jeequan.jeepay.pay.channel.IChannelUserService;
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/*
......@@ -38,6 +41,8 @@ import org.springframework.stereotype.Service;
@Slf4j
public class WxpayChannelUserService implements IChannelUserService {
@Autowired private ConfigContextQueryService configContextQueryService;
/** 默认官方跳转地址 **/
private static final String DEFAULT_OAUTH_URL = "https://open.weixin.qq.com/connect/oauth2/authorize";
......@@ -80,7 +85,9 @@ public class WxpayChannelUserService implements IChannelUserService {
public String getChannelUserId(JSONObject reqParams, MchAppConfigContext mchAppConfigContext) {
String code = reqParams.getString("code");
try {
return mchAppConfigContext.getWxServiceWrapper().getWxMpService().getOAuth2Service().getAccessToken(code).getOpenId();
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
return wxServiceWrapper.getWxMpService().getOAuth2Service().getAccessToken(code).getOpenId();
} catch (WxErrorException e) {
e.printStackTrace();
return null;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment