商户、应用、服务商配置信息支持直接数据库查询(第二卷);
This commit is contained in:
parent
ca31cf0633
commit
021f010a4b
|
|
@ -57,7 +57,7 @@ public class WxpayChannelUserService implements IChannelUserService {
|
|||
String appId = null;
|
||||
String oauth2Url = "";
|
||||
if(mchAppConfigContext.isIsvsubMch()){
|
||||
WxpayIsvParams wxpayIsvParams = mchAppConfigContext.getIsvConfigContext().getIsvParamsByIfCode(CS.IF_CODE.WXPAY, WxpayIsvParams.class);
|
||||
WxpayIsvParams wxpayIsvParams = (WxpayIsvParams)configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), CS.IF_CODE.WXPAY);
|
||||
if(wxpayIsvParams == null) {
|
||||
throw new BizException("服务商微信支付接口没有配置!");
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ public class WxpayChannelUserService implements IChannelUserService {
|
|||
oauth2Url = wxpayIsvParams.getOauth2Url();
|
||||
}else{
|
||||
//获取商户配置信息
|
||||
WxpayNormalMchParams normalMchParams = mchAppConfigContext.getNormalMchParamsByIfCode(CS.IF_CODE.WXPAY, WxpayNormalMchParams.class);
|
||||
WxpayNormalMchParams normalMchParams = (WxpayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), CS.IF_CODE.WXPAY);
|
||||
if(normalMchParams == null) {
|
||||
throw new BizException("商户微信支付接口没有配置!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class XxpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
@Override
|
||||
public ChannelRetMsg doNotice(HttpServletRequest request, Object params, PayOrder payOrder, 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;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,10 @@ import com.jeequan.jeepay.core.utils.JeepayKit;
|
|||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
@ -42,6 +44,8 @@ import java.util.TreeMap;
|
|||
@Slf4j
|
||||
public class XxpayPayOrderQueryService implements IPayOrderQueryService {
|
||||
|
||||
@Autowired private ConfigContextQueryService configContextQueryService;
|
||||
|
||||
@Override
|
||||
public String getIfCode() {
|
||||
return CS.IF_CODE.XXPAY;
|
||||
|
|
@ -49,7 +53,7 @@ public class XxpayPayOrderQueryService implements IPayOrderQueryService {
|
|||
|
||||
@Override
|
||||
public ChannelRetMsg query(PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
|
||||
XxpayNormalMchParams xxpayParams = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
|
||||
XxpayNormalMchParams xxpayParams = (XxpayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
Map<String,Object> paramMap = new TreeMap();
|
||||
// 接口类型
|
||||
paramMap.put("mchId", xxpayParams.getMchId());
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ public class XxpayRefundService extends AbstractRefundService {
|
|||
@Override
|
||||
public ChannelRetMsg refund(RefundOrderRQ bizRQ, RefundOrder refundOrder, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
|
||||
XxpayNormalMchParams params = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
|
||||
XxpayNormalMchParams params = (XxpayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
|
||||
// 构造支付请求参数
|
||||
Map<String,Object> paramMap = new TreeMap();
|
||||
|
|
@ -130,7 +130,7 @@ public class XxpayRefundService extends AbstractRefundService {
|
|||
@Override
|
||||
public ChannelRetMsg query(RefundOrder refundOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
|
||||
XxpayNormalMchParams params = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
|
||||
XxpayNormalMchParams params = (XxpayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
|
||||
// 构造支付请求参数
|
||||
Map<String,Object> paramMap = new TreeMap();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class AliBar extends XxpayPaymentService {
|
|||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
|
||||
AliBarOrderRQ bizRQ = (AliBarOrderRQ) rq;
|
||||
XxpayNormalMchParams params = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
|
||||
XxpayNormalMchParams params = (XxpayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
// 构造支付请求参数
|
||||
Map<String,Object> paramMap = new TreeMap();
|
||||
paramMap.put("mchId", params.getMchId());
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class AliJsapi extends XxpayPaymentService {
|
|||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
AliJsapiOrderRQ bizRQ = (AliJsapiOrderRQ) rq;
|
||||
XxpayNormalMchParams params = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
|
||||
XxpayNormalMchParams params = (XxpayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
// 构造支付请求参数
|
||||
Map<String,Object> paramMap = new TreeMap();
|
||||
paramMap.put("mchId", params.getMchId());
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class WxBar extends XxpayPaymentService {
|
|||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext){
|
||||
WxBarOrderRQ bizRQ = (WxBarOrderRQ) rq;
|
||||
XxpayNormalMchParams params = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
|
||||
XxpayNormalMchParams params = (XxpayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
// 构造支付请求参数
|
||||
Map<String,Object> paramMap = new TreeMap();
|
||||
paramMap.put("mchId", params.getMchId());
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ public class WxJsapi extends XxpayPaymentService {
|
|||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception{
|
||||
WxJsapiOrderRQ bizRQ = (WxJsapiOrderRQ) rq;
|
||||
XxpayNormalMchParams params = mchAppConfigContext.getNormalMchParamsByIfCode(getIfCode(), XxpayNormalMchParams.class);
|
||||
|
||||
XxpayNormalMchParams params = (XxpayNormalMchParams)configContextQueryService.queryNormalMchParams(mchAppConfigContext.getMchNo(), mchAppConfigContext.getAppId(), getIfCode());
|
||||
// 构造支付请求参数
|
||||
Map<String,Object> paramMap = new TreeMap();
|
||||
paramMap.put("mchId", params.getMchId());
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class YsfpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
log.info("{} 回调参数, jsonParams:{}", logPrefix, jsonParams);
|
||||
|
||||
// 校验支付回调
|
||||
boolean verifyResult = verifyParams(jsonParams, payOrder, mchAppConfigContext.getIsvConfigContext());
|
||||
boolean verifyResult = verifyParams(jsonParams, payOrder, mchAppConfigContext);
|
||||
// 验证参数失败
|
||||
if(!verifyResult){
|
||||
throw ResponseException.buildText("ERROR");
|
||||
|
|
@ -100,7 +100,7 @@ public class YsfpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
* 验证云闪付支付通知参数
|
||||
* @return
|
||||
*/
|
||||
public boolean verifyParams(JSONObject jsonParams, PayOrder payOrder, IsvConfigContext isvConfigContext) {
|
||||
public boolean verifyParams(JSONObject jsonParams, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) {
|
||||
|
||||
String orderNo = jsonParams.getString("orderNo"); // 商户订单号
|
||||
String txnAmt = jsonParams.getString("txnAmt"); // 支付金额
|
||||
|
|
@ -113,7 +113,8 @@ public class YsfpayChannelNoticeService extends AbstractChannelNoticeService {
|
|||
return false;
|
||||
}
|
||||
|
||||
YsfpayIsvParams isvParams = isvConfigContext.getIsvParamsByIfCode(getIfCode(), YsfpayIsvParams.class);
|
||||
YsfpayIsvParams isvParams = (YsfpayIsvParams)configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), getIfCode());
|
||||
|
||||
//验签
|
||||
String ysfpayPublicKey = isvParams.getYsfpayPublicKey();
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class YsfpayPayOrderQueryService implements IPayOrderQueryService {
|
|||
reqParams.put("orderType", orderType); //订单类型
|
||||
|
||||
//封装公共参数 & 签名 & 调起http请求 & 返回响应数据并包装为json格式。
|
||||
JSONObject resJSON = ysfpayPaymentService.packageParamAndReq("/gateway/api/pay/queryOrder", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
JSONObject resJSON = ysfpayPaymentService.packageParamAndReq("/gateway/api/pay/queryOrder", reqParams, logPrefix, mchAppConfigContext);
|
||||
log.info("查询订单 payorderId:{}, 返回结果:{}", payOrder.getPayOrderId(), resJSON);
|
||||
if(resJSON == null){
|
||||
return ChannelRetMsg.waiting(); //支付中
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ public class YsfpayPaymentService extends AbstractPaymentService {
|
|||
|
||||
|
||||
/** 封装参数 & 统一请求 **/
|
||||
public JSONObject packageParamAndReq(String apiUri, JSONObject reqParams, String logPrefix, IsvConfigContext isvConfigContext, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
public JSONObject packageParamAndReq(String apiUri, JSONObject reqParams, String logPrefix, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
|
||||
YsfpayIsvParams isvParams = isvConfigContext.getIsvParamsByIfCode(getIfCode(), YsfpayIsvParams.class);
|
||||
YsfpayIsvParams isvParams = (YsfpayIsvParams)configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), getIfCode());
|
||||
|
||||
if (isvParams.getSerProvId() == null) {
|
||||
log.error("服务商配置为空:isvParams:{}", isvParams);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public class YsfpayRefundService extends AbstractRefundService {
|
|||
reqParams.put("orderType ", orderType); // 订单类型
|
||||
|
||||
//封装公共参数 & 签名 & 调起http请求 & 返回响应数据并包装为json格式。
|
||||
JSONObject resJSON = ysfpayPaymentService.packageParamAndReq("/gateway/api/pay/refund", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
JSONObject resJSON = ysfpayPaymentService.packageParamAndReq("/gateway/api/pay/refund", reqParams, logPrefix, mchAppConfigContext);
|
||||
log.info("查询订单 payorderId:{}, 返回结果:{}", payOrder.getPayOrderId(), resJSON);
|
||||
if(resJSON == null){
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.UNKNOWN); // 状态不明确
|
||||
|
|
@ -101,7 +101,7 @@ public class YsfpayRefundService extends AbstractRefundService {
|
|||
reqParams.put("origOrderNo", refundOrder.getPayOrderId()); // 原交易订单号
|
||||
|
||||
//封装公共参数 & 签名 & 调起http请求 & 返回响应数据并包装为json格式。
|
||||
JSONObject resJSON = ysfpayPaymentService.packageParamAndReq("/gateway/api/pay/refundQuery", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
JSONObject resJSON = ysfpayPaymentService.packageParamAndReq("/gateway/api/pay/refundQuery", reqParams, logPrefix, mchAppConfigContext);
|
||||
log.info("查询订单 refundOrderId:{}, 返回结果:{}", refundOrder.getRefundOrderId(), resJSON);
|
||||
if(resJSON == null){
|
||||
channelRetMsg.setChannelState(ChannelRetMsg.ChannelState.UNKNOWN); // 状态不明确
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class AliBar extends YsfpayPaymentService {
|
|||
reqParams.put("termInfo", "{\"ip\": \""+StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1")+"\"}"); //终端信息
|
||||
|
||||
// 发送请求
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class AliJsapi extends YsfpayPaymentService {
|
|||
reqParams.put("customerIp", StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1"));
|
||||
|
||||
// 发送请求并返回订单状态
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class WxBar extends YsfpayPaymentService {
|
|||
reqParams.put("termInfo", "{\"ip\": \""+StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1")+"\"}"); //终端信息
|
||||
|
||||
// 发送请求
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -70,11 +70,11 @@ public class WxJsapi extends YsfpayPaymentService {
|
|||
reqParams.put("customerIp", StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1"));
|
||||
|
||||
// 获取微信官方配置 的appId
|
||||
WxpayIsvParams wxpayIsvParams = mchAppConfigContext.getIsvConfigContext().getIsvParamsByIfCode(CS.IF_CODE.WXPAY, WxpayIsvParams.class);
|
||||
WxpayIsvParams wxpayIsvParams = (WxpayIsvParams)configContextQueryService.queryIsvParams(mchAppConfigContext.getMchInfo().getIsvNo(), CS.IF_CODE.WXPAY);
|
||||
reqParams.put("subAppId", wxpayIsvParams.getAppId()); //用户ID
|
||||
|
||||
// 发送请求并返回订单状态
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class YsfBar extends YsfpayPaymentService {
|
|||
reqParams.put("termInfo", "{\"ip\": \""+StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1")+"\"}"); //终端信息
|
||||
|
||||
// 发送请求
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchAppConfigContext.getIsvConfigContext(), mchAppConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/micropay", reqParams, logPrefix, mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ public class YsfJsapi extends YsfpayPaymentService {
|
|||
return null;
|
||||
}
|
||||
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, IsvConfigContext isvConfigContext, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
@Override
|
||||
public AbstractRS pay(UnifiedOrderRQ rq, PayOrder payOrder, MchAppConfigContext mchAppConfigContext) throws Exception {
|
||||
String logPrefix = "【云闪付(unionpay)jsapi支付】";
|
||||
JSONObject reqParams = new JSONObject();
|
||||
YsfJsapiOrderRS res = ApiResBuilder.buildSuccess(YsfJsapiOrderRS.class);
|
||||
|
|
@ -61,7 +62,7 @@ public class YsfJsapi extends YsfpayPaymentService {
|
|||
//客户端IP
|
||||
reqParams.put("customerIp", StringUtils.defaultIfEmpty(payOrder.getClientIp(), "127.0.0.1"));
|
||||
// 发送请求并返回订单状态
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, isvConfigContext, mchAppConfigContext);
|
||||
JSONObject resJSON = packageParamAndReq("/gateway/api/pay/unifiedorder", reqParams, logPrefix, mchAppConfigContext);
|
||||
//请求 & 响应成功, 判断业务逻辑
|
||||
String respCode = resJSON.getString("respCode"); //应答码
|
||||
String respMsg = resJSON.getString("respMsg"); //应答信息
|
||||
|
|
|
|||
Loading…
Reference in New Issue