商户、应用、服务商配置信息支持直接数据库查询(第一卷);
This commit is contained in:
parent
30b232b111
commit
ca31cf0633
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -27,8 +27,11 @@ import com.jeequan.jeepay.core.utils.SeqKit;
|
|||
import com.jeequan.jeepay.pay.channel.IDivisionService;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
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.ConfigContextQueryService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
|
@ -45,6 +48,8 @@ import java.util.List;
|
|||
@Service
|
||||
public class WxpayDivisionService implements IDivisionService {
|
||||
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
@Override
|
||||
public String getIfCode() {
|
||||
return CS.IF_CODE.WXPAY;
|
||||
|
|
@ -75,8 +80,10 @@ public class WxpayDivisionService implements IDivisionService {
|
|||
receiverJSON.put("custom_relation", mchDivisionReceiver.getRelationTypeName());
|
||||
request.setReceiver(receiverJSON.toJSONString());
|
||||
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
|
||||
ProfitSharingReceiverResult profitSharingReceiverResult =
|
||||
mchAppConfigContext.getWxServiceWrapper().getWxPayService().getProfitSharingService().addReceiver(request);
|
||||
wxServiceWrapper.getWxPayService().getProfitSharingService().addReceiver(request);
|
||||
|
||||
// 明确成功
|
||||
return ChannelRetMsg.confirmSuccess(null);
|
||||
|
|
@ -137,7 +144,9 @@ public class WxpayDivisionService implements IDivisionService {
|
|||
|
||||
request.setReceivers(receiverJSONArray.toJSONString());
|
||||
|
||||
ProfitSharingResult profitSharingResult = mchAppConfigContext.getWxServiceWrapper().getWxPayService().getProfitSharingService().profitSharing(request);
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
|
||||
ProfitSharingResult profitSharingResult = wxServiceWrapper.getWxPayService().getProfitSharingService().profitSharing(request);
|
||||
return ChannelRetMsg.confirmSuccess(profitSharingResult.getOrderId());
|
||||
|
||||
} catch (WxPayException wxPayException) {
|
||||
|
|
@ -168,7 +177,9 @@ public class WxpayDivisionService implements IDivisionService {
|
|||
request.setTransactionId(payOrder.getChannelOrderNo());
|
||||
request.setOutOrderNo(SeqKit.genDivisionBatchId());
|
||||
request.setDescription("完结分账");
|
||||
return mchAppConfigContext.getWxServiceWrapper().getWxPayService().getProfitSharingService().profitSharingFinish(request).getOrderId();
|
||||
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
return wxServiceWrapper.getWxPayService().getProfitSharingService().profitSharingFinish(request).getOrderId();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ import com.jeequan.jeepay.pay.channel.IPayOrderQueryService;
|
|||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayV3Util;
|
||||
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.ConfigContextQueryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/*
|
||||
|
|
@ -40,6 +43,8 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class WxpayPayOrderQueryService implements IPayOrderQueryService {
|
||||
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
@Override
|
||||
public String getIfCode() {
|
||||
return CS.IF_CODE.WXPAY;
|
||||
|
|
@ -50,7 +55,9 @@ public class WxpayPayOrderQueryService implements IPayOrderQueryService {
|
|||
|
||||
try {
|
||||
|
||||
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
|
||||
|
||||
WxPayOrderQueryRequest req = new WxPayOrderQueryRequest();
|
||||
|
||||
|
|
@ -59,7 +66,7 @@ public class WxpayPayOrderQueryService implements IPayOrderQueryService {
|
|||
|
||||
req.setOutTradeNo(payOrder.getPayOrderId());
|
||||
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
|
||||
WxPayOrderQueryResult result = wxPayService.queryOrder(req);
|
||||
|
||||
|
|
@ -75,19 +82,19 @@ public class WxpayPayOrderQueryService implements IPayOrderQueryService {
|
|||
return ChannelRetMsg.unknown();
|
||||
}
|
||||
|
||||
}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
|
||||
|
||||
String reqUrl;
|
||||
String query;
|
||||
if(mchAppConfigContext.isIsvsubMch()){ // 特约商户
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayIsvsubMchParams.class);
|
||||
WxpayIsvsubMchParams isvsubMchParams = (WxpayIsvsubMchParams) configContextQueryService.queryIsvsubMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
reqUrl = String.format("/v3/pay/partner/transactions/out-trade-no/%s", payOrder.getPayOrderId());
|
||||
query = String.format("?sp_mchid=%s&sub_mchid=%s", mchAppConfigContext.getWxServiceWrapper().getWxPayService().getConfig().getMchId(), isvsubMchParams.getSubMchId());
|
||||
query = String.format("?sp_mchid=%s&sub_mchid=%s", wxServiceWrapper.getWxPayService().getConfig().getMchId(), isvsubMchParams.getSubMchId());
|
||||
}else {
|
||||
reqUrl = String.format("/v3/pay/transactions/out-trade-no/%s", payOrder.getPayOrderId());
|
||||
query = String.format("?mchid=%s", mchAppConfigContext.getWxServiceWrapper().getWxPayService().getConfig().getMchId());
|
||||
query = String.format("?mchid=%s", wxServiceWrapper.getWxPayService().getConfig().getMchId());
|
||||
}
|
||||
JSONObject resultJSON = WxpayV3Util.queryOrderV3(reqUrl + query, mchAppConfigContext.getWxServiceWrapper().getWxPayService().getConfig());
|
||||
JSONObject resultJSON = WxpayV3Util.queryOrderV3(reqUrl + query, wxServiceWrapper.getWxPayService().getConfig());
|
||||
|
||||
String channelState = resultJSON.getString("trade_state");
|
||||
if ("SUCCESS".equals(channelState)) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.jeequan.jeepay.core.entity.PayOrder;
|
|||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvsubMchParams;
|
||||
import com.jeequan.jeepay.pay.channel.AbstractPaymentService;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.util.PaywayUtil;
|
||||
|
|
@ -60,7 +61,10 @@ public class WxpayPaymentService extends AbstractPaymentService {
|
|||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
|
||||
// 微信API版本
|
||||
String apiVersion = mchAppConfigContext.getWxServiceWrapper().getApiVersion();
|
||||
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
|
||||
String apiVersion = wxServiceWrapper.getApiVersion();
|
||||
if (CS.PAY_IF_VERSION.WX_V2.equals(apiVersion)) {
|
||||
return PaywayUtil.getRealPaywayService(this, payOrder.getWayCode()).pay(rq, payOrder, mchAppConfigContext);
|
||||
} else if (CS.PAY_IF_VERSION.WX_V3.equals(apiVersion)) {
|
||||
|
|
@ -97,7 +101,7 @@ public class WxpayPaymentService extends AbstractPaymentService {
|
|||
|
||||
// 特约商户
|
||||
if(mchAppConfigContext.isIsvsubMch()){
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(getIfCode(), WxpayIsvsubMchParams.class);
|
||||
WxpayIsvsubMchParams isvsubMchParams = (WxpayIsvsubMchParams) configContextQueryService.queryIsvsubMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
request.setSubMchId(isvsubMchParams.getSubMchId());
|
||||
if (StringUtils.isNotBlank(isvsubMchParams.getSubMchAppId())) {
|
||||
request.setSubAppId(isvsubMchParams.getSubMchAppId());
|
||||
|
|
@ -137,9 +141,10 @@ public class WxpayPaymentService extends AbstractPaymentService {
|
|||
reqJSON.put("settle_info", settleInfo);
|
||||
}
|
||||
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxPayService wxPayService = configContextQueryService.getWxServiceWrapper(mchAppConfigContext).getWxPayService();
|
||||
if(mchAppConfigContext.isIsvsubMch()){ // 特约商户
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(getIfCode(), WxpayIsvsubMchParams.class);
|
||||
|
||||
WxpayIsvsubMchParams isvsubMchParams = (WxpayIsvsubMchParams) configContextQueryService.queryIsvsubMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
reqJSON.put("sp_appid", wxPayService.getConfig().getAppId());
|
||||
reqJSON.put("sp_mchid", wxPayService.getConfig().getMchId());
|
||||
reqJSON.put("sub_mchid", isvsubMchParams.getSubMchId());
|
||||
|
|
|
|||
|
|
@ -18,16 +18,20 @@ package com.jeequan.jeepay.pay.channel.wxpay;
|
|||
import com.github.binarywang.wxpay.bean.entpay.EntPayRequest;
|
||||
import com.github.binarywang.wxpay.bean.entpay.EntPayResult;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.TransferOrder;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams;
|
||||
import com.jeequan.jeepay.pay.channel.ITransferService;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
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.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 +45,8 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class WxpayTransferService implements ITransferService {
|
||||
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
@Override
|
||||
public String getIfCode() {
|
||||
return CS.IF_CODE.WXPAY;
|
||||
|
|
@ -78,8 +84,11 @@ public class WxpayTransferService implements ITransferService {
|
|||
try {
|
||||
|
||||
EntPayRequest request = new EntPayRequest();
|
||||
request.setMchAppid(mchAppConfigContext.getWxServiceWrapper().getWxPayService().getConfig().getAppId()); // 商户账号appid
|
||||
request.setMchId(mchAppConfigContext.getWxServiceWrapper().getWxPayService().getConfig().getMchId()); //商户号
|
||||
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
|
||||
request.setMchAppid(wxServiceWrapper.getWxPayService().getConfig().getAppId()); // 商户账号appid
|
||||
request.setMchId(wxServiceWrapper.getWxPayService().getConfig().getMchId()); //商户号
|
||||
|
||||
request.setPartnerTradeNo(transferOrder.getTransferId()); //商户订单号
|
||||
request.setOpenid(transferOrder.getAccountNo()); //openid
|
||||
|
|
@ -93,7 +102,7 @@ public class WxpayTransferService implements ITransferService {
|
|||
request.setCheckName("NO_CHECK");
|
||||
}
|
||||
|
||||
EntPayResult entPayResult = mchAppConfigContext.getWxServiceWrapper().getWxPayService().getEntPayService().entPay(request);
|
||||
EntPayResult entPayResult = wxServiceWrapper.getWxPayService().getEntPayService().entPay(request);
|
||||
|
||||
// SUCCESS/FAIL,注意:当状态为FAIL时,存在业务结果未明确的情况。如果状态为FAIL,请务必关注错误代码(err_code字段),通过查询接口确认此次付款的结果。
|
||||
if("SUCCESS".equalsIgnoreCase(entPayResult.getResultCode())){
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
|
|||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvsubMchParams;
|
||||
import com.jeequan.jeepay.core.utils.SpringBeansUtil;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/*
|
||||
|
|
@ -40,7 +42,11 @@ public class WxpayKit {
|
|||
return ;
|
||||
}
|
||||
|
||||
WxpayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayIsvsubMchParams.class);
|
||||
ConfigContextQueryService configContextQueryService = SpringBeansUtil.getBean(ConfigContextQueryService.class);
|
||||
|
||||
WxpayIsvsubMchParams isvsubMchParams =
|
||||
(WxpayIsvsubMchParams) configContextQueryService.queryIsvsubMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.WXPAY);
|
||||
|
||||
req.setSubMchId(isvsubMchParams.getSubMchId());
|
||||
req.setSubAppId(isvsubMchParams.getSubMchAppId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.github.binarywang.wxpay.service.WxPayService;
|
|||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxAppOrderRS;
|
||||
|
|
@ -62,7 +63,8 @@ public class WxApp extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
try {
|
||||
WxPayAppOrderResult payResult = wxPayService.createOrder(req);
|
||||
JSONObject resJSON = (JSONObject) JSON.toJSON(payResult);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.jeequan.jeepay.core.constants.CS;
|
|||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxH5OrderRQ;
|
||||
|
|
@ -64,7 +65,9 @@ public class WxH5 extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
try {
|
||||
WxPayMwebOrderResult wxPayMwebOrderResult = wxPayService.createOrder(req);
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.jeequan.jeepay.core.entity.PayOrder;
|
|||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ;
|
||||
|
|
@ -76,7 +77,8 @@ public class WxJsapi extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
try {
|
||||
WxPayMpOrderResult payResult = wxPayService.createOrder(req);
|
||||
JSONObject resJSON = (JSONObject) JSON.toJSON(payResult);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.jeequan.jeepay.core.entity.PayOrder;
|
|||
import com.jeequan.jeepay.core.exception.BizException;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ;
|
||||
|
|
@ -74,7 +75,8 @@ public class WxLite extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
try {
|
||||
WxPayMpOrderResult payResult = wxPayService.createOrder(req);
|
||||
JSONObject resJSON = (JSONObject) JSON.toJSON(payResult);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.jeequan.jeepay.core.constants.CS;
|
|||
import com.jeequan.jeepay.core.entity.PayOrder;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxNativeOrderRQ;
|
||||
|
|
@ -65,7 +66,8 @@ public class WxNative extends WxpayPaymentService {
|
|||
// 调起上游接口:
|
||||
// 1. 如果抛异常,则订单状态为: 生成状态,此时没有查单处理操作。 订单将超时关闭
|
||||
// 2. 接口调用成功, 后续异常需进行捕捉, 如果 逻辑代码出现异常则需要走完正常流程,此时订单状态为: 支付中, 需要查单处理。
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
try {
|
||||
WxPayNativeOrderResult wxPayNativeOrderResult = wxPayService.createOrder(req);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
|||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayV3Util;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -49,7 +50,8 @@ public class WxApp extends WxpayPaymentService {
|
|||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
wxPayService.getConfig().setTradeType(WxPayConstants.TradeType.APP);
|
||||
|
||||
// 构造请求数据
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
|||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayV3Util;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -53,7 +54,8 @@ public class WxH5 extends WxpayPaymentService {
|
|||
|
||||
WxH5OrderRQ bizRQ = (WxH5OrderRQ) rq;
|
||||
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
wxPayService.getConfig().setTradeType(WxPayConstants.TradeType.MWEB);
|
||||
|
||||
// 构造请求数据
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
|||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayV3Util;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -52,8 +53,8 @@ public class WxJsapi extends WxpayPaymentService {
|
|||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
WxJsapiOrderRQ bizRQ = (WxJsapiOrderRQ) rq;
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
// 构造请求数据
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchAppConfigContext);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
|||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayV3Util;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -52,7 +53,8 @@ public class WxLite extends WxpayPaymentService {
|
|||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
|
||||
WxJsapiOrderRQ bizRQ = (WxJsapiOrderRQ) rq;
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
|
||||
// 构造请求数据
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchAppConfigContext);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.jeequan.jeepay.pay.channel.wxpay.WxpayPaymentService;
|
|||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayKit;
|
||||
import com.jeequan.jeepay.pay.channel.wxpay.kits.WxpayV3Util;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.WxServiceWrapper;
|
||||
import com.jeequan.jeepay.pay.rqrs.AbstractRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
|
|
@ -53,7 +54,9 @@ public class WxNative extends WxpayPaymentService {
|
|||
|
||||
WxNativeOrderRQ bizRQ = (WxNativeOrderRQ) rq;
|
||||
|
||||
WxPayService wxPayService = mchAppConfigContext.getWxServiceWrapper().getWxPayService();
|
||||
WxServiceWrapper wxServiceWrapper = configContextQueryService.getWxServiceWrapper(mchAppConfigContext);
|
||||
|
||||
WxPayService wxPayService = wxServiceWrapper.getWxPayService();
|
||||
|
||||
// 构造请求数据
|
||||
JSONObject reqJSON = buildV3OrderRequest(payOrder, mchAppConfigContext);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class XxpayChannelRefundNoticeService extends AbstractChannelRefundNotice
|
|||
@Override
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, RefundOrder refundOrder, MchAppConfigContext mchAppConfigContext, NoticeTypeEnum noticeTypeEnum) {
|
||||
try {
|
||||
XxpayNormalMchParams xxpayParams = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
|
||||
XxpayNormalMchParams xxpayParams = (XxpayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
|
||||
// 获取请求参数
|
||||
JSONObject jsonParams = (JSONObject) params;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class YsfpayPaymentService extends AbstractPaymentService {
|
|||
}
|
||||
|
||||
reqParams.put("serProvId", isvParams.getSerProvId()); //云闪付服务商标识
|
||||
YsfpayIsvsubMchParams isvsubMchParams = mchAppConfigContext.getIsvsubMchParamsByIfCode(getIfCode(), YsfpayIsvsubMchParams.class);
|
||||
YsfpayIsvsubMchParams isvsubMchParams = (YsfpayIsvsubMchParams) configContextQueryService.queryIsvsubMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
reqParams.put("merId", isvsubMchParams.getMerId()); // 商户号
|
||||
|
||||
//签名
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.jeequan.jeepay.pay.rqrs.division.DivisionReceiverBindRQ;
|
|||
import com.jeequan.jeepay.pay.rqrs.division.DivisionReceiverBindRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.transfer.TransferOrderRS;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.service.impl.MchDivisionReceiverGroupService;
|
||||
import com.jeequan.jeepay.service.impl.MchDivisionReceiverService;
|
||||
|
|
@ -53,7 +54,7 @@ import java.util.Date;
|
|||
@RestController
|
||||
public class MchDivisionReceiverBindController extends ApiController {
|
||||
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
|
||||
@Autowired private MchDivisionReceiverService mchDivisionReceiverService;
|
||||
@Autowired private MchDivisionReceiverGroupService mchDivisionReceiverGroupService;
|
||||
|
|
@ -72,7 +73,7 @@ public class MchDivisionReceiverBindController extends ApiController {
|
|||
|
||||
|
||||
// 商户配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(bizRQ.getMchNo(), bizRQ.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(bizRQ.getMchNo(), bizRQ.getAppId());
|
||||
if(mchAppConfigContext == null){
|
||||
throw new BizException("获取商户应用信息失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
|||
import com.jeequan.jeepay.pay.rqrs.division.PayOrderDivisionExecRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.division.PayOrderDivisionExecRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.PayOrderDivisionProcessService;
|
||||
import com.jeequan.jeepay.service.impl.MchDivisionReceiverGroupService;
|
||||
|
|
@ -56,7 +57,7 @@ import java.util.Set;
|
|||
@RestController
|
||||
public class PayOrderDivisionExecController extends ApiController {
|
||||
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private PayOrderService payOrderService;
|
||||
@Autowired private MchDivisionReceiverService mchDivisionReceiverService;
|
||||
@Autowired private MchDivisionReceiverGroupService mchDivisionReceiverGroupService;
|
||||
|
|
@ -95,7 +96,7 @@ public class PayOrderDivisionExecController extends ApiController {
|
|||
this.checkReceiverList(receiverList, payOrder.getIfCode(), bizRQ.getMchNo(), bizRQ.getAppId());
|
||||
|
||||
// 商户配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(bizRQ.getMchNo(), bizRQ.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(bizRQ.getMchNo(), bizRQ.getAppId());
|
||||
if(mchAppConfigContext == null){
|
||||
throw new BizException("获取商户应用信息失败");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
package com.jeequan.jeepay.pay.ctrl.payorder;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.jeequan.jeepay.components.mq.model.PayOrderDivisionMQ;
|
||||
import com.jeequan.jeepay.components.mq.model.PayOrderReissueMQ;
|
||||
import com.jeequan.jeepay.components.mq.vender.IMQSender;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
|
|
@ -31,15 +29,13 @@ import com.jeequan.jeepay.core.utils.*;
|
|||
import com.jeequan.jeepay.pay.channel.IPaymentService;
|
||||
import com.jeequan.jeepay.pay.ctrl.ApiController;
|
||||
import com.jeequan.jeepay.pay.exception.ChannelException;
|
||||
import com.jeequan.jeepay.pay.model.IsvConfigContext;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.QrCashierOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.QrCashierOrderRS;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.PayMchNotifyService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.PayOrderProcessService;
|
||||
import com.jeequan.jeepay.service.impl.MchPayPassageService;
|
||||
import com.jeequan.jeepay.service.impl.PayOrderService;
|
||||
|
|
@ -64,7 +60,7 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
|
||||
@Autowired private MchPayPassageService mchPayPassageService;
|
||||
@Autowired private PayOrderService payOrderService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private PayOrderProcessService payOrderProcessService;
|
||||
@Autowired private SysConfigService sysConfigService;
|
||||
@Autowired private IMQSender mqSender;
|
||||
|
|
@ -126,7 +122,7 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
}
|
||||
|
||||
//获取支付参数 (缓存数据) 和 商户信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(mchNo, appId);
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(mchNo, appId);
|
||||
if(mchAppConfigContext == null){
|
||||
throw new BizException("获取商户应用信息失败");
|
||||
}
|
||||
|
|
@ -283,20 +279,16 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
|
||||
if(mchAppConfigContext.getMchType() == MchInfo.TYPE_NORMAL){ //普通商户
|
||||
|
||||
if(mchAppConfigContext.getNormalMchParamsByIfCode(ifCode) == null){
|
||||
if(configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), ifCode) == null){
|
||||
throw new BizException("商户应用参数未配置");
|
||||
}
|
||||
}else if(mchAppConfigContext.getMchType() == MchInfo.TYPE_ISVSUB){ //特约商户
|
||||
|
||||
mchAppConfigContext = configContextService.getMchAppConfigContext(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId());
|
||||
|
||||
if(mchAppConfigContext == null || mchAppConfigContext.getIsvsubMchParamsByIfCode(ifCode) == null){
|
||||
if(configContextQueryService.queryIsvsubMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), ifCode) == null){
|
||||
throw new BizException("特约商户参数未配置");
|
||||
}
|
||||
|
||||
IsvConfigContext isvConfigContext = configContextService.getIsvConfigContext(mchAppConfigContext.getMchInfo().getIsvNo());
|
||||
|
||||
if(isvConfigContext == null || isvConfigContext.getIsvParamsByIfCode(ifCode) == null){
|
||||
if(configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), ifCode) == null){
|
||||
throw new BizException("服务商参数未配置");
|
||||
}
|
||||
}
|
||||
|
|
@ -396,7 +388,7 @@ public abstract class AbstractPayOrderController extends ApiController {
|
|||
bizRS.setErrMsg(bizRS.getChannelRetMsg() != null ? bizRS.getChannelRetMsg().getChannelErrMsg() : null);
|
||||
}
|
||||
|
||||
return ApiRes.okWithSign(bizRS, configContextService.getMchAppConfigContext(bizRQ.getMchNo(), bizRQ.getAppId()).getMchApp().getAppSecret());
|
||||
return ApiRes.okWithSign(bizRS, configContextQueryService.queryMchApp(bizRQ.getMchNo(), bizRQ.getAppId()).getAppSecret());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.jeequan.jeepay.core.utils.SpringBeansUtil;
|
|||
import com.jeequan.jeepay.pay.channel.IChannelNoticeService;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.PayMchNotifyService;
|
||||
import com.jeequan.jeepay.pay.service.PayOrderProcessService;
|
||||
|
|
@ -51,7 +52,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
public class ChannelNoticeController extends AbstractCtrl {
|
||||
|
||||
@Autowired private PayOrderService payOrderService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private PayMchNotifyService payMchNotifyService;
|
||||
@Autowired private PayOrderProcessService payOrderProcessService;
|
||||
|
||||
|
|
@ -105,7 +106,7 @@ public class ChannelNoticeController extends AbstractCtrl {
|
|||
}
|
||||
|
||||
//查询出商户应用的配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(payOrder.getMchNo(), payOrder.getAppId());
|
||||
|
||||
//调起接口的回调判断
|
||||
ChannelRetMsg notifyResult = payNotifyService.doNotice(request, mutablePair.getRight(), payOrder, mchAppConfigContext, IChannelNoticeService.NoticeTypeEnum.DO_RETURN);
|
||||
|
|
@ -202,7 +203,8 @@ public class ChannelNoticeController extends AbstractCtrl {
|
|||
}
|
||||
|
||||
//查询出商户应用的配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(payOrder.getMchNo(), payOrder.getAppId());
|
||||
|
||||
|
||||
//调起接口的回调判断
|
||||
ChannelRetMsg notifyResult = payNotifyService.doNotice(request, mutablePair.getRight(), payOrder, mchAppConfigContext, IChannelNoticeService.NoticeTypeEnum.DO_NOTIFY);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.jeequan.jeepay.core.model.ApiRes;
|
|||
import com.jeequan.jeepay.pay.ctrl.ApiController;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.QueryPayOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.QueryPayOrderRS;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.service.impl.PayOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -41,7 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
public class QueryOrderController extends ApiController {
|
||||
|
||||
@Autowired private PayOrderService payOrderService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
/**
|
||||
* 查单接口
|
||||
|
|
@ -62,7 +63,7 @@ public class QueryOrderController extends ApiController {
|
|||
}
|
||||
|
||||
QueryPayOrderRS bizRes = QueryPayOrderRS.buildByPayOrder(payOrder);
|
||||
return ApiRes.okWithSign(bizRes, configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId()).getMchApp().getAppSecret());
|
||||
return ApiRes.okWithSign(bizRes, configContextQueryService.queryMchApp(rq.getMchNo(), rq.getAppId()).getAppSecret());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import com.jeequan.jeepay.core.utils.JeepayKit;
|
|||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.UnifiedOrderRS;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.AutoBarOrderRQ;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.service.impl.PayWayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
|
@ -44,7 +44,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
public class UnifiedOrderController extends AbstractPayOrderController {
|
||||
|
||||
@Autowired private PayWayService payWayService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
/**
|
||||
* 统一下单接口
|
||||
|
|
@ -75,7 +75,7 @@ public class UnifiedOrderController extends AbstractPayOrderController {
|
|||
res.setPayData(bizRes.buildPayData());
|
||||
}
|
||||
|
||||
return ApiRes.okWithSign(res, configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId()).getMchApp().getAppSecret());
|
||||
return ApiRes.okWithSign(res, configContextQueryService.queryMchApp(rq.getMchNo(), rq.getAppId()).getAppSecret());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.jeequan.jeepay.pay.channel.IChannelUserService;
|
|||
import com.jeequan.jeepay.pay.ctrl.payorder.AbstractPayOrderController;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.ChannelUserIdRQ;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.service.impl.SysConfigService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -45,7 +46,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RequestMapping("/api/channelUserId")
|
||||
public class ChannelUserIdController extends AbstractPayOrderController {
|
||||
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private SysConfigService sysConfigService;
|
||||
|
||||
/** 重定向到微信地址 **/
|
||||
|
|
@ -79,7 +80,7 @@ public class ChannelUserIdController extends AbstractPayOrderController {
|
|||
String callbackUrl = sysConfigService.getDBApplicationConfig().genMchChannelUserIdApiOauth2RedirectUrlEncode(jsonObject);
|
||||
|
||||
//获取商户配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(rq.getMchNo(), rq.getAppId());
|
||||
String redirectUrl = channelUserService.buildUserRedirectUrl(callbackUrl, mchAppConfigContext);
|
||||
response.sendRedirect(redirectUrl);
|
||||
|
||||
|
|
@ -106,7 +107,7 @@ public class ChannelUserIdController extends AbstractPayOrderController {
|
|||
}
|
||||
|
||||
//获取商户配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(mchNo, appId);
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(mchNo, appId);
|
||||
|
||||
//获取渠道用户ID
|
||||
String channelUserId = channelUserService.getChannelUserId(getReqParamJSON(), mchAppConfigContext);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import com.jeequan.jeepay.pay.channel.IChannelUserService;
|
|||
import com.jeequan.jeepay.pay.ctrl.payorder.AbstractPayOrderController;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.AliJsapiOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.payorder.payway.WxJsapiOrderRQ;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.PayMchNotifyService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
|
|
@ -48,7 +49,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
public class QrCashierController extends AbstractPayOrderController {
|
||||
|
||||
@Autowired private PayOrderService payOrderService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private SysConfigService sysConfigService;
|
||||
@Autowired private PayMchNotifyService payMchNotifyService;
|
||||
|
||||
|
|
@ -65,7 +66,7 @@ public class QrCashierController extends AbstractPayOrderController {
|
|||
String redirectUrlEncode = sysConfigService.getDBApplicationConfig().genOauth2RedirectUrlEncode(payOrder.getPayOrderId());
|
||||
|
||||
//获取商户配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(payOrder.getMchNo(), payOrder.getAppId());
|
||||
|
||||
//获取接口并返回数据
|
||||
IChannelUserService channelUserService = getServiceByWayCode(getWayCode(), "ChannelUserService", IChannelUserService.class);
|
||||
|
|
@ -85,7 +86,7 @@ public class QrCashierController extends AbstractPayOrderController {
|
|||
String wayCode = getWayCode();
|
||||
|
||||
//获取商户配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(payOrder.getMchNo(), payOrder.getAppId());
|
||||
IChannelUserService channelUserService = getServiceByWayCode(wayCode, "ChannelUserService", IChannelUserService.class);
|
||||
return ApiRes.ok(channelUserService.getChannelUserId(getReqParamJSON(), mchAppConfigContext));
|
||||
|
||||
|
|
@ -106,7 +107,7 @@ public class QrCashierController extends AbstractPayOrderController {
|
|||
resOrder.setMchOrderNo(payOrder.getMchOrderNo());
|
||||
resOrder.setMchName(payOrder.getMchName());
|
||||
resOrder.setAmount(payOrder.getAmount());
|
||||
resOrder.setReturnUrl(payMchNotifyService.createReturnUrl(payOrder, configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId()).getMchApp().getAppSecret()));
|
||||
resOrder.setReturnUrl(payMchNotifyService.createReturnUrl(payOrder, configContextQueryService.queryMchInfoAndAppInfo(payOrder.getMchNo(), payOrder.getAppId()).getMchApp().getAppSecret()));
|
||||
return ApiRes.ok(resOrder);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import com.jeequan.jeepay.core.utils.SpringBeansUtil;
|
|||
import com.jeequan.jeepay.pay.channel.IChannelRefundNoticeService;
|
||||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.RefundOrderProcessService;
|
||||
import com.jeequan.jeepay.service.impl.RefundOrderService;
|
||||
|
|
@ -50,7 +51,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
public class ChannelRefundNoticeController extends AbstractCtrl {
|
||||
|
||||
@Autowired private RefundOrderService refundOrderService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private RefundOrderProcessService refundOrderProcessService;
|
||||
|
||||
/** 异步回调入口 **/
|
||||
|
|
@ -104,7 +105,7 @@ public class ChannelRefundNoticeController extends AbstractCtrl {
|
|||
}
|
||||
|
||||
//查询出商户应用的配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(refundOrder.getMchNo(), refundOrder.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(refundOrder.getMchNo(), refundOrder.getAppId());
|
||||
|
||||
//调起接口的回调判断
|
||||
ChannelRetMsg notifyResult = refundNotifyService.doNotice(request, mutablePair.getRight(), refundOrder, mchAppConfigContext, IChannelRefundNoticeService.NoticeTypeEnum.DO_NOTIFY);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.jeequan.jeepay.core.model.ApiRes;
|
|||
import com.jeequan.jeepay.pay.ctrl.ApiController;
|
||||
import com.jeequan.jeepay.pay.rqrs.refund.QueryRefundOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.refund.QueryRefundOrderRS;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.service.impl.RefundOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -41,7 +42,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
public class QueryRefundOrderController extends ApiController {
|
||||
|
||||
@Autowired private RefundOrderService refundOrderService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
/**
|
||||
* 查单接口
|
||||
|
|
@ -62,6 +63,6 @@ public class QueryRefundOrderController extends ApiController {
|
|||
}
|
||||
|
||||
QueryRefundOrderRS bizRes = QueryRefundOrderRS.buildByRefundOrder(refundOrder);
|
||||
return ApiRes.okWithSign(bizRes, configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId()).getMchApp().getAppSecret());
|
||||
return ApiRes.okWithSign(bizRes, configContextQueryService.queryMchApp(rq.getMchNo(), rq.getAppId()).getAppSecret());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
|||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.pay.rqrs.refund.RefundOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.refund.RefundOrderRS;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.PayMchNotifyService;
|
||||
import com.jeequan.jeepay.service.impl.PayOrderService;
|
||||
|
|
@ -57,8 +58,9 @@ public class RefundOrderController extends ApiController {
|
|||
|
||||
@Autowired private PayOrderService payOrderService;
|
||||
@Autowired private RefundOrderService refundOrderService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private PayMchNotifyService payMchNotifyService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
|
||||
/** 申请退款 **/
|
||||
@PostMapping("/api/refund/refundOrder")
|
||||
|
|
@ -120,7 +122,7 @@ public class RefundOrderController extends ApiController {
|
|||
}
|
||||
|
||||
//获取支付参数 (缓存数据) 和 商户信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(mchNo, appId);
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(mchNo, appId);
|
||||
if(mchAppConfigContext == null){
|
||||
throw new BizException("获取商户应用信息失败");
|
||||
}
|
||||
|
|
@ -148,7 +150,7 @@ public class RefundOrderController extends ApiController {
|
|||
this.processChannelMsg(channelRetMsg, refundOrder);
|
||||
|
||||
RefundOrderRS bizRes = RefundOrderRS.buildByRefundOrder(refundOrder);
|
||||
return ApiRes.okWithSign(bizRes, configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId()).getMchApp().getAppSecret());
|
||||
return ApiRes.okWithSign(bizRes, configContextQueryService.queryMchApp(rq.getMchNo(), rq.getAppId()).getAppSecret());
|
||||
|
||||
|
||||
} catch (BizException e) {
|
||||
|
|
@ -164,7 +166,7 @@ public class RefundOrderController extends ApiController {
|
|||
}
|
||||
|
||||
RefundOrderRS bizRes = RefundOrderRS.buildByRefundOrder(refundOrder);
|
||||
return ApiRes.okWithSign(bizRes, configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId()).getMchApp().getAppSecret());
|
||||
return ApiRes.okWithSign(bizRes, configContextQueryService.queryMchApp(rq.getMchNo(), rq.getAppId()).getAppSecret());
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import com.jeequan.jeepay.core.model.ApiRes;
|
|||
import com.jeequan.jeepay.pay.ctrl.ApiController;
|
||||
import com.jeequan.jeepay.pay.rqrs.transfer.QueryTransferOrderRQ;
|
||||
import com.jeequan.jeepay.pay.rqrs.transfer.QueryTransferOrderRS;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.service.impl.TransferOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
public class QueryTransferOrderController extends ApiController {
|
||||
|
||||
@Autowired private TransferOrderService transferOrderService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
/**
|
||||
* 查单接口
|
||||
|
|
@ -62,6 +62,6 @@ public class QueryTransferOrderController extends ApiController {
|
|||
}
|
||||
|
||||
QueryTransferOrderRS bizRes = QueryTransferOrderRS.buildByRecord(refundOrder);
|
||||
return ApiRes.okWithSign(bizRes, configContextService.getMchAppConfigContext(rq.getMchNo(), rq.getAppId()).getMchApp().getAppSecret());
|
||||
return ApiRes.okWithSign(bizRes, configContextQueryService.queryMchApp(rq.getMchNo(), rq.getAppId()).getAppSecret());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ 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.rqrs.transfer.TransferOrderRS;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextQueryService;
|
||||
import com.jeequan.jeepay.pay.service.ConfigContextService;
|
||||
import com.jeequan.jeepay.pay.service.PayMchNotifyService;
|
||||
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
|
||||
|
|
@ -53,7 +54,7 @@ import java.util.Date;
|
|||
@RestController
|
||||
public class TransferOrderController extends ApiController {
|
||||
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private TransferOrderService transferOrderService;
|
||||
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
|
||||
@Autowired private PayMchNotifyService payMchNotifyService;
|
||||
|
|
@ -86,7 +87,7 @@ public class TransferOrderController extends ApiController {
|
|||
}
|
||||
|
||||
// 商户配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(mchNo, appId);
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(mchNo, appId);
|
||||
if(mchAppConfigContext == null){
|
||||
throw new BizException("获取商户应用信息失败");
|
||||
}
|
||||
|
|
@ -142,7 +143,7 @@ public class TransferOrderController extends ApiController {
|
|||
}
|
||||
|
||||
TransferOrderRS bizRes = TransferOrderRS.buildByRecord(transferOrder);
|
||||
return ApiRes.okWithSign(bizRes, configContextService.getMchAppConfigContext(bizRQ.getMchNo(), bizRQ.getAppId()).getMchApp().getAppSecret());
|
||||
return ApiRes.okWithSign(bizRes, configContextQueryService.queryMchApp(bizRQ.getMchNo(), bizRQ.getAppId()).getAppSecret());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("系统异常:{}", e);
|
||||
|
|
|
|||
|
|
@ -15,12 +15,14 @@
|
|||
*/
|
||||
package com.jeequan.jeepay.pay.model;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.AlipayRequest;
|
||||
import com.alipay.api.AlipayResponse;
|
||||
import com.alipay.api.*;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
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.AlipayNormalMchParams;
|
||||
import com.jeequan.jeepay.core.utils.SpringBeansUtil;
|
||||
import com.jeequan.jeepay.pay.exception.ChannelException;
|
||||
import com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -71,5 +73,104 @@ public class AlipayClientWrapper {
|
|||
throw ChannelException.sysError("调用支付宝client服务异常");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 构建支付宝client 包装类
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/6/8 17:46
|
||||
*/
|
||||
public static AlipayClientWrapper buildAlipayClientWrapper(Byte useCert, Byte sandbox, String appId, String privateKey, String alipayPublicKey, String signType, String appCert,
|
||||
String alipayPublicCert, String alipayRootCert){
|
||||
|
||||
//避免空值
|
||||
sandbox = sandbox == null ? CS.NO : sandbox;
|
||||
|
||||
AlipayClient alipayClient = null;
|
||||
if(useCert != null && useCert == CS.YES){ //证书的方式
|
||||
|
||||
ChannelCertConfigKitBean channelCertConfigKitBean = SpringBeansUtil.getBean(ChannelCertConfigKitBean.class);
|
||||
|
||||
CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
|
||||
certAlipayRequest.setServerUrl(sandbox == CS.YES ? com.jeequan.jeepay.core.model.params.alipay.AlipayConfig.SANDBOX_SERVER_URL : com.jeequan.jeepay.core.model.params.alipay.AlipayConfig.PROD_SERVER_URL);
|
||||
certAlipayRequest.setAppId(appId);
|
||||
certAlipayRequest.setPrivateKey(privateKey);
|
||||
certAlipayRequest.setFormat(com.jeequan.jeepay.core.model.params.alipay.AlipayConfig.FORMAT);
|
||||
certAlipayRequest.setCharset(com.jeequan.jeepay.core.model.params.alipay.AlipayConfig.CHARSET);
|
||||
certAlipayRequest.setSignType(signType);
|
||||
|
||||
certAlipayRequest.setCertPath(channelCertConfigKitBean.getCertFilePath(appCert));
|
||||
certAlipayRequest.setAlipayPublicCertPath(channelCertConfigKitBean.getCertFilePath(alipayPublicCert));
|
||||
certAlipayRequest.setRootCertPath(channelCertConfigKitBean.getCertFilePath(alipayRootCert));
|
||||
try {
|
||||
alipayClient = new DefaultAlipayClient(certAlipayRequest);
|
||||
} catch (AlipayApiException e) {
|
||||
log.error("error" ,e);
|
||||
alipayClient = null;
|
||||
}
|
||||
}else{
|
||||
alipayClient = new DefaultAlipayClient(sandbox == CS.YES ? com.jeequan.jeepay.core.model.params.alipay.AlipayConfig.SANDBOX_SERVER_URL : com.jeequan.jeepay.core.model.params.alipay.AlipayConfig.PROD_SERVER_URL
|
||||
, appId, privateKey, com.jeequan.jeepay.core.model.params.alipay.AlipayConfig.FORMAT, AlipayConfig.CHARSET,
|
||||
alipayPublicKey, signType);
|
||||
}
|
||||
|
||||
return new AlipayClientWrapper(useCert, alipayClient);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static AlipayClientWrapper buildAlipayClientWrapper(AlipayIsvParams alipayParams){
|
||||
|
||||
return buildAlipayClientWrapper(
|
||||
alipayParams.getUseCert(), alipayParams.getSandbox(), alipayParams.getAppId(), alipayParams.getPrivateKey(),
|
||||
alipayParams.getAlipayPublicKey(), alipayParams.getSignType(), alipayParams.getAppPublicCert(),
|
||||
alipayParams.getAlipayPublicCert(), alipayParams.getAlipayRootCert()
|
||||
);
|
||||
}
|
||||
|
||||
public static AlipayClientWrapper buildAlipayClientWrapper(AlipayNormalMchParams alipayParams){
|
||||
|
||||
return buildAlipayClientWrapper(
|
||||
alipayParams.getUseCert(), alipayParams.getSandbox(), alipayParams.getAppId(), alipayParams.getPrivateKey(),
|
||||
alipayParams.getAlipayPublicKey(), alipayParams.getSignType(), alipayParams.getAppPublicCert(),
|
||||
alipayParams.getAlipayPublicCert(), alipayParams.getAlipayRootCert()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,21 @@
|
|||
*/
|
||||
package com.jeequan.jeepay.pay.model;
|
||||
|
||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvParams;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams;
|
||||
import com.jeequan.jeepay.core.utils.SpringBeansUtil;
|
||||
import com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/*
|
||||
* wxService 包装类
|
||||
|
|
@ -40,4 +51,61 @@ public class WxServiceWrapper {
|
|||
/** 缓存 wxJavaService 对象 **/
|
||||
private WxMpService wxMpService;
|
||||
|
||||
|
||||
public static WxServiceWrapper buildWxServiceWrapper(String mchId, String appId, String appSecret, String mchKey, String apiVersion, String apiV3Key,
|
||||
String serialNo, String cert, String apiClientKey){
|
||||
|
||||
WxPayConfig wxPayConfig = new WxPayConfig();
|
||||
wxPayConfig.setMchId(mchId);
|
||||
wxPayConfig.setAppId(appId);
|
||||
wxPayConfig.setMchKey(mchKey);
|
||||
|
||||
if (CS.PAY_IF_VERSION.WX_V2.equals(apiVersion)) { // 微信API V2
|
||||
wxPayConfig.setSignType(WxPayConstants.SignType.MD5);
|
||||
|
||||
ChannelCertConfigKitBean channelCertConfigKitBean = SpringBeansUtil.getBean(ChannelCertConfigKitBean.class);
|
||||
|
||||
// api证书。
|
||||
if(StringUtils.isNotBlank(cert)){
|
||||
wxPayConfig.setKeyPath(channelCertConfigKitBean.getCertFilePath(cert));
|
||||
}
|
||||
} else if (CS.PAY_IF_VERSION.WX_V3.equals(apiVersion)) { // 微信API V3
|
||||
|
||||
ChannelCertConfigKitBean channelCertConfigKitBean = SpringBeansUtil.getBean(ChannelCertConfigKitBean.class);
|
||||
|
||||
wxPayConfig.setApiV3Key(apiV3Key);
|
||||
wxPayConfig.setCertSerialNo(serialNo);
|
||||
wxPayConfig.setPrivateCertPath(channelCertConfigKitBean.getCertFilePath(cert));
|
||||
wxPayConfig.setPrivateKeyPath(channelCertConfigKitBean.getCertFilePath(apiClientKey));
|
||||
}
|
||||
|
||||
WxPayService wxPayService = new WxPayServiceImpl();
|
||||
wxPayService.setConfig(wxPayConfig); //微信配置信息
|
||||
|
||||
WxMpDefaultConfigImpl wxMpConfigStorage = new WxMpDefaultConfigImpl();
|
||||
wxMpConfigStorage.setAppId(appId);
|
||||
wxMpConfigStorage.setSecret(appSecret);
|
||||
|
||||
WxMpService wxMpService = new WxMpServiceImpl();
|
||||
wxMpService.setWxMpConfigStorage(wxMpConfigStorage); //微信配置信息
|
||||
|
||||
return new WxServiceWrapper(apiVersion, wxPayService, wxMpService);
|
||||
}
|
||||
|
||||
|
||||
public static WxServiceWrapper buildWxServiceWrapper(WxpayIsvParams wxpayParams){
|
||||
//放置 wxJavaService
|
||||
return buildWxServiceWrapper(wxpayParams.getMchId(), wxpayParams.getAppId(),
|
||||
wxpayParams.getAppSecret(), wxpayParams.getKey(), wxpayParams.getApiVersion(), wxpayParams.getApiV3Key(),
|
||||
wxpayParams.getSerialNo(), wxpayParams.getCert(), wxpayParams.getApiClientKey());
|
||||
}
|
||||
|
||||
public static WxServiceWrapper buildWxServiceWrapper(WxpayNormalMchParams wxpayParams){
|
||||
//放置 wxJavaService
|
||||
return buildWxServiceWrapper(wxpayParams.getMchId(), wxpayParams.getAppId(),
|
||||
wxpayParams.getAppSecret(), wxpayParams.getKey(), wxpayParams.getApiVersion(), wxpayParams.getApiV3Key(),
|
||||
wxpayParams.getSerialNo(), wxpayParams.getCert(), wxpayParams.getApiClientKey());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ import com.jeequan.jeepay.pay.channel.IRefundService;
|
|||
import com.jeequan.jeepay.pay.model.MchAppConfigContext;
|
||||
import com.jeequan.jeepay.pay.rqrs.msg.ChannelRetMsg;
|
||||
import com.jeequan.jeepay.service.impl.PayOrderService;
|
||||
import com.jeequan.jeepay.service.impl.RefundOrderService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -41,11 +39,9 @@ import org.springframework.stereotype.Service;
|
|||
@Slf4j
|
||||
public class ChannelOrderReissueService {
|
||||
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private PayOrderService payOrderService;
|
||||
@Autowired private RefundOrderService refundOrderService;
|
||||
@Autowired private PayOrderProcessService payOrderProcessService;
|
||||
@Autowired private PayMchNotifyService payMchNotifyService;
|
||||
@Autowired private RefundOrderProcessService refundOrderProcessService;
|
||||
|
||||
|
||||
|
|
@ -66,7 +62,7 @@ public class ChannelOrderReissueService {
|
|||
}
|
||||
|
||||
//查询出商户应用的配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(payOrder.getMchNo(), payOrder.getAppId());
|
||||
|
||||
ChannelRetMsg channelRetMsg = queryService.query(payOrder, mchAppConfigContext);
|
||||
if(channelRetMsg == null){
|
||||
|
|
@ -116,7 +112,7 @@ public class ChannelOrderReissueService {
|
|||
}
|
||||
|
||||
//查询出商户应用的配置信息
|
||||
MchAppConfigContext mchAppConfigContext = configContextService.getMchAppConfigContext(refundOrder.getMchNo(), refundOrder.getAppId());
|
||||
MchAppConfigContext mchAppConfigContext = configContextQueryService.queryMchInfoAndAppInfo(refundOrder.getMchNo(), refundOrder.getAppId());
|
||||
|
||||
ChannelRetMsg channelRetMsg = queryService.query(refundOrder, mchAppConfigContext);
|
||||
if(channelRetMsg == null){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,221 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2031, 河北计全科技有限公司 (https://www.jeequan.com & jeequan@126.com).
|
||||
* <p>
|
||||
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* <p>
|
||||
* http://www.gnu.org/licenses/lgpl.html
|
||||
* <p>
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.jeequan.jeepay.pay.service;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.CertAlipayRequest;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.IsvInfo;
|
||||
import com.jeequan.jeepay.core.entity.MchApp;
|
||||
import com.jeequan.jeepay.core.entity.MchInfo;
|
||||
import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
|
||||
import com.jeequan.jeepay.core.model.params.IsvParams;
|
||||
import com.jeequan.jeepay.core.model.params.IsvsubMchParams;
|
||||
import com.jeequan.jeepay.core.model.params.NormalMchParams;
|
||||
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.AlipayNormalMchParams;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvParams;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams;
|
||||
import com.jeequan.jeepay.pay.model.*;
|
||||
import com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean;
|
||||
import com.jeequan.jeepay.service.impl.IsvInfoService;
|
||||
import com.jeequan.jeepay.service.impl.MchAppService;
|
||||
import com.jeequan.jeepay.service.impl.MchInfoService;
|
||||
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/*
|
||||
* 配置信息查询服务 (兼容 缓存 和 直接查询方式)
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/11/18 14:41
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ConfigContextQueryService {
|
||||
|
||||
@Autowired ConfigContextService configContextService;
|
||||
@Autowired private MchInfoService mchInfoService;
|
||||
@Autowired private MchAppService mchAppService;
|
||||
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
|
||||
|
||||
private boolean isCache(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public MchApp queryMchApp(String mchNo, String mchAppId){
|
||||
|
||||
if(isCache()){
|
||||
return configContextService.getMchAppConfigContext(mchNo, mchAppId).getMchApp();
|
||||
}
|
||||
|
||||
return mchAppService.getOneByMch(mchNo, mchAppId);
|
||||
}
|
||||
|
||||
public MchAppConfigContext queryMchInfoAndAppInfo(String mchNo, String mchAppId){
|
||||
|
||||
if(isCache()){
|
||||
return configContextService.getMchAppConfigContext(mchNo, mchAppId);
|
||||
}
|
||||
|
||||
MchInfo mchInfo = mchInfoService.getById(mchNo);
|
||||
MchApp mchApp = queryMchApp(mchNo, mchAppId);
|
||||
|
||||
if(mchInfo == null || mchApp == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
MchAppConfigContext result = new MchAppConfigContext();
|
||||
result.setMchInfo(mchInfo);
|
||||
result.setMchNo(mchNo);
|
||||
result.setMchType(mchInfo.getType());
|
||||
|
||||
result.setMchApp(mchApp);
|
||||
result.setAppId(mchAppId);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public NormalMchParams queryNormalMchParams(String mchNo, String mchAppId, String ifCode){
|
||||
|
||||
if(isCache()){
|
||||
return configContextService.getMchAppConfigContext(mchNo, mchAppId).getNormalMchParamsByIfCode(ifCode);
|
||||
}
|
||||
|
||||
// 查询商户的所有支持的参数配置
|
||||
PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getOne(PayInterfaceConfig.gw()
|
||||
.select(PayInterfaceConfig::getIfCode, PayInterfaceConfig::getIfParams)
|
||||
.eq(PayInterfaceConfig::getState, CS.YES)
|
||||
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_MCH_APP)
|
||||
.eq(PayInterfaceConfig::getInfoId, mchAppId)
|
||||
.eq(PayInterfaceConfig::getIfCode, ifCode)
|
||||
);
|
||||
|
||||
if(payInterfaceConfig == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
return NormalMchParams.factory(payInterfaceConfig.getIfCode(), payInterfaceConfig.getIfParams());
|
||||
}
|
||||
|
||||
|
||||
public IsvsubMchParams queryIsvsubMchParams(String mchNo, String mchAppId, String ifCode){
|
||||
|
||||
if(isCache()){
|
||||
return configContextService.getMchAppConfigContext(mchNo, mchAppId).getIsvsubMchParamsByIfCode(ifCode);
|
||||
}
|
||||
|
||||
// 查询商户的所有支持的参数配置
|
||||
PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getOne(PayInterfaceConfig.gw()
|
||||
.select(PayInterfaceConfig::getIfCode, PayInterfaceConfig::getIfParams)
|
||||
.eq(PayInterfaceConfig::getState, CS.YES)
|
||||
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_MCH_APP)
|
||||
.eq(PayInterfaceConfig::getInfoId, mchAppId)
|
||||
.eq(PayInterfaceConfig::getIfCode, ifCode)
|
||||
);
|
||||
|
||||
if(payInterfaceConfig == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
return IsvsubMchParams.factory(payInterfaceConfig.getIfCode(), payInterfaceConfig.getIfParams());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public IsvParams queryIsvParams(String isvNo, String ifCode){
|
||||
|
||||
if(isCache()){
|
||||
IsvConfigContext isvConfigContext = configContextService.getIsvConfigContext(isvNo);
|
||||
return isvConfigContext == null ? null : isvConfigContext.getIsvParamsByIfCode(ifCode);
|
||||
}
|
||||
|
||||
// 查询商户的所有支持的参数配置
|
||||
PayInterfaceConfig payInterfaceConfig = payInterfaceConfigService.getOne(PayInterfaceConfig.gw()
|
||||
.select(PayInterfaceConfig::getIfCode, PayInterfaceConfig::getIfParams)
|
||||
.eq(PayInterfaceConfig::getState, CS.YES)
|
||||
.eq(PayInterfaceConfig::getInfoType, CS.INFO_TYPE_ISV)
|
||||
.eq(PayInterfaceConfig::getInfoId, isvNo)
|
||||
.eq(PayInterfaceConfig::getIfCode, ifCode)
|
||||
);
|
||||
|
||||
if(payInterfaceConfig == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
return IsvParams.factory(payInterfaceConfig.getIfCode(), payInterfaceConfig.getIfParams());
|
||||
|
||||
}
|
||||
|
||||
public AlipayClientWrapper getAlipayClientWrapper(MchAppConfigContext mchAppConfigContext){
|
||||
|
||||
if(isCache()){
|
||||
return
|
||||
configContextService.getMchAppConfigContext(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId()).getAlipayClientWrapper();
|
||||
}
|
||||
|
||||
if(mchAppConfigContext.isIsvsubMch()){
|
||||
|
||||
AlipayIsvParams alipayParams = (AlipayIsvParams)queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), CS.IF_CODE.ALIPAY);
|
||||
return AlipayClientWrapper.buildAlipayClientWrapper(alipayParams);
|
||||
}else{
|
||||
|
||||
AlipayNormalMchParams alipayParams = (AlipayNormalMchParams)queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.ALIPAY);
|
||||
return AlipayClientWrapper.buildAlipayClientWrapper(alipayParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public WxServiceWrapper getWxServiceWrapper(MchAppConfigContext mchAppConfigContext){
|
||||
|
||||
if(isCache()){
|
||||
return
|
||||
configContextService.getMchAppConfigContext(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId()).getWxServiceWrapper();
|
||||
}
|
||||
|
||||
if(mchAppConfigContext.isIsvsubMch()){
|
||||
|
||||
WxpayIsvParams wxParams = (WxpayIsvParams)queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), CS.IF_CODE.WXPAY);
|
||||
return WxServiceWrapper.buildWxServiceWrapper(wxParams);
|
||||
}else{
|
||||
|
||||
WxpayNormalMchParams wxParams = (WxpayNormalMchParams)queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.WXPAY);
|
||||
return WxServiceWrapper.buildWxServiceWrapper(wxParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -15,14 +15,6 @@
|
|||
*/
|
||||
package com.jeequan.jeepay.pay.service;
|
||||
|
||||
import com.alipay.api.AlipayApiException;
|
||||
import com.alipay.api.AlipayClient;
|
||||
import com.alipay.api.CertAlipayRequest;
|
||||
import com.alipay.api.DefaultAlipayClient;
|
||||
import com.github.binarywang.wxpay.config.WxPayConfig;
|
||||
import com.github.binarywang.wxpay.constant.WxPayConstants;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
||||
import com.jeequan.jeepay.core.constants.CS;
|
||||
import com.jeequan.jeepay.core.entity.IsvInfo;
|
||||
import com.jeequan.jeepay.core.entity.MchApp;
|
||||
|
|
@ -31,22 +23,16 @@ import com.jeequan.jeepay.core.entity.PayInterfaceConfig;
|
|||
import com.jeequan.jeepay.core.model.params.IsvParams;
|
||||
import com.jeequan.jeepay.core.model.params.IsvsubMchParams;
|
||||
import com.jeequan.jeepay.core.model.params.NormalMchParams;
|
||||
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.AlipayNormalMchParams;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayIsvParams;
|
||||
import com.jeequan.jeepay.core.model.params.wxpay.WxpayNormalMchParams;
|
||||
import com.jeequan.jeepay.pay.model.*;
|
||||
import com.jeequan.jeepay.pay.util.ChannelCertConfigKitBean;
|
||||
import com.jeequan.jeepay.service.impl.IsvInfoService;
|
||||
import com.jeequan.jeepay.service.impl.MchAppService;
|
||||
import com.jeequan.jeepay.service.impl.MchInfoService;
|
||||
import com.jeequan.jeepay.service.impl.PayInterfaceConfigService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -79,7 +65,6 @@ public class ConfigContextService {
|
|||
@Autowired private MchAppService mchAppService;
|
||||
@Autowired private IsvInfoService isvInfoService;
|
||||
@Autowired private PayInterfaceConfigService payInterfaceConfigService;
|
||||
@Autowired private ChannelCertConfigKitBean channelCertConfigKitBean;
|
||||
|
||||
|
||||
/** 获取 [商户配置信息] **/
|
||||
|
|
@ -224,22 +209,13 @@ public class ConfigContextService {
|
|||
|
||||
AlipayNormalMchParams alipayParams = mchAppConfigContext.getNormalMchParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayNormalMchParams.class);
|
||||
if(alipayParams != null){
|
||||
|
||||
mchAppConfigContext.setAlipayClientWrapper(buildAlipayClientWrapper(
|
||||
alipayParams.getUseCert(), alipayParams.getSandbox(), alipayParams.getAppId(), alipayParams.getPrivateKey(),
|
||||
alipayParams.getAlipayPublicKey(), alipayParams.getSignType(), alipayParams.getAppPublicCert(),
|
||||
alipayParams.getAlipayPublicCert(), alipayParams.getAlipayRootCert()
|
||||
)
|
||||
);
|
||||
|
||||
mchAppConfigContext.setAlipayClientWrapper(AlipayClientWrapper.buildAlipayClientWrapper(alipayParams));
|
||||
}
|
||||
|
||||
//放置 wxJavaService
|
||||
WxpayNormalMchParams wxpayParams = mchAppConfigContext.getNormalMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayNormalMchParams.class);
|
||||
if(wxpayParams != null){
|
||||
mchAppConfigContext.setWxServiceWrapper(buildWxServiceWrapper(wxpayParams.getMchId(), wxpayParams.getAppId(),
|
||||
wxpayParams.getAppSecret(), wxpayParams.getKey(), wxpayParams.getApiVersion(), wxpayParams.getApiV3Key(),
|
||||
wxpayParams.getSerialNo(), wxpayParams.getCert(), wxpayParams.getApiClientKey()));
|
||||
mchAppConfigContext.setWxServiceWrapper(WxServiceWrapper.buildWxServiceWrapper(wxpayParams));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -311,20 +287,13 @@ public class ConfigContextService {
|
|||
//放置alipay client
|
||||
AlipayIsvParams alipayParams = isvConfigContext.getIsvParamsByIfCode(CS.IF_CODE.ALIPAY, AlipayIsvParams.class);
|
||||
if(alipayParams != null){
|
||||
isvConfigContext.setAlipayClientWrapper(buildAlipayClientWrapper(
|
||||
alipayParams.getUseCert(), alipayParams.getSandbox(), alipayParams.getAppId(), alipayParams.getPrivateKey(),
|
||||
alipayParams.getAlipayPublicKey(), alipayParams.getSignType(), alipayParams.getAppPublicCert(),
|
||||
alipayParams.getAlipayPublicCert(), alipayParams.getAlipayRootCert()
|
||||
)
|
||||
);
|
||||
isvConfigContext.setAlipayClientWrapper(AlipayClientWrapper.buildAlipayClientWrapper(alipayParams));
|
||||
}
|
||||
|
||||
//放置 wxJavaService
|
||||
WxpayIsvParams wxpayParams = isvConfigContext.getIsvParamsByIfCode(CS.IF_CODE.WXPAY, WxpayIsvParams.class);
|
||||
if(wxpayParams != null){
|
||||
isvConfigContext.setWxServiceWrapper(buildWxServiceWrapper(wxpayParams.getMchId(), wxpayParams.getAppId(),
|
||||
wxpayParams.getAppSecret(), wxpayParams.getKey(), wxpayParams.getApiVersion(), wxpayParams.getApiV3Key(),
|
||||
wxpayParams.getSerialNo(), wxpayParams.getCert(), wxpayParams.getApiClientKey()));
|
||||
isvConfigContext.setWxServiceWrapper(WxServiceWrapper.buildWxServiceWrapper(wxpayParams));
|
||||
}
|
||||
|
||||
isvConfigContextMap.put(isvNo, isvConfigContext);
|
||||
|
|
@ -340,81 +309,8 @@ public class ConfigContextService {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* 构建支付宝client 包装类
|
||||
*
|
||||
* @author terrfly
|
||||
* @site https://www.jeequan.com
|
||||
* @date 2021/6/8 17:46
|
||||
*/
|
||||
private AlipayClientWrapper buildAlipayClientWrapper(Byte useCert, Byte sandbox, String appId, String privateKey, String alipayPublicKey, String signType, String appCert,
|
||||
String alipayPublicCert, String alipayRootCert){
|
||||
|
||||
//避免空值
|
||||
sandbox = sandbox == null ? CS.NO : sandbox;
|
||||
|
||||
AlipayClient alipayClient = null;
|
||||
if(useCert != null && useCert == CS.YES){ //证书的方式
|
||||
|
||||
CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
|
||||
certAlipayRequest.setServerUrl(sandbox == CS.YES ? AlipayConfig.SANDBOX_SERVER_URL : AlipayConfig.PROD_SERVER_URL);
|
||||
certAlipayRequest.setAppId(appId);
|
||||
certAlipayRequest.setPrivateKey(privateKey);
|
||||
certAlipayRequest.setFormat(AlipayConfig.FORMAT);
|
||||
certAlipayRequest.setCharset(AlipayConfig.CHARSET);
|
||||
certAlipayRequest.setSignType(signType);
|
||||
|
||||
certAlipayRequest.setCertPath(channelCertConfigKitBean.getCertFilePath(appCert));
|
||||
certAlipayRequest.setAlipayPublicCertPath(channelCertConfigKitBean.getCertFilePath(alipayPublicCert));
|
||||
certAlipayRequest.setRootCertPath(channelCertConfigKitBean.getCertFilePath(alipayRootCert));
|
||||
try {
|
||||
alipayClient = new DefaultAlipayClient(certAlipayRequest);
|
||||
} catch (AlipayApiException e) {
|
||||
log.error("error" ,e);
|
||||
alipayClient = null;
|
||||
}
|
||||
}else{
|
||||
alipayClient = new DefaultAlipayClient(sandbox == CS.YES ? AlipayConfig.SANDBOX_SERVER_URL : AlipayConfig.PROD_SERVER_URL
|
||||
, appId, privateKey, AlipayConfig.FORMAT, AlipayConfig.CHARSET,
|
||||
alipayPublicKey, signType);
|
||||
}
|
||||
|
||||
return new AlipayClientWrapper(useCert, alipayClient);
|
||||
}
|
||||
|
||||
private WxServiceWrapper buildWxServiceWrapper(String mchId, String appId, String appSecret, String mchKey, String apiVersion, String apiV3Key,
|
||||
String serialNo, String cert, String apiClientKey){
|
||||
|
||||
WxPayConfig wxPayConfig = new WxPayConfig();
|
||||
wxPayConfig.setMchId(mchId);
|
||||
wxPayConfig.setAppId(appId);
|
||||
wxPayConfig.setMchKey(mchKey);
|
||||
|
||||
if (CS.PAY_IF_VERSION.WX_V2.equals(apiVersion)) { // 微信API V2
|
||||
wxPayConfig.setSignType(WxPayConstants.SignType.MD5);
|
||||
|
||||
// api证书。
|
||||
if(StringUtils.isNotBlank(cert)){
|
||||
wxPayConfig.setKeyPath(channelCertConfigKitBean.getCertFilePath(cert));
|
||||
}
|
||||
} else if (CS.PAY_IF_VERSION.WX_V3.equals(apiVersion)) { // 微信API V3
|
||||
wxPayConfig.setApiV3Key(apiV3Key);
|
||||
wxPayConfig.setCertSerialNo(serialNo);
|
||||
wxPayConfig.setPrivateCertPath(channelCertConfigKitBean.getCertFilePath(cert));
|
||||
wxPayConfig.setPrivateKeyPath(channelCertConfigKitBean.getCertFilePath(apiClientKey));
|
||||
}
|
||||
|
||||
WxPayService wxPayService = new WxPayServiceImpl();
|
||||
wxPayService.setConfig(wxPayConfig); //微信配置信息
|
||||
|
||||
WxMpDefaultConfigImpl wxMpConfigStorage = new WxMpDefaultConfigImpl();
|
||||
wxMpConfigStorage.setAppId(appId);
|
||||
wxMpConfigStorage.setSecret(appSecret);
|
||||
|
||||
WxMpService wxMpService = new WxMpServiceImpl();
|
||||
wxMpService.setWxMpConfigStorage(wxMpConfigStorage); //微信配置信息
|
||||
|
||||
return new WxServiceWrapper(apiVersion, wxPayService, wxMpService);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import org.springframework.stereotype.Service;
|
|||
public class PayMchNotifyService {
|
||||
|
||||
@Autowired private MchNotifyRecordService mchNotifyRecordService;
|
||||
@Autowired private ConfigContextService configContextService;
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
@Autowired private IMQSender mqSender;
|
||||
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ public class PayMchNotifyService {
|
|||
}
|
||||
|
||||
//商户app私钥
|
||||
String appSecret = configContextService.getMchAppConfigContext(dbPayOrder.getMchNo(), dbPayOrder.getAppId()).getMchApp().getAppSecret();
|
||||
String appSecret = configContextQueryService.queryMchApp(dbPayOrder.getMchNo(), dbPayOrder.getAppId()).getAppSecret();
|
||||
|
||||
// 封装通知url
|
||||
String notifyUrl = createNotifyUrl(dbPayOrder, appSecret);
|
||||
|
|
@ -119,7 +119,7 @@ public class PayMchNotifyService {
|
|||
}
|
||||
|
||||
//商户app私钥
|
||||
String appSecret = configContextService.getMchAppConfigContext(dbRefundOrder.getMchNo(), dbRefundOrder.getAppId()).getMchApp().getAppSecret();
|
||||
String appSecret = configContextQueryService.queryMchApp(dbRefundOrder.getMchNo(), dbRefundOrder.getAppId()).getAppSecret();
|
||||
|
||||
// 封装通知url
|
||||
String notifyUrl = createNotifyUrl(dbRefundOrder, appSecret);
|
||||
|
|
@ -170,7 +170,7 @@ public class PayMchNotifyService {
|
|||
}
|
||||
|
||||
//商户app私钥
|
||||
String appSecret = configContextService.getMchAppConfigContext(dbTransferOrder.getMchNo(), dbTransferOrder.getAppId()).getMchApp().getAppSecret();
|
||||
String appSecret = configContextQueryService.queryMchApp(dbTransferOrder.getMchNo(), dbTransferOrder.getAppId()).getAppSecret();
|
||||
|
||||
// 封装通知url
|
||||
String notifyUrl = createNotifyUrl(dbTransferOrder, appSecret);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class PayOrderDivisionProcessService {
|
|||
@Autowired
|
||||
private PayOrderDivisionRecordService payOrderDivisionRecordService;
|
||||
@Autowired
|
||||
private ConfigContextService configContextService;
|
||||
private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
/***
|
||||
* 处理分账,
|
||||
|
|
@ -147,7 +147,7 @@ public class PayOrderDivisionProcessService {
|
|||
throw new BizException("通道无此分账接口");
|
||||
}
|
||||
|
||||
channelRetMsg = divisionService.singleDivision(payOrder, recordList, configContextService.getMchAppConfigContext(payOrder.getMchNo(), payOrder.getAppId()));
|
||||
channelRetMsg = divisionService.singleDivision(payOrder, recordList, configContextQueryService.queryMchInfoAndAppInfo(payOrder.getMchNo(), payOrder.getAppId()));
|
||||
|
||||
// 确认分账成功
|
||||
if(channelRetMsg.getChannelState() == ChannelRetMsg.ChannelState.CONFIRM_SUCCESS) {
|
||||
|
|
|
|||
|
|
@ -89,4 +89,9 @@ public class MchAppService extends ServiceImpl<MchAppMapper, MchApp> {
|
|||
|
||||
return pages;
|
||||
}
|
||||
|
||||
public MchApp getOneByMch(String mchNo, String appId){
|
||||
return getOne(MchApp.gw().eq(MchApp::getMchNo, mchNo).eq(MchApp::getAppId, appId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue