Commit ca31cf06 authored by terrfly's avatar terrfly
Browse files

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

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