mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-31 04:49:54 +08:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -16,22 +16,35 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
public abstract class BasePayConfigStorage implements PayConfigStorage{
|
||||
|
||||
|
||||
// ali rsa_private 商户私钥,pkcs8格式
|
||||
//wx api_key 应用私钥(生成签名时使用)
|
||||
private volatile String keyPrivate ;
|
||||
// 支付平台公钥(签名校验使用)
|
||||
/**
|
||||
* 应用私钥,rsa_private pkcs8格式 生成签名时使用
|
||||
*/
|
||||
private volatile String keyPrivate;
|
||||
/**
|
||||
* 支付平台公钥(签名校验使用)
|
||||
*/
|
||||
private volatile String keyPublic;
|
||||
//异步回调地址
|
||||
/**
|
||||
* 异步回调地址
|
||||
*/
|
||||
private volatile String notifyUrl;
|
||||
//同步回调地址
|
||||
/**
|
||||
* 同步回调地址,支付完成后展示的页面
|
||||
*/
|
||||
private volatile String returnUrl;;
|
||||
//签名加密类型
|
||||
/**
|
||||
* 签名加密类型
|
||||
*/
|
||||
private volatile String signType;
|
||||
//字符类型
|
||||
/**
|
||||
* 字符类型
|
||||
*/
|
||||
private volatile String inputCharset;
|
||||
|
||||
|
||||
//支付类型 aliPay 支付宝, wxPay微信..等等,开发者自定义,唯一
|
||||
/**
|
||||
* 支付类型 aliPay 支付宝, wxPay微信..等等,扩展支付模块定义唯一。
|
||||
*/
|
||||
private volatile String payType;
|
||||
|
||||
/**
|
||||
@@ -40,13 +53,21 @@ public abstract class BasePayConfigStorage implements PayConfigStorage{
|
||||
private volatile MsgType msgType;
|
||||
|
||||
|
||||
// 访问令牌 每次请求其他方法都要传入的值
|
||||
/**
|
||||
* 访问令牌 每次请求其他方法都要传入的值
|
||||
*/
|
||||
private volatile String accessToken;
|
||||
// access token 到期时间时间戳
|
||||
/**
|
||||
* access token 到期时间时间戳
|
||||
*/
|
||||
private volatile long expiresTime;
|
||||
//授权码锁
|
||||
/**
|
||||
* 授权码锁
|
||||
*/
|
||||
private Lock accessTokenLock = new ReentrantLock();
|
||||
|
||||
/**
|
||||
* 是否为沙箱环境,默认为正式环境
|
||||
*/
|
||||
private boolean isTest = false;
|
||||
|
||||
|
||||
@@ -77,6 +98,7 @@ public abstract class BasePayConfigStorage implements PayConfigStorage{
|
||||
this.notifyUrl = notifyUrl;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getReturnUrl() {
|
||||
return returnUrl;
|
||||
|
||||
@@ -14,21 +14,14 @@ import java.util.concurrent.locks.Lock;
|
||||
*/
|
||||
public interface PayConfigStorage {
|
||||
|
||||
/*
|
||||
/**
|
||||
* 应用id
|
||||
* @return 应用id
|
||||
*/
|
||||
String getAppid();
|
||||
|
||||
/**
|
||||
* 合作商唯一标识
|
||||
* @see #getPid() 代替者
|
||||
* @return 合作商唯一标识
|
||||
*/
|
||||
@Deprecated
|
||||
String getPartner();
|
||||
/**
|
||||
* 合作商唯一标识
|
||||
* @see #getPartner() 代替者
|
||||
* @return 合作商唯一标识
|
||||
*/
|
||||
String getPid();
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.egzosn.pay.common.api;
|
||||
|
||||
import com.egzosn.pay.common.bean.PayMessage;
|
||||
import com.egzosn.pay.common.bean.PayOutMessage;
|
||||
|
||||
import com.egzosn.pay.common.util.LogExceptionHandler;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -43,18 +44,32 @@ import java.util.concurrent.Future;
|
||||
*/
|
||||
public class PayMessageRouter {
|
||||
|
||||
protected final Log log = LogFactory.getLog(PayMessageRouter.class);
|
||||
|
||||
protected final Log LOG = LogFactory.getLog(PayMessageRouter.class);
|
||||
/**
|
||||
* 异步线程大小
|
||||
*/
|
||||
private static final int DEFAULT_THREAD_POOL_SIZE = 100;
|
||||
|
||||
/**
|
||||
* 规则集
|
||||
*/
|
||||
private final List<PayMessageRouterRule> rules = new ArrayList<PayMessageRouterRule>();
|
||||
|
||||
/**
|
||||
* 支付服务
|
||||
*/
|
||||
private final PayService payService;
|
||||
|
||||
/**
|
||||
* 异步线程处理器
|
||||
*/
|
||||
private ExecutorService executorService;
|
||||
|
||||
/**
|
||||
* 支付异常处理器
|
||||
*/
|
||||
private PayErrorExceptionHandler exceptionHandler;
|
||||
|
||||
/**
|
||||
* 根据支付服务创建路由
|
||||
* @param payService 支付服务
|
||||
*/
|
||||
public PayMessageRouter(PayService payService) {
|
||||
this.payService = payService;
|
||||
this.executorService = Executors.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE);
|
||||
@@ -130,6 +145,7 @@ public class PayMessageRouter {
|
||||
if(rule.isAsync()) {
|
||||
futures.add(
|
||||
executorService.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
rule.service(payMessage, payService, exceptionHandler);
|
||||
}
|
||||
@@ -138,7 +154,7 @@ public class PayMessageRouter {
|
||||
} else {
|
||||
res = rule.service(payMessage, payService, exceptionHandler);
|
||||
// 在同步操作结束,session访问结束
|
||||
log.debug("End session access: async=false, fromPay=" + payMessage.getFromPay());
|
||||
LOG.debug("End session access: async=false, fromPay=" + payMessage.getFromPay());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,12 +165,12 @@ public class PayMessageRouter {
|
||||
for (Future future : futures) {
|
||||
try {
|
||||
future.get();
|
||||
log.debug("End session access: async=true, fromPay=" + payMessage.getFromPay());
|
||||
LOG.debug("End session access: async=true, fromPay=" + payMessage.getFromPay());
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
log.error("Error happened when wait task finish", e);
|
||||
LOG.error("Error happened when wait task finish", e);
|
||||
} catch (ExecutionException e) {
|
||||
log.error("Error happened when wait task finish", e);
|
||||
LOG.error("Error happened when wait task finish", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user