├── README.md ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── hugnew │ │ ├── core │ │ ├── common │ │ │ ├── constant │ │ │ │ ├── ActionConstants.java │ │ │ │ └── SystemConfig.java │ │ │ ├── exception │ │ │ │ ├── BaseException.java │ │ │ │ ├── BusinessException.java │ │ │ │ ├── DBException.java │ │ │ │ ├── ResultCode.java │ │ │ │ ├── SystemException.java │ │ │ │ └── ValidationError.java │ │ │ └── model │ │ │ │ └── json │ │ │ │ └── AjaxResult.java │ │ ├── dao │ │ │ └── IBaseMapper.java │ │ ├── mq │ │ │ └── Gson2JsonMessageConverter.java │ │ ├── service │ │ │ ├── IBaseService.java │ │ │ └── impl │ │ │ │ └── BaseService.java │ │ ├── util │ │ │ ├── DateUtils.java │ │ │ ├── IdGenerator.java │ │ │ ├── PropertiesUtil.java │ │ │ ├── SqlSessionFactoryBeanUtil.java │ │ │ └── StringUtil.java │ │ └── web │ │ │ └── system │ │ │ ├── filters │ │ │ ├── LoggingFilter.java │ │ │ ├── RequestWrapper.java │ │ │ ├── ResponseWrapper.java │ │ │ └── TeePrintWriter.java │ │ │ └── listener │ │ │ └── InitListener.java │ │ └── sps │ │ ├── controllers │ │ ├── base │ │ │ ├── BaseController.java │ │ │ └── RestErrorHandler.java │ │ └── front │ │ │ ├── mobile │ │ │ └── pay │ │ │ │ └── PayRequestController.java │ │ │ ├── open │ │ │ └── pay │ │ │ │ └── PayNotifyController.java │ │ │ └── pc │ │ │ └── pay │ │ │ └── PayRequestController.java │ │ ├── dao │ │ ├── MemberMapper.java │ │ ├── PayMapMapper.java │ │ ├── SysConfigMapper.java │ │ ├── domain │ │ │ ├── BaseDomain.java │ │ │ ├── Member.java │ │ │ ├── PayMap.java │ │ │ ├── Payment.java │ │ │ └── SysConfig.java │ │ └── mapper │ │ │ ├── MemberMapper.xml │ │ │ ├── PayMapMapper.xml │ │ │ ├── PaymentMapper.xml │ │ │ └── SysConfigMapper.xml │ │ ├── dto │ │ ├── DDDetails.java │ │ ├── MobileInfo.java │ │ └── PayRequestParam.java │ │ ├── enums │ │ ├── PayPlatform.java │ │ ├── PayType.java │ │ ├── PlatformType.java │ │ └── RequestFrom.java │ │ ├── mq │ │ └── PayRequestQueueListener.java │ │ ├── realm │ │ ├── StatelessAuthRealm.java │ │ ├── filter │ │ │ └── StatelessAuthcFilter.java │ │ └── token │ │ │ ├── HmacSHA256Utils.java │ │ │ └── StatelessAuthToken.java │ │ └── services │ │ ├── IAlipayNotifyService.java │ │ ├── ICEBGatewayNotifyService.java │ │ ├── ICEBNotifyService.java │ │ ├── ICacheService.java │ │ ├── ICheckSellerService.java │ │ ├── IPSBCNotifyService.java │ │ ├── IPayMapService.java │ │ ├── IPayRouteService.java │ │ ├── ISysConfigService.java │ │ ├── IUnionPayNotifyService.java │ │ ├── IWechatNotifyService.java │ │ ├── impls │ │ ├── AlipayNotifyService.java │ │ ├── CEBGatewayNotifyService.java │ │ ├── CEBNotifyService.java │ │ ├── CacheService.java │ │ ├── CheckSellerService.java │ │ ├── PSBCNotifyService.java │ │ ├── PayMapService.java │ │ ├── PayRouteService.java │ │ ├── SysConfigService.java │ │ ├── UnionPayNotifyService.java │ │ └── WechatNotifyService.java │ │ └── pay │ │ ├── strategy │ │ ├── AlipayAppStrategy.java │ │ ├── AlipayWapStrategy.java │ │ ├── AlipayWebStrategy.java │ │ ├── CEBGatewayPayStrategy.java │ │ ├── CEBGatewayPayWapStrategy.java │ │ ├── CEBWapStragegy.java │ │ ├── CEBWebStragegy.java │ │ ├── PSBCWapStragegy.java │ │ ├── PSBCWebStragegy.java │ │ ├── PayStrategy.java │ │ ├── StrategyContext.java │ │ ├── StrategyFactory.java │ │ ├── UnionAppStrategy.java │ │ ├── UnionWapStrategy.java │ │ ├── UnionWebStrategy.java │ │ └── WechatPayAppStrategy.java │ │ └── util │ │ ├── app │ │ ├── ali │ │ │ ├── global │ │ │ │ ├── sign │ │ │ │ │ ├── Base64.java │ │ │ │ │ └── RSA.java │ │ │ │ └── util │ │ │ │ │ ├── AlipayCore.java │ │ │ │ │ ├── AlipayNotify.java │ │ │ │ │ ├── AlipaySubmit.java │ │ │ │ │ ├── UtilDate.java │ │ │ │ │ └── httpClient │ │ │ │ │ ├── HttpProtocolHandler.java │ │ │ │ │ ├── HttpRequest.java │ │ │ │ │ ├── HttpResponse.java │ │ │ │ │ └── HttpResultType.java │ │ │ └── main │ │ │ │ ├── sign │ │ │ │ ├── Base64.java │ │ │ │ └── RSA.java │ │ │ │ └── util │ │ │ │ ├── AlipayCore.java │ │ │ │ ├── AlipayNotify.java │ │ │ │ ├── AlipaySubmit.java │ │ │ │ ├── UtilDate.java │ │ │ │ └── httpClient │ │ │ │ ├── HttpProtocolHandler.java │ │ │ │ ├── HttpRequest.java │ │ │ │ ├── HttpResponse.java │ │ │ │ └── HttpResultType.java │ │ └── wechat │ │ │ └── util │ │ │ ├── AesUtils.java │ │ │ ├── HttpUtils.java │ │ │ ├── MD5.java │ │ │ ├── MD5Util.java │ │ │ └── Util.java │ │ └── web │ │ ├── ali │ │ ├── bonded │ │ │ ├── config │ │ │ │ └── AlipayConfig.java │ │ │ ├── sign │ │ │ │ └── MD5.java │ │ │ └── util │ │ │ │ ├── AlipayCore.java │ │ │ │ ├── AlipayNotify.java │ │ │ │ ├── AlipaySubmit.java │ │ │ │ ├── UtilDate.java │ │ │ │ └── httpClient │ │ │ │ ├── HttpProtocolHandler.java │ │ │ │ ├── HttpRequest.java │ │ │ │ ├── HttpResponse.java │ │ │ │ └── HttpResultType.java │ │ ├── global │ │ │ ├── sign │ │ │ │ └── MD5.java │ │ │ └── util │ │ │ │ ├── AlipayCore.java │ │ │ │ ├── AlipayNotify.java │ │ │ │ ├── AlipaySubmit.java │ │ │ │ ├── UtilDate.java │ │ │ │ └── httpClient │ │ │ │ ├── HttpProtocolHandler.java │ │ │ │ ├── HttpRequest.java │ │ │ │ ├── HttpResponse.java │ │ │ │ └── HttpResultType.java │ │ └── main │ │ │ ├── sign │ │ │ └── MD5.java │ │ │ └── util │ │ │ ├── AlipayCore.java │ │ │ ├── AlipayNotify.java │ │ │ ├── AlipaySubmit.java │ │ │ ├── UtilDate.java │ │ │ └── httpClient │ │ │ ├── HttpProtocolHandler.java │ │ │ ├── HttpRequest.java │ │ │ ├── HttpResponse.java │ │ │ └── HttpResultType.java │ │ ├── ceb │ │ ├── PayUtils.java │ │ ├── SpsSecureProtocolSocketFactory.java │ │ └── SpsX509TrustManager.java │ │ └── unionpay │ │ ├── upop │ │ └── sdk │ │ │ ├── PinUtils.java │ │ │ ├── QuickPayBack.java │ │ │ ├── QuickPayConf.java │ │ │ ├── QuickPayQuery.java │ │ │ ├── QuickPayResSampleServLet.java │ │ │ ├── QuickPaySampleServLet.java │ │ │ ├── QuickPayUtils.java │ │ │ ├── SSLConnetionUtils.java │ │ │ └── Sms.java │ │ └── util │ │ ├── BackRcvResponse.java │ │ ├── DemoBase.java │ │ ├── Form_6_2_AppConsume.java │ │ ├── Form_6_2_FrontConsume.java │ │ ├── Form_6_3_ConsumeUndo.java │ │ ├── Form_6_4_Refund.java │ │ ├── Form_6_5_Query.java │ │ ├── Form_6_6_FileTransfer.java │ │ ├── Form_6_7_1_AuthDeal_App.java │ │ ├── Form_6_7_1_AuthDeal_Front.java │ │ ├── Form_6_7_2_AuthUndo.java │ │ ├── Form_6_7_3_AuthFinish.java │ │ ├── Form_6_7_4_AutnFinishUndo.java │ │ └── FrontRcvResponse.java ├── resources │ ├── acp_sdk.properties │ ├── applicationContext.xml │ ├── ceb-product │ │ └── cebmerchantreal.jks │ ├── ceb_merchant.properties │ ├── certsProduct │ │ ├── ScriptX.keystore │ │ ├── UpopRsaCert.cer │ │ ├── cebmerchant.jks │ │ ├── electronicInvoice.cer │ │ ├── electronicInvoice.keystore │ │ ├── encryptpub.cer │ │ ├── hugnew.keystore │ │ ├── hugneweinv.cer │ │ ├── hugnewhes.keystore │ │ ├── readme.txt │ │ └── xxxx.pfx │ ├── certsTest │ │ ├── PM_acp.pfx │ │ ├── acp_test_verify_sign.cer │ │ └── kf.cer │ ├── generatorConfig.xml │ ├── log4j.xml │ ├── logback.xml │ ├── mybatis_config.xml │ ├── payNotify_config.properties │ ├── payRequest_config.properties │ ├── psbc-merchant-toolkit │ │ ├── pro-env │ │ │ ├── merchant.pfx │ │ │ └── psbc_merchant.jks │ │ ├── psbc_merchant.jks │ │ └── test-env │ │ │ └── merchant.pfx │ ├── psbc_merchant.properties │ ├── ready.keystore │ ├── server_config.properties │ ├── spring_mvc.xml │ ├── spring_rabbitmq.xml │ ├── spring_shiro.xml │ ├── sql │ │ ├── sps_member.sql │ │ ├── sps_pay_map.sql │ │ ├── sps_payment.sql │ │ └── sps_sys_config.sql │ └── sys_config.properties └── webapp │ ├── WEB-INF │ ├── ceb-merchant-0.01.jar │ ├── psbc-merchant-toolkit-1.0.1.jar │ ├── unionpay-acp-sdk-1.0.0.jar │ └── web.xml │ └── index.jsp └── test └── java └── com └── hugnew └── test └── sps └── common └── BaseContextCase.java /README.md: -------------------------------------------------------------------------------- 1 | # PayMap 2 | PayMap是一个使用Java语言集成三方支付的小Demo,现已集成支付宝(国内、国际、移动端、PC端)、微信、银联(ACP、UPOP)、光大(网关、网页)、邮政支付,采用的技术栈为:SpringMVC+Spring+MyBatis+Shiro+RabbitMQ+Redis。 3 | ## 特性 4 | * 支持前面提到的各种**支付 5 | * 支付请求调用支持HTTP和异步MQ 6 | * 控制层统一异常处理 7 | * LogBack日志记录 8 | * Redis缓存机制 9 | * Shiro安全机制 10 | * MyBatis代码自动生成 11 | * HTTP请求日志记录 12 | * RESTful APIs 13 | 14 | ## 使用 15 | 这里不多说,先去看三方支付提供的官方文档,如有疑问可以跟我交流。 16 | 17 | ## 补充 18 | 由于是Demo,银联支付会支持ACP和UPOP,UPOP属于老平台文档较少有可能有人会用到,现在用的基本都是ACP。另外三方支付对接由于各种网络原因,支付可能存在通知失败或者MQ消息有可能失败的情况,这里需要采用补偿机制,一般的补偿方案是:消息落地数据库,流程成功删掉指定消息,对于失败的消息有专门的定时任务轮询重发,重发次数可以参考指数退避算法,业务方也要做好接口幂等,至于具体的补偿方案请自行查阅,本Demo没有提供。对于支付通知失败的情况官方建议的流程是:业务方主动向三方支付查询消费交易状态然后进行后续业务处理,查询接口本Demo中也没有提供请自行实现。如果发现缺少JAR包,可以从WEB-INF目录下找到,请自行更新到你本地Maven库中。最后一点是涉及到支付证书一类的配置文件均为空文件请自行替换,如果出现“hugnew”字符的均需修改为您自己的配置信息。 19 | 20 | ## 交流 21 | 微信:crackxb 22 | E-Mail:hugnew.com@gmail.com 23 | QQ群:427697041 24 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/common/constant/ActionConstants.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.common.constant; 2 | 3 | /** 4 | * Created by Martin on 2016/7/01. 5 | */ 6 | public class ActionConstants { 7 | 8 | /** 9 | * 默认值 - 执行失败时ReturnContext的ReturnMsg 10 | */ 11 | public static final String DEFAULT_FAILED_RETURNMSG = "执行失败!"; 12 | /** 13 | * 默认值KEY - 执行成功时ReturnContext的ReturnMsg 14 | */ 15 | public static final String DEFAULT_SUCCESS_RETURNMSG = "执行成功!"; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/common/constant/SystemConfig.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.common.constant; 2 | 3 | 4 | /** 5 | * 从SpringApplicationContext中设置的系统参数 6 | * Created by Martin on 2016/7/01. 7 | */ 8 | public class SystemConfig { 9 | 10 | //系统默认游客的用户名 11 | private static String guestUsername = ""; 12 | 13 | private SystemConfig() { 14 | } 15 | 16 | public static String getGuestUsername() { 17 | return guestUsername; 18 | } 19 | 20 | public static void setGuestUsername(String guestUsername) { 21 | SystemConfig.guestUsername = guestUsername; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/common/exception/BaseException.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.common.exception; 2 | 3 | /** 4 | * Created by Martin on 2016/7/01. 5 | */ 6 | public class BaseException extends RuntimeException { 7 | 8 | public BaseException(String message) { 9 | super(message, new Throwable(message)); 10 | } 11 | 12 | public BaseException(Throwable cause) { 13 | super(cause); 14 | } 15 | 16 | public BaseException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/common/exception/BusinessException.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.common.exception; 2 | 3 | /** 4 | * 业务异常的自定义封装类 5 | * Created by Martin on 2016/7/01. 6 | */ 7 | public class BusinessException extends BaseException { 8 | 9 | public BusinessException(String message) { 10 | super(message, new Throwable(message)); 11 | } 12 | 13 | public BusinessException(Throwable cause) { 14 | super(cause); 15 | } 16 | 17 | public BusinessException(String message, Throwable cause) { 18 | super(message, cause); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/common/exception/DBException.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.common.exception; 2 | 3 | /** 4 | * 数据库异常 5 | * Created by Martin on 2016/7/01. 6 | */ 7 | public class DBException extends BaseException { 8 | 9 | /** 10 | * @Fields serialVersionUID : default 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | 14 | public DBException(String message) { 15 | super(message, new Throwable()); 16 | } 17 | 18 | public DBException(String message, Throwable cause) { 19 | super(message, cause); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/common/exception/ResultCode.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.common.exception; 2 | 3 | /** 4 | * Created by Martin on 2016/7/01. 5 | */ 6 | public enum ResultCode { 7 | 8 | /** 9 | * 成功. ErrorCode : 0 10 | */ 11 | SUCCESS("0", "成功"), 12 | /** 13 | * 未知异常. ErrorCode : 01 14 | */ 15 | UnknownException("01", "未知异常"), 16 | /** 17 | * 系统异常. ErrorCode : 02 18 | */ 19 | SystemException("02", "系统异常"), 20 | /** 21 | * 业务错误. ErrorCode : 03 22 | */ 23 | BusinessException("03", "业务错误"), 24 | /** 25 | * 提示级错误. ErrorCode : 04 26 | */ 27 | InfoException("04", "提示级错误"), 28 | /** 29 | * 数据库操作异常. ErrorCode : 020001 30 | */ 31 | DBException("020001", "数据库操作异常"), 32 | /** 33 | * 参数验证错误. ErrorCode : 040001 34 | */ 35 | ParamException("040001", "参数验证错误"), 36 | 37 | SystemMaintainException("11", "系统正在维护"); 38 | 39 | private String _code; 40 | private String _msg; 41 | 42 | private ResultCode(String code, String msg) { 43 | _code = code; 44 | _msg = msg; 45 | } 46 | 47 | public String getCode() { 48 | return _code; 49 | } 50 | 51 | public String getMsg() { 52 | return _msg; 53 | } 54 | 55 | public static ResultCode getByCode(String code) { 56 | for (ResultCode ec : ResultCode.values()) { 57 | if (ec.getCode().equals(code)) { 58 | return ec; 59 | } 60 | } 61 | return null; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/common/exception/SystemException.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.common.exception; 2 | 3 | /** 4 | * Created by Martin on 2016/7/01. 5 | */ 6 | public class SystemException extends BaseException { 7 | 8 | public SystemException(String message) { 9 | super(message, new Throwable(message)); 10 | } 11 | 12 | public SystemException(Throwable cause) { 13 | super(cause); 14 | } 15 | 16 | public SystemException(String message, Throwable cause) { 17 | super(message, cause); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/common/exception/ValidationError.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.common.exception; 2 | 3 | /** 4 | * Created by Martin on 2016/7/01. 5 | */ 6 | public class ValidationError { 7 | 8 | private String objectName; 9 | 10 | private String fieldName; 11 | 12 | private String defaultMessage; 13 | 14 | public ValidationError() { 15 | } 16 | 17 | public ValidationError(String objectName, String fieldName, String defaultMessage) { 18 | 19 | this.objectName = objectName; 20 | 21 | this.fieldName = fieldName; 22 | 23 | this.defaultMessage = defaultMessage; 24 | } 25 | 26 | public String getObjectName() { 27 | return objectName; 28 | } 29 | 30 | public void setObjectName(String objectName) { 31 | this.objectName = objectName; 32 | } 33 | 34 | public String getDefaultMessage() { 35 | return defaultMessage; 36 | } 37 | 38 | public void setDefaultMessage(String defaultMessage) { 39 | this.defaultMessage = defaultMessage; 40 | } 41 | 42 | public String getFieldName() { 43 | return fieldName; 44 | } 45 | 46 | public void setFieldName(String fieldName) { 47 | this.fieldName = fieldName; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "ValidationError{" + 53 | "objectName='" + objectName + '\'' + 54 | ", fieldName='" + fieldName + '\'' + 55 | ", defaultMessage='" + defaultMessage + '\'' + 56 | '}'; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/common/model/json/AjaxResult.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.common.model.json; 2 | 3 | import com.hugnew.core.common.constant.ActionConstants; 4 | import com.hugnew.core.common.exception.ResultCode; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * AJAX调用返回对象 10 | * Created by Martin on 2016/7/01. 11 | */ 12 | public class AjaxResult implements Serializable { 13 | 14 | //请求结果是否成功 15 | private String ErrorCode = ResultCode.SUCCESS.getCode(); 16 | 17 | //请求返回信息 18 | private String Message = ActionConstants.DEFAULT_SUCCESS_RETURNMSG; 19 | 20 | //请求结果 21 | private Object Data = null; 22 | 23 | public AjaxResult() { 24 | } 25 | 26 | public String getErrorCode() { 27 | return ErrorCode; 28 | } 29 | 30 | public void setErrorCode(String errorCode) { 31 | ErrorCode = errorCode; 32 | } 33 | 34 | public String getMessage() { 35 | return Message; 36 | } 37 | 38 | public void setMessage(String message) { 39 | Message = message; 40 | } 41 | 42 | public Object getData() { 43 | return Data; 44 | } 45 | 46 | public void setData(Object data) { 47 | Data = data; 48 | } 49 | 50 | /** 51 | * 获取正确结果模板 52 | * @param message 请求返回信息 53 | * @param obj 请求结果 54 | * @return AjaxResult 55 | */ 56 | public static AjaxResult getOK(String message, Object obj) { 57 | AjaxResult result = new AjaxResult(); 58 | result.setMessage(message); 59 | result.setData(obj); 60 | return result; 61 | } 62 | 63 | /** 64 | * 获取正确结果模板 65 | * @param obj 请求结果 66 | * @return AjaxResult 67 | */ 68 | public static AjaxResult getOK(Object obj) { 69 | AjaxResult result = new AjaxResult(); 70 | result.setMessage(ActionConstants.DEFAULT_SUCCESS_RETURNMSG); 71 | result.setData(obj); 72 | return result; 73 | } 74 | 75 | /** 76 | * 获取错误结果模板 77 | * @param message 请求返回信息 78 | * @param obj 请求结果 79 | * @return AjaxResult 80 | */ 81 | public static AjaxResult getError(ResultCode errorCode, String message, Object obj) { 82 | AjaxResult result = new AjaxResult(); 83 | result.setErrorCode(errorCode.getCode()); 84 | result.setMessage(message); 85 | result.setData(obj); 86 | return result; 87 | } 88 | 89 | /** 90 | * 获取正确结果模板 91 | * @return AjaxResult 92 | */ 93 | public static AjaxResult getOK() { 94 | return getOK(ActionConstants.DEFAULT_SUCCESS_RETURNMSG, null); 95 | } 96 | 97 | 98 | /** 99 | * 获取错误结果模板 100 | * @return AjaxResult 101 | */ 102 | public static AjaxResult getError(ResultCode resultCode) { 103 | return getError(resultCode, resultCode.getMsg(), ""); 104 | } 105 | 106 | @Override 107 | public String toString() { 108 | return "AjaxResult{" + 109 | "ErrorCode='" + ErrorCode + '\'' + 110 | ", Message='" + Message + '\'' + 111 | ", Data=" + Data + 112 | '}'; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/dao/IBaseMapper.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.dao; 2 | 3 | import com.github.abel533.mapper.MapperProvider; 4 | import org.apache.ibatis.annotations.*; 5 | import org.apache.ibatis.session.RowBounds; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Martin on 2016/7/01. 11 | */ 12 | public interface IBaseMapper { 13 | 14 | @SelectProvider(type = MapperProvider.class, method = "dynamicSQL") 15 | T selectOne(T record); 16 | 17 | @SelectProvider(type = MapperProvider.class, method = "dynamicSQL") 18 | List select(T record); 19 | 20 | @SelectProvider(type = MapperProvider.class, method = "dynamicSQL") 21 | int selectCount(T record); 22 | 23 | @SelectProvider(type = MapperProvider.class, method = "dynamicSQL") 24 | T selectByPrimaryKey(Object key); 25 | 26 | @InsertProvider(type = MapperProvider.class, method = "dynamicSQL") 27 | int insert(T record); 28 | 29 | @InsertProvider(type = MapperProvider.class, method = "dynamicSQL") 30 | int insertSelective(T record); 31 | 32 | @DeleteProvider(type = MapperProvider.class, method = "dynamicSQL") 33 | int delete(T record); 34 | 35 | @DeleteProvider(type = MapperProvider.class, method = "dynamicSQL") 36 | int deleteByPrimaryKey(Object key); 37 | 38 | @UpdateProvider(type = MapperProvider.class, method = "dynamicSQL") 39 | int updateByPrimaryKey(T record); 40 | 41 | @UpdateProvider(type = MapperProvider.class, method = "dynamicSQL") 42 | int updateByPrimaryKeySelective(T record); 43 | 44 | @SelectProvider(type = MapperProvider.class, method = "dynamicSQL") 45 | int selectCountByExample(Object example); 46 | 47 | @DeleteProvider(type = MapperProvider.class, method = "dynamicSQL") 48 | int deleteByExample(Object example); 49 | 50 | @SelectProvider(type = MapperProvider.class, method = "dynamicSQL") 51 | List selectByExample(Object example); 52 | 53 | @UpdateProvider(type = MapperProvider.class, method = "dynamicSQL") 54 | int updateByExampleSelective(@Param("record") T record, @Param("example") Object example); 55 | 56 | @UpdateProvider(type = MapperProvider.class, method = "dynamicSQL") 57 | int updateByExample(@Param("record") T record, @Param("example") Object example); 58 | 59 | List getAllByPage(RowBounds rowBounds); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/service/IBaseService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.service; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.hugnew.core.common.exception.DBException; 5 | import org.apache.ibatis.session.RowBounds; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Martin on 2016/7/01. 11 | */ 12 | public interface IBaseService { 13 | 14 | /** 15 | * 根据主键查询指定实体 16 | * @param id 17 | * @return 18 | */ 19 | T getById(Object id); 20 | 21 | /** 22 | * 列表查询 23 | * @param entity 24 | * @return 25 | */ 26 | List getByEntity(T entity); 27 | 28 | /** 29 | * 获取分页数据 30 | * @param rowBounds 31 | * @return 32 | */ 33 | PageInfo getByPage(RowBounds rowBounds); 34 | 35 | /** 36 | * 保存对象,保存所有属性 37 | * @param entity 38 | * @return 39 | */ 40 | int save(T entity); 41 | 42 | /** 43 | * 更新对象中所有属性,主键不能为NULL 44 | * @param entity 45 | * @return 46 | */ 47 | int update(T entity); 48 | 49 | /** 50 | * 删除指定数据 51 | * @param id 52 | * @return 53 | */ 54 | int delete(Object id); 55 | 56 | /** 57 | * 保存对象,只保存对象中不为NULL的属性 58 | * @param entity 59 | * @return 60 | */ 61 | int saveSelective(T entity) throws DBException; 62 | 63 | /** 64 | * 更新对象,只更新对象中不为NULL的属性,主键不能为NULL 65 | * @param entity 66 | * @return 67 | */ 68 | int updateSelective(T entity); 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/service/impl/BaseService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.service.impl; 2 | 3 | import com.github.pagehelper.PageInfo; 4 | import com.hugnew.core.common.exception.DBException; 5 | import com.hugnew.core.dao.IBaseMapper; 6 | import com.hugnew.core.service.IBaseService; 7 | import org.apache.ibatis.session.RowBounds; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.data.redis.core.RedisTemplate; 13 | import org.springframework.stereotype.Service; 14 | 15 | import javax.annotation.Resource; 16 | import java.util.List; 17 | 18 | /** 19 | * Created by Martin on 2016/7/01. 20 | */ 21 | @Service 22 | public abstract class BaseService implements IBaseService { 23 | 24 | private static Logger logger = LoggerFactory.getLogger(BaseService.class); 25 | @Resource 26 | protected RabbitTemplate amqpTemplate; 27 | @Autowired 28 | protected RedisTemplate redisTemplate; 29 | 30 | public abstract IBaseMapper getBaseMapper(); 31 | 32 | /** 33 | * 根据主键查询指定实体 34 | * @param id 35 | * @return 36 | */ 37 | @Override 38 | public T getById(Object id) { 39 | return this.getBaseMapper().selectByPrimaryKey(id); 40 | } 41 | 42 | /** 43 | * 列表查询 44 | * @param entity 45 | * @return 46 | */ 47 | @Override 48 | public List getByEntity(T entity) { 49 | return this.getBaseMapper().select(entity); 50 | } 51 | 52 | /** 53 | * 获取分页数据 54 | * @param rowBounds 55 | * @return 56 | */ 57 | @Override 58 | public PageInfo getByPage(RowBounds rowBounds) { 59 | List list = this.getBaseMapper().getAllByPage(rowBounds); 60 | return new PageInfo(list); 61 | } 62 | 63 | /** 64 | * 保存对象,保存所有属性 65 | * @param entity 66 | * @return 67 | */ 68 | @Override 69 | public int save(T entity) { 70 | return this.getBaseMapper().insert(entity); 71 | } 72 | 73 | /** 74 | * 更新对象中所有属性,主键不能为NULL 75 | * @param entity 76 | * @return 77 | */ 78 | @Override 79 | public int update(T entity) { 80 | return this.getBaseMapper().updateByPrimaryKey(entity); 81 | } 82 | 83 | /** 84 | * 删除指定数据 85 | * @param id 86 | * @return 87 | */ 88 | @Override 89 | public int delete(Object id) { 90 | return this.getBaseMapper().deleteByPrimaryKey(id); 91 | } 92 | 93 | /** 94 | * 保存对象,只保存对象中不为NULL的属性 95 | * @param entity 96 | * @return 97 | */ 98 | @Override 99 | public int saveSelective(T entity) throws DBException { 100 | int result = this.getBaseMapper().insertSelective(entity); 101 | if (result <= 0) { 102 | throw new DBException("数据保存异常"); 103 | } 104 | return result; 105 | } 106 | 107 | /** 108 | * 更新对象,只更新对象中不为NULL的属性,主键不能为NULL 109 | * @param entity 110 | * @return 111 | */ 112 | @Override 113 | public int updateSelective(T entity) { 114 | return this.getBaseMapper().updateByPrimaryKeySelective(entity); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/util/PropertiesUtil.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.util; 2 | 3 | import com.hugnew.core.common.exception.BusinessException; 4 | 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.util.Arrays; 8 | import java.util.List; 9 | import java.util.Properties; 10 | 11 | /** 12 | * Properties文件加载工具 13 | * Created by Martin on 2016/7/01. 14 | */ 15 | public class PropertiesUtil { 16 | public static Properties properties = new Properties(); 17 | public static List configFile = Arrays.asList( 18 | "payNotify_config.properties", "server_config.properties", "sys_config.properties", "payRequest_config.properties"); 19 | 20 | static { 21 | try { 22 | for(String fileName:configFile) { 23 | InputStream in = PropertiesUtil.class.getClassLoader().getResourceAsStream(fileName); 24 | properties.load(in); 25 | } 26 | } catch (IOException e) { 27 | throw new BusinessException("读取配置文件错误!"); 28 | } 29 | } 30 | 31 | public static String getValue(String key){ 32 | return properties.getProperty(key,""); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/util/SqlSessionFactoryBeanUtil.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.util; 2 | 3 | import org.apache.ibatis.executor.ErrorContext; 4 | import org.apache.ibatis.session.SqlSessionFactory; 5 | import org.mybatis.spring.SqlSessionFactoryBean; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.core.NestedIOException; 9 | 10 | import java.io.IOException; 11 | 12 | /** 13 | * Created by Martin on 2016/7/01. 14 | */ 15 | public class SqlSessionFactoryBeanUtil extends SqlSessionFactoryBean { 16 | 17 | private static Logger logger = LoggerFactory.getLogger(SqlSessionFactoryBeanUtil.class); 18 | 19 | @Override 20 | protected SqlSessionFactory buildSqlSessionFactory() throws IOException { 21 | try { 22 | return super.buildSqlSessionFactory(); 23 | } catch (NestedIOException e) { 24 | logger.error("ex:{}",e.getMessage()); 25 | throw new NestedIOException("Failed to parse mapping resource: ", e); 26 | } finally { 27 | ErrorContext.instance().reset(); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/web/system/filters/RequestWrapper.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.web.system.filters; 2 | 3 | import org.apache.commons.io.input.TeeInputStream; 4 | 5 | import javax.servlet.ServletInputStream; 6 | import javax.servlet.http.HttpServletRequest; 7 | import javax.servlet.http.HttpServletRequestWrapper; 8 | import java.io.ByteArrayOutputStream; 9 | import java.io.IOException; 10 | 11 | /** 12 | * Created by Martin on 2016/7/01. 13 | */ 14 | public class RequestWrapper extends HttpServletRequestWrapper { 15 | 16 | private final ByteArrayOutputStream bos = new ByteArrayOutputStream(); 17 | private long id; 18 | 19 | public RequestWrapper(Long requestId, HttpServletRequest request) { 20 | super(request); 21 | this.id = requestId; 22 | } 23 | 24 | @Override 25 | public ServletInputStream getInputStream() throws IOException { 26 | return new ServletInputStream() { 27 | private TeeInputStream tee = new TeeInputStream(RequestWrapper.super.getInputStream(), bos); 28 | 29 | @Override 30 | public int read() throws IOException { 31 | return tee.read(); 32 | } 33 | }; 34 | } 35 | 36 | public byte[] toByteArray() { 37 | return bos.toByteArray(); 38 | } 39 | 40 | public long getId() { 41 | return id; 42 | } 43 | 44 | public void setId(long id) { 45 | this.id = id; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/web/system/filters/ResponseWrapper.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.web.system.filters; 2 | 3 | import org.apache.commons.io.output.TeeOutputStream; 4 | 5 | import javax.servlet.ServletOutputStream; 6 | import javax.servlet.ServletResponse; 7 | import javax.servlet.http.HttpServletResponse; 8 | import javax.servlet.http.HttpServletResponseWrapper; 9 | import java.io.ByteArrayOutputStream; 10 | import java.io.IOException; 11 | import java.io.PrintWriter; 12 | 13 | /** 14 | * Created by Martin on 2016/7/01. 15 | */ 16 | public class ResponseWrapper extends HttpServletResponseWrapper { 17 | 18 | private final ByteArrayOutputStream bos = new ByteArrayOutputStream(); 19 | private PrintWriter writer = new PrintWriter(bos); 20 | private long id; 21 | 22 | public ResponseWrapper(Long requestId, HttpServletResponse response) { 23 | super(response); 24 | this.id = requestId; 25 | } 26 | 27 | @Override 28 | public ServletResponse getResponse() { 29 | return this; 30 | } 31 | 32 | @Override 33 | public ServletOutputStream getOutputStream() throws IOException { 34 | return new ServletOutputStream() { 35 | private TeeOutputStream tee = new TeeOutputStream(ResponseWrapper.super.getOutputStream(), bos); 36 | 37 | @Override 38 | public void write(int b) throws IOException { 39 | tee.write(b); 40 | } 41 | }; 42 | } 43 | 44 | @Override 45 | public PrintWriter getWriter() throws IOException { 46 | return new TeePrintWriter(super.getWriter(), writer); 47 | } 48 | 49 | public byte[] toByteArray() { 50 | return bos.toByteArray(); 51 | } 52 | 53 | public long getId() { 54 | return id; 55 | } 56 | 57 | public void setId(long id) { 58 | this.id = id; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/web/system/filters/TeePrintWriter.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.web.system.filters; 2 | 3 | import java.io.PrintWriter; 4 | 5 | /** 6 | * Created by Martin on 2016/7/01. 7 | */ 8 | public class TeePrintWriter extends PrintWriter { 9 | 10 | PrintWriter branch; 11 | 12 | public TeePrintWriter(PrintWriter main, PrintWriter branch) { 13 | super(main, true); 14 | this.branch = branch; 15 | } 16 | 17 | public void write(char buf[], int off, int len) { 18 | super.write(buf, off, len); 19 | super.flush(); 20 | branch.write(buf, off, len); 21 | branch.flush(); 22 | } 23 | 24 | public void write(String s, int off, int len) { 25 | super.write(s, off, len); 26 | super.flush(); 27 | branch.write(s, off, len); 28 | branch.flush(); 29 | } 30 | 31 | public void write(int c) { 32 | super.write(c); 33 | super.flush(); 34 | branch.write(c); 35 | branch.flush(); 36 | } 37 | 38 | public void flush() { 39 | super.flush(); 40 | branch.flush(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/core/web/system/listener/InitListener.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.core.web.system.listener; 2 | 3 | import com.unionpay.acp.sdk.SDKConfig; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.context.ApplicationContext; 7 | import org.springframework.web.context.support.WebApplicationContextUtils; 8 | 9 | import javax.servlet.ServletContextEvent; 10 | 11 | /** 12 | * 系统初始化监听器,在系统启动时运行,进行一些初始化工作 13 | * Created by Martin on 2016/7/01. 14 | */ 15 | public class InitListener implements javax.servlet.ServletContextListener { 16 | 17 | private static Logger logger = LoggerFactory.getLogger(InitListener.class); 18 | public static ApplicationContext context; 19 | 20 | public void contextDestroyed(ServletContextEvent arg0) { 21 | } 22 | 23 | public void contextInitialized(ServletContextEvent servletContextEvent) { 24 | context = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContextEvent.getServletContext()); 25 | //加载银联upop配置文件 26 | SDKConfig.getConfig().loadPropertiesFromSrc(); 27 | String proPath = servletContextEvent.getServletContext().getRealPath("/"); 28 | SDKConfig config = SDKConfig.getConfig(); 29 | config.setSignCertDir(proPath + config.getSignCertDir()); 30 | config.setSignCertPath(proPath + config.getSignCertPath()); 31 | config.setValidateCertDir(proPath + config.getValidateCertDir()); 32 | //缓存初始化忽略 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/controllers/base/BaseController.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.controllers.base; 2 | 3 | import com.hugnew.core.common.exception.BusinessException; 4 | import com.hugnew.core.util.StringUtil; 5 | import com.hugnew.sps.dto.MobileInfo; 6 | import com.hugnew.sps.enums.RequestFrom; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | 12 | /** 13 | * Created by Martin on 2016/7/01. 14 | */ 15 | public abstract class BaseController { 16 | 17 | private Logger logger = LoggerFactory.getLogger(BaseController.class); 18 | 19 | /** 20 | * 获取用户ID,用户ID可能为NULL,需自行判断 21 | * @param request 22 | * @return 23 | */ 24 | protected Long getUserId(HttpServletRequest request) { 25 | String sId = request.getHeader("userId"); 26 | if (!StringUtil.isEmpty(sId)) { 27 | try { 28 | Long userId = Long.parseLong(sId); 29 | return userId; 30 | } catch (NumberFormatException e) { 31 | logger.warn("请求头userId参数格式错误:{}", sId); 32 | } 33 | } 34 | return null; 35 | } 36 | 37 | /** 38 | * 获取用户ID,当userId为空的时候抛出异常 39 | * @param request 40 | * @return 41 | * @throws BusinessException 用户ID不能为空 42 | */ 43 | protected Long getNotNullUserId(HttpServletRequest request) throws BusinessException { 44 | Long userId = getUserId(request); 45 | if (userId == null) { 46 | throw new BusinessException("用户ID不能为空"); 47 | } 48 | return userId; 49 | } 50 | 51 | /** 52 | * 获取请求来源类型 53 | * @param request 54 | * @return 55 | * @throws BusinessException 56 | */ 57 | protected RequestFrom getRequestFrom(HttpServletRequest request) throws BusinessException { 58 | String from = request.getHeader("from"); 59 | if (StringUtil.isEmpty(from)) { 60 | throw new BusinessException("请求头错误未包含来源字段"); 61 | } 62 | try { 63 | int iFom = Integer.parseInt(from); 64 | return RequestFrom.getById(iFom); 65 | } catch (NumberFormatException e) { 66 | throw new BusinessException("请求头来源字段类型错误"); 67 | } 68 | 69 | } 70 | 71 | /** 72 | * 获取移动端请求头信息 73 | * @param request 74 | * @return MobileInfo 75 | * @throws BusinessException 76 | */ 77 | protected MobileInfo getMobileInfo(HttpServletRequest request) throws BusinessException { 78 | String appVersion = request.getHeader("appVersion"); 79 | String systemVersion = request.getHeader("appSystemVersion"); 80 | String deviceId = request.getHeader("appDeviceId"); 81 | Integer width = null; 82 | Integer height = null; 83 | int night = 0; 84 | try { 85 | width = Integer.parseInt(request.getHeader("appDeviceWidth")); 86 | height = Integer.parseInt(request.getHeader("appDeviceHeight")); 87 | if (request.getHeader("nightMode") != null) { 88 | night = Integer.parseInt(request.getHeader("nightMode")); 89 | } 90 | } catch (NumberFormatException e) { 91 | throw new BusinessException("移动端请求头不符合约定"); 92 | } 93 | if (StringUtil.isEmpty(appVersion) || width == null || height == null) { 94 | throw new BusinessException("移动端请求头不符合约定"); 95 | } 96 | return new MobileInfo(appVersion, systemVersion, deviceId, width, height, night != 0); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/controllers/base/RestErrorHandler.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.controllers.base; 2 | 3 | import com.hugnew.core.common.exception.*; 4 | import com.hugnew.core.common.model.json.AjaxResult; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | import org.springframework.validation.BindException; 8 | import org.springframework.validation.FieldError; 9 | import org.springframework.web.bind.MethodArgumentNotValidException; 10 | import org.springframework.web.bind.annotation.ControllerAdvice; 11 | import org.springframework.web.bind.annotation.ExceptionHandler; 12 | import org.springframework.web.bind.annotation.ResponseBody; 13 | 14 | import java.util.HashSet; 15 | import java.util.Set; 16 | 17 | /** 18 | * 控制层异常统一处理 19 | * Created by Martin on 2016/7/01. 20 | */ 21 | @ControllerAdvice 22 | public class RestErrorHandler { 23 | 24 | private static Logger logger = LoggerFactory.getLogger(RestErrorHandler.class); 25 | 26 | @ExceptionHandler(BindException.class) 27 | @ResponseBody 28 | public AjaxResult handleBindException(BindException exception) { 29 | AjaxResult result = AjaxResult.getError(ResultCode.ParamException); 30 | Set errors = new HashSet(); 31 | for (FieldError er : exception.getFieldErrors()) { 32 | errors.add(new ValidationError(er.getObjectName(), er.getField(), er.getDefaultMessage())); 33 | } 34 | result.setData(errors); 35 | logger.warn("参数绑定错误:{}", exception.getObjectName()); 36 | return result; 37 | } 38 | 39 | 40 | @ExceptionHandler(MethodArgumentNotValidException.class) 41 | @ResponseBody 42 | public AjaxResult handleMethodArgumentNotValidException(MethodArgumentNotValidException exception) { 43 | AjaxResult result = AjaxResult.getError(ResultCode.ParamException); 44 | Set errors = new HashSet(); 45 | for (FieldError er : exception.getBindingResult().getFieldErrors()) { 46 | errors.add(new ValidationError(er.getObjectName(), er.getField(), er.getDefaultMessage())); 47 | } 48 | result.setData(errors); 49 | logger.warn("参数绑定错误:{}", exception.getBindingResult().getObjectName()); 50 | return result; 51 | } 52 | 53 | @ExceptionHandler(BusinessException.class) 54 | @ResponseBody 55 | public AjaxResult handleBusinessException(BusinessException exception) { 56 | AjaxResult result = AjaxResult.getError(ResultCode.BusinessException); 57 | result.setMessage(exception.getMessage()); 58 | logger.warn("业务错误:{}", exception.getMessage()); 59 | return result; 60 | } 61 | 62 | @ExceptionHandler(SystemException.class) 63 | @ResponseBody 64 | public AjaxResult handleSystemException(SystemException exception) { 65 | AjaxResult result = AjaxResult.getError(ResultCode.SystemException); 66 | result.setMessage("系统错误"); 67 | logger.error("系统错误:{}", exception); 68 | return result; 69 | } 70 | 71 | @ExceptionHandler(DBException.class) 72 | @ResponseBody 73 | public AjaxResult handleDBException(DBException exception) { 74 | AjaxResult result = AjaxResult.getError(ResultCode.DBException); 75 | result.setMessage("数据库错误"); 76 | logger.error("数据库错误:{}", exception); 77 | return result; 78 | } 79 | 80 | @ExceptionHandler(Exception.class) 81 | @ResponseBody 82 | public AjaxResult handleException(Exception exception) { 83 | AjaxResult result = AjaxResult.getError(ResultCode.UnknownException); 84 | result.setMessage("服务器错误"); 85 | logger.error("服务器错误:{}", exception); 86 | return result; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/controllers/front/mobile/pay/PayRequestController.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.controllers.front.mobile.pay; 2 | 3 | import com.hugnew.core.common.exception.BusinessException; 4 | import com.hugnew.core.common.exception.SystemException; 5 | import com.hugnew.core.common.model.json.AjaxResult; 6 | import com.hugnew.sps.controllers.base.BaseController; 7 | import com.hugnew.sps.dto.PayRequestParam; 8 | import com.hugnew.sps.services.*; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | /** 16 | * 支付请求相关接口 17 | * Created by Martin on 2016/7/01. 18 | */ 19 | @Controller 20 | @RequestMapping("/app/payRequest") 21 | public class PayRequestController extends BaseController { 22 | 23 | private static Logger logger = LoggerFactory.getLogger(PayRequestController.class); 24 | @Autowired 25 | private IPayRouteService payRouteService; 26 | 27 | /** 28 | * 组装支付请求报文 29 | * @param payRequestParam 30 | * @return 31 | * @throws BusinessException 32 | * @throws SystemException 33 | */ 34 | @ResponseBody 35 | @RequestMapping(value = "/getPayParams", method = RequestMethod.POST) 36 | public AjaxResult getPayParams(@RequestBody PayRequestParam payRequestParam) throws BusinessException, SystemException { 37 | return AjaxResult.getOK(payRouteService.getPayRetMap(payRequestParam)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/controllers/front/pc/pay/PayRequestController.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.controllers.front.pc.pay; 2 | 3 | import com.hugnew.core.common.exception.BusinessException; 4 | import com.hugnew.core.common.exception.SystemException; 5 | import com.hugnew.core.common.model.json.AjaxResult; 6 | import com.hugnew.sps.controllers.base.BaseController; 7 | import com.hugnew.sps.dto.PayRequestParam; 8 | import com.hugnew.sps.services.*; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Controller; 13 | import org.springframework.web.bind.annotation.*; 14 | 15 | /** 16 | * 支付请求相关接口 17 | * Created by Martin on 2016/7/01. 18 | */ 19 | @Controller("pc_payRequestController") 20 | @RequestMapping("/pc/payRequest") 21 | public class PayRequestController extends BaseController { 22 | 23 | private static Logger logger = LoggerFactory.getLogger(PayRequestController.class); 24 | @Autowired 25 | private IPayRouteService payRouteService; 26 | 27 | /** 28 | * 组装支付请求报文 29 | * @param payRequestParam 30 | * @return 31 | * @throws BusinessException 32 | * @throws SystemException 33 | */ 34 | @ResponseBody 35 | @RequestMapping(value = "/getPayParams", method = RequestMethod.POST) 36 | public AjaxResult getPayParams(@RequestBody PayRequestParam payRequestParam) throws BusinessException, SystemException { 37 | return AjaxResult.getOK(payRouteService.getPayRetMap(payRequestParam)); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/dao/MemberMapper.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.dao; 2 | 3 | import com.hugnew.core.dao.IBaseMapper; 4 | import com.hugnew.sps.dao.domain.Member; 5 | 6 | /** 7 | * Created by Martin on 2016/7/01. 8 | */ 9 | public interface MemberMapper extends IBaseMapper { 10 | public Member findByUsername(String username); 11 | } -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/dao/PayMapMapper.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.dao; 2 | 3 | 4 | import com.hugnew.core.dao.IBaseMapper; 5 | import com.hugnew.sps.dao.domain.PayMap; 6 | 7 | /** 8 | * Created by Martin on 2016/7/01. 9 | */ 10 | public interface PayMapMapper extends IBaseMapper { 11 | } -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/dao/SysConfigMapper.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.dao; 2 | 3 | import com.hugnew.core.dao.IBaseMapper; 4 | import com.hugnew.sps.dao.domain.SysConfig; 5 | import org.apache.ibatis.annotations.Param; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by Martin on 2016/7/01. 11 | */ 12 | public interface SysConfigMapper extends IBaseMapper { 13 | 14 | public Integer updateSysConfig(@Param("key") String key, @Param("sysValue") String sysValue); 15 | 16 | public List getAll(); 17 | 18 | } -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/dao/domain/BaseDomain.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.dao.domain; 2 | 3 | import javax.persistence.GeneratedValue; 4 | import javax.persistence.GenerationType; 5 | import javax.persistence.Id; 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 实体基类 10 | * Created by Martin on 2016/7/01. 11 | */ 12 | public class BaseDomain implements Serializable { 13 | 14 | private static final long serialVersionUID = -5386818304619762871L; 15 | 16 | /** 17 | * 主键ID 18 | */ 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.IDENTITY) 21 | protected Long id; 22 | 23 | /** 24 | * 获取主键ID 25 | * 26 | * @return id - ID 27 | */ 28 | public Long getId() { 29 | return id; 30 | } 31 | 32 | /** 33 | * 设置主键ID 34 | * 35 | * @param id ID 36 | */ 37 | public void setId(Long id) { 38 | this.id = id; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/dao/mapper/MemberMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/dao/mapper/PayMapMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/dao/mapper/PaymentMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/dao/mapper/SysConfigMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | UPDATE sps_sys_config SET sysValue=#{sysValue},modifyTime=unix_timestamp(now()) where sysKey=#{key} 16 | 17 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/dto/DDDetails.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.dto; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 数据字典中关于id和name的json串处理DTO 7 | * Created by Martin on 2016/7/01. 8 | */ 9 | public class DDDetails implements Serializable { 10 | 11 | /** 12 | * The Id. 13 | */ 14 | private String id; 15 | 16 | /** 17 | * The Name. 18 | */ 19 | private String name; 20 | 21 | /** 22 | * 获取 id. 23 | * 24 | * @return the id 25 | */ 26 | public String getId() { 27 | return id; 28 | } 29 | 30 | /** 31 | * 设置 id. 32 | * 33 | * @param id the id 34 | */ 35 | public void setId(String id) { 36 | this.id = id; 37 | } 38 | 39 | /** 40 | * 获取 name. 41 | * 42 | * @return the name 43 | */ 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | /** 49 | * 设置 name. 50 | * 51 | * @param name the name 52 | */ 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/enums/PayPlatform.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.enums; 2 | 3 | /** 4 | * 三方支付 5 | * Created by Martin on 2016/7/01. 6 | */ 7 | public enum PayPlatform { 8 | 9 | UNION_PC("101", "银联(onlinePay)"), 10 | UNION_APP("102", "银联(手机)"), 11 | CEB_GATEWAY("201", "光大网关"), 12 | CEB("202", "光大网页"), 13 | ALIPAY_GLOBAL("301", "支付宝(国际)"), 14 | ALIPAY_COMMON("302", "支付宝(普通)"), 15 | WECHAT_APP("401", "微信支付(开放平台)"), 16 | WECHAT_WAP("402", "微信支付(公众平台)"), 17 | ACCOUNT_COMMON("501", "现金账户"), 18 | PSBC("601", "邮政银行"); 19 | 20 | private String code; 21 | private String label; 22 | 23 | private PayPlatform(String code, String label) { 24 | this.code = code; 25 | this.label = label; 26 | } 27 | 28 | public String getCode() { 29 | return code; 30 | } 31 | 32 | public String getLabel() { 33 | return label; 34 | } 35 | 36 | public static PayPlatform getByCode(String code) { 37 | for (PayPlatform o : PayPlatform.values()) { 38 | if (o.getCode().equals(code)) { 39 | return o; 40 | } 41 | } 42 | throw new IllegalArgumentException("Not exist " 43 | + PayPlatform.class.getName() + " for code " + code); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/enums/PayType.java: -------------------------------------------------------------------------------- 1 | 2 | package com.hugnew.sps.enums; 3 | 4 | /** 5 | * Created by Martin on 2016/7/01. 6 | */ 7 | public enum PayType { 8 | 9 | ALIPAY_WEB(1, "支付宝网页支付"), 10 | ALIPAY_WAP(2, "支付宝手机网页支付"), 11 | UNION_WEB(3, "银联网页支付"), 12 | UNION_WAP(4, "银联手机网页支付"), 13 | UNION_APP(5, "银联手机APP支付"), 14 | ALIPAY_APP(6, "支付宝手机APP支付"), 15 | PSBC_WEB(7, "邮局网页支付"), 16 | PSBC_WAP(8, "邮局手机网页支付"), 17 | CEB_WEB(9, "光大银行网页支付"), 18 | CEB_WAP(10, "光大银行手机网页支付"), 19 | WECHAT_APP(11, "微信app支付"),//微信只支持app 20 | CEB_GATEWAY_WEB(12, "光大银行网关支付"), 21 | CEB_GATEWAY_WAP(13, "光大银行手机支付"); 22 | 23 | private Integer value; 24 | private String desc; 25 | private String name; 26 | 27 | PayType(Integer value, String desc) { 28 | this.value = value; 29 | this.desc = desc; 30 | 31 | } 32 | 33 | public static PayType valueOf(int value) { 34 | 35 | for (PayType type : PayType.values()) { 36 | if (type.value() == value) { 37 | return type; 38 | } 39 | } 40 | return null; 41 | } 42 | 43 | public Integer value() { 44 | return value; 45 | } 46 | 47 | public String desc() { 48 | return desc; 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/enums/PlatformType.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.enums; 2 | 3 | /** 4 | * Created by Martin on 2016/7/01. 5 | */ 6 | public enum PlatformType { 7 | 8 | DD("DD", "当当"), 9 | TB("TB", "淘宝"), 10 | JD("JD", "京东"), 11 | ICBC("ICBC", "工行"), 12 | UNIONPAY("UNIONPAY", "银联支付"), 13 | CEB("CEB", "光大银行"), 14 | PSBC("PSBC", "邮政储蓄"), 15 | CCB("CCB", "建行"), 16 | HZBSQ("HZBSQ", "杭州保税区"), 17 | NBBSQ("NBBSQ", "宁波保税区"), 18 | WECHAT("WECHAT", "微信支付"), 19 | YHD("YHD", "一号店"); 20 | private String value; 21 | private String desc; 22 | 23 | PlatformType(String value, String desc) { 24 | this.value = value; 25 | this.desc = desc; 26 | } 27 | 28 | public static PlatformType getPlatform(Integer value) { 29 | if (1 == value || 2 == value || 6 == value) { 30 | return PlatformType.TB; 31 | } else if (3 == value || 4 == value || 5 == value) { 32 | return PlatformType.UNIONPAY; 33 | } else if (7 == value || 8 == value) { 34 | return PlatformType.PSBC; 35 | } else if (9 == value || 10 == value || 12 == value) { 36 | return PlatformType.CEB; 37 | } else if (11 == value) { 38 | return PlatformType.WECHAT; 39 | } 40 | return null; 41 | } 42 | 43 | public String value() { 44 | return value; 45 | } 46 | 47 | public String desc() { 48 | return desc; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/enums/RequestFrom.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.enums; 2 | 3 | import com.hugnew.core.common.exception.BusinessException; 4 | 5 | /** 6 | * 请求来源 7 | * Created by Martin on 2016/7/01. 8 | */ 9 | public enum RequestFrom { 10 | 11 | PC(1, "PC"), 12 | WAP(2, "WAP"), 13 | WEIXIN(3, "微信"), 14 | ANDROID(4, "安卓"), 15 | IOS(5, "苹果"); 16 | 17 | private int _id; 18 | 19 | private String _name; 20 | 21 | RequestFrom(int id, String name){ 22 | _id = id; 23 | _name = name; 24 | } 25 | 26 | public int getId(){ 27 | return _id; 28 | } 29 | 30 | public String getName(){ 31 | return _name; 32 | } 33 | 34 | public static RequestFrom getById(int id) throws BusinessException { 35 | RequestFrom result = null; 36 | 37 | for(RequestFrom requestFrom : RequestFrom.values()){ 38 | if(requestFrom._id == id){ 39 | result = requestFrom; 40 | } 41 | } 42 | if(result == null){ 43 | throw new BusinessException("系统中未包含此请求来源类型"); 44 | }else { 45 | return result; 46 | } 47 | 48 | } 49 | 50 | public boolean isApp(){ 51 | if(_id==IOS._id||_id==ANDROID._id){ 52 | return true; 53 | } 54 | return false; 55 | } 56 | public boolean isIOS(){ 57 | if(_id==IOS._id){ 58 | return true; 59 | } 60 | return false; 61 | } 62 | public boolean isMobile(){ 63 | return _id != PC._id; 64 | } 65 | 66 | public int transToImageSizeType(){ 67 | return this.equals(PC) ? 0 : 1; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/mq/PayRequestQueueListener.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.mq; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.rabbitmq.client.Channel; 5 | import com.hugnew.core.mq.Gson2JsonMessageConverter; 6 | import com.hugnew.sps.dto.PayRequestParam; 7 | import com.hugnew.sps.services.IPayRouteService; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | import org.springframework.amqp.core.Message; 11 | import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | 14 | /** 15 | * MQ监听支付请求入口消息 16 | * Created by Martin on 2016/7/01. 17 | */ 18 | public class PayRequestQueueListener implements ChannelAwareMessageListener { 19 | 20 | private static Logger logger = LoggerFactory.getLogger(PayRequestQueueListener.class); 21 | @Autowired 22 | private IPayRouteService payRouteService; 23 | @Autowired 24 | private Gson2JsonMessageConverter messageConverter; 25 | 26 | @Override 27 | public void onMessage(Message message, Channel channel) throws Exception { 28 | channel.basicQos(100); 29 | PayRequestParam queueObject = (PayRequestParam)messageConverter.fromMessage(message); 30 | channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); 31 | if(payRouteService.getPayRetMap4MQ(queueObject)){ 32 | logger.trace("success processed pay request:{}", JSON.toJSONString(queueObject)); 33 | }else{ 34 | logger.error("error processed pay request:{}",JSON.toJSONString(queueObject)); 35 | //补偿机制忽略 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/realm/StatelessAuthRealm.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.realm; 2 | 3 | import com.hugnew.core.common.exception.BusinessException; 4 | import com.hugnew.sps.dao.MemberMapper; 5 | import com.hugnew.sps.dao.domain.Member; 6 | import com.hugnew.sps.realm.token.HmacSHA256Utils; 7 | import com.hugnew.sps.realm.token.StatelessAuthToken; 8 | import org.apache.shiro.authc.*; 9 | import org.apache.shiro.authz.AuthorizationInfo; 10 | import org.apache.shiro.authz.SimpleAuthorizationInfo; 11 | import org.apache.shiro.realm.AuthorizingRealm; 12 | import org.apache.shiro.subject.PrincipalCollection; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | 17 | /** 18 | * 登录用户的验证和授权 19 | * Created by Martin on 2016/7/01. 20 | */ 21 | public class StatelessAuthRealm extends AuthorizingRealm { 22 | 23 | private static Logger logger = LoggerFactory.getLogger(StatelessAuthRealm.class); 24 | @Autowired 25 | public MemberMapper memberMapper; 26 | 27 | @Override 28 | public boolean supports(AuthenticationToken token) { 29 | //仅支持StatelessToken类型的Token 30 | return token instanceof StatelessAuthToken; 31 | } 32 | 33 | /** 34 | * 授权 35 | * @param principals 36 | * @return 37 | */ 38 | @Override 39 | protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { 40 | String username = (String) principals.getPrimaryPrincipal(); 41 | Member user = memberMapper.findByUsername(username); 42 | if (user != null) { 43 | SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo(); 44 | return authorizationInfo; 45 | } else { 46 | logger.info("授权失败"); 47 | throw new IncorrectCredentialsException(); 48 | } 49 | } 50 | 51 | /** 52 | * 验证 53 | * @param token 54 | * @return 55 | * @throws AuthenticationException 56 | */ 57 | @Override 58 | protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException { 59 | StatelessAuthToken statelessToken = (StatelessAuthToken) token; 60 | String userId = statelessToken.getUserId(); 61 | String username=statelessToken.getUsername(); 62 | String key = null; 63 | try { 64 | key = this.getKey(userId,username); 65 | } catch (Exception e) { 66 | logger.info("获取加密key失败{}",e); 67 | throw new BusinessException("获取加密key失败{}",e); 68 | } 69 | //在服务器端生成客户端参数消息摘要 70 | String serverDigest = HmacSHA256Utils.digest(key, statelessToken.getParams()); 71 | logger.info("服务器端的randomKey:{},time:{},url:{},username:{},digest:{}",statelessToken.getParams().get("randomKey"), 72 | statelessToken.getParams().get("time"),statelessToken.getParams().get("url"), 73 | statelessToken.getParams().get("username"),serverDigest); 74 | //然后进行客户端消息摘要和服务器端消息摘要的匹配 75 | return new SimpleAuthenticationInfo( 76 | username, 77 | serverDigest, 78 | getName()); 79 | } 80 | 81 | /** 82 | * 根据用户名获取密码 83 | * @param username 用户名 84 | * @return 密码 85 | */ 86 | private String getKey(String userId,String username){ 87 | // 访客模式,密码为visit$13password经过MD5加密后的字符串 88 | return "abc"; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/realm/token/HmacSHA256Utils.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.realm.token; 2 | 3 | 4 | import com.hugnew.core.common.exception.BusinessException; 5 | import org.apache.commons.codec.binary.Base64; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import javax.crypto.Mac; 10 | import javax.crypto.SecretKey; 11 | import javax.crypto.spec.SecretKeySpec; 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | /** 16 | * Created by Liujishuai on 2015/5/15. 17 | */ 18 | 19 | /** 20 | * 消息摘要生成器 21 | */ 22 | public class HmacSHA256Utils { 23 | private static Logger logger = LoggerFactory.getLogger(HmacSHA256Utils.class); 24 | private HmacSHA256Utils(){} 25 | public static String digest(String key, String content) { 26 | try { 27 | logger.info("key:{};content:{}",key,content); 28 | Mac mac = Mac.getInstance("HmacSHA256"); 29 | byte[] secretByte = key.getBytes("utf-8"); 30 | byte[] dataBytes = content.getBytes("utf-8"); 31 | 32 | SecretKey secret = new SecretKeySpec(secretByte, "HmacSHA256"); 33 | mac.init(secret); 34 | 35 | byte[] doFinal = mac.doFinal(dataBytes); 36 | // byte[] hexB = new Hex().encode(doFinal); 37 | String oss=Base64.encodeBase64String(mac.doFinal(dataBytes)); 38 | logger.info("加密后的字符串:{}" , oss); 39 | return oss; 40 | 41 | // return new String(hexB, "utf-8"); 42 | } catch (Exception e) { 43 | throw new BusinessException(e); 44 | } 45 | } 46 | 47 | public static String digest(String key, Map map) { 48 | StringBuilder s = new StringBuilder(); 49 | for(Object values : map.values()) { 50 | if(values instanceof String[]) { 51 | for(String value : (String[])values) { 52 | s.append(value); 53 | } 54 | } else if(values instanceof List) { 55 | for(String value : (List)values) { 56 | s.append(value); 57 | } 58 | } else { 59 | s.append(values); 60 | } 61 | } 62 | return digest(key, s.toString()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/realm/token/StatelessAuthToken.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.realm.token; 2 | 3 | import org.apache.shiro.authc.AuthenticationToken; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Created by Liujishuai on 2015/6/3. 9 | */ 10 | public class StatelessAuthToken implements AuthenticationToken { 11 | private String username; 12 | private Map params; 13 | private String clientDigest; 14 | private String userId; 15 | 16 | public String getUserId() { 17 | return userId; 18 | } 19 | 20 | public void setUserId(String userId) { 21 | this.userId = userId; 22 | } 23 | 24 | public Map getParams() { 25 | return params; 26 | } 27 | 28 | public void setParams(Map params) { 29 | this.params = params; 30 | } 31 | 32 | public StatelessAuthToken(String username, Map params, String clientDigest,String userId) 33 | { 34 | 35 | this.username=username; 36 | this.params=params; 37 | this.clientDigest=clientDigest; 38 | this.userId=userId; 39 | } 40 | 41 | public String getUsername() { 42 | return username; 43 | } 44 | 45 | public void setUsername(String username) { 46 | this.username = username; 47 | } 48 | 49 | public String getClientDigest() { 50 | return clientDigest; 51 | } 52 | 53 | public void setClientDigest(String clientDigest) { 54 | this.clientDigest = clientDigest; 55 | } 56 | 57 | @Override 58 | public Object getPrincipal() { 59 | return username; 60 | } 61 | 62 | @Override 63 | public Object getCredentials() { 64 | return clientDigest; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/IAlipayNotifyService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | /** 7 | * 支付宝通知业务接口 8 | * Created by Martin on 2016/7/01. 9 | */ 10 | public interface IAlipayNotifyService { 11 | 12 | /** 13 | * 国内支付宝app通知 14 | * @param request 15 | * @param response 16 | */ 17 | void alipayNotifyMainApp(HttpServletRequest request, HttpServletResponse response); 18 | 19 | /** 20 | * 国内支付宝pc通知 21 | * @param request 22 | * @param response 23 | */ 24 | void alipayNotifyMain(HttpServletRequest request, HttpServletResponse response); 25 | 26 | /** 27 | * 国际支付宝pc通知 28 | * @param request 29 | * @param response 30 | */ 31 | void alipayNotifyGlobal(HttpServletRequest request, HttpServletResponse response); 32 | 33 | /** 34 | * 国际支付宝app通知 35 | * @param request 36 | * @param response 37 | */ 38 | void alipayNotifyGlobalApp(HttpServletRequest request, HttpServletResponse response); 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/ICEBGatewayNotifyService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | import javax.servlet.http.HttpServletResponse; 4 | 5 | /** 6 | * 光大网关通知业务接口 7 | * Created by Martin on 2016/7/01. 8 | */ 9 | public interface ICEBGatewayNotifyService { 10 | 11 | /** 12 | * 光大网关通知 13 | * @param response 14 | * @param plain 15 | * @param signature 16 | */ 17 | void cebGatewayNotify(HttpServletResponse response, String plain, String signature); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/ICEBNotifyService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | import javax.servlet.http.HttpServletResponse; 4 | 5 | /** 6 | * 光大网页通知业务接口 7 | * Created by Martin on 2016/7/01. 8 | */ 9 | public interface ICEBNotifyService { 10 | 11 | /** 12 | * 光大网页通知 13 | * @param response 14 | * @param plain 15 | * @param signature 16 | */ 17 | void cebNotify(HttpServletResponse response, String plain, String signature); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/ICheckSellerService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | /** 4 | * 商家校验业务接口 5 | * Created by Martin on 2016/7/01. 6 | */ 7 | public interface ICheckSellerService { 8 | 9 | /** 10 | * 是否使用国际支付宝 11 | * @param sellerCode 12 | * @return 13 | */ 14 | boolean isUseGlobalPay(String sellerCode); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/IPSBCNotifyService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | /** 4 | * 邮政通知业务接口 5 | * Created by Martin on 2016/7/01. 6 | */ 7 | public interface IPSBCNotifyService { 8 | 9 | /** 10 | * 邮政通知 11 | * @param plain 12 | * @param signature 13 | */ 14 | void psbcNotify(String plain, String signature); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/IPayMapService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | import com.hugnew.core.service.IBaseService; 4 | import com.hugnew.sps.dao.domain.PayMap; 5 | import com.hugnew.sps.enums.PlatformType; 6 | 7 | /** 8 | * 交易流水业务接口 9 | * Created by Martin on 2016/7/01. 10 | */ 11 | public interface IPayMapService extends IBaseService { 12 | 13 | /** 14 | * 支付通知更新交易记录 15 | * @param tempPayCode 16 | * @param msg 17 | * @param msg2 18 | * @param platformType 19 | * @param ssn 20 | * @param remark2 21 | * @return 22 | */ 23 | PayMap updatePayMapByPayCode(String tempPayCode, String msg, String msg2, PlatformType platformType, String ssn, String remark2); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/IPayRouteService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | import com.hugnew.sps.dto.PayRequestParam; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * Created by Martin on 2016/7/01. 9 | */ 10 | public interface IPayRouteService { 11 | 12 | /** 13 | * 组装支付请求报文(http入口) 14 | * @param payRequestParam 15 | * @return 16 | */ 17 | public Map getPayRetMap(PayRequestParam payRequestParam); 18 | 19 | /** 20 | * 组装支付请求报文(MQ入口) 21 | * @param payRequestParam 22 | * @return 23 | */ 24 | public Boolean getPayRetMap4MQ(PayRequestParam payRequestParam); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/ISysConfigService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | import com.hugnew.core.service.IBaseService; 4 | import com.hugnew.sps.dao.domain.SysConfig; 5 | import com.hugnew.sps.dto.DDDetails; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * 字典业务接口 11 | * Created by Martin on 2016/7/01. 12 | */ 13 | public interface ISysConfigService extends IBaseService { 14 | 15 | /** 16 | * 获取字典数据 17 | * @param sysKey 字典表中对应的记录key 18 | * @param id 字典id 19 | * @return dictionary 20 | */ 21 | public List getDictionary(String sysKey, String id); 22 | 23 | /** 24 | * 增加字典数据 25 | * @param sysKey 字典表中对应的记录key 26 | * @param ddDetails 字典数据内容 27 | * @param accountId the account id 28 | */ 29 | public void txaddDictionary(String sysKey, DDDetails ddDetails, Long accountId); 30 | 31 | /** 32 | * 更新字典数据 33 | * @param sysKey 字典表中对应的记录key 34 | * @param ddDetails 字典数据 35 | * @param accountId the account id 36 | */ 37 | public void txupdateDictionary(String sysKey, DDDetails ddDetails, Long accountId); 38 | 39 | /** 40 | * 删除字典数据 41 | * @param sysKey 字典表中对应的记录key 42 | * @param id 字典数据id 43 | * @param accountId the account id 44 | */ 45 | public void deleteDictionary(String sysKey, String id, Long accountId); 46 | 47 | /** 48 | * 获取需要缓存的字典列表 49 | * @return 50 | */ 51 | public List getSysConfigList(); 52 | 53 | /** 54 | * 更新系统配置 55 | * @param key 主键 56 | * @param value 值 57 | * @return 更新结果 58 | */ 59 | public Integer updateSysConfig(String key, String value); 60 | 61 | /** 62 | * 刷新字典缓存 63 | */ 64 | public void flushDictCache(); 65 | /** 66 | * 根据key获取系統參數值 67 | */ 68 | public String getValueByKey(String key); 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/IUnionPayNotifyService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | /** 7 | * 银联通知业务接口 8 | * Created by Martin on 2016/7/01. 9 | */ 10 | public interface IUnionPayNotifyService { 11 | 12 | /** 13 | * acp通知 14 | * @param request 15 | */ 16 | void unionPayNotifyApp(HttpServletRequest request); 17 | 18 | /** 19 | * upop通知 20 | * @param request 21 | * @param response 22 | */ 23 | void unionPayNotifyWeb(HttpServletRequest request, HttpServletResponse response); 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/IWechatNotifyService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | /** 7 | * 微信通知业务接口 8 | * Created by Martin on 2016/7/01. 9 | */ 10 | public interface IWechatNotifyService { 11 | 12 | /** 13 | * 微信通知 14 | * @param request 15 | * @param response 16 | */ 17 | void wechatNotify(HttpServletRequest request, HttpServletResponse response); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/impls/CheckSellerService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.impls; 2 | 3 | import com.hugnew.sps.services.ICacheService; 4 | import com.hugnew.sps.services.ICheckSellerService; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | /** 12 | * 商家校验业务 13 | * Created by Martin on 2016/7/01. 14 | */ 15 | @Service 16 | public class CheckSellerService implements ICheckSellerService { 17 | @Autowired 18 | private ICacheService cacheService; 19 | 20 | @Override 21 | public boolean isUseGlobalPay(String sellerCode) { 22 | String value = cacheService.getDictEntryByKey("seller:classification", "国际支付宝支付商家"); 23 | return getDictionaryList(value, sellerCode); 24 | } 25 | 26 | private Boolean getDictionaryList(String value, String sellerCode) { 27 | Boolean result = false; 28 | if (value == null || value.isEmpty()) { 29 | return result; 30 | } 31 | List stringList = Arrays.asList(value.split("[,,]")); 32 | if (stringList == null || stringList.isEmpty()) { 33 | return result; 34 | } 35 | if (stringList.contains(sellerCode)) { 36 | result = true; 37 | } 38 | return result; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/impls/PSBCNotifyService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.impls; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.psbc.payment.client.SignatureService; 5 | import com.hugnew.sps.dao.domain.PayMap; 6 | import com.hugnew.sps.enums.PayPlatform; 7 | import com.hugnew.sps.enums.PlatformType; 8 | import com.hugnew.sps.services.IPSBCNotifyService; 9 | import com.hugnew.sps.services.IPayMapService; 10 | import org.apache.commons.lang.StringUtils; 11 | import org.slf4j.Logger; 12 | import org.slf4j.LoggerFactory; 13 | import org.springframework.amqp.rabbit.core.RabbitTemplate; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | 17 | import javax.annotation.Resource; 18 | import java.util.HashMap; 19 | import java.util.Map; 20 | import java.util.regex.Matcher; 21 | import java.util.regex.Pattern; 22 | 23 | /** 24 | * 邮政通知业务 25 | * Created by Martin on 2016/7/01. 26 | */ 27 | @Service 28 | public class PSBCNotifyService implements IPSBCNotifyService { 29 | 30 | private static Logger logger = LoggerFactory.getLogger(PSBCNotifyService.class); 31 | @Autowired 32 | private IPayMapService payMapService; 33 | @Resource 34 | private RabbitTemplate amqpTemplate; 35 | 36 | @Override 37 | public void psbcNotify(String plain, String signature) { 38 | if (StringUtils.isNotBlank(plain) && StringUtils.isNotBlank(signature)) { 39 | Boolean isValid = SignatureService.verify(plain, signature); 40 | if (isValid) { 41 | Map temp = genMapPSBC(plain); 42 | if (!temp.isEmpty()) { 43 | String code = temp.get("RespCode"); 44 | if ("00000000".equals(code)) { //00000000表示交易成功 45 | PayMap payMap = payMapService.updatePayMapByPayCode(temp.get("TermSsn"), plain, signature, PlatformType.PSBC, temp.get("TermSsn"), PayPlatform.PSBC.getCode()); 46 | amqpTemplate.convertAndSend("payNotify." + payMap.getRequestBiz() + payMap.getOrderCode(), JSON.toJSONString(payMap)); 47 | } 48 | } 49 | } else { 50 | logger.warn("邮局支付出现验证签名不通过信息!返回明文如下:【{}】,签名如下:【{}】", new Object[]{plain, signature}); 51 | } 52 | } 53 | } 54 | 55 | private Map genMapPSBC(String plain) { 56 | Pattern pattern = Pattern.compile("([\\w]+)=([\\w]*)"); 57 | Map toRet = new HashMap<>(); 58 | if (StringUtils.isNotBlank(plain)) { 59 | String[] temp = plain.split("\\|"); 60 | if (temp.length > 0) { 61 | for (int i = 0; i < temp.length; i++) { 62 | if (StringUtils.isNotBlank(temp[i])) { 63 | Matcher matcher = pattern.matcher(temp[i]); 64 | while (matcher.find()) { 65 | toRet.put(matcher.group(1), matcher.group(2)); 66 | 67 | } 68 | } 69 | 70 | } 71 | } 72 | } 73 | return toRet; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/impls/PayMapService.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.impls; 2 | 3 | import com.hugnew.core.common.exception.BusinessException; 4 | import com.hugnew.core.dao.IBaseMapper; 5 | import com.hugnew.core.service.impl.BaseService; 6 | import com.hugnew.core.util.DateUtils; 7 | import com.hugnew.sps.dao.PayMapMapper; 8 | import com.hugnew.sps.dao.domain.PayMap; 9 | import com.hugnew.sps.enums.PlatformType; 10 | import com.hugnew.sps.services.IPayMapService; 11 | import org.apache.commons.lang.StringUtils; 12 | import org.slf4j.Logger; 13 | import org.slf4j.LoggerFactory; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.stereotype.Service; 16 | import org.springframework.util.Assert; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * 交易流水业务 22 | * Created by Martin on 2016/7/01. 23 | */ 24 | @Service 25 | public class PayMapService extends BaseService implements IPayMapService { 26 | 27 | private static Logger logger = LoggerFactory.getLogger(PayMapService.class); 28 | @Autowired 29 | private PayMapMapper payMapMapper; 30 | 31 | @Override 32 | public IBaseMapper getBaseMapper() { 33 | return payMapMapper; 34 | } 35 | 36 | @Override 37 | public PayMap updatePayMapByPayCode(String tempPayCode, String msg, String msg2, PlatformType platformType, String ssn, String remark2) { 38 | PayMap param = new PayMap(); 39 | param.setTempPayCode(tempPayCode); 40 | param.setPlatform(platformType.value()); 41 | List payMaps = payMapMapper.select(param); 42 | Assert.notNull(payMaps); 43 | if (payMaps != null && !payMaps.isEmpty()) { 44 | PayMap payMap = payMaps.get(0); 45 | payMap.setRetMsg(msg); 46 | payMap.setRetMsg2(msg2); 47 | payMap.setSwiftNumber(ssn); 48 | payMap.setIsPaid("1"); 49 | payMap.setNotifyTime(DateUtils.getUnixTimestamp()); 50 | if (StringUtils.isNotBlank(remark2)) { 51 | payMap.setRemark2(remark2); 52 | } 53 | payMapMapper.updateByPrimaryKeySelective(payMap); 54 | return payMap; 55 | } else { 56 | throw new BusinessException("数据库异常,交易记录查询为Null"); 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/strategy/PSBCWapStragegy.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.strategy; 2 | 3 | import com.psbc.payment.client.SignatureService; 4 | import com.hugnew.core.util.PropertiesUtil; 5 | import com.hugnew.sps.enums.PayType; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.io.UnsupportedEncodingException; 10 | import java.math.BigDecimal; 11 | import java.net.URLEncoder; 12 | import java.text.DateFormat; 13 | import java.text.SimpleDateFormat; 14 | import java.util.Date; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | /** 19 | * 邮政wap支付 20 | * Created by Martin on 2016/7/01. 21 | */ 22 | public class PSBCWapStragegy implements PayStrategy { 23 | 24 | private static Logger logger = LoggerFactory.getLogger(PSBCWapStragegy.class); 25 | 26 | @Override 27 | public String generatePayParams(PayType payType, Map params) { 28 | DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); 29 | Map plainMap = new HashMap<>(); 30 | //IPER个人客户支付 WPER手机支付 IPSR退货交易 IQSR单笔交易查询 BQSR多笔交易查询 IDFR对帐文件下载 31 | plainMap.put("TranAbbr", PropertiesUtil.getValue("pay.request.psbc.wap.TranAbbr")); 32 | plainMap.put("MercDtTm", format.format(new Date())); 33 | //最长为20位,保证唯一,不能重复 34 | plainMap.put("TermSsn", (String) params.get("payCode")); 35 | plainMap.put("OSttDate", "");//可以为空但是不可以不传;原交易商户日期,支付交易不用赋值 36 | plainMap.put("OAcqSsn", ""); 37 | plainMap.put("MercCode", PropertiesUtil.getValue("pay.request.psbc.MercCode")); 38 | plainMap.put("TermCode", ""); 39 | plainMap.put("TranAmt", String.valueOf(((BigDecimal) params.get("toPay")).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())); 40 | try { 41 | plainMap.put("MercUrl", URLEncoder.encode(PropertiesUtil.getValue("pay.notify.psbc.url"), "utf-8")); 42 | } catch (UnsupportedEncodingException e) { 43 | logger.error("MercUrl encode error:{}", PropertiesUtil.getValue("pay.notify.psbc.url")); 44 | } 45 | plainMap.put("Remark1", ""); 46 | plainMap.put("Remark2", ""); 47 | String plain = concatMap(plainMap); 48 | String sign = SignatureService.sign(plain); 49 | Map toRet = new HashMap<>(); 50 | toRet.put("transName", PropertiesUtil.getValue("pay.request.psbc.wap.transName")); 51 | toRet.put("Plain", plain); 52 | toRet.put("Signature", sign); 53 | toRet.put("url", PropertiesUtil.getValue("pay.request.psbc.url")); 54 | if(logger.isDebugEnabled()){ 55 | logger.debug("psbc参数信息:{}", toRet.toString()); 56 | } 57 | return buildRequestParams(toRet); 58 | } 59 | 60 | private String concatMap(Map plainMap) { 61 | StringBuffer toRetBuff = new StringBuffer(); 62 | for (Map.Entry entry : plainMap.entrySet()) { 63 | toRetBuff.append(entry.getKey()).append("=").append(entry.getValue()).append("|"); 64 | } 65 | return toRetBuff.substring(0, toRetBuff.length() - 1); 66 | } 67 | 68 | private String buildRequestParams(Map sParaTemp) { 69 | StringBuffer toRet = new StringBuffer(); 70 | for (Map.Entry entry : sParaTemp.entrySet()) { 71 | toRet.append(entry.getKey()).append("=").append("\"").append(entry.getValue()).append("\"").append("&"); 72 | } 73 | return toRet.substring(0, toRet.length() - 1); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/strategy/PSBCWebStragegy.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.strategy; 2 | 3 | import com.psbc.payment.client.SignatureService; 4 | import com.hugnew.core.util.PropertiesUtil; 5 | import com.hugnew.sps.enums.PayType; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.io.UnsupportedEncodingException; 10 | import java.math.BigDecimal; 11 | import java.net.URLEncoder; 12 | import java.text.DateFormat; 13 | import java.text.SimpleDateFormat; 14 | import java.util.Date; 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | /** 19 | * 邮政web支付 20 | * Created by Martin on 2016/7/01. 21 | */ 22 | public class PSBCWebStragegy implements PayStrategy { 23 | 24 | private static Logger logger = LoggerFactory.getLogger(PSBCWebStragegy.class); 25 | 26 | @Override 27 | public String generatePayParams(PayType payType, Map params) { 28 | DateFormat format = new SimpleDateFormat("yyyyMMddHHmmss"); 29 | Map plainMap = new HashMap<>(); 30 | //IPER个人客户支付 WPER手机支付 IPSR退货交易 IQSR单笔交易查询 BQSR多笔交易查询 IDFR对帐文件下载 31 | plainMap.put("TranAbbr", PropertiesUtil.getValue("pay.request.psbc.web.TranAbbr")); 32 | plainMap.put("MercDtTm", format.format(new Date())); 33 | //最长为20位,保证唯一,不能重复 34 | plainMap.put("TermSsn", (String) params.get("payCode")); 35 | plainMap.put("OSttDate", "");//可以为空但是不可以不传;原交易商户日期,支付交易不用赋值 36 | plainMap.put("OAcqSsn", ""); 37 | plainMap.put("MercCode", PropertiesUtil.getValue("pay.request.psbc.MercCode")); 38 | plainMap.put("TermCode", ""); 39 | plainMap.put("TranAmt", String.valueOf(((BigDecimal) params.get("toPay")).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue())); 40 | try { 41 | plainMap.put("MercUrl", URLEncoder.encode(PropertiesUtil.getValue("pay.notify.psbc.url"), "utf-8")); 42 | } catch (UnsupportedEncodingException e) { 43 | logger.error("MercUrl encode error:{}", PropertiesUtil.getValue("pay.notify.psbc.url")); 44 | } 45 | plainMap.put("Remark1", ""); 46 | plainMap.put("Remark2", ""); 47 | String plain = concatMap(plainMap); 48 | String sign = SignatureService.sign(plain); 49 | Map toRet = new HashMap<>(); 50 | toRet.put("transName", PropertiesUtil.getValue("pay.request.psbc.web.transName")); 51 | toRet.put("Plain", plain); 52 | toRet.put("Signature", sign); 53 | toRet.put("url", PropertiesUtil.getValue("pay.request.psbc.url")); 54 | if(logger.isDebugEnabled()){ 55 | logger.debug("psbc参数信息:{}", toRet.toString()); 56 | } 57 | return buildRequestParams(toRet); 58 | } 59 | 60 | private String concatMap(Map plainMap) { 61 | StringBuffer toRetBuff = new StringBuffer(); 62 | for (Map.Entry entry : plainMap.entrySet()) { 63 | toRetBuff.append(entry.getKey()).append("=").append(entry.getValue()).append("|"); 64 | } 65 | return toRetBuff.substring(0, toRetBuff.length() - 1); 66 | } 67 | 68 | private String buildRequestParams(Map sParaTemp) { 69 | StringBuffer toRet = new StringBuffer(); 70 | for (Map.Entry entry : sParaTemp.entrySet()) { 71 | toRet.append(entry.getKey()).append("=").append("\"").append(entry.getValue()).append("\"").append("&"); 72 | } 73 | return toRet.substring(0, toRet.length() - 1); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/strategy/PayStrategy.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.strategy; 2 | 3 | import com.hugnew.sps.enums.PayType; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * 支付策略路由 9 | * Created by Martin on 2016/7/01. 10 | */ 11 | public interface PayStrategy { 12 | 13 | /** 14 | * 调用对应支付平台组装支付请求报文 15 | * @param payType 传入需要的支付方式 16 | * @param params 其他额外需要的参数 17 | * @return 生成的支付请求 18 | */ 19 | String generatePayParams(PayType payType, Map params); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/strategy/StrategyContext.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.strategy; 2 | 3 | import com.hugnew.sps.enums.PayType; 4 | 5 | import java.util.Map; 6 | 7 | /** 8 | * 支付策略上下文 9 | * Created by Martin on 2016/7/01. 10 | */ 11 | public class StrategyContext { 12 | 13 | private PayStrategy payStrategy; 14 | 15 | /** 16 | * 调用对应支付平台组装支付请求报文 17 | * @param payType 18 | * @param params 19 | * @return 20 | */ 21 | public String generatePayParams(PayType payType, Map params) { 22 | payStrategy = StrategyFactory.getInstance().creator(payType.value()); 23 | return payStrategy.generatePayParams(payType, params); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/strategy/StrategyFactory.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.strategy; 2 | 3 | import com.hugnew.sps.enums.PayType; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | /** 9 | * 支付策略工厂 10 | * Created by Martin on 2016/7/01. 11 | */ 12 | public class StrategyFactory { 13 | 14 | private static Map strategyMap = new HashMap<>(); 15 | 16 | static { 17 | strategyMap.put(PayType.ALIPAY_WEB.value(), new AlipayWebStrategy()); 18 | strategyMap.put(PayType.ALIPAY_APP.value(), new AlipayAppStrategy()); 19 | strategyMap.put(PayType.ALIPAY_WAP.value(), new AlipayWapStrategy()); 20 | strategyMap.put(PayType.UNION_WEB.value(), new UnionWebStrategy()); 21 | strategyMap.put(PayType.UNION_WAP.value(), new UnionWapStrategy()); 22 | strategyMap.put(PayType.UNION_APP.value(), new UnionAppStrategy()); 23 | strategyMap.put(PayType.PSBC_WEB.value(), new PSBCWebStragegy()); 24 | strategyMap.put(PayType.PSBC_WAP.value(), new PSBCWapStragegy()); 25 | strategyMap.put(PayType.CEB_WEB.value(), new CEBWebStragegy()); 26 | strategyMap.put(PayType.CEB_WAP.value(), new CEBWapStragegy()); 27 | strategyMap.put(PayType.CEB_GATEWAY_WEB.value(), new CEBGatewayPayStrategy()); 28 | strategyMap.put(PayType.CEB_GATEWAY_WAP.value(), new CEBGatewayPayWapStrategy()); 29 | strategyMap.put(PayType.WECHAT_APP.value(), new WechatPayAppStrategy()); 30 | } 31 | 32 | private StrategyFactory() { 33 | } 34 | 35 | private static class InstanceHolder { 36 | public static StrategyFactory instance = new StrategyFactory(); 37 | } 38 | 39 | public static StrategyFactory getInstance() { 40 | return InstanceHolder.instance; 41 | } 42 | 43 | public PayStrategy creator(Integer type) { 44 | return strategyMap.get(type); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/strategy/UnionAppStrategy.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.strategy; 2 | 3 | import com.hugnew.core.util.PropertiesUtil; 4 | import com.hugnew.sps.services.pay.util.web.unionpay.util.DemoBase; 5 | import com.hugnew.sps.enums.PayType; 6 | import com.unionpay.acp.sdk.SDKConfig; 7 | import org.apache.commons.lang3.StringUtils; 8 | import org.slf4j.Logger; 9 | import org.slf4j.LoggerFactory; 10 | 11 | import java.math.BigDecimal; 12 | import java.text.SimpleDateFormat; 13 | import java.util.Date; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | 17 | /** 18 | * 银联app支付(对接acp) 19 | * Created by Martin on 2016/7/01. 20 | */ 21 | public class UnionAppStrategy extends DemoBase implements PayStrategy { 22 | 23 | private static Logger logger = LoggerFactory.getLogger(UnionAppStrategy.class); 24 | 25 | @Override 26 | public String generatePayParams(PayType payType, Map params) { 27 | String retUrl = null; 28 | if (params.size() > 0 && null != params.get("retUrl")) { 29 | retUrl = (String) params.get("retUrl"); 30 | } 31 | //组装请求报文 32 | Map data = new HashMap(); 33 | // 版本号 34 | data.put("version", PropertiesUtil.getValue("pay.request.unionpayApp.version")); 35 | // 字符集编码 默认"UTF-8" 36 | data.put("encoding", PropertiesUtil.getValue("pay.request.unionpayApp.encoding")); 37 | // 签名方法 01 RSA 38 | data.put("signMethod", PropertiesUtil.getValue("pay.request.unionpayApp.signMethod")); 39 | // 交易类型 01-消费 40 | data.put("txnType", PropertiesUtil.getValue("pay.request.unionpayApp.txnType")); 41 | // 交易子类型 01:自助消费 02:订购 03:分期付款 42 | data.put("txnSubType", PropertiesUtil.getValue("pay.request.unionpayApp.txnSubType")); 43 | // 业务类型 44 | data.put("bizType", PropertiesUtil.getValue("pay.request.unionpayApp.bizType")); 45 | // 渠道类型,07-PC,08-手机 46 | data.put("channelType", PropertiesUtil.getValue("pay.request.unionpayApp.channelType")); 47 | // 前台通知地址 ,控件接入方式无作用 48 | data.put("frontUrl", null != retUrl ? retUrl : PropertiesUtil.getValue("pay.request.retUrl")); 49 | // 后台通知地址 50 | data.put("backUrl", PropertiesUtil.getValue("pay.notify.unionpay.url")); 51 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 52 | data.put("accessType", PropertiesUtil.getValue("pay.request.unionpayApp.accessType")); 53 | // 商户号码,请改成自己的商户号 54 | data.put("merId", PropertiesUtil.getValue("pay.request.unionpayApp.merId")); 55 | // 商户订单号,8-40位数字字母 56 | data.put("orderId", (String) params.get("payCode")); 57 | // 订单发送时间,取系统时间 58 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 59 | data.put("txnAmt", String.valueOf(((BigDecimal) params.get("toPay")).multiply(BigDecimal.valueOf(100)).longValue())); 60 | // 交易币种 61 | data.put("currencyCode", PropertiesUtil.getValue("pay.request.unionpayApp.currencyCode")); 62 | Map submitFromData = signData(data); 63 | String requestAppUrl = SDKConfig.getConfig().getAppRequestUrl(); 64 | Map resmap = submitUrl(submitFromData, requestAppUrl); 65 | if(logger.isDebugEnabled()){ 66 | logger.debug("union resmap:{}", resmap.toString()); 67 | } 68 | if (StringUtils.isNotBlank(resmap.get("respCode")) && "00".equals(resmap.get("respCode"))) { 69 | return resmap.get("tn"); 70 | } else { 71 | return null; 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/strategy/UnionWapStrategy.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.strategy; 2 | 3 | import com.hugnew.core.util.PropertiesUtil; 4 | import com.hugnew.sps.services.pay.util.web.unionpay.util.DemoBase; 5 | import com.hugnew.sps.enums.PayType; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | 9 | import java.math.BigDecimal; 10 | import java.text.SimpleDateFormat; 11 | import java.util.Date; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | /** 16 | * 银联wap支付(对接acp) 17 | * Created by Martin on 2016/7/01. 18 | */ 19 | public class UnionWapStrategy extends DemoBase implements PayStrategy { 20 | 21 | private static Logger logger = LoggerFactory.getLogger(UnionWapStrategy.class); 22 | 23 | @Override 24 | public String generatePayParams(PayType payType, Map params) { 25 | String retUrl = null; 26 | if (params.size() > 0 && null != params.get("retUrl")) { 27 | retUrl = (String) params.get("retUrl"); 28 | } 29 | //组装请求报文 30 | Map data = new HashMap(); 31 | // 版本号 32 | data.put("version", PropertiesUtil.getValue("pay.request.unionpayApp.version")); 33 | // 字符集编码 默认"UTF-8" 34 | data.put("encoding", PropertiesUtil.getValue("pay.request.unionpayApp.encoding")); 35 | // 签名方法 01 RSA 36 | data.put("signMethod", PropertiesUtil.getValue("pay.request.unionpayApp.signMethod")); 37 | // 交易类型 01-消费 38 | data.put("txnType", PropertiesUtil.getValue("pay.request.unionpayApp.txnType")); 39 | // 交易子类型 01:自助消费 02:订购 03:分期付款 40 | data.put("txnSubType", PropertiesUtil.getValue("pay.request.unionpayApp.txnSubType")); 41 | // 业务类型 42 | data.put("bizType", PropertiesUtil.getValue("pay.request.unionpayApp.bizType")); 43 | // 渠道类型,07-PC,08-手机 44 | data.put("channelType", PropertiesUtil.getValue("pay.request.unionpayApp.channelType")); 45 | // 前台通知地址 ,控件接入方式无作用 46 | data.put("frontUrl", null != retUrl ? retUrl : PropertiesUtil.getValue("pay.request.retUrl")); 47 | // 后台通知地址 48 | data.put("backUrl", PropertiesUtil.getValue("pay.notify.unionpay.url")); 49 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 50 | data.put("accessType", PropertiesUtil.getValue("pay.request.unionpayApp.accessType")); 51 | // 商户号码,请改成自己的商户号 52 | data.put("merId", PropertiesUtil.getValue("pay.request.unionpayApp.merId")); 53 | // 商户订单号,8-40位数字字母 54 | data.put("orderId", (String) params.get("payCode")); 55 | // 订单发送时间,取系统时间 56 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 57 | data.put("txnAmt", String.valueOf(((BigDecimal)params.get("toPay")).multiply(BigDecimal.valueOf(100)).longValue())); 58 | // 交易币种 59 | data.put("currencyCode", PropertiesUtil.getValue("pay.request.unionpayApp.currencyCode")); 60 | Map submitFromData = signData(data); 61 | //待请求参数数组 62 | StringBuffer toRet = new StringBuffer(); 63 | for (Map.Entry entry : submitFromData.entrySet()) { 64 | toRet.append(entry.getKey()).append("=").append("\"").append(entry.getValue()).append("\"").append("&"); 65 | } 66 | if(logger.isDebugEnabled()){ 67 | logger.debug("union参数信息:{}", toRet.toString()); 68 | } 69 | return toRet.substring(0, toRet.length() - 1); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/strategy/UnionWebStrategy.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.strategy; 2 | 3 | import com.hugnew.core.util.PropertiesUtil; 4 | import com.hugnew.sps.services.pay.util.web.unionpay.upop.sdk.QuickPayConf; 5 | import com.hugnew.sps.services.pay.util.web.unionpay.upop.sdk.QuickPayUtils; 6 | import com.hugnew.sps.services.pay.util.web.unionpay.util.DemoBase; 7 | import com.hugnew.sps.enums.PayType; 8 | import org.apache.commons.lang.StringUtils; 9 | import org.slf4j.Logger; 10 | import org.slf4j.LoggerFactory; 11 | 12 | import java.math.BigDecimal; 13 | import java.text.SimpleDateFormat; 14 | import java.util.Date; 15 | import java.util.Map; 16 | 17 | /** 18 | * 银联web支付(对接upop,仅用于示范,upop属于老平台,acp是新平台) 19 | * Created by Martin on 2016/7/01. 20 | */ 21 | public class UnionWebStrategy extends DemoBase implements PayStrategy { 22 | 23 | private static Logger logger = LoggerFactory.getLogger(UnionWebStrategy.class); 24 | 25 | @Override 26 | public String generatePayParams(PayType payType, Map params) { 27 | String retUrl = null; 28 | if (params.size() > 0 && null != params.get("retUrl")) { 29 | retUrl = (String) params.get("retUrl"); 30 | } 31 | //商户需要组装如下对象的数据 32 | String[] valueVo = new String[]{ 33 | QuickPayConf.version,//协议版本 34 | QuickPayConf.charset,//字符编码 35 | QuickPayConf.transType,//交易类型 36 | "",//原始交易流水号 37 | QuickPayConf.merCode,//商户代码 38 | QuickPayConf.merName,//商户简称 39 | "",//收单机构代码(仅收单机构接入需要填写) 40 | "",//商户类别(收单机构接入需要填写) 41 | "",//商品URL 42 | QuickPayConf.commodityName,//商品名称 43 | "",//商品单价 单位:分 44 | "",//商品数量 45 | QuickPayConf.commodityDiscount,//折扣 单位:分 46 | "",//运费 单位:分 47 | (String) params.get("payCode"),//订单号(需要商户自己生成) 48 | String.valueOf(((BigDecimal)params.get("toPay")).multiply(BigDecimal.valueOf(100)).longValue()),//交易金额 单位:分 49 | QuickPayConf.orderCurrency,//交易币种 50 | new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()),//交易时间 51 | QuickPayConf.customerIp,//用户IP 52 | "",//用户真实姓名 53 | "",//默认支付方式 54 | "",//默认银行编号 55 | "",//交易超时时间 56 | StringUtils.isNotBlank(retUrl) ? retUrl : PropertiesUtil.getValue("pay.request.retUrl"),// 前台回调商户URL 57 | PropertiesUtil.getValue("pay.notify.unionpayWeb.url"),// 后台回调商户URL 58 | ""//商户保留域 59 | }; 60 | String signType = QuickPayConf.signType; 61 | String rethtml = new QuickPayUtils().createPayHtml(valueVo, signType);//跳转到银联页面支付 62 | if(logger.isDebugEnabled()){ 63 | logger.debug("union参数信息:{}", rethtml); 64 | } 65 | return rethtml; 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/ali/global/util/UtilDate.java: -------------------------------------------------------------------------------- 1 | 2 | package com.hugnew.sps.services.pay.util.app.ali.global.util; 3 | 4 | import java.util.Date; 5 | import java.util.Random; 6 | import java.text.SimpleDateFormat; 7 | import java.text.DateFormat; 8 | 9 | /* * 10 | *类名:UtilDate 11 | *功能:自定义订单类 12 | *详细:工具类,可以用作获取系统日期、订单编号等 13 | *版本:3.3 14 | *日期:2012-08-17 15 | *说明: 16 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 17 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 18 | */ 19 | public class UtilDate { 20 | 21 | /** 22 | * 年月日时分秒(无下划线) yyyyMMddHHmmss 23 | */ 24 | public static final String dtLong = "yyyyMMddHHmmss"; 25 | 26 | /** 27 | * 完整时间 yyyy-MM-dd HH:mm:ss 28 | */ 29 | public static final String simple = "yyyy-MM-dd HH:mm:ss"; 30 | 31 | /** 32 | * 年月日(无下划线) yyyyMMdd 33 | */ 34 | public static final String dtShort = "yyyyMMdd"; 35 | 36 | 37 | /** 38 | * 返回系统当前时间(精确到毫秒),作为一个唯一的订单编号 39 | * 40 | * @return 以yyyyMMddHHmmss为格式的当前系统时间 41 | */ 42 | public static String getOrderNum() { 43 | Date date = new Date(); 44 | DateFormat df = new SimpleDateFormat(dtLong); 45 | return df.format(date); 46 | } 47 | 48 | /** 49 | * 获取系统当前日期(精确到毫秒),格式:yyyy-MM-dd HH:mm:ss 50 | * 51 | * @return 52 | */ 53 | public static String getDateFormatter() { 54 | Date date = new Date(); 55 | DateFormat df = new SimpleDateFormat(simple); 56 | return df.format(date); 57 | } 58 | 59 | /** 60 | * 获取系统当期年月日(精确到天),格式:yyyyMMdd 61 | * 62 | * @return 63 | */ 64 | public static String getDate() { 65 | Date date = new Date(); 66 | DateFormat df = new SimpleDateFormat(dtShort); 67 | return df.format(date); 68 | } 69 | 70 | /** 71 | * 产生随机的三位数 72 | * 73 | * @return 74 | */ 75 | public static String getThree() { 76 | Random rad = new Random(); 77 | return rad.nextInt(1000) + ""; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/ali/global/util/httpClient/HttpRequest.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.app.ali.global.util.httpClient; 2 | 3 | import org.apache.commons.httpclient.NameValuePair; 4 | 5 | /* * 6 | *类名:HttpRequest 7 | *功能:Http请求对象的封装 8 | *详细:封装Http请求 9 | *版本:3.3 10 | *日期:2011-08-17 11 | *说明: 12 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 13 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 14 | */ 15 | 16 | public class HttpRequest { 17 | 18 | /** 19 | * HTTP GET method 20 | */ 21 | public static final String METHOD_GET = "GET"; 22 | 23 | /** 24 | * HTTP POST method 25 | */ 26 | public static final String METHOD_POST = "POST"; 27 | 28 | /** 29 | * 待请求的url 30 | */ 31 | private String url = null; 32 | 33 | /** 34 | * 默认的请求方式 35 | */ 36 | private String method = METHOD_POST; 37 | 38 | private int timeout = 0; 39 | 40 | private int connectionTimeout = 0; 41 | 42 | /** 43 | * Post方式请求时组装好的参数值对 44 | */ 45 | private NameValuePair[] parameters = null; 46 | 47 | /** 48 | * Get方式请求时对应的参数 49 | */ 50 | private String queryString = null; 51 | 52 | /** 53 | * 默认的请求编码方式 54 | */ 55 | private String charset = "GBK"; 56 | 57 | /** 58 | * 请求发起方的ip地址 59 | */ 60 | private String clientIp; 61 | 62 | /** 63 | * 请求返回的方式 64 | */ 65 | private HttpResultType resultType = HttpResultType.BYTES; 66 | 67 | public HttpRequest(HttpResultType resultType) { 68 | super(); 69 | this.resultType = resultType; 70 | } 71 | 72 | /** 73 | * @return Returns the clientIp. 74 | */ 75 | public String getClientIp() { 76 | return clientIp; 77 | } 78 | 79 | /** 80 | * @param clientIp The clientIp to set. 81 | */ 82 | public void setClientIp(String clientIp) { 83 | this.clientIp = clientIp; 84 | } 85 | 86 | public NameValuePair[] getParameters() { 87 | return parameters; 88 | } 89 | 90 | public void setParameters(NameValuePair[] parameters) { 91 | this.parameters = parameters; 92 | } 93 | 94 | public String getQueryString() { 95 | return queryString; 96 | } 97 | 98 | public void setQueryString(String queryString) { 99 | this.queryString = queryString; 100 | } 101 | 102 | public String getUrl() { 103 | return url; 104 | } 105 | 106 | public void setUrl(String url) { 107 | this.url = url; 108 | } 109 | 110 | public String getMethod() { 111 | return method; 112 | } 113 | 114 | public void setMethod(String method) { 115 | this.method = method; 116 | } 117 | 118 | public int getConnectionTimeout() { 119 | return connectionTimeout; 120 | } 121 | 122 | public void setConnectionTimeout(int connectionTimeout) { 123 | this.connectionTimeout = connectionTimeout; 124 | } 125 | 126 | public int getTimeout() { 127 | return timeout; 128 | } 129 | 130 | public void setTimeout(int timeout) { 131 | this.timeout = timeout; 132 | } 133 | 134 | /** 135 | * @return Returns the charset. 136 | */ 137 | public String getCharset() { 138 | return charset; 139 | } 140 | 141 | /** 142 | * @param charset The charset to set. 143 | */ 144 | public void setCharset(String charset) { 145 | this.charset = charset; 146 | } 147 | 148 | public HttpResultType getResultType() { 149 | return resultType; 150 | } 151 | 152 | public void setResultType(HttpResultType resultType) { 153 | this.resultType = resultType; 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/ali/global/util/httpClient/HttpResponse.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.app.ali.global.util.httpClient; 2 | 3 | 4 | import com.hugnew.core.util.PropertiesUtil; 5 | import org.apache.commons.httpclient.Header; 6 | 7 | import java.io.UnsupportedEncodingException; 8 | 9 | /* * 10 | *类名:HttpResponse 11 | *功能:Http返回对象的封装 12 | *详细:封装Http返回信息 13 | *版本:3.3 14 | *日期:2011-08-17 15 | *说明: 16 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 17 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 18 | */ 19 | 20 | public class HttpResponse { 21 | 22 | /** 23 | * 返回中的Header信息 24 | */ 25 | private Header[] responseHeaders; 26 | 27 | /** 28 | * String类型的result 29 | */ 30 | private String stringResult; 31 | 32 | /** 33 | * btye类型的result 34 | */ 35 | private byte[] byteResult; 36 | 37 | public Header[] getResponseHeaders() { 38 | return responseHeaders; 39 | } 40 | 41 | public void setResponseHeaders(Header[] responseHeaders) { 42 | this.responseHeaders = responseHeaders; 43 | } 44 | 45 | public byte[] getByteResult() { 46 | if (byteResult != null) { 47 | return byteResult; 48 | } 49 | if (stringResult != null) { 50 | return stringResult.getBytes(); 51 | } 52 | return null; 53 | } 54 | 55 | public void setByteResult(byte[] byteResult) { 56 | this.byteResult = byteResult; 57 | } 58 | 59 | public String getStringResult() throws UnsupportedEncodingException { 60 | if (stringResult != null) { 61 | return stringResult; 62 | } 63 | if (byteResult != null) { 64 | return new String(byteResult, PropertiesUtil.getValue("pay.request.alipayAppGlobal.input_charset")); 65 | } 66 | return null; 67 | } 68 | 69 | public void setStringResult(String stringResult) { 70 | this.stringResult = stringResult; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/ali/global/util/httpClient/HttpResultType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Alipay.com Inc. 3 | * Copyright (c) 2004-2005 All Rights Reserved. 4 | */ 5 | package com.hugnew.sps.services.pay.util.app.ali.global.util.httpClient; 6 | 7 | /* * 8 | *类名:HttpResultType 9 | *功能:表示Http返回的结果字符方式 10 | *详细:表示Http返回的结果字符方式 11 | *版本:3.3 12 | *日期:2012-08-17 13 | *说明: 14 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 15 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 16 | */ 17 | public enum HttpResultType { 18 | /** 19 | * 字符串方式 20 | */ 21 | STRING, 22 | 23 | /** 24 | * 字节数组方式 25 | */ 26 | BYTES 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/ali/main/util/UtilDate.java: -------------------------------------------------------------------------------- 1 | 2 | package com.hugnew.sps.services.pay.util.app.ali.main.util; 3 | 4 | import java.util.Date; 5 | import java.util.Random; 6 | import java.text.SimpleDateFormat; 7 | import java.text.DateFormat; 8 | 9 | /* * 10 | *类名:UtilDate 11 | *功能:自定义订单类 12 | *详细:工具类,可以用作获取系统日期、订单编号等 13 | *版本:3.3 14 | *日期:2012-08-17 15 | *说明: 16 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 17 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 18 | */ 19 | public class UtilDate { 20 | 21 | /** 22 | * 年月日时分秒(无下划线) yyyyMMddHHmmss 23 | */ 24 | public static final String dtLong = "yyyyMMddHHmmss"; 25 | 26 | /** 27 | * 完整时间 yyyy-MM-dd HH:mm:ss 28 | */ 29 | public static final String simple = "yyyy-MM-dd HH:mm:ss"; 30 | 31 | /** 32 | * 年月日(无下划线) yyyyMMdd 33 | */ 34 | public static final String dtShort = "yyyyMMdd"; 35 | 36 | 37 | /** 38 | * 返回系统当前时间(精确到毫秒),作为一个唯一的订单编号 39 | * 40 | * @return 以yyyyMMddHHmmss为格式的当前系统时间 41 | */ 42 | public static String getOrderNum() { 43 | Date date = new Date(); 44 | DateFormat df = new SimpleDateFormat(dtLong); 45 | return df.format(date); 46 | } 47 | 48 | /** 49 | * 获取系统当前日期(精确到毫秒),格式:yyyy-MM-dd HH:mm:ss 50 | * 51 | * @return 52 | */ 53 | public static String getDateFormatter() { 54 | Date date = new Date(); 55 | DateFormat df = new SimpleDateFormat(simple); 56 | return df.format(date); 57 | } 58 | 59 | /** 60 | * 获取系统当期年月日(精确到天),格式:yyyyMMdd 61 | * 62 | * @return 63 | */ 64 | public static String getDate() { 65 | Date date = new Date(); 66 | DateFormat df = new SimpleDateFormat(dtShort); 67 | return df.format(date); 68 | } 69 | 70 | /** 71 | * 产生随机的三位数 72 | * 73 | * @return 74 | */ 75 | public static String getThree() { 76 | Random rad = new Random(); 77 | return rad.nextInt(1000) + ""; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/ali/main/util/httpClient/HttpRequest.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.app.ali.main.util.httpClient; 2 | 3 | import org.apache.commons.httpclient.NameValuePair; 4 | 5 | /* * 6 | *类名:HttpRequest 7 | *功能:Http请求对象的封装 8 | *详细:封装Http请求 9 | *版本:3.3 10 | *日期:2011-08-17 11 | *说明: 12 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 13 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 14 | */ 15 | 16 | public class HttpRequest { 17 | 18 | /** 19 | * HTTP GET method 20 | */ 21 | public static final String METHOD_GET = "GET"; 22 | 23 | /** 24 | * HTTP POST method 25 | */ 26 | public static final String METHOD_POST = "POST"; 27 | 28 | /** 29 | * 待请求的url 30 | */ 31 | private String url = null; 32 | 33 | /** 34 | * 默认的请求方式 35 | */ 36 | private String method = METHOD_POST; 37 | 38 | private int timeout = 0; 39 | 40 | private int connectionTimeout = 0; 41 | 42 | /** 43 | * Post方式请求时组装好的参数值对 44 | */ 45 | private NameValuePair[] parameters = null; 46 | 47 | /** 48 | * Get方式请求时对应的参数 49 | */ 50 | private String queryString = null; 51 | 52 | /** 53 | * 默认的请求编码方式 54 | */ 55 | private String charset = "GBK"; 56 | 57 | /** 58 | * 请求发起方的ip地址 59 | */ 60 | private String clientIp; 61 | 62 | /** 63 | * 请求返回的方式 64 | */ 65 | private HttpResultType resultType = HttpResultType.BYTES; 66 | 67 | public HttpRequest(HttpResultType resultType) { 68 | super(); 69 | this.resultType = resultType; 70 | } 71 | 72 | /** 73 | * @return Returns the clientIp. 74 | */ 75 | public String getClientIp() { 76 | return clientIp; 77 | } 78 | 79 | /** 80 | * @param clientIp The clientIp to set. 81 | */ 82 | public void setClientIp(String clientIp) { 83 | this.clientIp = clientIp; 84 | } 85 | 86 | public NameValuePair[] getParameters() { 87 | return parameters; 88 | } 89 | 90 | public void setParameters(NameValuePair[] parameters) { 91 | this.parameters = parameters; 92 | } 93 | 94 | public String getQueryString() { 95 | return queryString; 96 | } 97 | 98 | public void setQueryString(String queryString) { 99 | this.queryString = queryString; 100 | } 101 | 102 | public String getUrl() { 103 | return url; 104 | } 105 | 106 | public void setUrl(String url) { 107 | this.url = url; 108 | } 109 | 110 | public String getMethod() { 111 | return method; 112 | } 113 | 114 | public void setMethod(String method) { 115 | this.method = method; 116 | } 117 | 118 | public int getConnectionTimeout() { 119 | return connectionTimeout; 120 | } 121 | 122 | public void setConnectionTimeout(int connectionTimeout) { 123 | this.connectionTimeout = connectionTimeout; 124 | } 125 | 126 | public int getTimeout() { 127 | return timeout; 128 | } 129 | 130 | public void setTimeout(int timeout) { 131 | this.timeout = timeout; 132 | } 133 | 134 | /** 135 | * @return Returns the charset. 136 | */ 137 | public String getCharset() { 138 | return charset; 139 | } 140 | 141 | /** 142 | * @param charset The charset to set. 143 | */ 144 | public void setCharset(String charset) { 145 | this.charset = charset; 146 | } 147 | 148 | public HttpResultType getResultType() { 149 | return resultType; 150 | } 151 | 152 | public void setResultType(HttpResultType resultType) { 153 | this.resultType = resultType; 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/ali/main/util/httpClient/HttpResponse.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.app.ali.main.util.httpClient; 2 | 3 | 4 | import com.hugnew.core.util.PropertiesUtil; 5 | import org.apache.commons.httpclient.Header; 6 | 7 | import java.io.UnsupportedEncodingException; 8 | 9 | /* * 10 | *类名:HttpResponse 11 | *功能:Http返回对象的封装 12 | *详细:封装Http返回信息 13 | *版本:3.3 14 | *日期:2011-08-17 15 | *说明: 16 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 17 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 18 | */ 19 | 20 | public class HttpResponse { 21 | 22 | 23 | /** 24 | * 返回中的Header信息 25 | */ 26 | private Header[] responseHeaders; 27 | 28 | /** 29 | * String类型的result 30 | */ 31 | private String stringResult; 32 | 33 | /** 34 | * btye类型的result 35 | */ 36 | private byte[] byteResult; 37 | 38 | public Header[] getResponseHeaders() { 39 | return responseHeaders; 40 | } 41 | 42 | public void setResponseHeaders(Header[] responseHeaders) { 43 | this.responseHeaders = responseHeaders; 44 | } 45 | 46 | public byte[] getByteResult() { 47 | if (byteResult != null) { 48 | return byteResult; 49 | } 50 | if (stringResult != null) { 51 | return stringResult.getBytes(); 52 | } 53 | return null; 54 | } 55 | 56 | public void setByteResult(byte[] byteResult) { 57 | this.byteResult = byteResult; 58 | } 59 | 60 | public String getStringResult() throws UnsupportedEncodingException { 61 | if (stringResult != null) { 62 | return stringResult; 63 | } 64 | if (byteResult != null) { 65 | return new String(byteResult, PropertiesUtil.getValue("pay.request.alipayAppMain.input_charset")); 66 | } 67 | return null; 68 | } 69 | 70 | public void setStringResult(String stringResult) { 71 | this.stringResult = stringResult; 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/ali/main/util/httpClient/HttpResultType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Alipay.com Inc. 3 | * Copyright (c) 2004-2005 All Rights Reserved. 4 | */ 5 | package com.hugnew.sps.services.pay.util.app.ali.main.util.httpClient; 6 | 7 | /* * 8 | *类名:HttpResultType 9 | *功能:表示Http返回的结果字符方式 10 | *详细:表示Http返回的结果字符方式 11 | *版本:3.3 12 | *日期:2012-08-17 13 | *说明: 14 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 15 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 16 | */ 17 | public enum HttpResultType { 18 | /** 19 | * 字符串方式 20 | */ 21 | STRING, 22 | 23 | /** 24 | * 字节数组方式 25 | */ 26 | BYTES 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/wechat/util/MD5.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.app.wechat.util; 2 | 3 | import java.security.MessageDigest; 4 | 5 | public class MD5 { 6 | 7 | private MD5() { 8 | } 9 | 10 | public final static String getMessageDigest(byte[] buffer) { 11 | char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; 12 | try { 13 | MessageDigest mdTemp = MessageDigest.getInstance("MD5"); 14 | mdTemp.update(buffer); 15 | byte[] md = mdTemp.digest(); 16 | int j = md.length; 17 | char str[] = new char[j * 2]; 18 | int k = 0; 19 | for (int i = 0; i < j; i++) { 20 | byte byte0 = md[i]; 21 | str[k++] = hexDigits[byte0 >>> 4 & 0xf]; 22 | str[k++] = hexDigits[byte0 & 0xf]; 23 | } 24 | return new String(str); 25 | } catch (Exception e) { 26 | return null; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/app/wechat/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.app.wechat.util; 2 | 3 | import java.security.MessageDigest; 4 | 5 | public class MD5Util { 6 | 7 | private static final String hexDigits[] = {"0", "1", "2", "3", "4", "5", 8 | "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"}; 9 | 10 | private static String byteArrayToHexString(byte b[]) { 11 | StringBuffer resultSb = new StringBuffer(); 12 | for (int i = 0; i < b.length; i++) 13 | resultSb.append(byteToHexString(b[i])); 14 | 15 | return resultSb.toString(); 16 | } 17 | 18 | private static String byteToHexString(byte b) { 19 | int n = b; 20 | if (n < 0) 21 | n += 256; 22 | int d1 = n / 16; 23 | int d2 = n % 16; 24 | return hexDigits[d1] + hexDigits[d2]; 25 | } 26 | 27 | public static String MD5Encode(String origin, String charsetname) { 28 | String resultString = null; 29 | try { 30 | resultString = new String(origin); 31 | MessageDigest md = MessageDigest.getInstance("MD5"); 32 | if (charsetname == null || "".equals(charsetname)) 33 | resultString = byteArrayToHexString(md.digest(resultString 34 | .getBytes())); 35 | else 36 | resultString = byteArrayToHexString(md.digest(resultString 37 | .getBytes(charsetname))); 38 | } catch (Exception exception) { 39 | } 40 | return resultString; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/bonded/config/AlipayConfig.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.bonded.config; 2 | /* * 3 | *类名:AlipayConfig 4 | *功能:基础配置类 5 | *详细:设置帐户有关信息及返回路径 6 | *版本:3.3 7 | *日期:2012-08-10 8 | *说明: 9 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 10 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 11 | 12 | *提示:如何获取安全校验码和合作身份者ID 13 | *1.用您的签约支付宝账号登录支付宝网站(www.alipay.com) 14 | *2.点击“商家服务”(https://b.alipay.com/order/myOrder.htm) 15 | *3.点击“查询合作者身份(PID)”、“查询安全校验码(Key)” 16 | 17 | *安全校验码查看时,输入支付密码后,页面呈灰色的现象,怎么办? 18 | *解决方法: 19 | *1、检查浏览器配置,不让浏览器做弹框屏蔽设置 20 | *2、更换浏览器或电脑,重新登录查询。 21 | */ 22 | 23 | public class AlipayConfig { 24 | 25 | //↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 26 | // 合作身份者ID,以2088开头由16位纯数字组成的字符串 27 | public static String partner = "2088811910068693"; 28 | 29 | // 收款支付宝账号 30 | public static String seller_email = "suxiangpuhui@163.com"; 31 | // 商户的私钥 32 | public static String key = "27x1pzvp3cqenozarsuyvl69he9hw0ro"; 33 | 34 | //↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ 35 | 36 | 37 | // 调试用,创建TXT日志文件夹路径 38 | public static String log_path = "/var/log/sps/alipay/bonded/"; 39 | 40 | // 字符编码格式 目前支持 gbk 或 utf-8 41 | public static String input_charset = "utf-8"; 42 | 43 | // 签名方式 不需修改 44 | public static String sign_type = "MD5"; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/bonded/sign/MD5.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.bonded.sign; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.security.SignatureException; 5 | 6 | import org.apache.commons.codec.digest.DigestUtils; 7 | 8 | /** 9 | * 功能:支付宝MD5签名处理核心文件,不需要修改 10 | * 版本:3.3 11 | * 修改日期:2012-08-17 12 | * 说明: 13 | * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 14 | * 该代码仅供学习和研究支付宝接口使用,只是提供一个 15 | */ 16 | 17 | public class MD5 { 18 | 19 | /** 20 | * 签名字符串 21 | * 22 | * @param text 需要签名的字符串 23 | * @param key 密钥 24 | * @param input_charset 编码格式 25 | * @return 签名结果 26 | */ 27 | public static String sign(String text, String key, String input_charset) { 28 | text = text + key; 29 | return DigestUtils.md5Hex(getContentBytes(text, input_charset)); 30 | } 31 | 32 | /** 33 | * 签名字符串 34 | * 35 | * @param text 需要签名的字符串 36 | * @param sign 签名结果 37 | * @param key 密钥 38 | * @param input_charset 编码格式 39 | * @return 签名结果 40 | */ 41 | public static boolean verify(String text, String sign, String key, String input_charset) { 42 | text = text + key; 43 | String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset)); 44 | return mysign.equals(sign); 45 | } 46 | 47 | /** 48 | * @param content 49 | * @param charset 50 | * @return 51 | * @throws SignatureException 52 | * @throws UnsupportedEncodingException 53 | */ 54 | private static byte[] getContentBytes(String content, String charset) { 55 | if (charset == null || "".equals(charset)) { 56 | return content.getBytes(); 57 | } 58 | try { 59 | return content.getBytes(charset); 60 | } catch (UnsupportedEncodingException e) { 61 | throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset); 62 | } 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/bonded/util/UtilDate.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.bonded.util; 2 | 3 | import java.util.Date; 4 | import java.util.Random; 5 | import java.text.SimpleDateFormat; 6 | import java.text.DateFormat; 7 | 8 | /* * 9 | *类名:UtilDate 10 | *功能:自定义订单类 11 | *详细:工具类,可以用作获取系统日期、订单编号等 12 | *版本:3.3 13 | *日期:2012-08-17 14 | *说明: 15 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 16 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 17 | */ 18 | public class UtilDate { 19 | 20 | /** 21 | * 年月日时分秒(无下划线) yyyyMMddHHmmss 22 | */ 23 | public static final String dtLong = "yyyyMMddHHmmss"; 24 | 25 | /** 26 | * 完整时间 yyyy-MM-dd HH:mm:ss 27 | */ 28 | public static final String simple = "yyyy-MM-dd HH:mm:ss"; 29 | 30 | /** 31 | * 年月日(无下划线) yyyyMMdd 32 | */ 33 | public static final String dtShort = "yyyyMMdd"; 34 | 35 | 36 | /** 37 | * 返回系统当前时间(精确到毫秒),作为一个唯一的订单编号 38 | * 39 | * @return 以yyyyMMddHHmmss为格式的当前系统时间 40 | */ 41 | public static String getOrderNum() { 42 | Date date = new Date(); 43 | DateFormat df = new SimpleDateFormat(dtLong); 44 | return df.format(date); 45 | } 46 | 47 | /** 48 | * 获取系统当前日期(精确到毫秒),格式:yyyy-MM-dd HH:mm:ss 49 | * 50 | * @return 51 | */ 52 | public static String getDateFormatter() { 53 | Date date = new Date(); 54 | DateFormat df = new SimpleDateFormat(simple); 55 | return df.format(date); 56 | } 57 | 58 | /** 59 | * 获取系统当期年月日(精确到天),格式:yyyyMMdd 60 | * 61 | * @return 62 | */ 63 | public static String getDate() { 64 | Date date = new Date(); 65 | DateFormat df = new SimpleDateFormat(dtShort); 66 | return df.format(date); 67 | } 68 | 69 | /** 70 | * 产生随机的三位数 71 | * 72 | * @return 73 | */ 74 | public static String getThree() { 75 | Random rad = new Random(); 76 | return rad.nextInt(1000) + ""; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/bonded/util/httpClient/HttpResponse.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.bonded.util.httpClient; 2 | 3 | import com.hugnew.sps.services.pay.util.web.ali.bonded.config.AlipayConfig; 4 | 5 | import org.apache.commons.httpclient.Header; 6 | 7 | import java.io.UnsupportedEncodingException; 8 | 9 | /* * 10 | *类名:HttpResponse 11 | *功能:Http返回对象的封装 12 | *详细:封装Http返回信息 13 | *版本:3.3 14 | *日期:2011-08-17 15 | *说明: 16 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 17 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 18 | */ 19 | 20 | public class HttpResponse { 21 | 22 | /** 23 | * 返回中的Header信息 24 | */ 25 | private Header[] responseHeaders; 26 | 27 | /** 28 | * String类型的result 29 | */ 30 | private String stringResult; 31 | 32 | /** 33 | * btye类型的result 34 | */ 35 | private byte[] byteResult; 36 | 37 | public Header[] getResponseHeaders() { 38 | return responseHeaders; 39 | } 40 | 41 | public void setResponseHeaders(Header[] responseHeaders) { 42 | this.responseHeaders = responseHeaders; 43 | } 44 | 45 | public byte[] getByteResult() { 46 | if (byteResult != null) { 47 | return byteResult; 48 | } 49 | if (stringResult != null) { 50 | return stringResult.getBytes(); 51 | } 52 | return null; 53 | } 54 | 55 | public void setByteResult(byte[] byteResult) { 56 | this.byteResult = byteResult; 57 | } 58 | 59 | public String getStringResult() throws UnsupportedEncodingException { 60 | if (stringResult != null) { 61 | return stringResult; 62 | } 63 | if (byteResult != null) { 64 | return new String(byteResult, AlipayConfig.input_charset); 65 | } 66 | return null; 67 | } 68 | 69 | public void setStringResult(String stringResult) { 70 | this.stringResult = stringResult; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/bonded/util/httpClient/HttpResultType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Alipay.com Inc. 3 | * Copyright (c) 2004-2005 All Rights Reserved. 4 | */ 5 | package com.hugnew.sps.services.pay.util.web.ali.bonded.util.httpClient; 6 | 7 | /* * 8 | *类名:HttpResultType 9 | *功能:表示Http返回的结果字符方式 10 | *详细:表示Http返回的结果字符方式 11 | *版本:3.3 12 | *日期:2012-08-17 13 | *说明: 14 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 15 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 16 | */ 17 | public enum HttpResultType { 18 | /** 19 | * 字符串方式 20 | */ 21 | STRING, 22 | 23 | /** 24 | * 字节数组方式 25 | */ 26 | BYTES 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/global/sign/MD5.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.global.sign; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.security.SignatureException; 5 | 6 | import org.apache.commons.codec.digest.DigestUtils; 7 | 8 | /** 9 | * 功能:支付宝MD5签名处理核心文件,不需要修改 10 | * 版本:3.3 11 | * 修改日期:2012-08-17 12 | * 说明: 13 | * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 14 | * 该代码仅供学习和研究支付宝接口使用,只是提供一个 15 | */ 16 | 17 | public class MD5 { 18 | 19 | /** 20 | * 签名字符串 21 | * 22 | * @param text 需要签名的字符串 23 | * @param key 密钥 24 | * @param input_charset 编码格式 25 | * @return 签名结果 26 | */ 27 | public static String sign(String text, String key, String input_charset) { 28 | text = text + key; 29 | return DigestUtils.md5Hex(getContentBytes(text, input_charset)); 30 | } 31 | 32 | /** 33 | * 签名字符串 34 | * 35 | * @param text 需要签名的字符串 36 | * @param sign 签名结果 37 | * @param key 密钥 38 | * @param input_charset 编码格式 39 | * @return 签名结果 40 | */ 41 | public static boolean verify(String text, String sign, String key, String input_charset) { 42 | text = text + key; 43 | String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset)); 44 | return mysign.equals(sign); 45 | } 46 | 47 | /** 48 | * @param content 49 | * @param charset 50 | * @return 51 | * @throws SignatureException 52 | * @throws UnsupportedEncodingException 53 | */ 54 | private static byte[] getContentBytes(String content, String charset) { 55 | if (charset == null || "".equals(charset)) { 56 | return content.getBytes(); 57 | } 58 | try { 59 | return content.getBytes(charset); 60 | } catch (UnsupportedEncodingException e) { 61 | throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset); 62 | } 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/global/util/UtilDate.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.global.util; 2 | 3 | import java.util.Date; 4 | import java.util.Random; 5 | import java.text.SimpleDateFormat; 6 | import java.text.DateFormat; 7 | 8 | /* * 9 | *类名:UtilDate 10 | *功能:自定义订单类 11 | *详细:工具类,可以用作获取系统日期、订单编号等 12 | *版本:3.3 13 | *日期:2012-08-17 14 | *说明: 15 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 16 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 17 | */ 18 | public class UtilDate { 19 | 20 | /** 21 | * 年月日时分秒(无下划线) yyyyMMddHHmmss 22 | */ 23 | public static final String dtLong = "yyyyMMddHHmmss"; 24 | 25 | /** 26 | * 完整时间 yyyy-MM-dd HH:mm:ss 27 | */ 28 | public static final String simple = "yyyy-MM-dd HH:mm:ss"; 29 | 30 | /** 31 | * 年月日(无下划线) yyyyMMdd 32 | */ 33 | public static final String dtShort = "yyyyMMdd"; 34 | 35 | 36 | /** 37 | * 返回系统当前时间(精确到毫秒),作为一个唯一的订单编号 38 | * 39 | * @return 以yyyyMMddHHmmss为格式的当前系统时间 40 | */ 41 | public static String getOrderNum() { 42 | Date date = new Date(); 43 | DateFormat df = new SimpleDateFormat(dtLong); 44 | return df.format(date); 45 | } 46 | 47 | /** 48 | * 获取系统当前日期(精确到毫秒),格式:yyyy-MM-dd HH:mm:ss 49 | * 50 | * @return 51 | */ 52 | public static String getDateFormatter() { 53 | Date date = new Date(); 54 | DateFormat df = new SimpleDateFormat(simple); 55 | return df.format(date); 56 | } 57 | 58 | /** 59 | * 获取系统当期年月日(精确到天),格式:yyyyMMdd 60 | * 61 | * @return 62 | */ 63 | public static String getDate() { 64 | Date date = new Date(); 65 | DateFormat df = new SimpleDateFormat(dtShort); 66 | return df.format(date); 67 | } 68 | 69 | /** 70 | * 产生随机的三位数 71 | * 72 | * @return 73 | */ 74 | public static String getThree() { 75 | Random rad = new Random(); 76 | return rad.nextInt(1000) + ""; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/global/util/httpClient/HttpResponse.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.global.util.httpClient; 2 | 3 | 4 | import com.hugnew.core.util.PropertiesUtil; 5 | import org.apache.commons.httpclient.Header; 6 | 7 | import java.io.UnsupportedEncodingException; 8 | 9 | /* * 10 | *类名:HttpResponse 11 | *功能:Http返回对象的封装 12 | *详细:封装Http返回信息 13 | *版本:3.3 14 | *日期:2011-08-17 15 | *说明: 16 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 17 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 18 | */ 19 | 20 | public class HttpResponse { 21 | 22 | /** 23 | * 返回中的Header信息 24 | */ 25 | private Header[] responseHeaders; 26 | 27 | /** 28 | * String类型的result 29 | */ 30 | private String stringResult; 31 | 32 | /** 33 | * btye类型的result 34 | */ 35 | private byte[] byteResult; 36 | 37 | public Header[] getResponseHeaders() { 38 | return responseHeaders; 39 | } 40 | 41 | public void setResponseHeaders(Header[] responseHeaders) { 42 | this.responseHeaders = responseHeaders; 43 | } 44 | 45 | public byte[] getByteResult() { 46 | if (byteResult != null) { 47 | return byteResult; 48 | } 49 | if (stringResult != null) { 50 | return stringResult.getBytes(); 51 | } 52 | return null; 53 | } 54 | 55 | public void setByteResult(byte[] byteResult) { 56 | this.byteResult = byteResult; 57 | } 58 | 59 | public String getStringResult() throws UnsupportedEncodingException { 60 | if (stringResult != null) { 61 | return stringResult; 62 | } 63 | if (byteResult != null) { 64 | return new String(byteResult, PropertiesUtil.getValue("pay.request.alipayWebGlobal.input_charset")); 65 | } 66 | return null; 67 | } 68 | 69 | public void setStringResult(String stringResult) { 70 | this.stringResult = stringResult; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/global/util/httpClient/HttpResultType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Alipay.com Inc. 3 | * Copyright (c) 2004-2005 All Rights Reserved. 4 | */ 5 | package com.hugnew.sps.services.pay.util.web.ali.global.util.httpClient; 6 | 7 | /* * 8 | *类名:HttpResultType 9 | *功能:表示Http返回的结果字符方式 10 | *详细:表示Http返回的结果字符方式 11 | *版本:3.3 12 | *日期:2012-08-17 13 | *说明: 14 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 15 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 16 | */ 17 | public enum HttpResultType { 18 | /** 19 | * 字符串方式 20 | */ 21 | STRING, 22 | 23 | /** 24 | * 字节数组方式 25 | */ 26 | BYTES 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/main/sign/MD5.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.main.sign; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.security.SignatureException; 5 | 6 | import org.apache.commons.codec.digest.DigestUtils; 7 | 8 | /** 9 | * 功能:支付宝MD5签名处理核心文件,不需要修改 10 | * 版本:3.3 11 | * 修改日期:2012-08-17 12 | * 说明: 13 | * 以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 14 | * 该代码仅供学习和研究支付宝接口使用,只是提供一个 15 | */ 16 | 17 | public class MD5 { 18 | 19 | /** 20 | * 签名字符串 21 | * 22 | * @param text 需要签名的字符串 23 | * @param key 密钥 24 | * @param input_charset 编码格式 25 | * @return 签名结果 26 | */ 27 | public static String sign(String text, String key, String input_charset) { 28 | text = text + key; 29 | return DigestUtils.md5Hex(getContentBytes(text, input_charset)); 30 | } 31 | 32 | /** 33 | * 签名字符串 34 | * 35 | * @param text 需要签名的字符串 36 | * @param sign 签名结果 37 | * @param key 密钥 38 | * @param input_charset 编码格式 39 | * @return 签名结果 40 | */ 41 | public static boolean verify(String text, String sign, String key, String input_charset) { 42 | text = text + key; 43 | String mysign = DigestUtils.md5Hex(getContentBytes(text, input_charset)); 44 | return mysign.equals(sign); 45 | } 46 | 47 | /** 48 | * @param content 49 | * @param charset 50 | * @return 51 | * @throws SignatureException 52 | * @throws UnsupportedEncodingException 53 | */ 54 | private static byte[] getContentBytes(String content, String charset) { 55 | if (charset == null || "".equals(charset)) { 56 | return content.getBytes(); 57 | } 58 | try { 59 | return content.getBytes(charset); 60 | } catch (UnsupportedEncodingException e) { 61 | throw new RuntimeException("MD5签名过程中出现错误,指定的编码集不对,您目前指定的编码集是:" + charset); 62 | } 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/main/util/UtilDate.java: -------------------------------------------------------------------------------- 1 | 2 | package com.hugnew.sps.services.pay.util.web.ali.main.util; 3 | 4 | import java.util.Date; 5 | import java.util.Random; 6 | import java.text.SimpleDateFormat; 7 | import java.text.DateFormat; 8 | 9 | /* * 10 | *类名:UtilDate 11 | *功能:自定义订单类 12 | *详细:工具类,可以用作获取系统日期、订单编号等 13 | *版本:3.3 14 | *日期:2012-08-17 15 | *说明: 16 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 17 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 18 | */ 19 | public class UtilDate { 20 | 21 | /** 22 | * 年月日时分秒(无下划线) yyyyMMddHHmmss 23 | */ 24 | public static final String dtLong = "yyyyMMddHHmmss"; 25 | 26 | /** 27 | * 完整时间 yyyy-MM-dd HH:mm:ss 28 | */ 29 | public static final String simple = "yyyy-MM-dd HH:mm:ss"; 30 | 31 | /** 32 | * 年月日(无下划线) yyyyMMdd 33 | */ 34 | public static final String dtShort = "yyyyMMdd"; 35 | 36 | 37 | /** 38 | * 返回系统当前时间(精确到毫秒),作为一个唯一的订单编号 39 | * 40 | * @return 以yyyyMMddHHmmss为格式的当前系统时间 41 | */ 42 | public static String getOrderNum() { 43 | Date date = new Date(); 44 | DateFormat df = new SimpleDateFormat(dtLong); 45 | return df.format(date); 46 | } 47 | 48 | /** 49 | * 获取系统当前日期(精确到毫秒),格式:yyyy-MM-dd HH:mm:ss 50 | * 51 | * @return 52 | */ 53 | public static String getDateFormatter() { 54 | Date date = new Date(); 55 | DateFormat df = new SimpleDateFormat(simple); 56 | return df.format(date); 57 | } 58 | 59 | /** 60 | * 获取系统当期年月日(精确到天),格式:yyyyMMdd 61 | * 62 | * @return 63 | */ 64 | public static String getDate() { 65 | Date date = new Date(); 66 | DateFormat df = new SimpleDateFormat(dtShort); 67 | return df.format(date); 68 | } 69 | 70 | /** 71 | * 产生随机的三位数 72 | * 73 | * @return 74 | */ 75 | public static String getThree() { 76 | Random rad = new Random(); 77 | return rad.nextInt(1000) + ""; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/main/util/httpClient/HttpRequest.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.main.util.httpClient; 2 | 3 | import org.apache.commons.httpclient.NameValuePair; 4 | 5 | /* * 6 | *类名:HttpRequest 7 | *功能:Http请求对象的封装 8 | *详细:封装Http请求 9 | *版本:3.3 10 | *日期:2011-08-17 11 | *说明: 12 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 13 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 14 | */ 15 | 16 | public class HttpRequest { 17 | 18 | /** 19 | * HTTP GET method 20 | */ 21 | public static final String METHOD_GET = "GET"; 22 | 23 | /** 24 | * HTTP POST method 25 | */ 26 | public static final String METHOD_POST = "POST"; 27 | 28 | /** 29 | * 待请求的url 30 | */ 31 | private String url = null; 32 | 33 | /** 34 | * 默认的请求方式 35 | */ 36 | private String method = METHOD_POST; 37 | 38 | private int timeout = 0; 39 | 40 | private int connectionTimeout = 0; 41 | 42 | /** 43 | * Post方式请求时组装好的参数值对 44 | */ 45 | private NameValuePair[] parameters = null; 46 | 47 | /** 48 | * Get方式请求时对应的参数 49 | */ 50 | private String queryString = null; 51 | 52 | /** 53 | * 默认的请求编码方式 54 | */ 55 | private String charset = "GBK"; 56 | 57 | /** 58 | * 请求发起方的ip地址 59 | */ 60 | private String clientIp; 61 | 62 | /** 63 | * 请求返回的方式 64 | */ 65 | private HttpResultType resultType = HttpResultType.BYTES; 66 | 67 | public HttpRequest(HttpResultType resultType) { 68 | super(); 69 | this.resultType = resultType; 70 | } 71 | 72 | /** 73 | * @return Returns the clientIp. 74 | */ 75 | public String getClientIp() { 76 | return clientIp; 77 | } 78 | 79 | /** 80 | * @param clientIp The clientIp to set. 81 | */ 82 | public void setClientIp(String clientIp) { 83 | this.clientIp = clientIp; 84 | } 85 | 86 | public NameValuePair[] getParameters() { 87 | return parameters; 88 | } 89 | 90 | public void setParameters(NameValuePair[] parameters) { 91 | this.parameters = parameters; 92 | } 93 | 94 | public String getQueryString() { 95 | return queryString; 96 | } 97 | 98 | public void setQueryString(String queryString) { 99 | this.queryString = queryString; 100 | } 101 | 102 | public String getUrl() { 103 | return url; 104 | } 105 | 106 | public void setUrl(String url) { 107 | this.url = url; 108 | } 109 | 110 | public String getMethod() { 111 | return method; 112 | } 113 | 114 | public void setMethod(String method) { 115 | this.method = method; 116 | } 117 | 118 | public int getConnectionTimeout() { 119 | return connectionTimeout; 120 | } 121 | 122 | public void setConnectionTimeout(int connectionTimeout) { 123 | this.connectionTimeout = connectionTimeout; 124 | } 125 | 126 | public int getTimeout() { 127 | return timeout; 128 | } 129 | 130 | public void setTimeout(int timeout) { 131 | this.timeout = timeout; 132 | } 133 | 134 | /** 135 | * @return Returns the charset. 136 | */ 137 | public String getCharset() { 138 | return charset; 139 | } 140 | 141 | /** 142 | * @param charset The charset to set. 143 | */ 144 | public void setCharset(String charset) { 145 | this.charset = charset; 146 | } 147 | 148 | public HttpResultType getResultType() { 149 | return resultType; 150 | } 151 | 152 | public void setResultType(HttpResultType resultType) { 153 | this.resultType = resultType; 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/main/util/httpClient/HttpResponse.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ali.main.util.httpClient; 2 | 3 | 4 | import com.hugnew.core.util.PropertiesUtil; 5 | import org.apache.commons.httpclient.Header; 6 | 7 | import java.io.UnsupportedEncodingException; 8 | 9 | /* * 10 | *类名:HttpResponse 11 | *功能:Http返回对象的封装 12 | *详细:封装Http返回信息 13 | *版本:3.3 14 | *日期:2011-08-17 15 | *说明: 16 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 17 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 18 | */ 19 | 20 | public class HttpResponse { 21 | 22 | /** 23 | * 返回中的Header信息 24 | */ 25 | private Header[] responseHeaders; 26 | 27 | /** 28 | * String类型的result 29 | */ 30 | private String stringResult; 31 | 32 | /** 33 | * btye类型的result 34 | */ 35 | private byte[] byteResult; 36 | 37 | public Header[] getResponseHeaders() { 38 | return responseHeaders; 39 | } 40 | 41 | public void setResponseHeaders(Header[] responseHeaders) { 42 | this.responseHeaders = responseHeaders; 43 | } 44 | 45 | public byte[] getByteResult() { 46 | if (byteResult != null) { 47 | return byteResult; 48 | } 49 | if (stringResult != null) { 50 | return stringResult.getBytes(); 51 | } 52 | return null; 53 | } 54 | 55 | public void setByteResult(byte[] byteResult) { 56 | this.byteResult = byteResult; 57 | } 58 | 59 | public String getStringResult() throws UnsupportedEncodingException { 60 | if (stringResult != null) { 61 | return stringResult; 62 | } 63 | if (byteResult != null) { 64 | return new String(byteResult, PropertiesUtil.getValue("pay.request.alipayWebMain.input_charset")); 65 | } 66 | return null; 67 | } 68 | 69 | public void setStringResult(String stringResult) { 70 | this.stringResult = stringResult; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ali/main/util/httpClient/HttpResultType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Alipay.com Inc. 3 | * Copyright (c) 2004-2005 All Rights Reserved. 4 | */ 5 | package com.hugnew.sps.services.pay.util.web.ali.main.util.httpClient; 6 | 7 | /* * 8 | *类名:HttpResultType 9 | *功能:表示Http返回的结果字符方式 10 | *详细:表示Http返回的结果字符方式 11 | *版本:3.3 12 | *日期:2012-08-17 13 | *说明: 14 | *以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。 15 | *该代码仅供学习和研究支付宝接口使用,只是提供一个参考。 16 | */ 17 | public enum HttpResultType { 18 | /** 19 | * 字符串方式 20 | */ 21 | STRING, 22 | 23 | /** 24 | * 字节数组方式 25 | */ 26 | BYTES 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/ceb/SpsX509TrustManager.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.ceb; 2 | 3 | /** 4 | * Created by bill on 2015/11/25. 5 | */ 6 | import java.security.cert.CertificateException; 7 | import java.security.cert.X509Certificate; 8 | 9 | import javax.net.ssl.X509TrustManager; 10 | 11 | public class SpsX509TrustManager implements X509TrustManager { 12 | 13 | /* (non-Javadoc) 14 | * @see javax.net.ssl.X509TrustManager#checkClientTrusted(java.security.cert.X509Certificate[], java.lang.String) 15 | */ 16 | public void checkClientTrusted(X509Certificate[] arg0, String arg1) 17 | throws CertificateException { 18 | 19 | } 20 | 21 | /* (non-Javadoc) 22 | * @see javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate[], java.lang.String) 23 | */ 24 | public void checkServerTrusted(X509Certificate[] arg0, String arg1) 25 | throws CertificateException { 26 | 27 | } 28 | 29 | /* (non-Javadoc) 30 | * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers() 31 | */ 32 | public X509Certificate[] getAcceptedIssuers() { 33 | return null; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/upop/sdk/QuickPayResSampleServLet.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.upop.sdk; 2 | 3 | import java.io.IOException; 4 | import java.io.UnsupportedEncodingException; 5 | 6 | import javax.servlet.http.HttpServlet; 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | /** 11 | * 名称:支付应答类 12 | * 功能:servlet方式,建议前台通知和后台通知用两个类实现,后台通知进行商户的数据库等处理,前台通知实现客户浏览器跳转 13 | * 类属性: 14 | * 版本:1.0 15 | * 日期:2011-03-11 16 | * 作者:中国银联UPOP团队 17 | * 版权:中国银联 18 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。该代码仅供参考。 19 | */ 20 | 21 | public class QuickPayResSampleServLet extends HttpServlet { 22 | /** 23 | * 24 | */ 25 | private static final long serialVersionUID = -6247574514957274823L; 26 | 27 | public void init() { 28 | 29 | } 30 | 31 | public void service(HttpServletRequest request, HttpServletResponse response) { 32 | try { 33 | request.setCharacterEncoding(QuickPayConf.charset); 34 | } catch (UnsupportedEncodingException e) { 35 | } 36 | 37 | String[] resArr = new String[QuickPayConf.notifyVo.length]; 38 | for (int i = 0; i < QuickPayConf.notifyVo.length; i++) { 39 | resArr[i] = request.getParameter(QuickPayConf.notifyVo[i]); 40 | } 41 | String signature = request.getParameter(QuickPayConf.signature); 42 | String signMethod = request.getParameter(QuickPayConf.signMethod); 43 | 44 | response.setContentType("text/html;charset=" + QuickPayConf.charset); 45 | response.setCharacterEncoding(QuickPayConf.charset); 46 | 47 | try { 48 | Boolean signatureCheck = new QuickPayUtils().checkSign(resArr, signMethod, signature); 49 | response.getWriter() 50 | .append("建议前台通知和后台通知用两个类实现,后台通知进行商户的数据库等处理,前台通知实现客户浏览器跳转
") 51 | .append("签名是否正确:" + signatureCheck) 52 | .append("
交易是否成功:" + "00".equals(resArr[10])); 53 | if (!"00".equals(resArr[10])) { 54 | response.getWriter().append("
失败原因:" + resArr[11]); 55 | } 56 | } catch (IOException e) { 57 | 58 | } 59 | 60 | response.setStatus(HttpServletResponse.SC_OK); 61 | } 62 | 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/upop/sdk/QuickPaySampleServLet.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.upop.sdk; 2 | 3 | import java.io.IOException; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Date; 6 | 7 | import javax.servlet.http.HttpServlet; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | 11 | /** 12 | * 名称:支付请求类 13 | * 功能:servlet方式支付类请求 14 | * 类属性: 15 | * 版本:1.0 16 | * 日期:2011-03-11 17 | * 作者:中国银联UPOP团队 18 | * 版权:中国银联 19 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己网站的需要,按照技术文档编写,并非一定要使用该代码。该代码仅供参考。 20 | */ 21 | 22 | public class QuickPaySampleServLet extends HttpServlet { 23 | /** 24 | * 25 | */ 26 | private static final long serialVersionUID = -6247574514957274823L; 27 | static int i = 0; 28 | 29 | public void init() { 30 | 31 | } 32 | 33 | 34 | public void service(HttpServletRequest request, HttpServletResponse response) { 35 | //商户需要组装如下对象的数据 36 | String[] valueVo = new String[]{ 37 | QuickPayConf.version,//协议版本 38 | QuickPayConf.charset,//字符编码 39 | "01",//交易类型 40 | "",//原始交易流水号 41 | QuickPayConf.merCode,//商户代码 42 | QuickPayConf.merName,//商户简称 43 | "",//收单机构代码(仅收单机构接入需要填写) 44 | "",//商户类别(收单机构接入需要填写) 45 | "http://218.80.192.2231/shop1/payment/quickpay/quickpay_result.php?payid=123456&dd=123",//商品URL 46 | "物品名称如短袖",//商品名称 47 | "3000",//商品单价 单位:分 48 | "1",//商品数量 49 | "0",//折扣 单位:分 50 | "1000",//运费 单位:分 51 | new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + (++i),//订单号(需要商户自己生成) 52 | "3100",//交易金额 单位:分 53 | "156",//交易币种 54 | new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()),//交易时间 55 | "127.0.0.1",//用户IP 56 | "张三",//用户真实姓名 57 | "",//默认支付方式 58 | "",//默认银行编号 59 | "300000",//交易超时时间 60 | QuickPayConf.merFrontEndUrl,// 前台回调商户URL 61 | QuickPayConf.merBackEndUrl,// 后台回调商户URL 62 | ""//商户保留域 63 | }; 64 | 65 | String signType = request.getParameter("sign"); 66 | if (!QuickPayConf.signType_SHA1withRSA.equalsIgnoreCase(signType)) { 67 | signType = QuickPayConf.signType; 68 | } 69 | 70 | String html = new QuickPayUtils().createPayHtml(valueVo, signType);//跳转到银联页面支付 71 | 72 | response.setContentType("text/html;charset=" + QuickPayConf.charset); 73 | response.setCharacterEncoding(QuickPayConf.charset); 74 | try { 75 | response.getWriter().write(html); 76 | } catch (IOException e) { 77 | 78 | } 79 | response.setStatus(HttpServletResponse.SC_OK); 80 | } 81 | 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/upop/sdk/Sms.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.upop.sdk; 2 | 3 | public class Sms { 4 | 5 | /** 6 | * 商户无跳转发送短信请求 7 | * 8 | * @param args 9 | */ 10 | public static void main(String[] args) { 11 | new Sms().send(); 12 | } 13 | 14 | public void send() { 15 | //普通商户 16 | /*String[] valueVo = new String[]{ 17 | QuickPayConf.version,//协议版本 18 | QuickPayConf.charset,//字符编码 19 | "",//收单机构代码 20 | QuickPayConf.merCode,//商户代码 21 | "测试商户简称",//商户简称 22 | "2011060512345678",//订单号 23 | "2012",//金额 24 | "156",//币种 25 | "13888888888",//手机号 26 | ""//保留域 说明:如果是收单机构保留域需传收单代码如:{acqCode=00215800},商户直接接入upop不传收单代码 27 | };*/ 28 | //收单机构 29 | /*String[] valueVo = new String[]{ 30 | QuickPayConf.version,//协议版本 31 | QuickPayConf.charset,//字符编码 32 | "00215800",//收单机构代码 33 | QuickPayConf.merCode,//商户代码 34 | "测试商户简称",//商户简称 35 | "2011060512345678",//订单号 36 | "2012",//金额 37 | "156",//币种 38 | "13888888887",//手机号 39 | ""//保留域 说明:如果是收单机构保留域需传收单代码如:{acqCode=00215800},商户直接接入upop不传收单代码 40 | };*/ 41 | //二级商户 42 | /*String[] valueVo = new String[]{ 43 | QuickPayConf.version,//协议版本 44 | QuickPayConf.charset,//字符编码 45 | "",//收单机构代码 46 | QuickPayConf.merCode,//商户代码 47 | "测试商户简称",//商户简称 48 | "2011060512345678",//订单号 49 | "2012",//金额 50 | "156",//币种 51 | "13888888886",//手机号 52 | "{merPlatformType=1&secondaryMerId=10000011110022&secondaryMerFullName=二级商户全称&secondaryMerAbbr=二级商户简称}"//保留域 说明:如果是收单机构保留域需传收单代码如:{acqCode=00215800},商户直接接入upop不传收单代码 53 | };*/ 54 | //特殊配置商户 55 | String[] valueVo = new String[]{ 56 | QuickPayConf.version,//协议版本 57 | QuickPayConf.charset,//字符编码 58 | "",//收单机构代码 59 | "100000000000069",//商户代码 60 | "特殊配置商户",//商户简称 61 | "2011060512345678",//订单号 62 | "2012",//金额 63 | "156",//币种 64 | "{phoneNumber=13888888888&cardNumber=6212341111111111111}"//保留域 说明:如果是收单机构保留域需传收单代码如:{acqCode=00215800},商户直接接入upop不传收单代码 65 | }; 66 | QuickPayUtils quickPayUtils = new QuickPayUtils(); 67 | String res = quickPayUtils.doPostQueryCmd(QuickPayConf.smsUrl, new QuickPayUtils().createBackStrForBackTrans(valueVo, QuickPayConf.smsVo)); 68 | 69 | if (res != null && !"".equals(res)) { 70 | 71 | String[] arr = QuickPayUtils.getResArr(res); 72 | 73 | if (new QuickPayQuery().checkSecurity(arr)) {//验证签名 74 | merBusiness(arr);//商户业务逻辑 75 | } 76 | } else { 77 | System.out.println("报文格式为空"); 78 | } 79 | } 80 | 81 | //商户的业务逻辑 82 | public void merBusiness(String[] arr) { 83 | 84 | //以下是商户业务处理 85 | String smsResult = ""; 86 | for (int i = 0; i < arr.length; i++) { 87 | String[] smsResultArr = arr[i].split("="); 88 | // 处理商户业务逻辑 89 | if (smsResultArr.length >= 2 && "respMsg".equals(smsResultArr[0])) { 90 | smsResult = arr[i].substring(smsResultArr[0].length() + 1); 91 | 92 | break; 93 | } 94 | } 95 | if (smsResult != "") { 96 | System.out.println(smsResult); 97 | } 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_2_AppConsume.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.unionpay.acp.sdk.SDKConfig; 9 | 10 | /** 11 | * 名称: 第一卷 商户卷 第5部分 手机支付 ——手机控件支付产品
12 | * 功能: 6.2 消费类交易
13 | * 前台交易类
14 | * 版本: 5.0
15 | * 日期: 2014-07
16 | * 作者: 中国银联ACP团队
17 | * 版权: 中国银联
18 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
19 | */ 20 | public class Form_6_2_AppConsume extends DemoBase { 21 | 22 | public static void main(String[] args) { 23 | 24 | /** 25 | * 参数初始化 26 | * 在java main 方式运行时必须每次都执行加载 27 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 28 | */ 29 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 30 | 31 | /** 32 | * 组装请求报文 33 | */ 34 | Map data = new HashMap(); 35 | // 版本号 36 | data.put("version", "5.0.0"); 37 | // 字符集编码 默认"UTF-8" 38 | data.put("encoding", "UTF-8"); 39 | // 签名方法 01 RSA 40 | data.put("signMethod", "01"); 41 | // 交易类型 01-消费 42 | data.put("txnType", "01"); 43 | // 交易子类型 01:自助消费 02:订购 03:分期付款 44 | data.put("txnSubType", "01"); 45 | // 业务类型 46 | data.put("bizType", "000201"); 47 | // 渠道类型,07-PC,08-手机 48 | data.put("channelType", "08"); 49 | // 前台通知地址 ,控件接入方式无作用 50 | data.put("frontUrl", "http://localhost:8080/ACPTest/acp_front_url.do"); 51 | // 后台通知地址 52 | data.put("backUrl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do"); 53 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 54 | data.put("accessType", "0"); 55 | // 商户号码,请改成自己的商户号 56 | data.put("merId", "888888888888888"); 57 | // 商户订单号,8-40位数字字母 58 | data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 59 | // 订单发送时间,取系统时间 60 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 61 | // 交易金额,单位分 62 | data.put("txnAmt", "1"); 63 | // 交易币种 64 | data.put("currencyCode", "156"); 65 | // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 66 | // data.put("reqReserved", "透传信息"); 67 | // 订单描述,可不上送,上送时控件中会显示该信息 68 | // data.put("orderDesc", "订单描述"); 69 | 70 | data = signData(data); 71 | 72 | // 交易请求url 从配置文件读取 73 | String requestAppUrl = SDKConfig.getConfig().getAppRequestUrl(); 74 | 75 | Map resmap = submitUrl(data, requestAppUrl); 76 | 77 | System.out.println("请求报文=[" + data.toString() + "]"); 78 | System.out.println("应答报文=[" + resmap.toString() + "]"); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_2_FrontConsume.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.unionpay.acp.sdk.SDKConfig; 9 | 10 | /** 11 | * 名称: 第一卷 商户卷 第1/6部分 手机支付 ——跳转网关支付产品/手机网页支付产品
12 | * 功能: 6.2 消费类交易
13 | * 前台交易类
14 | * 版本: 5.0
15 | * 日期: 2014-07
16 | * 作者: 中国银联ACP团队
17 | * 版权: 中国银联
18 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
19 | */ 20 | public class Form_6_2_FrontConsume extends DemoBase { 21 | 22 | public static void main(String[] args) { 23 | 24 | /**ddddddd 25 | * 参数初始化 26 | * 在java main 方式运行时必须每次都执行加载 27 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 28 | */ 29 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 30 | 31 | /** 32 | * 组装请求报文 33 | */ 34 | Map data = new HashMap(); 35 | // 版本号 36 | data.put("version", "5.0.0"); 37 | // 字符集编码 默认"UTF-8" 38 | data.put("encoding", "UTF-8"); 39 | // 签名方法 01 RSA 40 | data.put("signMethod", "01"); 41 | // 交易类型 01-消费 42 | data.put("txnType", "01"); 43 | // 交易子类型 01:自助消费 02:订购 03:分期付款 44 | data.put("txnSubType", "01"); 45 | // 业务类型 46 | data.put("bizType", "000201"); 47 | // 渠道类型,07-PC,08-手机 48 | data.put("channelType", "08"); 49 | // 前台通知地址 ,控件接入方式无作用 50 | data.put("frontUrl", "http://localhost:8080/ACPTest/acp_front_url.do"); 51 | // 后台通知地址 52 | data.put("backUrl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do"); 53 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 54 | data.put("accessType", "0"); 55 | // 商户号码,请改成自己的商户号 56 | data.put("merId", "888888888888888"); 57 | // 商户订单号,8-40位数字字母 58 | data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 59 | // 订单发送时间,取系统时间 60 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 61 | // 交易金额,单位分 62 | data.put("txnAmt", "1"); 63 | // 交易币种 64 | data.put("currencyCode", "156"); 65 | // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 66 | // data.put("reqReserved", "透传信息"); 67 | // 订单描述,可不上送,上送时控件中会显示该信息 68 | // data.put("orderDesc", "订单描述"); 69 | 70 | Map submitFromData = signData(data); 71 | 72 | // 交易请求url 从配置文件读取 73 | String requestFrontUrl = SDKConfig.getConfig().getFrontRequestUrl(); 74 | 75 | /** 76 | * 创建表单 77 | */ 78 | String html = createHtml(requestFrontUrl, submitFromData); 79 | System.out.println(html); 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_3_ConsumeUndo.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.unionpay.acp.sdk.SDKConfig; 9 | 10 | /** 11 | * 名称: 第一卷 商户卷 第1\5\6部分 跳转网关支付产品\手机控件支付产品\手机网页支付产品
12 | * 功能: 6.3 消费撤销类交易
13 | * 版本: 5.0
14 | * 日期: 2014-07
15 | * 作者: 中国银联ACP团队
16 | * 版权: 中国银联
17 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
18 | */ 19 | public class Form_6_3_ConsumeUndo extends DemoBase { 20 | 21 | public static void main(String[] args) { 22 | 23 | /** 24 | * 参数初始化 25 | * 在java main 方式运行时必须每次都执行加载 26 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 27 | */ 28 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 29 | 30 | /** 31 | * 组装请求报文 32 | */ 33 | Map data = new HashMap(); 34 | // 版本号 35 | data.put("version", "5.0.0"); 36 | // 字符集编码 默认"UTF-8" 37 | data.put("encoding", "UTF-8"); 38 | // 签名方法 01 RSA 39 | data.put("signMethod", "01"); 40 | // 交易类型 41 | data.put("txnType", "31"); 42 | // 交易子类型 43 | data.put("txnSubType", "00"); 44 | // 业务类型 45 | data.put("bizType", "000201"); 46 | // 渠道类型,07-PC,08-手机 47 | data.put("channelType", "08"); 48 | // 前台通知地址 ,控件接入方式无作用 49 | data.put("frontUrl", "http://localhost:8080/ACPTest/acp_front_url.do"); 50 | // 后台通知地址 51 | data.put("backUrl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do"); 52 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 53 | data.put("accessType", "0"); 54 | // 商户号码,请改成自己的商户号 55 | data.put("merId", "888888888888888"); 56 | //原消费的queryId,可以从查询接口或者通知接口中获取 57 | data.put("origQryId", "201502112158205063088"); 58 | // 商户订单号,8-40位数字字母,重新产生,不同于原消费 59 | data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 60 | // 订单发送时间,取系统时间 61 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 62 | // 交易金额,消费撤销时需和原消费一致 63 | data.put("txnAmt", "1"); 64 | // 交易币种 65 | data.put("currencyCode", "156"); 66 | // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 67 | // data.put("reqReserved", "透传信息"); 68 | 69 | data = signData(data); 70 | 71 | // 交易请求url 从配置文件读取 72 | String url = SDKConfig.getConfig().getBackRequestUrl(); 73 | 74 | Map resmap = submitUrl(data, url); 75 | 76 | System.out.println("请求报文=[" + data.toString() + "]"); 77 | System.out.println("应答报文=[" + resmap.toString() + "]"); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_4_Refund.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import com.unionpay.acp.sdk.SDKConfig; 4 | 5 | import java.text.SimpleDateFormat; 6 | import java.util.Date; 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | /** 11 | * 名称: 第一卷 商户卷 第1\5\6部分 跳转网关支付产品\手机控件支付产品\手机网页支付产品
12 | * 功能:6.4 退货类交易
13 | * 版本: 5.0
14 | * 日期: 2014-07
15 | * 作者: 中国银联ACP团队
16 | * 版权: 中国银联
17 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
18 | */ 19 | public class Form_6_4_Refund extends DemoBase { 20 | 21 | public static void main(String[] args) throws InterruptedException { 22 | 23 | /** 24 | * 参数初始化 25 | * 在java main 方式运行时必须每次都执行加载 26 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 27 | */ 28 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 29 | 30 | /** 31 | * 组装请求报文 32 | */ 33 | Map data = new HashMap(); 34 | // 版本号 35 | data.put("version", "5.0.0"); 36 | // 字符集编码 默认"UTF-8" 37 | data.put("encoding", "UTF-8"); 38 | // 签名方法 01 RSA 39 | data.put("signMethod", "01"); 40 | // 交易类型 41 | data.put("txnType", "04"); 42 | // 交易子类型 43 | data.put("txnSubType", "00"); 44 | // 业务类型 45 | data.put("bizType", "000201"); 46 | // 渠道类型,07-PC,08-手机 47 | data.put("channelType", "08"); 48 | // 前台通知地址 ,控件接入方式无作用 49 | data.put("frontUrl", "http://localhost:8080/ACPTest/acp_front_url.do"); 50 | // 后台通知地址 51 | data.put("backUrl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do"); 52 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 53 | data.put("accessType", "0"); 54 | // 商户号码,请改成自己的商户号 55 | data.put("merId", "888888888888888"); 56 | //原消费的queryId,可以从查询接口或者通知接口中获取 57 | data.put("origQryId", "201502252152025421848"); 58 | // 商户订单号,8-40位数字字母,重新产生,不同于原消费 59 | data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 60 | // 订单发送时间,取系统时间 61 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 62 | // 交易金额 63 | data.put("txnAmt", "1"); 64 | // 交易币种 65 | data.put("currencyCode", "156"); 66 | // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 67 | // data.put("reqReserved", "透传信息"); 68 | 69 | data = signData(data); 70 | 71 | // 交易请求url 从配置文件读取 72 | String url = SDKConfig.getConfig().getBackRequestUrl(); 73 | 74 | Map resmap = submitUrl(data, url); 75 | 76 | // resmap 里返回报文中 77 | // 银联订单号 tn 商户推送订单后银联移动支付系统返回该流水号,商户调用支付控件时使用 78 | System.out.println("请求报文=[" + data.toString() + "]"); 79 | System.out.println("应答报文=[" + resmap.toString() + "]"); 80 | 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_5_Query.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import com.unionpay.acp.sdk.SDKConfig; 7 | 8 | /** 9 | * 名称: 第一卷 商户卷 第1\5\6部分 跳转网关支付产品\手机控件支付产品\手机网页支付产品
10 | * 功能:6.5 交易状态查询交易
11 | * 版本: 5.0
12 | * 日期: 2014-07
13 | * 作者: 中国银联ACP团队
14 | * 版权: 中国银联
15 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
16 | */ 17 | public class Form_6_5_Query extends DemoBase { 18 | 19 | public static void main(String[] args) throws InterruptedException { 20 | 21 | /** 22 | * 参数初始化 23 | * 在java main 方式运行时必须每次都执行加载 24 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 25 | */ 26 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 27 | 28 | /** 29 | * 组装请求报文 30 | */ 31 | Map data = new HashMap(); 32 | // 版本号 33 | data.put("version", "5.0.0"); 34 | // 字符集编码 默认"UTF-8" 35 | data.put("encoding", "UTF-8"); 36 | // 签名方法 01 RSA 37 | data.put("signMethod", "01"); 38 | // 交易类型 39 | data.put("txnType", "00"); 40 | // 交易子类型 41 | data.put("txnSubType", "00"); 42 | // 业务类型 43 | data.put("bizType", "000000"); 44 | // 渠道类型,07-PC,08-手机 45 | data.put("channelType", "08"); 46 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 47 | data.put("accessType", "0"); 48 | // 商户号码,请改成自己的商户号 49 | data.put("merId", "888888888888888"); 50 | // 商户订单号,请修改被查询的交易的订单号 51 | data.put("orderId", "20150211215817604"); 52 | // 订单发送时间,请修改被查询的交易的订单发送时间 53 | data.put("txnTime", "20150211215817"); 54 | 55 | data = signData(data); 56 | 57 | // 交易请求url 从配置文件读取 58 | String url = SDKConfig.getConfig().getSingleQueryUrl(); 59 | 60 | Map resmap = submitUrl(data, url); 61 | 62 | System.out.println("请求报文=[" + data.toString() + "]"); 63 | System.out.println("应答报文=[" + resmap.toString() + "]"); 64 | 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_6_FileTransfer.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.unionpay.acp.sdk.SDKConfig; 9 | 10 | /** 11 | * 名称: 第一卷 商户卷 第1\5\6部分 跳转网关支付产品\手机控件支付产品\手机网页支付产品
12 | * 功能: 6.6 文件传输类交易
13 | * 版本: 5.0
14 | * 日期: 2014-07
15 | * 作者: 中国银联ACP团队
16 | * 版权: 中国银联
17 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
18 | */ 19 | public class Form_6_6_FileTransfer extends DemoBase { 20 | 21 | public static void main(String[] args) { 22 | 23 | 24 | /** 25 | * 参数初始化 26 | * 在java main 方式运行时必须每次都执行加载 27 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 28 | */ 29 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 30 | 31 | /** 32 | * 组装请求报文 33 | */ 34 | Map data = new HashMap(); 35 | // 版本号 36 | data.put("version", "5.0.0"); 37 | // 字符集编码 默认"UTF-8" 38 | data.put("encoding", "UTF-8"); 39 | // 签名方法 01 RSA 40 | data.put("signMethod", "01"); 41 | // 交易类型 42 | data.put("txnType", "76"); 43 | // 交易子类型 44 | data.put("txnSubType", "01"); 45 | // 业务类型 46 | data.put("bizType", "000000"); 47 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 48 | data.put("accessType", "0"); 49 | // 商户代码,请替换实际商户号测试,如使用的是自助化平台注册的商户号,该商户号没有权限测文件下载接口的,请使用测试参数里写的文件下载的商户号和日期测。如需真实交易文件,请使用自助化平台下载文件。 50 | data.put("merId", "700000000000001"); 51 | // 清算日期 52 | data.put("settleDate", "0119"); 53 | // 订单发送时间,取系统时间 54 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 55 | // 文件类型 56 | data.put("fileType", "00"); 57 | 58 | data = signData(data); 59 | 60 | // 交易请求url 从配置文件读取 61 | String url = SDKConfig.getConfig().getFileTransUrl(); 62 | 63 | Map resmap = submitUrl(data, url); 64 | 65 | System.out.println("请求报文=[" + data.toString() + "]"); 66 | System.out.println("应答报文=[" + resmap.toString() + "]"); 67 | 68 | // 解析返回报文的文件流 69 | deCodeFileContent(resmap); 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_7_1_AuthDeal_App.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.unionpay.acp.sdk.SDKConfig; 9 | 10 | /**。 11 | * 名称: 第一卷 商户卷 第5部分 手机支付 ——手机控件支付产品
12 | * 功能: 6.7.1 预授权交易
13 | * 前台交易类
14 | * 版本: 5.0
15 | * 日期: 2014-07
16 | * 作者: 中国银联ACP团队
17 | * 版权: 中国银联
18 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
19 | */ 20 | public class Form_6_7_1_AuthDeal_App extends DemoBase { 21 | 22 | public static void main(String[] args) { 23 | 24 | /** 25 | * 参数初始化 26 | * 在java main 方式运行时必须每次都执行加载 27 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 28 | */ 29 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 30 | 31 | /** 32 | * 组装请求报文 33 | */ 34 | Map data = new HashMap(); 35 | // 版本号 36 | data.put("version", "5.0.0"); 37 | // 字符集编码 默认"UTF-8" 38 | data.put("encoding", "UTF-8"); 39 | // 签名方法 01 RSA 40 | data.put("signMethod", "01"); 41 | // 交易类型 01-消费 42 | data.put("txnType", "02"); 43 | // 交易子类型 01:自助消费 02:订购 03:分期付款 44 | data.put("txnSubType", "01"); 45 | // 业务类型 46 | data.put("bizType", "000201"); 47 | // 渠道类型,07-PC,08-手机 48 | data.put("channelType", "08"); 49 | // 前台通知地址 ,控件接入方式无作用 50 | data.put("frontUrl", "http://localhost:8080/ACPTest/acp_front_url.do"); 51 | // 后台通知地址 52 | data.put("backUrl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do"); 53 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 54 | data.put("accessType", "0"); 55 | // 商户号码,请改成自己的商户号 56 | data.put("merId", "888888888888888"); 57 | // 商户订单号,8-40位数字字母 58 | data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 59 | // 订单发送时间,取系统时间 60 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 61 | // 交易金额,单位分 62 | data.put("txnAmt", "1"); 63 | // 交易币种 64 | data.put("currencyCode", "156"); 65 | // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 66 | // data.put("reqReserved", "透传信息"); 67 | // 订单描述,可不上送,上送时控件中会显示该信息 68 | // data.put("orderDesc", "订单描述"); 69 | 70 | data = signData(data); 71 | 72 | // 交易请求url 从配置文件读取 73 | String requestAppUrl = SDKConfig.getConfig().getAppRequestUrl(); 74 | 75 | Map resmap = submitUrl(data, requestAppUrl); 76 | 77 | System.out.println("请求报文=[" + data.toString() + "]"); 78 | System.out.println("应答报文=[" + resmap.toString() + "]"); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_7_1_AuthDeal_Front.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.unionpay.acp.sdk.SDKConfig; 9 | 10 | /** 11 | * 名称: 第一卷 商户卷 第1/6部分 手机支付 ——跳转网关支付产品/手机网页支付产品
12 | * 功能: 6.7.1 预授权交易
13 | * 前台交易类
14 | * 版本: 5.0
15 | * 日期: 2014-07
16 | * 作者: 中国银联ACP团队
17 | * 版权: 中国银联
18 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
19 | */ 20 | public class Form_6_7_1_AuthDeal_Front extends DemoBase { 21 | 22 | public static void main(String[] args) { 23 | 24 | /** 25 | * 参数初始化 26 | * 在java main 方式运行时必须每次都执行加载 27 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 28 | */ 29 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 30 | 31 | /** 32 | * 组装请求报文 33 | */ 34 | Map data = new HashMap(); 35 | // 版本号 36 | data.put("version", "5.0.0"); 37 | // 字符集编码 默认"UTF-8" 38 | data.put("encoding", "UTF-8"); 39 | // 签名方法 01 RSA 40 | data.put("signMethod", "01"); 41 | // 交易类型 01-消费 42 | data.put("txnType", "01"); 43 | // 交易子类型 01:自助消费 02:订购 03:分期付款 44 | data.put("txnSubType", "01"); 45 | // 业务类型 46 | data.put("bizType", "000201"); 47 | // 渠道类型,07-PC,08-手机 48 | data.put("channelType", "07"); 49 | // 前台通知地址 ,控件接入方式无作用 50 | data.put("frontUrl", "http://101.231.204.84:11006/ACPTest/FrontRcvResponse.do"); 51 | // 后台通知地址 52 | data.put("backUrl", "http://101.231.204.84:11006/ACPTest/BackRcvResponse.do"); 53 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 54 | data.put("accessType", "0"); 55 | // 商户号码,请改成自己的商户号 56 | //data.put("merId", "802053248990067"); 57 | //data.put("merId", "808080580004811"); 58 | data.put("merId", "700000000000001"); 59 | 60 | 61 | // 商户订单号,8-40位数字字母 62 | data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 63 | // 订单发送时间,取系统时间 64 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 65 | // 交易金额,单位分 66 | data.put("txnAmt", "10"); 67 | // 交易币种 68 | data.put("currencyCode", "156"); 69 | // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 70 | // data.put("reqReserved", "透传信息"); 71 | // 订单描述,可不上送,上送时控件中会显示该信息 72 | // data.put("orderDesc", "订单描述"); 73 | 74 | 75 | //后台类交易且卡号上送;跨行收单且收单机构收集银行卡信息时上送01:银行卡02:存折03:C卡默认取值:01取值“03”表示以IC终端发起的IC卡交易,IC作为普通银行卡进行支付时,此域填写为“01” 76 | 77 | //data.put("accType", "01"); 78 | 79 | Map submitFromData = signData(data); 80 | 81 | // 交易请求url 从配置文件读取 82 | // 交易请求url 从配置文件读取 83 | String requestFrontUrl = SDKConfig.getConfig().getFrontRequestUrl(); 84 | 85 | /** 86 | * 创建表单 87 | */ 88 | String html = createHtml(requestFrontUrl, submitFromData); 89 | System.out.println(html); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_7_2_AuthUndo.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.unionpay.acp.sdk.SDKConfig; 9 | 10 | /** 11 | * 名称: 第一卷 商户卷 第1\5\6部分 跳转网关支付产品\手机控件支付产品\手机网页支付产品
12 | * 功能: 6.7.2 预授权撤销交易
13 | * 版本: 5.0
14 | * 日期: 2014-07
15 | * 作者: 中国银联ACP团队
16 | * 版权: 中国银联
17 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
18 | */ 19 | public class Form_6_7_2_AuthUndo extends DemoBase { 20 | 21 | public static void main(String[] args) { 22 | 23 | /** 24 | * 参数初始化 25 | * 在java main 方式运行时必须每次都执行加载 26 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 27 | */ 28 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 29 | 30 | /** 31 | * 组装请求报文 32 | */ 33 | Map data = new HashMap(); 34 | // 版本号 35 | data.put("version", "5.0.0"); 36 | // 字符集编码 默认"UTF-8" 37 | data.put("encoding", "UTF-8"); 38 | // 签名方法 01 RSA 39 | data.put("signMethod", "01"); 40 | // 交易类型 41 | data.put("txnType", "32"); 42 | // 交易子类型 43 | data.put("txnSubType", "00"); 44 | // 业务类型 45 | data.put("bizType", "000201"); 46 | // 渠道类型,07-PC,08-手机 47 | data.put("channelType", "08"); 48 | // 前台通知地址 ,控件接入方式无作用 49 | data.put("frontUrl", "http://localhost:8080/ACPTest/acp_front_url.do"); 50 | // 后台通知地址 51 | data.put("backUrl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do"); 52 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 53 | data.put("accessType", "0"); 54 | // 商户号码,请改成自己的商户号 55 | data.put("merId", "888888888888888"); 56 | // 原预授权的queryId,可以从查询接口或者通知接口中获取 57 | data.put("origQryId", "201502282020185545888"); 58 | // 商户订单号,8-40位数字字母,重新产生,不同于原交易 59 | data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 60 | // 订单发送时间,取系统时间 61 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 62 | // 交易金额,撤销时需和原预授权一致 63 | data.put("txnAmt", "1"); 64 | // 交易币种 65 | data.put("currencyCode", "156"); 66 | // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 67 | // data.put("reqReserved", "透传信息"); 68 | 69 | data = signData(data); 70 | 71 | // 交易请求url 从配置文件读取 72 | String url = SDKConfig.getConfig().getBackRequestUrl(); 73 | 74 | Map resmap = submitUrl(data, url); 75 | 76 | System.out.println("请求报文=[" + data.toString() + "]"); 77 | System.out.println("应答报文=[" + resmap.toString() + "]"); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_7_3_AuthFinish.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.unionpay.acp.sdk.SDKConfig; 9 | 10 | /** 11 | * 名称: 第一卷 商户卷 第1\5\6部分 跳转网关支付产品\手机控件支付产品\手机网页支付产品
12 | * 功能: 6.7.3 预授权完成交易
13 | * 版本: 5.0
14 | * 日期: 2014-07
15 | * 作者: 中国银联ACP团队
16 | * 版权: 中国银联
17 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
18 | */ 19 | public class Form_6_7_3_AuthFinish extends DemoBase { 20 | 21 | public static void main(String[] args) { 22 | 23 | /** 24 | * 参数初始化 25 | * 在java main 方式运行时必须每次都执行加载 26 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 27 | */ 28 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 29 | 30 | /** 31 | * 组装请求报文 32 | */ 33 | Map data = new HashMap(); 34 | // 版本号 35 | data.put("version", "5.0.0"); 36 | // 字符集编码 默认"UTF-8" 37 | data.put("encoding", "UTF-8"); 38 | // 签名方法 01 RSA 39 | data.put("signMethod", "01"); 40 | // 交易类型 41 | data.put("txnType", "03"); 42 | // 交易子类型 43 | data.put("txnSubType", "00"); 44 | // 业务类型 45 | data.put("bizType", "000201"); 46 | // 渠道类型,07-PC,08-手机 47 | data.put("channelType", "08"); 48 | // 前台通知地址 ,控件接入方式无作用 49 | data.put("frontUrl", "http://localhost:8080/ACPTest/acp_front_url.do"); 50 | // 后台通知地址 51 | data.put("backUrl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do"); 52 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 53 | data.put("accessType", "0"); 54 | // 商户号码,请改成自己的商户号 55 | data.put("merId", "888888888888888"); 56 | // 原预授权的queryId,可以从查询接口或者通知接口中获取 57 | data.put("origQryId", "201502282020185545888"); 58 | // 商户订单号,8-40位数字字母,重新产生,不同于原交易 59 | data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 60 | // 订单发送时间,取系统时间 61 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 62 | // 交易金额,小于等于原预授权金额的115% 63 | data.put("txnAmt", "1"); 64 | // 交易币种 65 | data.put("currencyCode", "156"); 66 | // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 67 | // data.put("reqReserved", "透传信息"); 68 | 69 | data = signData(data); 70 | 71 | // 交易请求url 从配置文件读取 72 | String url = SDKConfig.getConfig().getBackRequestUrl(); 73 | 74 | Map resmap = submitUrl(data, url); 75 | 76 | System.out.println("请求报文=[" + data.toString() + "]"); 77 | System.out.println("应答报文=[" + resmap.toString() + "]"); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/hugnew/sps/services/pay/util/web/unionpay/util/Form_6_7_4_AutnFinishUndo.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.sps.services.pay.util.web.unionpay.util; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | import com.unionpay.acp.sdk.SDKConfig; 9 | 10 | /** 11 | * 名称: 第一卷 商户卷 第1\5\6部分 跳转网关支付产品\手机控件支付产品\手机网页支付产品
12 | * 功能: 6.7.4 预授权完成撤销交易
13 | * 版本: 5.0
14 | * 日期: 2014-07
15 | * 作者: 中国银联ACP团队
16 | * 版权: 中国银联
17 | * 说明:以下代码只是为了方便商户测试而提供的样例代码,商户可以根据自己需要,按照技术文档编写。该代码仅供参考。
18 | */ 19 | public class Form_6_7_4_AutnFinishUndo extends DemoBase { 20 | 21 | public static void main(String[] args) { 22 | 23 | /** 24 | * 参数初始化 25 | * 在java main 方式运行时必须每次都执行加载 26 | * 如果是在web应用开发里,这个方写在可使用监听的方式写入缓存,无须在这出现 27 | */ 28 | SDKConfig.getConfig().loadPropertiesFromSrc();// 从classpath加载acp_sdk.properties文件 29 | 30 | /** 31 | * 组装请求报文 32 | */ 33 | Map data = new HashMap(); 34 | // 版本号 35 | data.put("version", "5.0.0"); 36 | // 字符集编码 默认"UTF-8" 37 | data.put("encoding", "UTF-8"); 38 | // 签名方法 01 RSA 39 | data.put("signMethod", "01"); 40 | // 交易类型 41 | data.put("txnType", "33"); 42 | // 交易子类型 43 | data.put("txnSubType", "00"); 44 | // 业务类型 45 | data.put("bizType", "000201"); 46 | // 渠道类型,07-PC,08-手机 47 | data.put("channelType", "08"); 48 | // 前台通知地址 ,控件接入方式无作用 49 | data.put("frontUrl", "http://localhost:8080/ACPTest/acp_front_url.do"); 50 | // 后台通知地址 51 | data.put("backUrl", "http://222.222.222.222:8080/ACPTest/acp_back_url.do"); 52 | // 接入类型,商户接入填0 0- 商户 , 1: 收单, 2:平台商户 53 | data.put("accessType", "0"); 54 | // 商户号码,请改成自己的商户号 55 | data.put("merId", "888888888888888"); 56 | // 原预授权完成的queryId,可以从查询接口或者通知接口中获取 57 | data.put("origQryId", "201502282031485545928"); 58 | // 商户订单号,8-40位数字字母,重新产生,不同于原交易 59 | data.put("orderId", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 60 | // 订单发送时间,取系统时间 61 | data.put("txnTime", new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())); 62 | // 交易金额,撤销时需和原预授权完成一致 63 | data.put("txnAmt", "1"); 64 | // 交易币种 65 | data.put("currencyCode", "156"); 66 | // 请求方保留域,透传字段,查询、通知、对账文件中均会原样出现 67 | // data.put("reqReserved", "透传信息"); 68 | 69 | data = signData(data); 70 | 71 | // 交易请求url 从配置文件读取 72 | String url = SDKConfig.getConfig().getBackRequestUrl(); 73 | 74 | Map resmap = submitUrl(data, url); 75 | 76 | System.out.println("请求报文=[" + data.toString() + "]"); 77 | System.out.println("应答报文=[" + resmap.toString() + "]"); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/resources/acp_sdk.properties: -------------------------------------------------------------------------------- 1 | ###### SDK \u914D\u7F6E\u6587\u4EF6 \u914D\u7F6E\u6587\u4EF6\u4E2D\u65E5\u5FD7\u548C\u8BC1\u4E66\u7684\u5B58\u653E\u8DEF\u5F84\u6839\u636E\u5B9E\u9645\u60C5\u51B5\u914D\u7F6E\uFF0C\u4EA4\u6613\u5730\u5740\u548C\u8BC1\u4E66\u6839\u636EPM\u73AF\u5883\u3001\u751F\u4EA7\u73AF\u5883\u914D\u5957\u914D\u7F6E##### 2 | #SDK \u65E5\u5FD7\u76EE\u5F55\u914D\u7F6E 3 | 4 | ##########################\u4EA4\u6613\u53D1\u9001\u5730\u5740\u914D\u7F6E############################# 5 | ######(\u4EE5\u4E0B\u914D\u7F6E\u4E3A\u751F\u4EA7\u73AF\u5883\u4EA4\u6613\u5730\u5740)####### 6 | ##\u524D\u53F0\u4EA4\u6613\u8BF7\u6C42\u5730\u5740 7 | acpsdk.frontTransUrl=https://gateway.95516.com/gateway/api/frontTransReq.do 8 | ## app \u4EA4\u6613\u8BF7\u6C42\u5730\u5740 9 | acpsdk.appTransUrl=https://gateway.95516.com/gateway/api/appTransReq.do 10 | ##\u540E\u53F0\u4EA4\u6613\u8BF7\u6C42\u5730\u5740 11 | acpsdk.backTransUrl=https://gateway.95516.com/gateway/api/backTransReq.do 12 | ##\u540E\u53F0\u4EA4\u6613\u8BF7\u6C42\u5730\u5740(\u82E5\u4E3A\u6709\u5361\u4EA4\u6613\u914D\u7F6E\u8BE5\u5730\u5740) 13 | acpsdk.cardTransUrl=https://gateway.95516.com/gateway/api/cardTransReq.do 14 | ##\u5355\u7B14\u67E5\u8BE2\u8BF7\u6C42\u5730\u5740 15 | acpsdk.singleQueryUrl=https://gateway.95516.com/gateway/api/queryTrans.do 16 | ##\u6279\u91CF\u4EA4\u6613\u8BF7\u6C42\u5730\u5740 17 | acpsdk.batchTransUrl=https://gateway.95516.com/gateway/api/batchTrans.do 18 | ##\u6587\u4EF6\u4F20\u8F93\u7C7B\u4EA4\u6613\u5730\u5740 19 | acpsdk.fileTransUrl=https://filedownload.95516.com/ 20 | 21 | 22 | 23 | #########################\u7B7E\u540D\u8BC1\u4E66\u914D\u7F6E ################################ 24 | ######(\u4EE5\u4E0B\u914D\u7F6E\u4E3A\u751F\u4EA7\u73AF\u5883\u914D\u7F6E\uFF0C\u8BF7\u6839\u636E\u5546\u6237\u7CFB\u7EDF\u81EA\u8EAB\u60C5\u51B5\u4FEE\u6539)####### 25 | ##\u7B7E\u540D\u8BC1\u4E66\u8DEF\u5F84 \uFF08\u8054\u7CFB\u8FD0\u8425\u83B7\u53D6\u4E24\u7801\uFF0C\u5728CFCA\u7F51\u7AD9\u4E0B\u8F7D\u540E\u914D\u7F6E\uFF0C\u81EA\u884C\u8BBE\u7F6E\u8BC1\u4E66\u5BC6\u7801\u5E76\u914D\u7F6E\uFF09 26 | #acpsdk.signCert.path=C:\\certsProduct\\802053248990067.pfx 27 | #linux\u4E0B\u76EE\u5F55\u5206\u9694\u7B26 28 | acpsdk.signCert.path=WEB-INF/classes/certsProduct/802053248990067.pfx 29 | #window\u4E0B\u6D4B\u8BD5 30 | #acpsdk.signCert.path=WEB-INF\\classes\\certsProduct\\802053248990067.pfx 31 | /home/left/opt/certsProduct 32 | ##\u7B7E\u540D\u8BC1\u4E66\u5BC6\u7801 33 | acpsdk.signCert.pwd=hugnew 34 | ##\u7B7E\u540D\u8BC1\u4E66\u7C7B\u578B 35 | acpsdk.signCert.type=PKCS12 36 | 37 | 38 | ##########################\u9A8C\u7B7E\u8BC1\u4E66\u914D\u7F6E################################ 39 | ##\u9A8C\u8BC1\u7B7E\u540D\u8BC1\u4E66\u76EE\u5F55 40 | #acpsdk.validateCert.dir=d:\\certsProduct\\ 41 | #acpsdk.validateCert.dir=/home/left/opt/certsProduct 42 | #linux\u4E0B\u76EE\u5F55\u5206\u9694\u7B26 43 | acpsdk.validateCert.dir=WEB-INF/classes/certsProduct 44 | #windows\u4E0B\u4F5C\u6D4B\u8BD5\u65F6\u7684\u5206\u9694\u7B26 45 | #acpsdk.validateCert.dir=WEB-INF\\classes\\certsProduct 46 | 47 | -------------------------------------------------------------------------------- /src/main/resources/ceb-product/cebmerchantreal.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/ceb-product/cebmerchantreal.jks -------------------------------------------------------------------------------- /src/main/resources/ceb_merchant.properties: -------------------------------------------------------------------------------- 1 | development=no 2 | cafile=C:/ceb-product/cebmerchantreal.jks 3 | 4 | #store_password=hugnew 5 | store_password=hugnew 6 | alias_key=hugnew 7 | #alias_key=hugnew 8 | key_alias=hugnew 9 | key_password=hugnew 10 | #key_password=hugnew 11 | 12 | alias_paygate=hugnew 13 | 14 | -------------------------------------------------------------------------------- /src/main/resources/certsProduct/ScriptX.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/ScriptX.keystore -------------------------------------------------------------------------------- /src/main/resources/certsProduct/UpopRsaCert.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/UpopRsaCert.cer -------------------------------------------------------------------------------- /src/main/resources/certsProduct/cebmerchant.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/cebmerchant.jks -------------------------------------------------------------------------------- /src/main/resources/certsProduct/electronicInvoice.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/electronicInvoice.cer -------------------------------------------------------------------------------- /src/main/resources/certsProduct/electronicInvoice.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/electronicInvoice.keystore -------------------------------------------------------------------------------- /src/main/resources/certsProduct/encryptpub.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/encryptpub.cer -------------------------------------------------------------------------------- /src/main/resources/certsProduct/hugnew.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/hugnew.keystore -------------------------------------------------------------------------------- /src/main/resources/certsProduct/hugneweinv.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/hugneweinv.cer -------------------------------------------------------------------------------- /src/main/resources/certsProduct/hugnewhes.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/hugnewhes.keystore -------------------------------------------------------------------------------- /src/main/resources/certsProduct/readme.txt: -------------------------------------------------------------------------------- 1 | ebpp.cer 生产验签证书 2 | encryptpub.cer 生产加密证书 3 | UpopRsaCert.cer 银联公钥证书 -------------------------------------------------------------------------------- /src/main/resources/certsProduct/xxxx.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsProduct/xxxx.pfx -------------------------------------------------------------------------------- /src/main/resources/certsTest/PM_acp.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsTest/PM_acp.pfx -------------------------------------------------------------------------------- /src/main/resources/certsTest/acp_test_verify_sign.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsTest/acp_test_verify_sign.cer -------------------------------------------------------------------------------- /src/main/resources/certsTest/kf.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/certsTest/kf.cer -------------------------------------------------------------------------------- /src/main/resources/generatorConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %X{req.remoteHost} %X{req.requestURI} %logger{36} - %msg %n 6 | 7 | 8 | 9 | TRACE 10 | 11 | 12 | 13 | 14 | 15 | 16 | /var/log/sps/core/sps-core.%d{yyyy-MM-dd_HH}.log 17 | 18 | 19 | 48 20 | 21 | 22 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %X{req.remoteHost} %X{req.requestURI} %logger{36} - %msg %n 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | /var/log/sps/error/sps-error.%d{yyyy-MM-dd_HH}.log 31 | 32 | 33 | 48 34 | 35 | 36 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %X{req.remoteHost} %X{req.requestURI} %logger{36} - %msg %n 37 | 38 | 39 | 40 | WARN 41 | 42 | System.err 43 | 44 | 45 | 46 | 47 | 48 | /var/log/sps/run/sps-run.%d{yyyy-MM-dd_HH}.log 49 | 50 | 51 | 48 52 | 53 | 54 | 55 | %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %X{req.remoteHost} %X{req.requestURI} %logger{36} - %msg %n 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/main/resources/mybatis_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/payNotify_config.properties: -------------------------------------------------------------------------------- 1 | 2 | pay.notify.unionpay.url=http://hugnew.com/PayMap/open/payNotify/unionPayNotify 3 | pay.notify.unionpayWeb.url=http://hugnew.com/PayMap/open/payNotify/unionPayNotifyWeb 4 | pay.notify.alipay.main.url=http://hugnew.com/PayMap/open/payNotify/alipayNotifyMain 5 | pay.notify.alipay.bonded.url=http://hugnew.com/PayMap/open/payNotify/alipayNotifyBonded 6 | pay.notify.alipay.global.url=http://hugnew.com/PayMap/open/payNotify/alipayNotifyGlobal 7 | wechat.pay.notify.url=http://hugnew.com/PayMap/open/payNotify/wechatNotify 8 | 9 | pay.notify.alipay.mainApp.url=http://hugnew.com/PayMap/open/payNotify/alipayNotifyMainApp 10 | pay.notify.alipay.bondedApp.url=http://hugnew.com/PayMap/open/payNotify/alipayNotifyBondedApp 11 | pay.notify.alipay.globalApp.url=http://hugnew.com/PayMap/open/payNotify/alipayNotifyGlobalApp 12 | pay.notify.psbc.url=http://hugnew.com/PayMap/open/payNotify/psbcNotify 13 | pay.notify.ceb.url=http://hugnew.com/PayMap/open/payNotify/cebNotify 14 | pay.notify.ceb.gateway.url=http://hugnew.com/PayMap/open/payNotify/cebGatewayNotify -------------------------------------------------------------------------------- /src/main/resources/psbc-merchant-toolkit/pro-env/merchant.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/psbc-merchant-toolkit/pro-env/merchant.pfx -------------------------------------------------------------------------------- /src/main/resources/psbc-merchant-toolkit/pro-env/psbc_merchant.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/psbc-merchant-toolkit/pro-env/psbc_merchant.jks -------------------------------------------------------------------------------- /src/main/resources/psbc-merchant-toolkit/psbc_merchant.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/psbc-merchant-toolkit/psbc_merchant.jks -------------------------------------------------------------------------------- /src/main/resources/psbc-merchant-toolkit/test-env/merchant.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/psbc-merchant-toolkit/test-env/merchant.pfx -------------------------------------------------------------------------------- /src/main/resources/psbc_merchant.properties: -------------------------------------------------------------------------------- 1 | #PFX\u6587\u4EF6\u8DEF\u5F84 2 | psbc.pfx.file=C:/psbc-merchant-toolkit/pro-env/merchant.pfx 3 | 4 | #PFX\u5BC6\u7801 5 | psbc.pfx.password=hugnew 6 | 7 | #JKS\u6587\u4EF6\u8DEF\u5F84 8 | psbc.jks.file=C:/psbc-merchant-toolkit/pro-env/psbc_merchant.jks 9 | 10 | #JKS\u6587\u4EF6\u5BC6\u7801 11 | psbc.jks.password=hugnew 12 | 13 | #\u5546\u6237\u8BC1\u4E66\u522B\u540D 14 | psbc.merchant.key.alias=hugnew 15 | 16 | #\u5546\u6237\u79C1\u94A5\u5BC6\u7801 17 | psbc.merchant.key.password=hugnew 18 | 19 | #\u652F\u4ED8\u7F51\u5173\u8BC1\u4E66\u522B\u540D 20 | psbc.paygate.key.alias=hugnew 21 | 22 | -------------------------------------------------------------------------------- /src/main/resources/ready.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/resources/ready.keystore -------------------------------------------------------------------------------- /src/main/resources/server_config.properties: -------------------------------------------------------------------------------- 1 | #MySQL 2 | mysql.jdbc.url=jdbc:mysql://127.0.0.1:3306/sps_db?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true 3 | mysql.jdbc.username=hugnew 4 | mysql.jdbc.password=hugnew 5 | mysql.jdbc.initialSize=10 6 | mysql.jdbc.minIdle=10 7 | mysql.jdbc.maxActive=100 8 | mysql.jdbc.maxWait=60000 9 | mysql.jdbc.timeBetweenEvictionRunsMillis=60000 10 | mysql.jdbc.minEvictableIdleTimeMillis=300000 11 | mysql.jdbc.removeAbandonedTimeout=7200 12 | mysql.jdbc.validationQuery=SELECT 'x' 13 | mysql.jdbc.testWhileIdle=true 14 | mysql.jdbc.testOnBorrow=false 15 | mysql.jdbc.testOnReturn=false 16 | mysql.jdbc.filters=slf4j 17 | mysql.jdbc.removeAbandoned=true 18 | mysql.jdbc.logAbandoned=true 19 | 20 | #Redis 21 | redis.ip=127.0.0.1 22 | redis.port=6379 23 | redis.timeout=6000 24 | #Redis-pool 25 | redis.pool.maxTotal=10000 26 | redis.pool.maxIdle=1000 27 | redis.pool.testOnBorrow=true 28 | 29 | #RabbitMQ 30 | rabbitmq.master.ip=127.0.0.1 31 | rabbitmq.master.port=5672 32 | rabbitmq.master.username=hugnew 33 | rabbitmq.master.password=hugnew 34 | 35 | -------------------------------------------------------------------------------- /src/main/resources/spring_mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 | 29 | 30 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/main/resources/spring_rabbitmq.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/resources/spring_shiro.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | /=anon 42 | /index.jsp=anon 43 | /app/**=stateless 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/main/resources/sql/sps_member.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE sps_db.sps_member( 2 | id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT ''用户ID'', 3 | username VARCHAR(200) DEFAULT '''' COMMENT ''用户名'', 4 | userCode VARCHAR(200) DEFAULT '''' COMMENT ''用户唯一推广编码'', 5 | userLabel INT(11) DEFAULT 1 COMMENT ''用户标签'', 6 | `password` VARCHAR(1000) DEFAULT '''' COMMENT ''用户密码'', 7 | salt VARCHAR(100) DEFAULT '''' COMMENT ''密码加密的盐'', 8 | status INT(11) DEFAULT 1 COMMENT ''用户状态:1 正常 /0 禁用'', 9 | grade INT(11) DEFAULT 1 COMMENT ''会员级别'', 10 | realName VARCHAR(100) DEFAULT '''' COMMENT ''真实姓名'', 11 | nickName VARCHAR(100) DEFAULT '''' COMMENT ''昵称'', 12 | showImage VARCHAR(500) DEFAULT '''' COMMENT ''用户头像'', 13 | birthday BIGINT(20) DEFAULT 0 COMMENT ''生日'', 14 | birthdayStr VARCHAR(100) DEFAULT ''0'' COMMENT ''生日字符串'', 15 | sex INT(11) DEFAULT 0 COMMENT ''性别:0 女 / 1 男'', 16 | email VARCHAR(100) DEFAULT '''' COMMENT ''邮箱'', 17 | emailStatus INT(11) NOT NULL DEFAULT 0 COMMENT ''邮箱校验状态:0 未校验 / 1 校验通过'', 18 | cellphone VARCHAR(50) DEFAULT '''' COMMENT ''手机号'', 19 | phoneStatus INT(11) NOT NULL DEFAULT 0 COMMENT ''手机号校验状态:0 未校验 / 1 校验通过'', 20 | telephone VARCHAR(50) DEFAULT '''' COMMENT ''电话号码'', 21 | province VARCHAR(50) DEFAULT '''' COMMENT ''所在省份'', 22 | city VARCHAR(100) DEFAULT '''' COMMENT ''所在城市'', 23 | country VARCHAR(200) DEFAULT '''' COMMENT ''所在区县'', 24 | address VARCHAR(1000) DEFAULT '''' COMMENT ''具体详细地址'', 25 | otherInfo TEXT DEFAULT NULL COMMENT ''更多其他信息'', 26 | createTime BIGINT(20) DEFAULT 0 COMMENT ''添加日期:Unix时间戳'', 27 | modifyTime BIGINT(20) DEFAULT 0 COMMENT ''最后更新日期:Unix时间戳'', 28 | idCardNo VARCHAR(50) DEFAULT '''' COMMENT ''证件号码'', 29 | referee BIGINT(20) DEFAULT 0 COMMENT ''介绍人ID'', 30 | amount DECIMAL(18, 2) DEFAULT 0.00 COMMENT ''现金账户余额'', 31 | points INT(11) DEFAULT 0 COMMENT ''剩余积分'', 32 | orderCount INT(11) DEFAULT 0 COMMENT ''交易次数'', 33 | odooId INT(20) DEFAULT 0 COMMENT ''对应odoo的id'', 34 | orderAmount DECIMAL(10, 2) DEFAULT 0.00 COMMENT ''所购订单总金额'', 35 | gradeAmount DECIMAL(10, 2) DEFAULT 0.00 COMMENT ''当前等级下花费的总金额'', 36 | gradeChangeTime BIGINT(20) DEFAULT 0 COMMENT ''会员等级改变时间'', 37 | memberMark INT(11) DEFAULT 0 COMMENT ''会员标记,0-普通会员,1-特殊关注会员'', 38 | memberLabel VARCHAR(100) DEFAULT ''0'' COMMENT ''会员标签'', 39 | labelReason VARCHAR(100) DEFAULT ''0'' COMMENT ''标记原因'', 40 | phoneUpdateTime BIGINT(20) DEFAULT 0 COMMENT ''手机更改时间'', 41 | emailUpdateTime BIGINT(20) DEFAULT 0 COMMENT ''邮箱更改时间'', 42 | del BIT(1) DEFAULT b''0'', 43 | PRIMARY KEY (id), 44 | INDEX cellphone (cellphone), 45 | INDEX email (email), 46 | INDEX username (username) 47 | ) 48 | ENGINE = INNODB 49 | CHARACTER SET utf8 50 | COLLATE utf8_general_ci 51 | COMMENT = ''用户信息表''; -------------------------------------------------------------------------------- /src/main/resources/sql/sps_pay_map.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE sps_pay_map( 2 | id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '订单ID', 3 | orderId BIGINT(20) NOT NULL COMMENT '所属订单ID', 4 | orderCode VARCHAR(200) NOT NULL COMMENT '所属订单code', 5 | tempPayCode VARCHAR(200) NOT NULL COMMENT '临时支付号ID', 6 | platform VARCHAR(200) DEFAULT NULL COMMENT '所属平台', 7 | payParams VARCHAR(3500) DEFAULT NULL COMMENT '支付所生成的请求信息', 8 | retMsg VARCHAR(800) DEFAULT NULL COMMENT '支付后回调时的详细信息', 9 | retMsg2 VARCHAR(800) DEFAULT NULL COMMENT '备用消息', 10 | isPaid CHAR(1) DEFAULT NULL COMMENT '是否已支付0否;1是', 11 | remark VARCHAR(200) DEFAULT NULL, 12 | swiftNumber VARCHAR(60) DEFAULT NULL COMMENT '交易流水号', 13 | payPurpose VARCHAR(30) DEFAULT NULL COMMENT '交易意图:支付订单,补齐差价', 14 | idBelongsTo VARCHAR(60) DEFAULT NULL COMMENT 'orderId 所在的表 ', 15 | cashAmt DECIMAL(18, 2) DEFAULT NULL COMMENT '本次支付所使用的现金账户金额,sps_order表中有该字段,所以普通订单支付时此字段为空', 16 | remark2 VARCHAR(200) DEFAULT NULL, 17 | notify_time BIGINT(20) DEFAULT NULL COMMENT '通知回调时间', 18 | requestBiz VARCHAR(200) DEFAULT NULL COMMENT '支付请求业务来源', 19 | PRIMARY KEY (id), 20 | INDEX orderCode (orderCode), 21 | INDEX orderId (orderId) 22 | ) 23 | ENGINE = INNODB 24 | CHARACTER SET utf8 25 | COLLATE utf8_general_ci 26 | COMMENT = '订单表'; 27 | -------------------------------------------------------------------------------- /src/main/resources/sql/sps_payment.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE sps_payment( 2 | id BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '主键', 3 | payName VARCHAR(100) DEFAULT NULL COMMENT '支付名称', 4 | payKey VARCHAR(100) DEFAULT NULL COMMENT '支付关键字', 5 | payData VARCHAR(500) DEFAULT NULL COMMENT '支付加密数据', 6 | payURI VARCHAR(500) DEFAULT NULL COMMENT '回调URI', 7 | payLogoPath VARCHAR(500) DEFAULT NULL COMMENT '支付对应logo地址', 8 | pcPayLogoPath VARCHAR(500) DEFAULT NULL COMMENT '支付对应logo地址', 9 | shiftPayLogoPath VARCHAR(500) DEFAULT NULL COMMENT '支付对应logo地址', 10 | isPlat INT(3) DEFAULT NULL COMMENT '是否支付平台1:支付平台;0:银行', 11 | isWebOn INT(3) DEFAULT NULL COMMENT '是否web可用 : 0:否;1是', 12 | isAppOn INT(3) DEFAULT NULL COMMENT '是否app可用', 13 | PRIMARY KEY (id) 14 | ) 15 | ENGINE = INNODB 16 | CHARACTER SET utf8 17 | COLLATE utf8_general_ci 18 | COMMENT = '支付表'; -------------------------------------------------------------------------------- /src/main/resources/sql/sps_sys_config.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE sps_sys_config( 2 | sysKey VARCHAR(200) NOT NULL COMMENT '参数名', 3 | sysValue TEXT DEFAULT NULL COMMENT '参数值', 4 | modifyTime BIGINT(20) DEFAULT 0 COMMENT '修改日期', 5 | accountId BIGINT(20) DEFAULT 0 COMMENT '修改人', 6 | isCache TINYINT(1) DEFAULT 0 COMMENT '是否缓存,true为是,false不是,默认false', 7 | description VARCHAR(200) DEFAULT '' COMMENT '参数描述', 8 | operator CHAR(4) DEFAULT '1111' COMMENT '字典对应的操作', 9 | PRIMARY KEY (sysKey) 10 | ) 11 | ENGINE = INNODB 12 | CHARACTER SET utf8 13 | COLLATE utf8_general_ci 14 | COMMENT = '系统参数表'; -------------------------------------------------------------------------------- /src/main/resources/sys_config.properties: -------------------------------------------------------------------------------- 1 | #Mybatis Generator 2 | mapper.plugin = com.github.abel533.generator.MapperPlugin 3 | mapper.Mapper = com.github.abel533.mapper.Mapper 4 | 5 | shiro.guest.username=visitor 6 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/ceb-merchant-0.01.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/webapp/WEB-INF/ceb-merchant-0.01.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/psbc-merchant-toolkit-1.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/webapp/WEB-INF/psbc-merchant-toolkit-1.0.1.jar -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/unionpay-acp-sdk-1.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martin404/PayMap/998ac58904a8b3d724192c2a8e5e71b13af350db/src/main/webapp/WEB-INF/unionpay-acp-sdk-1.0.0.jar -------------------------------------------------------------------------------- /src/main/webapp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> 2 | 3 | 4 | 5 | PAYMAP SERVICE 6 | 7 | 8 |
9 |

PayMap Service Started!

10 | 11 | 12 |

欢迎扫一扫关注下面微信订阅号:Martin说

13 |
14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /src/test/java/com/hugnew/test/sps/common/BaseContextCase.java: -------------------------------------------------------------------------------- 1 | package com.hugnew.test.sps.common; 2 | 3 | import org.junit.Before; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.mock.web.MockHttpServletRequest; 7 | import org.springframework.mock.web.MockHttpServletResponse; 8 | import org.springframework.mock.web.MockHttpSession; 9 | import org.springframework.test.context.ContextConfiguration; 10 | import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests; 11 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 12 | import org.springframework.test.context.web.WebAppConfiguration; 13 | import org.springframework.test.web.servlet.MockMvc; 14 | import org.springframework.test.web.servlet.setup.MockMvcBuilders; 15 | import org.springframework.web.context.WebApplicationContext; 16 | 17 | @RunWith(SpringJUnit4ClassRunner.class) 18 | @WebAppConfiguration 19 | @ContextConfiguration(locations={"/applicationContext.xml", "/spring_mvc.xml", "/spring_rabbitmq.xml", "/spring_shiro.xml"}) 20 | public class BaseContextCase extends 21 | AbstractTransactionalJUnit4SpringContextTests{ 22 | // AbstractJUnit4SpringContextTests { 23 | 24 | protected MockHttpServletRequest request; 25 | protected MockHttpSession session; 26 | protected MockHttpServletResponse response; 27 | protected MockMvc mockMvc; 28 | @Autowired 29 | private WebApplicationContext webApplicationContext; 30 | 31 | @Before 32 | public void setup() throws Exception { 33 | request = new MockHttpServletRequest(); 34 | response = new MockHttpServletResponse(); 35 | session = new MockHttpSession(); 36 | 37 | mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); 38 | 39 | 40 | } 41 | } 42 | --------------------------------------------------------------------------------