补全注释

This commit is contained in:
egzosn
2017-04-25 22:33:27 +08:00
parent f814835b28
commit c3c23b836e
69 changed files with 849 additions and 2430 deletions

View File

@@ -8,8 +8,10 @@ import java.util.concurrent.locks.ReentrantLock;
/**
* 支付基础配置存储
* @author: egan
* @email egzosn@gmail.com
* @date 2017/3/5 20:33
* <pre>
* email egzosn@gmail.com
* date 2017/3/5 20:33
* </pre>
*/
public abstract class BasePayConfigStorage implements PayConfigStorage{

View File

@@ -9,8 +9,10 @@ import java.util.Map;
/**
* 支付基础服务
* @author: egan
* @email egzosn@gmail.com
* @date 2017/3/5 20:36
* <pre>
* email egzosn@gmail.com
* date 2017/3/5 20:36
* </pre>
*/
public abstract class BasePayService implements PayService {
@@ -42,7 +44,7 @@ public abstract class BasePayService implements PayService {
/**
* 设置并创建请求模版, 代理请求配置这里是否合理??,
* @param configStorage http请求配置
* @return
* @return 支付服务
*/
@Override
public BasePayService setRequestTemplateConfigStorage(HttpConfigStorage configStorage) {
@@ -59,12 +61,25 @@ public abstract class BasePayService implements PayService {
setPayConfigStorage(payConfigStorage);
setRequestTemplateConfigStorage(configStorage);
}
/**
* 创建签名
*
* @param content 需要签名的内容
* @param characterEncoding 字符编码
* @return 签名
*/
@Override
public String createSign(String content, String characterEncoding) {
return SignUtils.valueOf(payConfigStorage.getSignType()).createSign(content, payConfigStorage.getKeyPrivate(),characterEncoding);
}
/**
* 创建签名
*
* @param content 需要签名的内容
* @param characterEncoding 字符编码
* @return 签名
*/
@Override
public String createSign(Map<String, Object> content, String characterEncoding) {
return SignUtils.valueOf(payConfigStorage.getSignType()).sign(content, payConfigStorage.getKeyPrivate(),characterEncoding);

View File

@@ -22,11 +22,17 @@ import java.util.Map;
/**
* 回调,可用于类型转换
* @author: egan
* @email egzosn@gmail.com
* @date 2017/3/7 18:55
* <pre>
* email egzosn@gmail.com
* date 2017/3/7 18:55
* </pre>
*/
public interface Callback<T> {
/**
* 执行者
* @param map 需要转化的map
* @return 处理过后的类型对象
*/
T perform(Map<String, Object> map);
}

View File

@@ -7,74 +7,88 @@ import java.util.concurrent.locks.Lock;
/**
* 支付客户端配置存储
* @author egan
* @email egzosn@gmail.com
* @date 2016-5-18 14:09:01
* @source chanjarster/weixin-java-tools
* <pre>
* email egzosn@gmail.com
* date 2016-5-18 14:09:01
* </pre>
*/
public interface PayConfigStorage {
/*
* 应用id
* @return 应用id
*/
String getAppid();
/**
* 合作商唯一标识
* @see #getPid() 代替者
* @return 合作商唯一标识
*/
@Deprecated
String getPartner();
/**
* 合作商唯一标识
* @see #getPartner() 代替者
* @return 合作商唯一标识
*/
String getPid();
/**
* 获取收款账号
* @return 收款账号
*/
String getSeller();
/**
* 授权令牌
* @return 授权令牌
*/
String getToken();
/**
* 服务端异步回调Url
* @return 异步回调Url
*/
String getNotifyUrl();
/**
* 服务端同步回调Url
* @return 同步回调Url
*/
String getReturnUrl();
/**
* 签名方式
* @return 签名方式
*/
String getSignType();
// 字符编码格式 目前支持 gbk 或 utf-8
/**
* 字符编码格式
* @return 字符编码
*/
String getInputCharset();
/**
* 获取密钥 与 #getKeyPrivate 类似
* @return 获取密钥
*/
String getSecretKey();
/**
* 公钥
* @return
* @return 公钥
*/
String getKeyPublic();
/**
* 私钥
* @return
* @return 私钥
*/
String getKeyPrivate();
/**
* 支付类型 自定义
* 这里暂定 aliPay 支付宝, wxPay微信支付
* @return
* @return 支付类型
*/
String getPayType();
@@ -89,18 +103,18 @@ import java.util.concurrent.locks.Lock;
/**
* 获取访问令牌
* @return
* @return 访问令牌
*/
String getAccessToken();
/**
* 访问令牌是否过期
* @return
* @return true过期
*/
boolean isAccessTokenExpired();
/**
* 获取access token锁
* @return
* @return access token锁
*/
Lock getAccessTokenLock();
@@ -110,6 +124,7 @@ import java.util.concurrent.locks.Lock;
void expireAccessToken();
/**
* 强制将access token过期掉
* @return 过期时间
*/
long getExpiresTime();
@@ -129,7 +144,7 @@ import java.util.concurrent.locks.Lock;
/**
* 是否为测试环境, true测试环境
* @return
* @return true测试环境
*/
boolean isTest();
}

View File

@@ -7,14 +7,16 @@ import com.egzosn.pay.common.exception.PayErrorException;
* PayErrorExceptionHandler处理器
*
* @author egan
* @email egzosn@gmail.com
* @date 2016-6-1 11:33:01
* <pre>
* email egzosn@gmail.com
* date 2016-6-1 11:33:01
* </pre>
*/
public interface PayErrorExceptionHandler {
/**
* 异常统一处理器
* @param e
* @param e 支付异常
*/
void handle(PayErrorException e);

View File

@@ -9,20 +9,25 @@ import java.util.Map;
/**
* 处理支付回调消息的处理器接口
* @source Daniel Qian
*
* @author egan
* @email egzosn@gmail.com
* @date 2016-6-1 11:40:30
* <pre>
* email egzosn@gmail.com
* date 2016-6-1 11:40:30
*
*
* source Daniel Qian
* </pre>
*/
public interface PayMessageHandler {
/**
* @param payMessage
* @param payMessage 支付消息
* @param context 上下文如果handler或interceptor之间有信息要传递可以用这个
* @param payService
* @param payService 支付服务
* @return xml,text格式的消息如果在异步规则里处理的话可以返回null
*/
public PayOutMessage handle(PayMessage payMessage,
PayOutMessage handle(PayMessage payMessage,
Map<String, Object> context,
PayService payService
) throws PayErrorException;

View File

@@ -8,19 +8,26 @@ import java.util.Map;
/**
* 支付消息拦截器,可以用来做验证
* @author Daniel Qian
* @author egan
* <pre>
* email egzosn@gmail.com
* date 2016-6-1 11:40:30
*
*
* source Daniel Qian
* </pre>
*/
public interface PayMessageInterceptor {
/**
* 拦截微信消息
*
* @param wxMessage
* @param payMessage 支付消息
* @param context 上下文如果handler或interceptor之间有信息要传递可以用这个
* @param payService
* @param payService 支付服务
* @return true代表OKfalse代表不OK
*/
public boolean intercept(PayMessage wxMessage,
boolean intercept(PayMessage payMessage,
Map<String, Object> context,
PayService payService
) throws PayErrorException;

View File

@@ -36,16 +36,14 @@ import java.util.concurrent.Future;
*
* // 将PayMessage交给消息路由器
* router.route(message);
*
* source chanjarster/weixin-java-tools Daniel Qian
* </pre>
* @source chanjarster/weixin-java-tools
* @source Daniel Qian
* @author egan
*
*/
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;
@@ -66,9 +64,9 @@ public class PayMessageRouter {
/**
* <pre>
* 设置自定义的 {@link ExecutorService}
* 如果不调用该方法,默认使 Executors.newFixedThreadPool(100)
* 如果不调用该方法,默认使 Executors.newFixedThreadPool(100)
* </pre>
* @param executorService
* @param executorService 异步线程处理器
*/
public void setExecutorService(ExecutorService executorService) {
this.executorService = executorService;
@@ -81,19 +79,23 @@ public class PayMessageRouter {
* 设置自定义的{@link PayErrorExceptionHandler}
* 如果不调用该方法,默认使用 {@link LogExceptionHandler}
* </pre>
* @param exceptionHandler
* @param exceptionHandler 异常处理器
*/
public void setExceptionHandler(PayErrorExceptionHandler exceptionHandler) {
this.exceptionHandler = exceptionHandler;
}
/**
* 获取所有的规则
* @return 规则
*/
List<PayMessageRouterRule> getRules() {
return this.rules;
}
/**
* 开始一个新的Route规则
* @return
* @return 新的Route规则
*/
public PayMessageRouterRule rule() {
return new PayMessageRouterRule(this);
@@ -101,7 +103,8 @@ public class PayMessageRouter {
/**
* 处理支付消息
* @param payMessage
* @param payMessage 支付消息
* @return 支付输出结果
*/
public PayOutMessage route(final PayMessage payMessage) {

View File

@@ -13,11 +13,15 @@ import java.util.regex.Pattern;
/**
*
* Route规则 路由
* @author egan
* @email egzosn@gmail.com
* @date 2016-6-1 11:28:01
* @source chanjarster/weixin-java-tools
* <pre>
* email egzosn@gmail.com
* date 2016-6-1 11:28:01
*
*
* source chanjarster/weixin-java-tools
* </pre>
*/
public class PayMessageRouterRule {
@@ -56,8 +60,8 @@ public class PayMessageRouterRule {
/**
* 设置是否异步执行默认是true
*
* @param async
* @return
* @param async 是否异步执行默认是true
* @return Route规则
*/
public PayMessageRouterRule async(boolean async) {
this.async = async;
@@ -67,8 +71,8 @@ public class PayMessageRouterRule {
/**
* 如果msgType等于某值
*
* @param msgType
* @return
* @param msgType 消息类型
* @return Route规则
*/
public PayMessageRouterRule msgType(String msgType) {
this.msgType = msgType;
@@ -78,8 +82,8 @@ public class PayMessageRouterRule {
/**
* 如果payType等于某值
*
* @param payType
* @return
* @param payType 支付类型
* @return Route规则
*/
public PayMessageRouterRule payType(String payType) {
this.payType = payType;
@@ -89,8 +93,8 @@ public class PayMessageRouterRule {
/**
* 如果transactionType等于某值
*
* @param transactionType
* @return
* @param transactionType 交易类型
* @return Route规则
*/
public PayMessageRouterRule transactionType(String ... transactionType) {
this.transactionType = transactionType;
@@ -100,8 +104,8 @@ public class PayMessageRouterRule {
/**
* 如果discount等于某值
*
* @param discount
* @return
* @param discount discount等于某值
* @return Route规则
*/
public PayMessageRouterRule discount(String discount) {
this.discount = discount;
@@ -111,8 +115,8 @@ public class PayMessageRouterRule {
/**
* 如果discount匹配该正则表达式
*
* @param regex
* @return
* @param regex discount匹配该正则表达式
* @return Route规则
*/
public PayMessageRouterRule rDiscount(String regex) {
this.rDiscount = regex;
@@ -120,10 +124,10 @@ public class PayMessageRouterRule {
}
/**
* 如果discount等于某值
* 如果subject等于某值
*
* @param subject
* @return
* @param subject 简介
* @return Route规则
*/
public PayMessageRouterRule subject(String subject) {
this.subject = subject;
@@ -131,10 +135,10 @@ public class PayMessageRouterRule {
}
/**
* 如果discount匹配该正则表达式
* 如果subject匹配该正则表达式
*
* @param regex
* @return
* @param regex 简介正则
* @return Route规则
*/
public PayMessageRouterRule rSubject(String regex) {
this.rSubject = regex;
@@ -143,32 +147,21 @@ public class PayMessageRouterRule {
/**
* 如果消息匹配某个matcher用在用户需要自定义更复杂的匹配规则的时候
* 设置消息拦截器
*
* @param matcher
* @return
*/
/* public PayMessageRouterRule matcher(WxMpMessageMatcher matcher) {
this.matcher = matcher;
return this;
}*/
/**
* 设置微信消息拦截器
*
* @param interceptor
* @return
* @param interceptor 消息拦截器
* @return Route规则
*/
public PayMessageRouterRule interceptor(PayMessageInterceptor interceptor) {
return interceptor(interceptor, (PayMessageInterceptor[]) null);
}
/**
* 设置微信消息拦截器
* 设置消息拦截器
*
* @param interceptor
* @param otherInterceptors
* @return
* @param interceptor 消息拦截器
* @param otherInterceptors 其他消息拦截器
* @return Route规则
*/
public PayMessageRouterRule interceptor(PayMessageInterceptor interceptor, PayMessageInterceptor... otherInterceptors) {
this.interceptors.add(interceptor);
@@ -181,21 +174,21 @@ public class PayMessageRouterRule {
}
/**
* 设置微信消息处理器
* 设置消息处理器
*
* @param handler
* @return
* @param handler 消息处理器
* @return Route规则
*/
public PayMessageRouterRule handler(PayMessageHandler handler) {
return handler(handler, (PayMessageHandler[]) null);
}
/**
* 设置微信消息处理器
* 设置消息处理器
*
* @param handler
* @param otherHandlers
* @return
* @param handler 消息处理器
* @param otherHandlers 其他消息处理器
* @return Route规则
*/
public PayMessageRouterRule handler(PayMessageHandler handler, PayMessageHandler... otherHandlers) {
this.handlers.add(handler);
@@ -210,7 +203,7 @@ public class PayMessageRouterRule {
/**
* 规则结束,代表如果一个消息匹配该规则,那么它将不再会进入其他规则
*
* @return
* @return Route规则
*/
public PayMessageRouter end() {
this.routerBuilder.getRules().add(this);
@@ -220,7 +213,7 @@ public class PayMessageRouterRule {
/**
* 规则结束,但是消息还会进入其他规则
*
* @return
* @return Route规则
*/
public PayMessageRouter next() {
this.reEnter = true;
@@ -230,8 +223,8 @@ public class PayMessageRouterRule {
/**
* 将支付事件修正为不区分大小写,
* 比如框架定义的事件常量为
* @param payMessage
* @return
* @param payMessage 支付消息
* @return 是否匹配通过
*/
protected boolean test(PayMessage payMessage) {
return (
@@ -261,7 +254,7 @@ public class PayMessageRouterRule {
/**
* 匹配交易类型
* @param transactionType 交易类型
* @return
* @return 匹配交易类型
*/
public boolean equalsTransactionType(String transactionType) {
if (null == transactionType){
@@ -278,12 +271,12 @@ public class PayMessageRouterRule {
}
/**
* 处理支付回调过来的消息
*
* @param payService
* @return true 代表继续执行别的routerfalse 代表停止执行别的router
* 返回支付响应消息
* @param payMessage 支付消息
* @param payService 支付服务
* @param exceptionHandler 异常处理器
* @return 支付响应消息
*/
protected PayOutMessage service(PayMessage payMessage,
PayService payService,

View File

@@ -18,36 +18,39 @@ import java.util.Map;
* 支付服务
*
* @author egan
* @email egzosn@gmail.com
* @date 2016-5-18 14:09:01
* <pre>
* email egzosn@gmail.com
* date 2016-5-18 14:09:01
*</pre>
*/
public interface PayService {
/**
* 设置支付配置
*
* @param payConfigStorage
* @param payConfigStorage 支付配置
* @return 支付服务
*/
PayService setPayConfigStorage(PayConfigStorage payConfigStorage);
/**
* 获取支付配置
*
* @return
* @return 支付配置
*/
PayConfigStorage getPayConfigStorage();
/**
* 获取http请求工具
*
* @return
* @return http请求工具
*/
HttpRequestTemplate getHttpRequestTemplate();
/**
* 设置 请求工具配置
* 设置 请求工具配置 设置并创建请求模版, 代理请求配置这里是否合理??,
* @param configStorage http请求配置
* @return
* @return 支付服务
*/
PayService setRequestTemplateConfigStorage(HttpConfigStorage configStorage);
@@ -55,7 +58,7 @@ public interface PayService {
* 回调校验
*
* @param params 回调回来的参数集
* @return
* @return 签名校验 true通过
*/
boolean verify(Map<String, String> params);
@@ -64,16 +67,16 @@ public interface PayService {
*
* @param params 参数集
* @param sign 签名
* @return
* @return 签名校验 true通过
*/
boolean signVerify(Map<String, String> params, String sign);
/**
* 支付宝需要,微信是否也需要再次校验来源,进行订单查询
* 校验数据来源
*
* @param id 业务id, 数据的真实性.
* @return
* @return true通过
*/
boolean verifySource(String id);
@@ -82,8 +85,8 @@ public interface PayService {
* 返回创建的订单信息
*
* @param order 支付订单
* @return
* @see PayOrder
* @return 订单信息
* @see PayOrder 支付订单信息
*/
Map orderInfo(PayOrder order);
@@ -92,7 +95,7 @@ public interface PayService {
*
* @param content 需要签名的内容
* @param characterEncoding 字符编码
* @return
* @return 签名
*/
String createSign(String content, String characterEncoding);
@@ -101,7 +104,7 @@ public interface PayService {
*
* @param content 需要签名的内容
* @param characterEncoding 字符编码
* @return
* @return 签名
*/
String createSign(Map<String, Object> content, String characterEncoding);
@@ -110,16 +113,16 @@ public interface PayService {
*
* @param parameterMap 请求参数
* @param is 请求流
* @return
* @return 获得回调的请求参数
*/
Map<String, String> getParameter2Map(Map<String, String[]> parameterMap, InputStream is);
/**
* 获取输出消息,用户返回给支付端
*
* @param code
* @param message
* @return
* @param code 状态
* @param message 消息
* @return 返回输出消息
*/
PayOutMessage getPayOutMessage(String code, String message);
@@ -128,8 +131,8 @@ public interface PayService {
*
* @param orderInfo 发起支付的订单信息
* @param method 请求方式 "post" "get",
* @return
* @see MethodType
* @return 获取输出消息,用户返回给支付端, 针对于web端
* @see MethodType 请求类型
*/
String buildRequest(Map<String, Object> orderInfo, MethodType method);
@@ -137,7 +140,7 @@ public interface PayService {
* 获取输出二维码,用户返回给支付端,
*
* @param order 发起支付的订单信息
* @return
* @return 返回图片信息,支付时需要的
*/
BufferedImage genQrPay(PayOrder order);
@@ -146,17 +149,17 @@ public interface PayService {
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @return
* @return 返回查询回来的结果集,支付方原值返回
*/
Map<String, Object> query(String tradeNo, String outTradeNo);
/**
* 交易查询接口
* 交易查询接口,带处理器
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @param callback 处理器
* @param <T> 返回类型
* @return
* @return 返回查询回来的结果集
*/
<T>T query(String tradeNo, String outTradeNo, Callback<T> callback);
@@ -165,7 +168,7 @@ public interface PayService {
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @return
* @return 返回支付方交易关闭后的结果
*/
Map<String, Object> close(String tradeNo, String outTradeNo);
@@ -176,7 +179,7 @@ public interface PayService {
* @param outTradeNo 商户单号
* @param callback 处理器
* @param <T> 返回类型
* @return
* @return 返回支付方交易关闭后的结果
*/
<T>T close(String tradeNo, String outTradeNo, Callback<T> callback);
@@ -187,7 +190,7 @@ public interface PayService {
* @param outTradeNo 商户单号
* @param refundAmount 退款金额
* @param totalAmount 总金额
* @return
* @return 返回支付方申请退款后的结果
*/
Map<String, Object> refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount);
/**
@@ -199,7 +202,7 @@ public interface PayService {
* @param totalAmount 总金额
* @param callback 处理器
* @param <T> 返回类型
* @return
* @return 返回支付方申请退款后的结果
*/
<T>T refund(String tradeNo, String outTradeNo, BigDecimal refundAmount, BigDecimal totalAmount, Callback<T> callback);
@@ -208,7 +211,7 @@ public interface PayService {
*
* @param tradeNo 支付平台订单号
* @param outTradeNo 商户单号
* @return
* @return 返回支付方查询退款后的结果
*/
Map<String, Object> refundquery(String tradeNo, String outTradeNo);
/**
@@ -218,7 +221,7 @@ public interface PayService {
* @param outTradeNo 商户单号
* @param callback 处理器
* @param <T> 返回类型
* @return
* @return 返回支付方查询退款后的结果
*/
<T>T refundquery(String tradeNo, String outTradeNo, Callback<T> callback);
@@ -227,7 +230,7 @@ public interface PayService {
*
* @param billDate 账单时间日账单格式为yyyy-MM-dd月账单格式为yyyy-MM。
* @param billType 账单类型商户通过接口或商户经开放平台授权后其所属服务商通过接口可以获取以下账单类型trade、signcustomertrade指商户基于支付宝交易收单的业务账单signcustomer是指基于商户支付宝余额收入及支出等资金变动的帐务账单
* @return
* @return 返回支付方下载对账单的结果
*/
Object downloadbill(Date billDate, String billType);
@@ -238,7 +241,7 @@ public interface PayService {
* @param billType 账单类型,具体请查看对应支付平台
* @param callback 处理器
* @param <T> 返回类型
* @return
* @return 返回支付方下载对账单的结果
*/
<T>T downloadbill(Date billDate, String billType, Callback<T> callback);
@@ -251,7 +254,7 @@ public interface PayService {
* @param transactionType 交易类型
* @param callback 处理器
* @param <T> 返回类型
* @return
* @return 返回支付方对应接口的结果
*/
<T>T secondaryInterface(Object tradeNoOrBillDate, String outTradeNoBillType, TransactionType transactionType, Callback<T> callback);