From 49d5696ef9a5f0e2921ad4dc968a9e15e33aa46d Mon Sep 17 00:00:00 2001
From: dzh
Date: Thu, 18 Jul 2019 16:04:33 +0800
Subject: [PATCH 01/47] add jframe-google
---
.../jframe/aliyun/service/STSService.java | 8 +-
jframe-plugin/jframe-google/pom.xml | 15 +
.../main/java/jframe/google/GooglePlugin.java | 10 +
.../jframe/google/service/GeocodingApi.java | 11 +
.../jframe/google/service/GoogleService.java | 14 +
.../service/impl/GoogleServiceImpl.java | 10 +
.../main/resources/META-INF/plugin.properties | 9 +
jframe-plugin/jframe-zk/pom.xml | 2 +-
jframe-plugin/pom.xml | 277 +++++++++---------
9 files changed, 213 insertions(+), 143 deletions(-)
create mode 100644 jframe-plugin/jframe-google/pom.xml
create mode 100644 jframe-plugin/jframe-google/src/main/java/jframe/google/GooglePlugin.java
create mode 100644 jframe-plugin/jframe-google/src/main/java/jframe/google/service/GeocodingApi.java
create mode 100644 jframe-plugin/jframe-google/src/main/java/jframe/google/service/GoogleService.java
create mode 100644 jframe-plugin/jframe-google/src/main/java/jframe/google/service/impl/GoogleServiceImpl.java
create mode 100644 jframe-plugin/jframe-google/src/main/resources/META-INF/plugin.properties
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/STSService.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/STSService.java
index ad06e9f..62dd7c5 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/STSService.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/STSService.java
@@ -1,12 +1,12 @@
/**
- *
+ *
*/
package jframe.aliyun.service;
-import java.util.Map;
-
import jframe.core.plugin.annotation.Service;
+import java.util.Map;
+
/**
* @author dzh
* @date Feb 28, 2016 9:13:38 AM
@@ -17,7 +17,7 @@ public interface STSService {
/**
* 获取临时访问权限
- *
+ *
* @param id
* @return
*/
diff --git a/jframe-plugin/jframe-google/pom.xml b/jframe-plugin/jframe-google/pom.xml
new file mode 100644
index 0000000..0fa451d
--- /dev/null
+++ b/jframe-plugin/jframe-google/pom.xml
@@ -0,0 +1,15 @@
+
+
+
+ jframe-plugin
+ io.github.dzh
+ 2.0.0-SNAPSHOT
+
+ 4.0.0
+
+ jframe-google
+
+
+
\ No newline at end of file
diff --git a/jframe-plugin/jframe-google/src/main/java/jframe/google/GooglePlugin.java b/jframe-plugin/jframe-google/src/main/java/jframe/google/GooglePlugin.java
new file mode 100644
index 0000000..0f55ad5
--- /dev/null
+++ b/jframe-plugin/jframe-google/src/main/java/jframe/google/GooglePlugin.java
@@ -0,0 +1,10 @@
+package jframe.google;
+
+import jframe.core.plugin.DefPlugin;
+
+/**
+ * @author dzh
+ * @date 2019-05-08 10:59
+ */
+public class GooglePlugin extends DefPlugin {
+}
diff --git a/jframe-plugin/jframe-google/src/main/java/jframe/google/service/GeocodingApi.java b/jframe-plugin/jframe-google/src/main/java/jframe/google/service/GeocodingApi.java
new file mode 100644
index 0000000..1b746e8
--- /dev/null
+++ b/jframe-plugin/jframe-google/src/main/java/jframe/google/service/GeocodingApi.java
@@ -0,0 +1,11 @@
+package jframe.google.service;
+
+/**
+ * https://developers.google.com/maps/documentation/geocoding/start
+ *
+ * @author dzh
+ * @date 2019-05-08 12:34
+ */
+public interface GeocodingApi {
+
+}
diff --git a/jframe-plugin/jframe-google/src/main/java/jframe/google/service/GoogleService.java b/jframe-plugin/jframe-google/src/main/java/jframe/google/service/GoogleService.java
new file mode 100644
index 0000000..87f1c1e
--- /dev/null
+++ b/jframe-plugin/jframe-google/src/main/java/jframe/google/service/GoogleService.java
@@ -0,0 +1,14 @@
+package jframe.google.service;
+
+import jframe.core.plugin.annotation.Service;
+
+/**
+ * @author dzh
+ * @date 2019-05-08 11:00
+ */
+@Service(clazz = "jframe.google.service.impl.GoogleServiceImpl", id = "jframe.service.google")
+public interface GoogleService {
+
+
+
+}
diff --git a/jframe-plugin/jframe-google/src/main/java/jframe/google/service/impl/GoogleServiceImpl.java b/jframe-plugin/jframe-google/src/main/java/jframe/google/service/impl/GoogleServiceImpl.java
new file mode 100644
index 0000000..00f24b9
--- /dev/null
+++ b/jframe-plugin/jframe-google/src/main/java/jframe/google/service/impl/GoogleServiceImpl.java
@@ -0,0 +1,10 @@
+package jframe.google.service.impl;
+
+import jframe.google.service.GoogleService;
+
+/**
+ * @author dzh
+ * @date 2019-05-08 11:01
+ */
+public class GoogleServiceImpl implements GoogleService {
+}
diff --git a/jframe-plugin/jframe-google/src/main/resources/META-INF/plugin.properties b/jframe-plugin/jframe-google/src/main/resources/META-INF/plugin.properties
new file mode 100644
index 0000000..0940fc7
--- /dev/null
+++ b/jframe-plugin/jframe-google/src/main/resources/META-INF/plugin.properties
@@ -0,0 +1,9 @@
+Plugin-Name=jframe.google.GooglePlugin
+Plugin-Class=jframe.google.GooglePlugin
+#Default library path is META-INF/lib/
+#Plugin-Lib =
+#Default DLL path is META-INF/dll
+#Plugin-Dll =
+Plugin-Service=jframe.google.service.GoogleService
+#Export-Class=
+
diff --git a/jframe-plugin/jframe-zk/pom.xml b/jframe-plugin/jframe-zk/pom.xml
index 382bfbf..5ab2f39 100644
--- a/jframe-plugin/jframe-zk/pom.xml
+++ b/jframe-plugin/jframe-zk/pom.xml
@@ -9,7 +9,7 @@
jframe-zk
- 4.0.1
+ 4.2.0
diff --git a/jframe-plugin/pom.xml b/jframe-plugin/pom.xml
index 252a4dc..8940462 100644
--- a/jframe-plugin/pom.xml
+++ b/jframe-plugin/pom.xml
@@ -1,141 +1,142 @@
- 4.0.0
- jframe-plugin
- 2.0.0-SNAPSHOT
- pom
-
- UTF-8
- 2.0.0-SNAPSHOT
- 1.7.25
-
-
- jframe-activemq
- jframe-clrfile
- jframe-datasource
- jframe-watch
- jframe-mybatis
- jframe-getui
- jframe-pushy
- jframe-apns
- jframe-memcached-client
- jframe-jedis
- jframe-httpclient
- jframe-mongodb-client
- jframe-yunpian
- jframe-qiniu
- jframe-activemq-client
- jframe-rabbitmq-client
- jframe-rongcloud
- jframe-aliyun
- jframe-umeng
- jframe-zk
- jframe-netty-http
- jframe-azure
- jframe-yunsms
- jframe-californium
- jframe-mqtt-client
- jframe-wx
- jframe-freemarker
- jframe-elasticsearch
- jframe-redisson
- jframe-qcloud
-
-
-
-
- ${project.groupId}
- jframe-ext
- ${jframe.version}
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
- 1.8
- 1.8
- ${project.build.sourceEncoding}
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 3.1.1
-
-
- plugin
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 3.1.0
-
-
- compile
-
-
-
- ${project.build.sourceEncoding}
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 3.0.0-M2
-
- true
-
-
-
- org.apache.maven.plugins
- maven-clean-plugin
- 3.1.0
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 3.0.0-M2
-
- true
-
-
-
-
-
-
- junit
- junit
- 4.10
- test
-
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
- org.slf4j
- slf4j-simple
- ${slf4j.version}
- test
-
-
- ${project.groupId}
- jframe-core
- ${jframe.version}
-
-
- io.github.dzh
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ jframe-plugin
+ 2.0.0-SNAPSHOT
+ pom
+ io.github.dzh
+
+ UTF-8
+ 2.0.0-SNAPSHOT
+ 1.7.25
+
+
+ jframe-activemq
+ jframe-clrfile
+ jframe-datasource
+ jframe-watch
+ jframe-mybatis
+ jframe-getui
+ jframe-pushy
+ jframe-apns
+ jframe-memcached-client
+ jframe-jedis
+ jframe-httpclient
+ jframe-mongodb-client
+ jframe-yunpian
+ jframe-qiniu
+ jframe-activemq-client
+ jframe-rabbitmq-client
+ jframe-rongcloud
+ jframe-aliyun
+ jframe-umeng
+ jframe-zk
+ jframe-netty-http
+ jframe-azure
+ jframe-yunsms
+ jframe-californium
+ jframe-mqtt-client
+ jframe-wx
+ jframe-freemarker
+ jframe-elasticsearch
+ jframe-redisson
+ jframe-qcloud
+ jframe-google
+
+
+
+
+ ${project.groupId}
+ jframe-ext
+ ${jframe.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+ 1.8
+ 1.8
+ ${project.build.sourceEncoding}
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.1.1
+
+
+ plugin
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.1.0
+
+
+ compile
+
+
+
+ ${project.build.sourceEncoding}
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M2
+
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-clean-plugin
+ 3.1.0
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M2
+
+ true
+
+
+
+
+
+
+ junit
+ junit
+ 4.10
+ test
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ org.slf4j
+ slf4j-simple
+ ${slf4j.version}
+ test
+
+
+ ${project.groupId}
+ jframe-core
+ ${jframe.version}
+
+
\ No newline at end of file
From 60baa730ba1f53508713ab2a35d8495083c674ff Mon Sep 17 00:00:00 2001
From: dzh
Date: Mon, 22 Jul 2019 07:59:30 +0800
Subject: [PATCH 02/47] upg jframe-pay 2.0.0
---
.gitignore | 16 +-
jframe-pay/README.md | 10 +
jframe-pay/jframe-pay-client/pom.xml | 36 --
.../jframe-pay-lib/jframe-pay-domain/pom.xml | 89 ++---
.../pay/domain/dao/mapper/Environment.java | 10 +-
.../java/jframe/pay/domain/util/HttpUtil.java | 21 +-
.../java/jframe/pay/domain/util/IDUtil.java | 28 +-
.../java/jframe/pay/domain/util/ToString.java | 27 +-
jframe-pay/jframe-pay-lib/pom.xml | 28 +-
.../jframe-pay-alipay/pom.xml | 80 ++---
.../java/jframe/pay/alipay/AlipayConfig.java | 6 +-
.../pay/alipay/service/AlipayServiceImpl.java | 78 ++---
.../jframe-pay-client/README.md | 0
.../jframe-pay-client/pom.xml | 33 ++
.../java/jframe/pay/client/PayClientConf.java | 0
.../jframe/pay/client/PayClientPlugin.java | 0
.../jframe/pay/client/core/PayClient.java | 0
.../client/service/HttpPayClientService.java | 22 +-
.../pay/client/service/PayClientService.java | 0
.../main/resources/META-INF/plugin.properties | 0
.../src/test/resources/payclient.properties | 0
.../jframe-pay-plugin/jframe-pay-dao/pom.xml | 42 ++-
.../jframe-pay-plugin/jframe-pay-http/pom.xml | 84 +++--
.../jframe/pay/http/handler/PayHandler.java | 13 +-
.../jframe-pay-plugin/jframe-pay-task/pom.xml | 17 +-
.../jframe-pay-plugin/jframe-pay-upmp/pom.xml | 125 ++++---
.../jframe/pay/upmp/domain/UpmpConfig.java | 9 +-
.../pay/upmp/service/UpmppayServiceImpl.java | 56 ++-
.../jframe-pay-plugin/jframe-pay-wx/pom.xml | 82 +++--
.../java/jframe/pay/wx/domain/WxConfig.java | 7 +-
.../pay/wx/service/WxpayServiceImpl.java | 54 ++-
jframe-pay/jframe-pay-plugin/pom.xml | 82 ++---
.../bin/jframe.sh | 0
.../filter.properties.example | 0
.../filter}/acp_sdk_dev.properties | 6 -
.../filter}/acp_sdk_run.properties | 6 -
.../filter}/activemq.properties | 8 +-
.../filter/alipay.properties | 20 ++
.../filter}/config.properties | 76 ++--
.../filter}/d-activemq.properties | 0
.../filter}/datasource.properties | 0
.../filter}/http.properties | 3 -
.../filter/httpclient.properties | 16 +
.../filter}/jmxremote.access | 0
.../filter}/jmxremote.password | 0
.../filter/logback-daemon.xml | 45 +++
.../jframe-pay-release/filter/logback.xml | 39 +++
.../filter}/management.properties | 32 --
.../filter/memcached.properties | 20 ++
.../filter}/mybatis-config.xml | 0
.../filter/payclient.properties | 14 +
.../jframe-pay-release/filter/task.properties | 15 +
.../jframe-pay-release/filter/upmp.properties | 18 +
.../conf => jframe-pay-release/filter}/vmargs | 0
.../filter}/vmargs-win | 0
.../filter/wxpay.properties | 20 ++
jframe-pay/jframe-pay-release/pom.xml | 116 ++++++
jframe-pay/pom.xml | 330 ++++++++++++------
.../release/jframe-pay/conf/alipay.properties | 24 --
.../jframe-pay/conf/httpclient.properties | 20 --
.../jframe-pay/conf/logback-daemon.xml | 45 ---
.../release/jframe-pay/conf/logback.xml | 39 ---
.../jframe-pay/conf/memcached.properties | 26 --
.../jframe-pay/conf/payclient.properties | 18 -
.../release/jframe-pay/conf/task.properties | 19 -
.../release/jframe-pay/conf/upmp.properties | 22 --
.../release/jframe-pay/conf/wxpay.properties | 27 --
jframe-pay/release/pom.xml | 121 -------
jframe-plugin/jframe-httpclient/pom.xml | 50 +--
69 files changed, 1108 insertions(+), 1142 deletions(-)
delete mode 100644 jframe-pay/jframe-pay-client/pom.xml
rename jframe-pay/{ => jframe-pay-plugin}/jframe-pay-client/README.md (100%)
create mode 100644 jframe-pay/jframe-pay-plugin/jframe-pay-client/pom.xml
rename jframe-pay/{ => jframe-pay-plugin}/jframe-pay-client/src/main/java/jframe/pay/client/PayClientConf.java (100%)
rename jframe-pay/{ => jframe-pay-plugin}/jframe-pay-client/src/main/java/jframe/pay/client/PayClientPlugin.java (100%)
rename jframe-pay/{ => jframe-pay-plugin}/jframe-pay-client/src/main/java/jframe/pay/client/core/PayClient.java (100%)
rename jframe-pay/{ => jframe-pay-plugin}/jframe-pay-client/src/main/java/jframe/pay/client/service/HttpPayClientService.java (89%)
rename jframe-pay/{ => jframe-pay-plugin}/jframe-pay-client/src/main/java/jframe/pay/client/service/PayClientService.java (100%)
rename jframe-pay/{ => jframe-pay-plugin}/jframe-pay-client/src/main/resources/META-INF/plugin.properties (100%)
rename jframe-pay/{ => jframe-pay-plugin}/jframe-pay-client/src/test/resources/payclient.properties (100%)
rename jframe-pay/{release/jframe-pay => jframe-pay-release}/bin/jframe.sh (100%)
create mode 100644 jframe-pay/jframe-pay-release/filter.properties.example
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/acp_sdk_dev.properties (98%)
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/acp_sdk_run.properties (98%)
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/activemq.properties (55%)
create mode 100644 jframe-pay/jframe-pay-release/filter/alipay.properties
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/config.properties (61%)
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/d-activemq.properties (100%)
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/datasource.properties (100%)
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/http.properties (94%)
create mode 100755 jframe-pay/jframe-pay-release/filter/httpclient.properties
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/jmxremote.access (100%)
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/jmxremote.password (100%)
create mode 100644 jframe-pay/jframe-pay-release/filter/logback-daemon.xml
create mode 100644 jframe-pay/jframe-pay-release/filter/logback.xml
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/management.properties (99%)
create mode 100755 jframe-pay/jframe-pay-release/filter/memcached.properties
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/mybatis-config.xml (100%)
create mode 100755 jframe-pay/jframe-pay-release/filter/payclient.properties
create mode 100755 jframe-pay/jframe-pay-release/filter/task.properties
create mode 100644 jframe-pay/jframe-pay-release/filter/upmp.properties
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/vmargs (100%)
rename jframe-pay/{release/jframe-pay/conf => jframe-pay-release/filter}/vmargs-win (100%)
create mode 100644 jframe-pay/jframe-pay-release/filter/wxpay.properties
create mode 100644 jframe-pay/jframe-pay-release/pom.xml
delete mode 100644 jframe-pay/release/jframe-pay/conf/alipay.properties
delete mode 100755 jframe-pay/release/jframe-pay/conf/httpclient.properties
delete mode 100644 jframe-pay/release/jframe-pay/conf/logback-daemon.xml
delete mode 100644 jframe-pay/release/jframe-pay/conf/logback.xml
delete mode 100755 jframe-pay/release/jframe-pay/conf/memcached.properties
delete mode 100755 jframe-pay/release/jframe-pay/conf/payclient.properties
delete mode 100755 jframe-pay/release/jframe-pay/conf/task.properties
delete mode 100644 jframe-pay/release/jframe-pay/conf/upmp.properties
delete mode 100644 jframe-pay/release/jframe-pay/conf/wxpay.properties
delete mode 100644 jframe-pay/release/pom.xml
diff --git a/.gitignore b/.gitignore
index 5a611c9..a7f7328 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,18 +20,10 @@ jframe-plugin/release/lib/
jframe-plugin/release/plugin/
-jframe-pay/release/jframe-pay/lib/
-jframe-pay/release/jframe-pay/plugin/
-jframe-pay/release/jframe-pay/temp/
-jframe-pay/release/jframe-pay/log/
-jframe-pay/release/jframe-pay/conf/cache/
-
-
-jframe-demo/demo-release/lib/
-jframe-demo/demo-release/plugin/
-jframe-demo/demo-release/temp/
-jframe-demo/demo-release/log/
-jframe-demo/demo-release/conf/cache/
+jframe-pay/jframe-pay-release/tmp/
+jframe-pay/jframe-pay-release/log/
+jframe-pay/jframe-pay-release/conf/
+jframe-pay/jframe-pay-release/filter.properties
# idea
*.iml
diff --git a/jframe-pay/README.md b/jframe-pay/README.md
index e69de29..a0d9574 100644
--- a/jframe-pay/README.md
+++ b/jframe-pay/README.md
@@ -0,0 +1,10 @@
+jframe pay
+===================================
+通用的支付网关
+
+
+## 工程源码
+
+
+## 使用说明
+
diff --git a/jframe-pay/jframe-pay-client/pom.xml b/jframe-pay/jframe-pay-client/pom.xml
deleted file mode 100644
index 3356176..0000000
--- a/jframe-pay/jframe-pay-client/pom.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
- 4.0.0
-
- cn
- jframe-pay
- 1.0.0
-
- jframe-pay-client
-
-
-
-
- maven-jar-plugin
- 2.4
-
- plugin
-
-
-
-
-
-
-
- cn
- jframe-httpclient
- 1.0.0
- plugin
-
-
- cn
- jframe-pay-domain
- 1.0.0
-
-
-
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-lib/jframe-pay-domain/pom.xml b/jframe-pay/jframe-pay-lib/jframe-pay-domain/pom.xml
index 292fda0..d701b96 100644
--- a/jframe-pay/jframe-pay-lib/jframe-pay-domain/pom.xml
+++ b/jframe-pay/jframe-pay-lib/jframe-pay-domain/pom.xml
@@ -1,45 +1,52 @@
- 4.0.0
-
- cn
- jframe-pay-lib
- 1.0.0
-
- jframe-pay-domain
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay-lib
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-domain
-
-
- com.alibaba
- fastjson
- 1.2.6
-
-
- com.jayway.jsonpath
- json-path
- 2.0.0
-
-
- net.minidev
- asm
-
-
-
-
- com.google.code.gson
- gson
- 2.3
-
-
- org.mybatis
- mybatis
- 3.3.0
-
-
- org.mongodb
- mongo-java-driver
- 3.0.2
-
+
+
+ com.alibaba
+ fastjson
+
+
+ com.jayway.jsonpath
+ json-path
+ 2.0.0
+
+
+ net.minidev
+ asm
+
+
+
+
+ com.google.code.gson
+ gson
+
+
+ org.mybatis
+ mybatis
+ 3.3.0
+
+
+ org.mongodb
+ mongo-java-driver
+ 3.0.2
+
-
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ org.apache.httpcomponents
+ httpcore
+
+
+
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/dao/mapper/Environment.java b/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/dao/mapper/Environment.java
index 0d63acc..9341a5e 100644
--- a/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/dao/mapper/Environment.java
+++ b/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/dao/mapper/Environment.java
@@ -1,21 +1,21 @@
/**
- *
+ *
*/
package jframe.pay.domain.dao.mapper;
/**
* enviroment id
- *
+ *
* @author dzh
* @date Jul 20, 2015 11:59:10 AM
* @since 1.0
*/
public interface Environment {
- String RUN = "run";
+ String RUN = "run";
- String RUN_RO1 = "run_ro1";
+ String RUN_RO1 = "run_ro1";
- String DEV = "dev";
+ String DEV = "dev";
}
diff --git a/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/HttpUtil.java b/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/HttpUtil.java
index 91b5157..a89315b 100644
--- a/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/HttpUtil.java
+++ b/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/HttpUtil.java
@@ -1,22 +1,17 @@
/**
- *
+ *
*/
package jframe.pay.domain.util;
-import static java.util.stream.Collectors.toList;
-
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
+import java.io.UnsupportedEncodingException;
+import java.util.*;
+
+import static java.util.stream.Collectors.toList;
+
/**
* @author dzh
* @date Jul 13, 2015 5:44:13 PM
@@ -27,7 +22,7 @@ public class HttpUtil {
/**
* If req not contains all mustParas , then return emptyList contains empty
* parameter
- *
+ *
* @param req
* req parameters
* @param mustParas
@@ -70,7 +65,7 @@ public final static String format(Map paras, String charset) {
/**
* 目前只支持单值情况, 不支持多值和编码
- *
+ *
* @param content
* @return
* @throws UnsupportedEncodingException
diff --git a/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/IDUtil.java b/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/IDUtil.java
index 33ed45d..ac8c3ee 100644
--- a/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/IDUtil.java
+++ b/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/IDUtil.java
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package jframe.pay.domain.util;
@@ -27,7 +27,7 @@ public class IDUtil {
/**
* 生成短信验证码 4位数字
- *
+ *
* @return
*/
public static String genVCode() {
@@ -220,7 +220,7 @@ public static String genSysTaskId() {
/**
* 线路ID
- *
+ *
* @return
*/
public static String genPathId() {
@@ -289,7 +289,7 @@ public static String genMsgGroupId() {
/**
* 消息头的key
- *
+ *
* @return
*/
public static String genSignKey() {
@@ -298,15 +298,15 @@ public static String genSignKey() {
int category = new Random().nextInt() % 3;
char ch = '0';
switch (category) {
- case 0:
- ch = (char) ((new Random().nextInt(10) % 10 + 48) & 0xffff);
- break;
- case 1:
- ch = (char) ((new Random().nextInt(26) % 26 + 65) & 0xffff);
- break;
- case 2:
- ch = (char) ((new Random().nextInt(26) % 26 + 97) & 0xffff);
- break;
+ case 0:
+ ch = (char) ((new Random().nextInt(10) % 10 + 48) & 0xffff);
+ break;
+ case 1:
+ ch = (char) ((new Random().nextInt(26) % 26 + 65) & 0xffff);
+ break;
+ case 2:
+ ch = (char) ((new Random().nextInt(26) % 26 + 97) & 0xffff);
+ break;
}
buf.append(ch);
}
@@ -315,7 +315,7 @@ public static String genSignKey() {
/**
* 生成邀请码
- *
+ *
* @return
*/
public static String genInviteCode() {
diff --git a/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/ToString.java b/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/ToString.java
index 3476944..b75b076 100755
--- a/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/ToString.java
+++ b/jframe-pay/jframe-pay-lib/jframe-pay-domain/src/main/java/jframe/pay/domain/util/ToString.java
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package jframe.pay.domain.util;
@@ -10,19 +10,20 @@
* @date Aug 15, 2014 5:26:56 PM
* @since 1.0
*/
+@Deprecated
public class ToString {
- public static final String toString(Map, ?> map) {
- if (map == null || map.isEmpty())
- return "";
- StringBuilder buf = new StringBuilder();
- buf.append("\nbegin\n");
- for (Object o : map.keySet()) {
- buf.append(String.valueOf(o) + "->" + String.valueOf(map.get(o))
- + ",");
- }
- buf.append("\nend\n");
- return buf.toString();
- }
+ public static final String toString(Map, ?> map) {
+ if (map == null || map.isEmpty())
+ return "";
+ StringBuilder buf = new StringBuilder();
+ buf.append("\nbegin\n");
+ for (Object o : map.keySet()) {
+ buf.append(String.valueOf(o) + "->" + String.valueOf(map.get(o))
+ + ",");
+ }
+ buf.append("\nend\n");
+ return buf.toString();
+ }
}
diff --git a/jframe-pay/jframe-pay-lib/pom.xml b/jframe-pay/jframe-pay-lib/pom.xml
index 00b745e..55302c8 100644
--- a/jframe-pay/jframe-pay-lib/pom.xml
+++ b/jframe-pay/jframe-pay-lib/pom.xml
@@ -1,17 +1,17 @@
- 4.0.0
-
- cn
- jframe-pay
- 1.0.0
-
- jframe-pay-lib
- pom
-
- jframe-pay-domain
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-lib
+ pom
-
-
+
+ jframe-pay-domain
+
+
+
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/pom.xml b/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/pom.xml
index 5db93eb..34cdc86 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/pom.xml
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/pom.xml
@@ -1,50 +1,36 @@
- 4.0.0
-
- cn
- jframe-pay-plugin
- 1.0.0
-
- jframe-pay-alipay
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay-plugin
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-alipay
-
-
- commons-codec
- commons-codec
- 1.10
-
-
- org.apache.httpcomponents
- httpcore
- 4.4.1
-
-
- org.apache.httpcomponents
- httpclient
- 4.5
-
-
- dom4j
- dom4j
- 1.6.1
-
-
- jaxen
- jaxen
- 1.1.6
-
-
- cn
- jframe-pay-dao
- 1.0.0
- plugin
-
-
- cn
- jframe-httpclient
- 1.0.0
- plugin
-
-
+
+
+ commons-codec
+ commons-codec
+
+
+ org.dom4j
+ dom4j
+
+
+ jaxen
+ jaxen
+
+
+
+ io.github.dzh
+ jframe-pay-dao
+ plugin
+
+
+ io.github.dzh
+ jframe-httpclient
+ plugin
+
+
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/src/main/java/jframe/pay/alipay/AlipayConfig.java b/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/src/main/java/jframe/pay/alipay/AlipayConfig.java
index 92f92cd..3a3e4f0 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/src/main/java/jframe/pay/alipay/AlipayConfig.java
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/src/main/java/jframe/pay/alipay/AlipayConfig.java
@@ -1,11 +1,9 @@
package jframe.pay.alipay;
-import jframe.ext.util.PropertiesConfig;
-
import com.alipay.sdk.pay.demo.SignUtils;
+import jframe.core.util.PropsConf;
/**
- *
* @author dzh
* @date Nov 27, 2014 4:49:43 PM
* @since 1.0
@@ -32,7 +30,7 @@ public class AlipayConfig {
public static final String SIGN_TYPE_QUERY = "sign.type.query";
public static final String SERVICE = "service";
- private static PropertiesConfig config = new PropertiesConfig();
+ private static PropsConf config = new PropsConf();
public static void init(String file) throws Exception {
config.init(file);
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/src/main/java/jframe/pay/alipay/service/AlipayServiceImpl.java b/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/src/main/java/jframe/pay/alipay/service/AlipayServiceImpl.java
index 1e8979f..2f27360 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/src/main/java/jframe/pay/alipay/service/AlipayServiceImpl.java
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-alipay/src/main/java/jframe/pay/alipay/service/AlipayServiceImpl.java
@@ -1,24 +1,10 @@
/**
- *
+ *
*/
package jframe.pay.alipay.service;
-import java.net.URL;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.alipay.util.OrderUtil;
-
-import jframe.core.plugin.annotation.InjectPlugin;
-import jframe.core.plugin.annotation.InjectService;
-import jframe.core.plugin.annotation.Injector;
-import jframe.core.plugin.annotation.Start;
-import jframe.core.plugin.annotation.Stop;
+import jframe.core.plugin.annotation.*;
import jframe.httpclient.service.HttpClientService;
import jframe.pay.alipay.AlipayConfig;
import jframe.pay.alipay.AlipayPlugin;
@@ -33,6 +19,14 @@
import jframe.pay.domain.util.HttpUtil;
import jframe.pay.domain.util.IDUtil;
import jframe.pay.domain.util.ObjectUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URL;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
/**
* @author dzh
@@ -291,7 +285,7 @@ private void doSuccess(Map req, Map rsp) throws
/**
* TODO
- *
+ *
* @param usrid
* @param accountid
* @return
@@ -333,7 +327,7 @@ public boolean accountExist(String usrid, String accountid) {
}
public void postBack(OrderAlipay order) {
- Map map = new HashMap();
+ Map map = new HashMap<>();
map.put(F_payNo, order.payNo);
map.put(F_payStatus, order.payStatus);
@@ -342,39 +336,37 @@ public void postBack(OrderAlipay order) {
URL url = new URL(order.backUrl);
int port = url.getPort() == -1 ? 80 : url.getPort();
- if (LOG.isDebugEnabled())
- LOG.debug("postBack start time->{},req->{}", new Date(), map);
+ LOG.info("postBack -> {},{},{}", url, new Date(), map);
Long backtime = System.currentTimeMillis();
Map paras = new HashMap<>(HTTP_PARAS);
paras.put("ip", url.getHost());
paras.put("port", String.valueOf(port));
- Map rsp = HttpClient.> send("payback", url.getPath(),
+ String rsp = HttpClient.send("payback", url.getPath(),
HttpUtil.format(map, "utf-8"), null, paras);
- if (LOG.isDebugEnabled())
- LOG.debug("postback orderNo={}, postBack->{}, use time->{}, rsp->{}", order.orderNo, url.getPath(),
- (System.currentTimeMillis() - backtime), rsp);
- if (RspCode.SUCCESS.code.equals(rsp.get(F_rspCode))) {
- succ = true;
- } else {
- LOG.error("payNo=" + order.payNo + "rsp=" + rsp);
- }
+ LOG.info("postback orderNo={}, postBack->{}, use time->{}, rsp->{}", order.orderNo, url.getPath(),
+ (System.currentTimeMillis() - backtime), rsp);
+
+// if (RspCode.SUCCESS.code.equals(rsp.get(F_rspCode))) {
+// succ = true;
+// } else {
+// LOG.error("payNo=" + order.payNo + "rsp=" + rsp);
+// }
} catch (Exception e) {
- succ = false;
- LOG.error(e.getMessage());
+ LOG.error(e.getMessage(), e);
}
- if (!succ) {
- // TODO
- // map.put(UsrFields.F_backUrl, order.getBackUrl());
- // Task t = createTask(TaskType.PAY_BACK.type,
- // TaskType.PAY_BACK.desc,
- // JsonUtil.encode(map), new Date().getTime());
- // try {
- // AlipayDao.insertTask_Order(conn, t);
- // } catch (Exception e1) {
- // LOG.error(e1.getMessage());
- // }
- }
+// if (!succ) {
+ // TODO
+ // map.put(UsrFields.F_backUrl, order.getBackUrl());
+ // Task t = createTask(TaskType.PAY_BACK.type,
+ // TaskType.PAY_BACK.desc,
+ // JsonUtil.encode(map), new Date().getTime());
+ // try {
+ // AlipayDao.insertTask_Order(conn, t);
+ // } catch (Exception e1) {
+ // LOG.error(e1.getMessage());
+ // }
+// }
}
diff --git a/jframe-pay/jframe-pay-client/README.md b/jframe-pay/jframe-pay-plugin/jframe-pay-client/README.md
similarity index 100%
rename from jframe-pay/jframe-pay-client/README.md
rename to jframe-pay/jframe-pay-plugin/jframe-pay-client/README.md
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-client/pom.xml b/jframe-pay/jframe-pay-plugin/jframe-pay-client/pom.xml
new file mode 100644
index 0000000..da34816
--- /dev/null
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-client/pom.xml
@@ -0,0 +1,33 @@
+
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-client
+
+
+
+
+ maven-jar-plugin
+
+ plugin
+
+
+
+
+
+
+
+ io.github.dzh
+ jframe-httpclient
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-domain
+
+
+
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/PayClientConf.java b/jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/PayClientConf.java
similarity index 100%
rename from jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/PayClientConf.java
rename to jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/PayClientConf.java
diff --git a/jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/PayClientPlugin.java b/jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/PayClientPlugin.java
similarity index 100%
rename from jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/PayClientPlugin.java
rename to jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/PayClientPlugin.java
diff --git a/jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/core/PayClient.java b/jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/core/PayClient.java
similarity index 100%
rename from jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/core/PayClient.java
rename to jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/core/PayClient.java
diff --git a/jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/service/HttpPayClientService.java b/jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/service/HttpPayClientService.java
similarity index 89%
rename from jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/service/HttpPayClientService.java
rename to jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/service/HttpPayClientService.java
index a03b1f3..a30fffe 100644
--- a/jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/service/HttpPayClientService.java
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/service/HttpPayClientService.java
@@ -1,15 +1,8 @@
/**
- *
+ *
*/
package jframe.pay.client.service;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import jframe.core.plugin.annotation.InjectPlugin;
import jframe.core.plugin.annotation.InjectService;
import jframe.core.plugin.annotation.Injector;
@@ -21,6 +14,13 @@
import jframe.pay.domain.TransType;
import jframe.pay.domain.http.ReqOp;
import jframe.pay.domain.util.HttpUtil;
+import jframe.pay.domain.util.JsonUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
/**
* @author dzh
@@ -98,15 +98,17 @@ public Map pay(Map req) throws Exception {
// TODO check
- return HttpClient.send(HttpClient_ID, Prefix_ord + req.get(F_reqOp), HttpUtil.format(req, "utf-8"), null,
+ String result = HttpClient.send(HttpClient_ID, Prefix_ord + req.get(F_reqOp), HttpUtil.format(req, "utf-8"), null,
HTTP_PARAS);
+ return JsonUtil.decode(result);
}
@Override
public Map usr(Map req) throws Exception {
// TODO check
- return HttpClient.send(HttpClient_ID, Prefix_usr + req.get(F_reqOp), HttpUtil.format(req, "utf-8"), null,
+ String result = HttpClient.send(HttpClient_ID, Prefix_usr + req.get(F_reqOp), HttpUtil.format(req, "utf-8"), null,
HTTP_PARAS);
+ return JsonUtil.decode(result);
}
}
diff --git a/jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/service/PayClientService.java b/jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/service/PayClientService.java
similarity index 100%
rename from jframe-pay/jframe-pay-client/src/main/java/jframe/pay/client/service/PayClientService.java
rename to jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/java/jframe/pay/client/service/PayClientService.java
diff --git a/jframe-pay/jframe-pay-client/src/main/resources/META-INF/plugin.properties b/jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/resources/META-INF/plugin.properties
similarity index 100%
rename from jframe-pay/jframe-pay-client/src/main/resources/META-INF/plugin.properties
rename to jframe-pay/jframe-pay-plugin/jframe-pay-client/src/main/resources/META-INF/plugin.properties
diff --git a/jframe-pay/jframe-pay-client/src/test/resources/payclient.properties b/jframe-pay/jframe-pay-plugin/jframe-pay-client/src/test/resources/payclient.properties
similarity index 100%
rename from jframe-pay/jframe-pay-client/src/test/resources/payclient.properties
rename to jframe-pay/jframe-pay-plugin/jframe-pay-client/src/test/resources/payclient.properties
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-dao/pom.xml b/jframe-pay/jframe-pay-plugin/jframe-pay-dao/pom.xml
index a99846d..85247c3 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-dao/pom.xml
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-dao/pom.xml
@@ -1,25 +1,23 @@
- 4.0.0
-
- cn
- jframe-pay-plugin
- 1.0.0
-
- jframe-pay-dao
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay-plugin
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-dao
-
-
- cn
- jframe-memcached-client
- 1.0.0
- plugin
-
-
- cn
- jframe-mybatis
- 1.0.0
- plugin
-
-
+
+
+ io.github.dzh
+ jframe-memcached-client
+ plugin
+
+
+ io.github.dzh
+ jframe-mybatis
+ plugin
+
+
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-http/pom.xml b/jframe-pay/jframe-pay-plugin/jframe-pay-http/pom.xml
index a5c5f21..1195825 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-http/pom.xml
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-http/pom.xml
@@ -1,48 +1,44 @@
- 4.0.0
-
- cn
- jframe-pay-plugin
- 1.0.0
-
- jframe-pay-http
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay-plugin
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-http
-
-
- io.netty
- netty-all
- 4.0.26.Final
-
-
- dom4j
- dom4j
- 1.6.1
-
+
+
+ io.netty
+ netty-all
+ 4.0.26.Final
+
+
+ dom4j
+ dom4j
+ 1.6.1
+
-
- cn
- jframe-pay-alipay
- 1.0.0
- plugin
-
-
- cn
- jframe-pay-dao
- 1.0.0
- plugin
-
-
- cn
- jframe-pay-wx
- 1.0.0
- plugin
-
-
- cn
- jframe-pay-upmp
- 1.0.0
- plugin
-
-
+
+ io.github.dzh
+ jframe-pay-alipay
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-dao
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-wx
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-upmp
+ plugin
+
+
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-http/src/main/java/jframe/pay/http/handler/PayHandler.java b/jframe-pay/jframe-pay-plugin/jframe-pay-http/src/main/java/jframe/pay/http/handler/PayHandler.java
index 652e3d6..68660dd 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-http/src/main/java/jframe/pay/http/handler/PayHandler.java
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-http/src/main/java/jframe/pay/http/handler/PayHandler.java
@@ -1,16 +1,15 @@
/**
- *
+ *
*/
package jframe.pay.http.handler;
-import java.util.Map;
-
import jframe.pay.domain.Fields;
import jframe.pay.domain.http.RspCode;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Map;
+
/**
* @author dzh
* @date Jul 29, 2015 2:09:06 PM
@@ -42,10 +41,8 @@ public void service(Map req, Map rsp) throws Pay
rsp.put(Fields.F_error, e.getMessage());
}
}
- if (LOG.isDebugEnabled()) {
- LOG.debug("remoteIp->{} reqOp->{} invokeTime->{}ms req->{} rsp->{}", getRemoteIp(), getReqOp(),
- System.currentTimeMillis() - start, req, rsp);
- }
+ LOG.info("remoteIp->{} reqOp->{} invokeTime->{}ms req->{} rsp->{}", getRemoteIp(), getReqOp(),
+ System.currentTimeMillis() - start, req, rsp);
}
protected abstract void doService(Map req, Map rsp) throws Exception;
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-task/pom.xml b/jframe-pay/jframe-pay-plugin/jframe-pay-task/pom.xml
index 2832f38..7af129f 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-task/pom.xml
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-task/pom.xml
@@ -1,9 +1,10 @@
-
- 4.0.0
-
- cn
- jframe-pay-plugin
- 1.0.0
-
- jframe-pay-task
+
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay-plugin
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-task
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/pom.xml b/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/pom.xml
index d0ebf6f..319b805 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/pom.xml
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/pom.xml
@@ -1,68 +1,65 @@
- 4.0.0
-
- cn
- jframe-pay-plugin
- 1.0.0
-
- jframe-pay-upmp
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay-plugin
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-upmp
-
-
- com.alibaba
- fastjson
- 1.1.41
-
-
- cn
- jframe-pay-dao
- 1.0.0
- plugin
-
-
- cn
- jframe-httpclient
- 1.0.0
- plugin
-
+
+
+ com.alibaba
+ fastjson
+
-
- com
- upacp_sdk
- 1.0.0
- system
- ${project.basedir}/compile/upacp_sdk-1.0.0-20150703140550.jar
-
-
- org.bouncycastle
- bcprov-jdk16
- 1.46
-
-
- commons-codec
- commons-codec
- 1.10
-
-
- commons-io
- commons-io
- 2.4
-
-
- commons-lang
- commons-lang
- 2.6
-
-
- log4j
- log4j
- 1.2.17
-
-
- org.slf4j
- slf4j-log4j12
- 1.7.13
-
-
+
+ com
+ upacp_sdk
+ 1.0.0
+ system
+ ${project.basedir}/compile/upacp_sdk-1.0.0-20150703140550.jar
+
+
+ org.bouncycastle
+ bcprov-jdk16
+ 1.46
+
+
+ commons-codec
+ commons-codec
+
+
+ commons-io
+ commons-io
+ 2.4
+
+
+ commons-lang
+ commons-lang
+ 2.6
+
+
+ log4j
+ log4j
+ 1.2.17
+
+
+ org.slf4j
+ slf4j-log4j12
+ 1.7.13
+
+
+
+ io.github.dzh
+ jframe-pay-dao
+ plugin
+
+
+ io.github.dzh
+ jframe-httpclient
+ plugin
+
+
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/src/main/java/jframe/pay/upmp/domain/UpmpConfig.java b/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/src/main/java/jframe/pay/upmp/domain/UpmpConfig.java
index 2323417..512b733 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/src/main/java/jframe/pay/upmp/domain/UpmpConfig.java
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/src/main/java/jframe/pay/upmp/domain/UpmpConfig.java
@@ -1,17 +1,16 @@
/**
- *
+ *
*/
package jframe.pay.upmp.domain;
+import jframe.core.util.PropsConf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import jframe.ext.util.PropertiesConfig;
-
/**
*
*
- *
+ *
* @author dzh
* @date Nov 25, 2015 3:05:10 PM
* @since 1.0
@@ -37,7 +36,7 @@ public class UpmpConfig {
static final Logger LOG = LoggerFactory.getLogger(UpmpConfig.class);
- public static PropertiesConfig config = new PropertiesConfig();
+ public static PropsConf config = new PropsConf();
public static void init(String file) throws Exception {
config.init(file);
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/src/main/java/jframe/pay/upmp/service/UpmppayServiceImpl.java b/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/src/main/java/jframe/pay/upmp/service/UpmppayServiceImpl.java
index f2c3ab6..ce09746 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/src/main/java/jframe/pay/upmp/service/UpmppayServiceImpl.java
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-upmp/src/main/java/jframe/pay/upmp/service/UpmppayServiceImpl.java
@@ -1,27 +1,12 @@
/**
- *
+ *
*/
package jframe.pay.upmp.service;
-import java.net.URL;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.unionpay.acp.sdk.SDKConfig;
-
import jframe.core.conf.VarHandler;
-import jframe.core.plugin.annotation.InjectPlugin;
-import jframe.core.plugin.annotation.InjectService;
-import jframe.core.plugin.annotation.Injector;
-import jframe.core.plugin.annotation.Start;
-import jframe.core.plugin.annotation.Stop;
-import jframe.ext.util.PropertiesConfig;
+import jframe.core.plugin.annotation.*;
+import jframe.core.util.PropsConf;
import jframe.httpclient.service.HttpClientService;
import jframe.memcached.client.MemcachedService;
import jframe.pay.dao.service.PayDaoService;
@@ -37,6 +22,15 @@
import jframe.pay.upmp.domain.UpmpConfig;
import jframe.pay.upmp.domain.UpmpFields;
import jframe.pay.upmp.req.ConsumeReq;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URL;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
/**
* @author dzh
@@ -74,7 +68,7 @@ void start() {
VarHandler vh = new VarHandler(Plugin.getContext().getConfig());
UpmpConfig.config.replace(vh);
- PropertiesConfig acpSDK = new PropertiesConfig();
+ PropsConf acpSDK = new PropsConf();
acpSDK.init(UpmpConfig.getConf(UpmpConfig.KEY_ACP_SDK));
acpSDK.replace(vh);
SDKConfig.getConfig().loadProperties(acpSDK.clone2Properties());
@@ -102,7 +96,7 @@ public void pay(Map req, Map rsp) throws Excepti
return;
}
- rsp.put(F_filter, JsonUtil.createPropertyFilter(new String[] { F_rspCode, F_rspDesc, F_tn }));
+ rsp.put(F_filter, JsonUtil.createPropertyFilter(new String[]{F_rspCode, F_rspDesc, F_tn}));
if (ConsumeReq.consume(req, rsp)) {
OrderUpmp od = PayDao.selectOrderUpmp(req.get(F_payNo));
@@ -226,24 +220,22 @@ public void postBack(OrderUpmp od) {
URL url = new URL(od.backUrl);
int port = url.getPort() == -1 ? 80 : url.getPort();
- if (LOG.isDebugEnabled())
- LOG.debug("postBack -> {}, {},{}", url.toString(), new Date(), map);
- Long packtime = System.currentTimeMillis();
+ LOG.info("postBack -> {},{},{}", url, new Date(), map);
+ Long backtime = System.currentTimeMillis();
Map paras = new HashMap<>(HTTP_PARAS);
paras.put("ip", url.getHost());
paras.put("port", String.valueOf(port));
- Map rsp = HttpClient.> send("payback", url.getPath(),
+ String rsp = HttpClient.send("payback", url.getPath(),
HttpUtil.format(map, "utf-8"), null, paras);
Long packTime = System.currentTimeMillis();
- if (LOG.isDebugEnabled())
- LOG.debug("orderNo=" + od.orderNo + " postBack" + new Date() + " use time=" + (packTime - packtime)
- + " rsp=" + rsp);
- if (RspCode.SUCCESS.code.equals(rsp.get(F_rspCode))) {
- succ = true;
- } else {
- LOG.error("payNo=" + od.payNo + "rsp=" + rsp);
- }
+ LOG.info("postback orderNo={}, postBack->{}, use time->{}, rsp->{}", od.orderNo, url.getPath(),
+ (System.currentTimeMillis() - backtime), rsp);
+// if (RspCode.SUCCESS.code.equals(rsp.get(F_rspCode))) {
+// succ = true;
+// } else {
+// LOG.error("payNo=" + od.payNo + "rsp=" + rsp);
+// }
} catch (Exception e) {
succ = false;
LOG.error(e.getMessage());
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-wx/pom.xml b/jframe-pay/jframe-pay-plugin/jframe-pay-wx/pom.xml
index 0f45575..fb189db 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-wx/pom.xml
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-wx/pom.xml
@@ -1,45 +1,43 @@
- 4.0.0
-
- cn
- jframe-pay-plugin
- 1.0.0
-
- jframe-pay-wx
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay-plugin
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-wx
-
-
- commons-dbutils
- commons-dbutils
- 1.6
-
-
- org.jdom
- jdom
- 2.0.2
-
-
- org.json
- json
- 20140107
-
-
- com.alibaba
- fastjson
- 1.1.41
-
-
- cn
- jframe-pay-dao
- 1.0.0
- plugin
-
-
- cn
- jframe-httpclient
- 1.0.0
- plugin
-
-
+
+
+ commons-dbutils
+ commons-dbutils
+ 1.6
+
+
+ org.jdom
+ jdom
+ 2.0.2
+
+
+ org.json
+ json
+ 20140107
+
+
+ com.alibaba
+ fastjson
+
+
+
+ io.github.dzh
+ jframe-pay-dao
+ plugin
+
+
+ io.github.dzh
+ jframe-httpclient
+ plugin
+
+
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-wx/src/main/java/jframe/pay/wx/domain/WxConfig.java b/jframe-pay/jframe-pay-plugin/jframe-pay-wx/src/main/java/jframe/pay/wx/domain/WxConfig.java
index 64dd8c6..3ab6677 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-wx/src/main/java/jframe/pay/wx/domain/WxConfig.java
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-wx/src/main/java/jframe/pay/wx/domain/WxConfig.java
@@ -1,13 +1,12 @@
/**
- *
+ *
*/
package jframe.pay.wx.domain;
+import jframe.core.util.PropsConf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import jframe.ext.util.PropertiesConfig;
-
/**
* @author dzh
* @date Sep 25, 2014 1:49:56 PM
@@ -39,7 +38,7 @@ public class WxConfig {
static Logger LOG = LoggerFactory.getLogger(WxConfig.class);
- public static PropertiesConfig config = new PropertiesConfig();
+ public static PropsConf config = new PropsConf();
public static void init(String file) throws Exception {
config.init(file);
diff --git a/jframe-pay/jframe-pay-plugin/jframe-pay-wx/src/main/java/jframe/pay/wx/service/WxpayServiceImpl.java b/jframe-pay/jframe-pay-plugin/jframe-pay-wx/src/main/java/jframe/pay/wx/service/WxpayServiceImpl.java
index 5074c6c..7c209c8 100644
--- a/jframe-pay/jframe-pay-plugin/jframe-pay-wx/src/main/java/jframe/pay/wx/service/WxpayServiceImpl.java
+++ b/jframe-pay/jframe-pay-plugin/jframe-pay-wx/src/main/java/jframe/pay/wx/service/WxpayServiceImpl.java
@@ -1,20 +1,6 @@
package jframe.pay.wx.service;
-import java.net.URL;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import jframe.core.plugin.annotation.InjectPlugin;
-import jframe.core.plugin.annotation.InjectService;
-import jframe.core.plugin.annotation.Injector;
-import jframe.core.plugin.annotation.Start;
-import jframe.core.plugin.annotation.Stop;
+import jframe.core.plugin.annotation.*;
import jframe.httpclient.service.HttpClientService;
import jframe.memcached.client.MemcachedService;
import jframe.pay.dao.service.PayDaoService;
@@ -30,6 +16,15 @@
import jframe.pay.wx.domain.WxConfig;
import jframe.pay.wx.domain.WxFields;
import jframe.pay.wx.http.client.WxServiceNew;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.URL;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
@Injector
public class WxpayServiceImpl implements WxpayService, WxFields {
@@ -178,7 +173,7 @@ public void payBack(Map req, Map rsp) throws Exc
/**
* TODO BitSet
- *
+ *
* @param req
* @return
*/
@@ -324,10 +319,8 @@ public void wxPayBack(Map req, Map rsp) throws E
/**
* 通知租车后台
- *
- * @param conn
+ *
* @param od
- * @param orderStatus
*/
public void postBack(OrderWx od) {
Map map = new HashMap(2, 1);
@@ -339,26 +332,23 @@ public void postBack(OrderWx od) {
URL url = new URL(od.backUrl);
int port = url.getPort() == -1 ? 80 : url.getPort();
- if (LOG.isDebugEnabled())
- LOG.debug("postBack -> {}, {},{}", url.toString(), new Date(), map);
- Long packtime = System.currentTimeMillis();
+ LOG.info("postBack -> {},{},{}", url, new Date(), map);
+ Long backtime = System.currentTimeMillis();
Map paras = new HashMap<>(HTTP_PARAS);
paras.put("ip", url.getHost());
paras.put("port", String.valueOf(port));
- Map rsp = HttpClient.> send("payback", url.getPath(),
+ String rsp = HttpClient.send("payback", url.getPath(),
HttpUtil.format(map, "utf-8"), null, paras);
Long packTime = System.currentTimeMillis();
- if (LOG.isDebugEnabled())
- LOG.debug("orderNo=" + od.orderNo + " postBack" + new Date() + " use time=" + (packTime - packtime)
- + " rsp=" + rsp);
- if (RspCode.SUCCESS.code.equals(rsp.get(F_rspCode))) {
- succ = true;
- } else {
- LOG.error("payNo=" + od.payNo + "rsp=" + rsp);
- }
+ LOG.info("postback orderNo={}, postBack->{}, use time->{}, rsp->{}", od.orderNo, url.getPath(),
+ (System.currentTimeMillis() - backtime), rsp);
+// if (RspCode.SUCCESS.code.equals(rsp.get(F_rspCode))) {
+// succ = true;
+// } else {
+// LOG.error("payNo=" + od.payNo + "rsp=" + rsp);
+// }
} catch (Exception e) {
- succ = false;
LOG.error(e.getMessage());
}
diff --git a/jframe-pay/jframe-pay-plugin/pom.xml b/jframe-pay/jframe-pay-plugin/pom.xml
index 0eabf0d..81bce4c 100644
--- a/jframe-pay/jframe-pay-plugin/pom.xml
+++ b/jframe-pay/jframe-pay-plugin/pom.xml
@@ -1,45 +1,45 @@
- 4.0.0
-
- cn
- jframe-pay
- 1.0.0
-
- jframe-pay-plugin
- pom
-
- jframe-pay-alipay
- jframe-pay-wx
- jframe-pay-http
- jframe-pay-dao
- jframe-pay-task
- jframe-pay-upmp
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-plugin
+ pom
+
+ jframe-pay-alipay
+ jframe-pay-wx
+ jframe-pay-http
+ jframe-pay-dao
+ jframe-pay-task
+ jframe-pay-upmp
+ jframe-pay-client
+
-
-
-
- maven-jar-plugin
- 2.4
-
- plugin
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+ plugin
+
+
+
+
-
-
- jframe-pay-domain
- cn
- 1.0.0
-
-
- cn
- jframe-memcached-client
- 1.0.0
- plugin
-
-
+
+
+ io.github.dzh
+ jframe-pay-domain
+
+
+
+ io.github.dzh
+ jframe-memcached-client
+ plugin
+
+
\ No newline at end of file
diff --git a/jframe-pay/release/jframe-pay/bin/jframe.sh b/jframe-pay/jframe-pay-release/bin/jframe.sh
similarity index 100%
rename from jframe-pay/release/jframe-pay/bin/jframe.sh
rename to jframe-pay/jframe-pay-release/bin/jframe.sh
diff --git a/jframe-pay/jframe-pay-release/filter.properties.example b/jframe-pay/jframe-pay-release/filter.properties.example
new file mode 100644
index 0000000..e69de29
diff --git a/jframe-pay/release/jframe-pay/conf/acp_sdk_dev.properties b/jframe-pay/jframe-pay-release/filter/acp_sdk_dev.properties
similarity index 98%
rename from jframe-pay/release/jframe-pay/conf/acp_sdk_dev.properties
rename to jframe-pay/jframe-pay-release/filter/acp_sdk_dev.properties
index aac64e1..090f453 100644
--- a/jframe-pay/release/jframe-pay/conf/acp_sdk_dev.properties
+++ b/jframe-pay/jframe-pay-release/filter/acp_sdk_dev.properties
@@ -1,5 +1,4 @@
###### 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#####
-
##########################\u4ea4\u6613\u53d1\u9001\u5730\u5740\u914d\u7f6e#############################
######(\u4ee5\u4e0b\u914d\u7f6e\u4e3aPM\u73af\u5883\uff1a\u5165\u7f51\u6d4b\u8bd5\u73af\u5883\u7528\uff0c\u751f\u4ea7\u73af\u5883\u914d\u7f6e\u89c1\u6587\u6863\u8bf4\u660e)#######
##\u524d\u53f0\u4ea4\u6613\u8bf7\u6c42\u5730\u5740
@@ -16,9 +15,6 @@ acpsdk.batchTransUrl=https://101.231.204.80:5000/gateway/api/batchTransReq.do
acpsdk.fileTransUrl=https://101.231.204.80:9080/
## app \u4EA4\u6613\u8BF7\u6C42\u5730\u5740
acpsdk.appTransUrl=https://101.231.204.80:5000/gateway/api/appTransReq.do
-
-
-
#########################\u7b7e\u540d\u8bc1\u4e66\u914d\u7f6e ################################
######(\u4ee5\u4e0b\u914d\u7f6e\u4e3aPM\u73af\u5883\uff1a\u5165\u7f51\u6d4b\u8bd5\u73af\u5883\u7528\uff0c\u751f\u4ea7\u73af\u5883\u914d\u7f6e\u89c1\u6587\u6863\u8bf4\u660e)#######
##\u7b7e\u540d\u8bc1\u4e66\u8def\u5f84
@@ -27,8 +23,6 @@ acpsdk.signCert.path=D:\\certs\\PM_700000000000001_acp.pfx
acpsdk.signCert.pwd=000000
##\u7b7e\u540d\u8bc1\u4e66\u7c7b\u578b
acpsdk.signCert.type=PKCS12
-
-
##########################\u9a8c\u7b7e\u8bc1\u4e66\u914d\u7f6e################################
##\u9a8c\u8bc1\u7b7e\u540d\u8bc1\u4e66\u76ee\u5f55
acpsdk.validateCert.dir=D:\\certs\\
diff --git a/jframe-pay/release/jframe-pay/conf/acp_sdk_run.properties b/jframe-pay/jframe-pay-release/filter/acp_sdk_run.properties
similarity index 98%
rename from jframe-pay/release/jframe-pay/conf/acp_sdk_run.properties
rename to jframe-pay/jframe-pay-release/filter/acp_sdk_run.properties
index aac64e1..090f453 100644
--- a/jframe-pay/release/jframe-pay/conf/acp_sdk_run.properties
+++ b/jframe-pay/jframe-pay-release/filter/acp_sdk_run.properties
@@ -1,5 +1,4 @@
###### 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#####
-
##########################\u4ea4\u6613\u53d1\u9001\u5730\u5740\u914d\u7f6e#############################
######(\u4ee5\u4e0b\u914d\u7f6e\u4e3aPM\u73af\u5883\uff1a\u5165\u7f51\u6d4b\u8bd5\u73af\u5883\u7528\uff0c\u751f\u4ea7\u73af\u5883\u914d\u7f6e\u89c1\u6587\u6863\u8bf4\u660e)#######
##\u524d\u53f0\u4ea4\u6613\u8bf7\u6c42\u5730\u5740
@@ -16,9 +15,6 @@ acpsdk.batchTransUrl=https://101.231.204.80:5000/gateway/api/batchTransReq.do
acpsdk.fileTransUrl=https://101.231.204.80:9080/
## app \u4EA4\u6613\u8BF7\u6C42\u5730\u5740
acpsdk.appTransUrl=https://101.231.204.80:5000/gateway/api/appTransReq.do
-
-
-
#########################\u7b7e\u540d\u8bc1\u4e66\u914d\u7f6e ################################
######(\u4ee5\u4e0b\u914d\u7f6e\u4e3aPM\u73af\u5883\uff1a\u5165\u7f51\u6d4b\u8bd5\u73af\u5883\u7528\uff0c\u751f\u4ea7\u73af\u5883\u914d\u7f6e\u89c1\u6587\u6863\u8bf4\u660e)#######
##\u7b7e\u540d\u8bc1\u4e66\u8def\u5f84
@@ -27,8 +23,6 @@ acpsdk.signCert.path=D:\\certs\\PM_700000000000001_acp.pfx
acpsdk.signCert.pwd=000000
##\u7b7e\u540d\u8bc1\u4e66\u7c7b\u578b
acpsdk.signCert.type=PKCS12
-
-
##########################\u9a8c\u7b7e\u8bc1\u4e66\u914d\u7f6e################################
##\u9a8c\u8bc1\u7b7e\u540d\u8bc1\u4e66\u76ee\u5f55
acpsdk.validateCert.dir=D:\\certs\\
diff --git a/jframe-pay/release/jframe-pay/conf/activemq.properties b/jframe-pay/jframe-pay-release/filter/activemq.properties
similarity index 55%
rename from jframe-pay/release/jframe-pay/conf/activemq.properties
rename to jframe-pay/jframe-pay-release/filter/activemq.properties
index 79c467a..91832d9 100644
--- a/jframe-pay/release/jframe-pay/conf/activemq.properties
+++ b/jframe-pay/jframe-pay-release/filter/activemq.properties
@@ -1,10 +1,8 @@
# def conf
-mq.url = tcp://192.168.1.123:61616
-mq.queue.pay = pay-queue
-
-# producer mq
+mq.url=tcp://192.168.1.123:61616
+mq.queue.pay=pay-queue
+# producer mq
#p.url = tcp://192.168.1.123:61616
-
# consumer mq
#c.url = tcp://192.168.1.123:61616
diff --git a/jframe-pay/jframe-pay-release/filter/alipay.properties b/jframe-pay/jframe-pay-release/filter/alipay.properties
new file mode 100644
index 0000000..d30fdac
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/filter/alipay.properties
@@ -0,0 +1,20 @@
+group.id=test
+notify_url=http://ip:port/pay/ord/aliback
+#
+@test.partner=208********202
+@test.seller.id=*****@***.com
+@test.subject=**\u79df\u8f66
+@test.app.id=****
+@test.private.key=
+@test.public.key =
+@test.ali_public_key=
+service = mobile.securitypay.pay
+payment_type=1
+input_charset=UTF-8
+it_b_pay=1h
+# return_url
+# paymethod
+# algo
+sign.type=RSA
+default_charset=UTF-8
+sign.algorithms=SHA1WithRSA
diff --git a/jframe-pay/release/jframe-pay/conf/config.properties b/jframe-pay/jframe-pay-release/filter/config.properties
similarity index 61%
rename from jframe-pay/release/jframe-pay/conf/config.properties
rename to jframe-pay/jframe-pay-release/filter/config.properties
index c1269c6..5e842ed 100755
--- a/jframe-pay/release/jframe-pay/conf/config.properties
+++ b/jframe-pay/jframe-pay-release/filter/config.properties
@@ -1,90 +1,78 @@
#application directory
-app.conf = ${app.home}/conf
-app.lib = ${app.home}/lib
-app.plugin = ${app.home}/plugin
+app.conf=${app.home}/conf
+app.lib=${app.home}/lib
+app.plugin=${app.home}/plugin
# upgrade file store directory
-app.update = ${app.home}/update
+app.update=${app.home}/update
# plug-in cache directory
-app.cache = ${app.home}/conf/cache
+app.cache=${app.home}/conf/cache
# plug-in temporary directory
-app.temp = ${app.home}/temp
-
+app.temp=${app.home}/temp
#configuration files
#file.units = ${app.home}/conf/units.xml
#file.signals = ${app.home}/conf/signals.def
-clean = true
+clean=true
#application's name,every app should has it's own name
-app.name = jframe.pay
+app.name=jframe.pay
#frame
-app.frame = jframe.core.DefFrame
-app.launcher = jframe.core.FrameLauncher
-
+app.frame=jframe.core.DefFrame
+app.launcher=jframe.core.FrameLauncher
#jvm's configuration file
-vmargs = ${app.home}/conf/vmargs
+vmargs=${app.home}/conf/vmargs
#if system is windows,use vmargs-win
#vmargs=${app.home}/conf/vmargs-win
-
#application's pid file
-app.pid = ${app.home}/temp/app.pid
+app.pid=${app.home}/temp/app.pid
#daemon process's pid file
-daemon.pid = ${app.home}/temp/daemon.pid
+daemon.pid=${app.home}/temp/daemon.pid
#launcher = jframe.launcher.FrameMain
#mode=daemon or normal,launch with daemon mode, otherwise launching normally
-launch.mode = daemon
+launch.mode=daemon
#context
#default dispatcher is jframe.core.dispatch.DefDispatcher
#context.dispatcher = jframe.ext.msg.pool.MsgPoolDispatcher
#context.dispatcher = jframe.ext.dispatch.ActivemqDispatcher
#file.dispatcher.mq = ${app.home}/conf/d-activemq.properties
-
-# plugins won't be started when starting
+# plugins won't be started when starting
#plugin.forbid = jframe.example.plugin.ExamplePlugin
-
# datasource
#multi.datasource=masterdb slavedb
#file.masterdb = ${app.home}/conf/mysql.properties
#file.slavedb = ${app.home}/conf/mysql_ro1.properties
#file.datasource = ${app.home}/conf/datasource.properties
-
# mybatis
-file.mybatis = ${app.home}/conf/mybatis-config.xml
-mybatis.id = run run_ro1
-file.mybatis.charset = utf-8
-
-
-file.upmp = ${app.home}/conf/upmp.properties
+file.mybatis=${app.home}/conf/mybatis-config.xml
+mybatis.id=run run_ro1
+file.mybatis.charset=utf-8
+file.upmp=${app.home}/conf/upmp.properties
#file.upmp = ${app.home}/conf/upmp_p.properties
-file.alipay = ${app.home}/conf/alipay.properties
-file.wx = ${app.home}/conf/wxpay.properties
+file.alipay=${app.home}/conf/alipay.properties
+file.wx=${app.home}/conf/wxpay.properties
#file.wx.pfx = ${app.home}/conf/1219114301_20140516113900.pfx
#alipay.properties
-groupid.alipay = test
+groupid.alipay=test
#wx.properties
-groupid.wxpay = test
+groupid.wxpay=test
#upmp.properties
-groupid.upmppay = test
-
-# http
-http.port = 8028
-https.enabled = false
-
+groupid.upmppay=test
+# http
+http.port=8028
+https.enabled=false
#redis conf file
#redis.conf = ${app.home}/conf/redis.properties
#file.getui = ${app.home}/conf/getui.properties
#file.pushy = ${app.home}/conf/pushy.properties
# task
-file.task = ${app.home}/conf/task.properties
+file.task=${app.home}/conf/task.properties
# activemq
#file.activemq = ${app.home}/conf/activemq.properties
-file.memcached = ${app.home}/conf/memcached.properties
+file.memcached=${app.home}/conf/memcached.properties
#file.emayclient = ${app.home}/conf/emayclient.properties
#file.yunpian = ${app.home}/conf/yunpian.properties
-file.httpclient = ${app.home}/conf/httpclient.properties
-
+file.httpclient=${app.home}/conf/httpclient.properties
#file.payclient = ${app.home}/conf/payclient.properties
#upmp.back.url = http://localhost:8018/pay/back/upmp
#file.qiniu = ${app.home}/conf/qiniu.properties
#file.mongoclient = ${app.home}/conf/mongoclient.properties
-
-token.disable = true
-jframe.debug = true
+token.disable=true
+jframe.debug=true
diff --git a/jframe-pay/release/jframe-pay/conf/d-activemq.properties b/jframe-pay/jframe-pay-release/filter/d-activemq.properties
similarity index 100%
rename from jframe-pay/release/jframe-pay/conf/d-activemq.properties
rename to jframe-pay/jframe-pay-release/filter/d-activemq.properties
diff --git a/jframe-pay/release/jframe-pay/conf/datasource.properties b/jframe-pay/jframe-pay-release/filter/datasource.properties
similarity index 100%
rename from jframe-pay/release/jframe-pay/conf/datasource.properties
rename to jframe-pay/jframe-pay-release/filter/datasource.properties
diff --git a/jframe-pay/release/jframe-pay/conf/http.properties b/jframe-pay/jframe-pay-release/filter/http.properties
similarity index 94%
rename from jframe-pay/release/jframe-pay/conf/http.properties
rename to jframe-pay/jframe-pay-release/filter/http.properties
index 04427c6..ac4bd45 100644
--- a/jframe-pay/release/jframe-pay/conf/http.properties
+++ b/jframe-pay/jframe-pay-release/filter/http.properties
@@ -1,14 +1,11 @@
# 连接超时
http.connection.timeout=15000
-
# 应答超时
http.so.timeout=30000
-
# 网络参数
http.stale.check.enabled=true
http.tcp.no.delay=true
http.default.max.connections.per.host=100
http.max.total.connections=1000
-
# 字符集
http.content.encoding=utf-8
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-release/filter/httpclient.properties b/jframe-pay/jframe-pay-release/filter/httpclient.properties
new file mode 100755
index 0000000..66e674f
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/filter/httpclient.properties
@@ -0,0 +1,16 @@
+group.id=payback
+#@indexHost.http.method = post
+#@indexHost.http.max.conn.route = 200
+#@indexHost.http.keep-alive = 5
+#@payback.ip = 127.0.0.1
+#@payback.port = 80
+@payback.group=jframe.pay
+http.method=post
+http.max.conn=100
+http.max.conn.route=200
+http.keep-alive=5
+#second
+http.idle.conn.close=30
+http.charset=utf-8
+http.so.timeout=2000
+http.conn.timeout=2000
diff --git a/jframe-pay/release/jframe-pay/conf/jmxremote.access b/jframe-pay/jframe-pay-release/filter/jmxremote.access
similarity index 100%
rename from jframe-pay/release/jframe-pay/conf/jmxremote.access
rename to jframe-pay/jframe-pay-release/filter/jmxremote.access
diff --git a/jframe-pay/release/jframe-pay/conf/jmxremote.password b/jframe-pay/jframe-pay-release/filter/jmxremote.password
similarity index 100%
rename from jframe-pay/release/jframe-pay/conf/jmxremote.password
rename to jframe-pay/jframe-pay-release/filter/jmxremote.password
diff --git a/jframe-pay/jframe-pay-release/filter/logback-daemon.xml b/jframe-pay/jframe-pay-release/filter/logback-daemon.xml
new file mode 100644
index 0000000..c21f188
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/filter/logback-daemon.xml
@@ -0,0 +1,45 @@
+
+
+ Application Daemon
+
+
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+ ${LOG_HOME}/jfd-%d{yyyy-MM-dd}.log
+
+ 10
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jframe-pay/jframe-pay-release/filter/logback.xml b/jframe-pay/jframe-pay-release/filter/logback.xml
new file mode 100644
index 0000000..ddf31d4
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/filter/logback.xml
@@ -0,0 +1,39 @@
+
+
+ Application
+
+
+
+
+
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
+
+
+
+
+
+
+
+ ${LOG_HOME}/jf-%d{yyyy-MM-dd}.log
+
+ 10
+
+
+ %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jframe-pay/release/jframe-pay/conf/management.properties b/jframe-pay/jframe-pay-release/filter/management.properties
similarity index 99%
rename from jframe-pay/release/jframe-pay/conf/management.properties
rename to jframe-pay/jframe-pay-release/filter/management.properties
index db08b78..48aad26 100644
--- a/jframe-pay/release/jframe-pay/conf/management.properties
+++ b/jframe-pay/jframe-pay-release/filter/management.properties
@@ -28,7 +28,6 @@
#
# For setting the SNMP agent port use the following line
# com.sun.management.snmp.port=
-
#####################################################################
# Optional Instrumentation
#####################################################################
@@ -45,10 +44,8 @@
# Refer to the specification for the java.lang.management.ThreadMBean
# interface - see isThreadContentionMonitoringSupported() method.
#
-
# To enable thread contention monitoring, uncomment the following line
# com.sun.management.enableThreadContentionMonitoring
-
#####################################################################
# SNMP Management Properties
#####################################################################
@@ -63,7 +60,6 @@
# Later changes to the above system property (e.g. via setProperty method), this
# config file, or the ACL file has no effect to the running SNMP agent.
#
-
#
# ##################### SNMP Trap Port #########################
#
@@ -73,10 +69,8 @@
# the SNMP agent will send traps at :
# Default for this property is 162.
#
-
# To set port for sending traps to a different port use the following line
# com.sun.management.snmp.trap=
-
#
# ################ SNMP listen interface #########################
#
@@ -90,10 +84,8 @@
# The format of the value for that property is any string accepted
# by java.net.InetAddress.getByName(String).
#
-
# For restricting the port on which SNMP agent listens use the following line
# com.sun.management.snmp.interface=
-
#
# #################### SNMP ACL file #########################
#
@@ -102,10 +94,8 @@
# If this property is specified as false then the ACL file
# is not checked: all manager hosts are allowed all access.
#
-
# For SNMP without checking ACL file uncomment the following line
# com.sun.management.snmp.acl=false
-
#
# com.sun.management.snmp.acl.file=filepath
# Specifies location for ACL file
@@ -121,10 +111,8 @@
# Modification to the ACL file has no effect to any running SNMP
# agents which read that ACL file at startup.
#
-
# For a non-default acl file location use the following line
# com.sun.management.snmp.acl.file=filepath
-
#####################################################################
# RMI Management Properties
#####################################################################
@@ -142,7 +130,6 @@
# this config file, the password file, or the access file have no effect to the
# running MBean server, the connector, or the registry.
#
-
#
# ########## RMI connector settings for local management ##########
#
@@ -158,11 +145,9 @@
# For remote management the remote JMX RMI connector server should
# be used instead with authentication and SSL/TLS encryption enabled.
#
-
# For allowing the local management agent accept local
# and remote connection requests use the following line
# com.sun.management.jmxremote.local.only=false
-
#
# ###################### RMI SSL #############################
#
@@ -170,10 +155,8 @@
# Default for this property is true. (Case for true/false ignored)
# If this property is specified as false then SSL is not used.
#
-
# For RMI monitoring without SSL use the following line
# com.sun.management.jmxremote.ssl=false
-
# com.sun.management.jmxremote.ssl.config.file=filepath
# Specifies the location of the SSL configuration file. A properties
# file can be used to supply the keystore and truststore location and
@@ -194,10 +177,8 @@
# If the property "com.sun.management.jmxremote.ssl" is set to false,
# then this property is ignored.
#
-
# For supplying the keystore settings in a file use the following line
# com.sun.management.jmxremote.ssl.config.file=filepath
-
# com.sun.management.jmxremote.ssl.enabled.cipher.suites=
# The value of this property is a string that is a comma-separated list
# of SSL/TLS cipher suites to enable. This property can be specified in
@@ -207,7 +188,6 @@
# the SSL/TLS RMI Server Socket Factory uses the SSL/TLS cipher suites that
# are enabled by default.
#
-
# com.sun.management.jmxremote.ssl.enabled.protocols=
# The value of this property is a string that is a comma-separated list
# of SSL/TLS protocol versions to enable. This property can be specified in
@@ -217,17 +197,14 @@
# specified then the SSL/TLS RMI Server Socket Factory uses the SSL/TLS
# protocol versions that are enabled by default.
#
-
# com.sun.management.jmxremote.ssl.need.client.auth=true|false
# Default for this property is false. (Case for true/false ignored)
# If this property is specified as true in conjunction with the previous
# property "com.sun.management.jmxremote.ssl" then the SSL/TLS RMI Server
# Socket Factory will require client authentication.
#
-
# For RMI monitoring with SSL client authentication use the following line
# com.sun.management.jmxremote.ssl.need.client.auth=true
-
# com.sun.management.jmxremote.registry.ssl=true|false
# Default for this property is false. (Case for true/false ignored)
# If this property is specified as true then the RMI registry used
@@ -243,10 +220,8 @@
# then the RMIServer remote object and the RMI registry are
# both exported with the same SSL/TLS RMI Socket Factories.
#
-
# For using an SSL/TLS protected RMI registry use the following line
# com.sun.management.jmxremote.registry.ssl=true
-
#
# ################ RMI User authentication ################
#
@@ -255,10 +230,8 @@
# If this property is specified as false then no authentication is
# performed and all users are allowed all access.
#
-
# For RMI monitoring without any checking use the following line
# com.sun.management.jmxremote.authenticate=false
-
#
# ################ RMI Login configuration ###################
#
@@ -279,10 +252,8 @@
# If the property "com.sun.management.jmxremote.authenticate" is set to
# false, then this property and the password & access files are ignored.
#
-
# For a non-default login configuration use the following line
# com.sun.management.jmxremote.login.config=
-
#
# ################ RMI Password file location ##################
#
@@ -296,10 +267,8 @@
# Otherwise the password file must exist and be in the valid format.
# If the password file is empty or non-existent then no access is allowed.
#
-
# For a non-default password file location use the following line
# com.sun.management.jmxremote.password.file=filepath
-
#
# ################ RMI Access file location #####################
#
@@ -313,6 +282,5 @@
# Otherwise, the access file must exist and be in the valid format.
# If the access file is empty or non-existent then no access is allowed.
#
-
# For a non-default password file location use the following line
# com.sun.management.jmxremote.access.file=filepath
diff --git a/jframe-pay/jframe-pay-release/filter/memcached.properties b/jframe-pay/jframe-pay-release/filter/memcached.properties
new file mode 100755
index 0000000..f940159
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/filter/memcached.properties
@@ -0,0 +1,20 @@
+mem.name=mem
+mem.servers=s1 s2
+#mem.servers = local
+mem.server.local.host=127.0.0.1
+mem.server.local.port=11211
+mem.server.local.weight=1
+mem.server.s1.host=10.4.8.151
+mem.server.s1.port=11211
+mem.server.s1.weight=1
+mem.server.s2.host=10.4.8.213
+mem.server.s2.port=11211
+mem.server.s2.weight=1
+# memcached parameters
+mem.initconn=10
+mem.minconn=5
+mem.maxconn=250
+# seconds
+mem.maxidle=3600000
+mem.timeout.read=3000
+mem.timeout.conn=3000
\ No newline at end of file
diff --git a/jframe-pay/release/jframe-pay/conf/mybatis-config.xml b/jframe-pay/jframe-pay-release/filter/mybatis-config.xml
similarity index 100%
rename from jframe-pay/release/jframe-pay/conf/mybatis-config.xml
rename to jframe-pay/jframe-pay-release/filter/mybatis-config.xml
diff --git a/jframe-pay/jframe-pay-release/filter/payclient.properties b/jframe-pay/jframe-pay-release/filter/payclient.properties
new file mode 100755
index 0000000..0820d55
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/filter/payclient.properties
@@ -0,0 +1,14 @@
+# http,https,ws,dono
+pay.connection=http
+pay.version=1.0.0
+pay.charset=utf-8
+# http
+http.ip=192.168.1.123
+http.port=8028
+http.pay.path=/pay
+http.usr.path=/usr
+# ws
+# ws.ip =
+#
+ch.timeout=5000
+ch.thread.count=1
diff --git a/jframe-pay/jframe-pay-release/filter/task.properties b/jframe-pay/jframe-pay-release/filter/task.properties
new file mode 100755
index 0000000..8146121
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/filter/task.properties
@@ -0,0 +1,15 @@
+#true or false ,default is true
+task.start=true
+# p,c,pc
+task.mode=p
+# default
+task.timeout=120
+task.count=30
+# TaskType
+task.types=1,100
+# task 1 back url
+task.1.timeout=120
+task.1.count=30
+# task 100 upmp query order
+task.100.timeout=180
+task.100.count=20
diff --git a/jframe-pay/jframe-pay-release/filter/upmp.properties b/jframe-pay/jframe-pay-release/filter/upmp.properties
new file mode 100644
index 0000000..716c9e2
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/filter/upmp.properties
@@ -0,0 +1,18 @@
+#group
+group.id=test run
+# test
+@test.mer.id=***********
+@test.back.url=http://ip:port/pay/back/upmpback
+#@test.front.url= http://183.129.161.72:8018/pay/back/upmp
+@test.acp.sdk=${app.home}/conf/acp_sdk_dev.properties
+# run
+@run.mer.id=************
+@run.back.url=http://ip:port/pay/back/upmpback
+#@test.front.url= http://183.129.161.72:8018/pay/back/upmp
+@run.acp.sdk=${app.home}/conf/acp_sdk_run.properties
+# 01-Debit Card 02-Credit Card
+# mer.reserved={cardType=02}
+# message info
+version=5.0.0
+charset=UTF-8
+
diff --git a/jframe-pay/release/jframe-pay/conf/vmargs b/jframe-pay/jframe-pay-release/filter/vmargs
similarity index 100%
rename from jframe-pay/release/jframe-pay/conf/vmargs
rename to jframe-pay/jframe-pay-release/filter/vmargs
diff --git a/jframe-pay/release/jframe-pay/conf/vmargs-win b/jframe-pay/jframe-pay-release/filter/vmargs-win
similarity index 100%
rename from jframe-pay/release/jframe-pay/conf/vmargs-win
rename to jframe-pay/jframe-pay-release/filter/vmargs-win
diff --git a/jframe-pay/jframe-pay-release/filter/wxpay.properties b/jframe-pay/jframe-pay-release/filter/wxpay.properties
new file mode 100644
index 0000000..8eff0e2
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/filter/wxpay.properties
@@ -0,0 +1,20 @@
+group.id=test
+# partner
+@test.partner=******1212
+#@test.partner.key = *********22276e34a
+# app
+@test.app.id=
+@test.app.secret=
+@test.app.key =
+# message info
+version=1.0.0
+charset=UTF-8
+sign.method=sha1
+grant.type=client_credential
+# url
+token.url=https://api.weixin.qq.com/cgi-bin/token
+#gate.url = https://api.weixin.qq.com/pay/genprepay?access_token=
+gate.url=https://api.weixin.qq.com/pay/genprepay
+notify.url=http://ip:port/pay/ord/wxback
+# default is http
+use.https=false
\ No newline at end of file
diff --git a/jframe-pay/jframe-pay-release/pom.xml b/jframe-pay/jframe-pay-release/pom.xml
new file mode 100644
index 0000000..8eb39d5
--- /dev/null
+++ b/jframe-pay/jframe-pay-release/pom.xml
@@ -0,0 +1,116 @@
+
+ 4.0.0
+
+ io.github.dzh
+ jframe-pay
+ 2.0.0-SNAPSHOT
+
+ jframe-pay-release
+ pom
+
+
+
+ ${project.basedir}/filter.properties
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+
+ compile
+
+
+ copy-resources
+ validate
+
+ copy-resources
+
+
+ ${project.basedir}/conf
+
+
+ ${project.basedir}/filter
+ true
+
+
+
+
+
+
+ ${project.build.sourceEncoding}
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy-plugin
+ package
+
+ copy-dependencies
+
+
+ ${project.basedir}/plugin/
+ true
+ true
+ false
+ compile
+ plugin
+
+
+
+ copy-lib
+ package
+
+ copy-dependencies
+
+
+ ${project.basedir}/lib/
+ true
+ true
+ false
+ compile
+ plugin
+
+
+
+
+
+
+
+
+
+ io.github.dzh
+ jframe-launcher
+
+
+
+ io.github.dzh
+ jframe-pay-http
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-dao
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-alipay
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-upmp
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-wx
+ plugin
+
+
+
\ No newline at end of file
diff --git a/jframe-pay/pom.xml b/jframe-pay/pom.xml
index 3323af8..f1131bb 100644
--- a/jframe-pay/pom.xml
+++ b/jframe-pay/pom.xml
@@ -1,111 +1,229 @@
- 4.0.0
- cn
- jframe-pay
- 1.0.0
- pom
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+ io.github.dzh
+ jframe-pay
+ 2.0.0-SNAPSHOT
+ pom
-
- UTF-8
- 1.2.1
-
+
+ UTF-8
+ 2.0.0-SNAPSHOT
+ 1.7.26
+
-
-
-
- src/main/java
-
- **/*.properties
- **/*.xml
-
-
-
- src/main/resources
-
- **/*.properties
- **/*.xml
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
- 1.8
- 1.8
- ${project.build.sourceEncoding}
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 3.1.0
-
-
- compile
-
-
-
- ${project.build.sourceEncoding}
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 3.0.0-M2
-
- true
-
-
-
-
+
+
+
+ src/main/java
+
+ **/*.properties
+ **/*.xml
+
+
+
+ src/main/resources
+
+ **/*.properties
+ **/*.xml
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 3.1.0
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+ 1.8
+ 1.8
+ ${project.build.sourceEncoding}
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.1.0
+
+
+ compile
+
+
+
+ ${project.build.sourceEncoding}
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M2
+
+ true
+
+
+
+
-
- jframe-pay-lib
- jframe-pay-plugin
- jframe-pay-client
- release
-
-
-
- junit
- junit
- 4.12
- test
-
-
- org.slf4j
- slf4j-api
- 1.7.12
-
-
- org.slf4j
- slf4j-simple
- 1.7.12
- test
-
-
- cn
- jframe-core
- ${jframe.version}
-
-
- cn
- jframe-ext
- ${jframe.version}
-
-
- org.apache.httpcomponents
- httpcore
- 4.4
-
-
- org.apache.httpcomponents
- httpclient
- 4.4
-
-
+
+ jframe-pay-lib
+ jframe-pay-plugin
+ jframe-pay-release
+
+
+
+
+
+
+ io.github.dzh
+ jframe-launcher
+ ${jframe.version}
+
+
+ io.github.dzh
+ jframe-core
+ ${jframe.version}
+
+
+ io.github.dzh
+ jframe-ext
+ ${jframe.version}
+
+
+
+
+ io.github.dzh
+ jframe-memcached-client
+ ${jframe.version}
+ plugin
+
+
+ io.github.dzh
+ jframe-httpclient
+ ${jframe.version}
+ plugin
+
+
+ io.github.dzh
+ jframe-mybatis
+ ${jframe.version}
+ plugin
+
+
+
+
+ io.github.dzh
+ jframe-pay-domain
+ ${project.version}
+
+
+ org.dom4j
+ dom4j
+ 2.1.1
+
+
+ jaxen
+ jaxen
+ 1.2.0
+
+
+ com.alibaba
+ fastjson
+ 1.2.58
+
+
+ com.google.code.gson
+ gson
+ 2.8.5
+
+
+ commons-codec
+ commons-codec
+ 1.12
+
+
+ org.apache.httpcomponents
+ httpcore
+ 4.4.11
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.9
+
+
+
+
+ io.github.dzh
+ jframe-pay-alipay
+ ${project.version}
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-dao
+ ${project.version}
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-http
+ ${project.version}
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-task
+ ${project.version}
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-upmp
+ ${project.version}
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-wx
+ ${project.version}
+ plugin
+
+
+ io.github.dzh
+ jframe-pay-client
+ ${project.version}
+ plugin
+
+
+
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+ org.slf4j
+ slf4j-simple
+ ${slf4j.version}
+ test
+
+
\ No newline at end of file
diff --git a/jframe-pay/release/jframe-pay/conf/alipay.properties b/jframe-pay/release/jframe-pay/conf/alipay.properties
deleted file mode 100644
index 73a296a..0000000
--- a/jframe-pay/release/jframe-pay/conf/alipay.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-group.id = test
-
-notify_url = http://ip:port/pay/ord/aliback
-
-#
-@test.partner = 208********202
-@test.seller.id = *****@***.com
-@test.subject = **\u79df\u8f66
-@test.app.id = ****
-@test.private.key =
-@test.public.key =
-@test.ali_public_key =
-
-service = mobile.securitypay.pay
-payment_type = 1
-input_charset = UTF-8
-it_b_pay = 1h
-# return_url
-# paymethod
-
-# algo
-sign.type = RSA
-default_charset = UTF-8
-sign.algorithms = SHA1WithRSA
diff --git a/jframe-pay/release/jframe-pay/conf/httpclient.properties b/jframe-pay/release/jframe-pay/conf/httpclient.properties
deleted file mode 100755
index da4a097..0000000
--- a/jframe-pay/release/jframe-pay/conf/httpclient.properties
+++ /dev/null
@@ -1,20 +0,0 @@
-group.id = payback
-
-#@indexHost.http.method = post
-#@indexHost.http.max.conn.route = 200
-#@indexHost.http.keep-alive = 5
-
-#@payback.ip = 127.0.0.1
-#@payback.port = 80
-@payback.group = jframe.pay
-
-http.method = post
-http.max.conn = 100
-http.max.conn.route = 200
-http.keep-alive = 5
-#second
-http.idle.conn.close = 30
-http.charset = utf-8
-
-http.so.timeout = 2000
-http.conn.timeout = 2000
diff --git a/jframe-pay/release/jframe-pay/conf/logback-daemon.xml b/jframe-pay/release/jframe-pay/conf/logback-daemon.xml
deleted file mode 100644
index c5cf1ae..0000000
--- a/jframe-pay/release/jframe-pay/conf/logback-daemon.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
- Application Daemon
-
-
-
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
- ${LOG_HOME}/jfd-%d{yyyy-MM-dd}.log
-
- 10
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jframe-pay/release/jframe-pay/conf/logback.xml b/jframe-pay/release/jframe-pay/conf/logback.xml
deleted file mode 100644
index 1d02fee..0000000
--- a/jframe-pay/release/jframe-pay/conf/logback.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
- Application
-
-
-
-
-
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
-
-
-
-
-
-
-
- ${LOG_HOME}/jf-%d{yyyy-MM-dd}.log
-
- 10
-
-
- %d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jframe-pay/release/jframe-pay/conf/memcached.properties b/jframe-pay/release/jframe-pay/conf/memcached.properties
deleted file mode 100755
index 075815b..0000000
--- a/jframe-pay/release/jframe-pay/conf/memcached.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-mem.name = mem
-
-mem.servers = s1 s2
-#mem.servers = local
-
-mem.server.local.host = 127.0.0.1
-mem.server.local.port = 11211
-mem.server.local.weight = 1
-
-mem.server.s1.host = 10.4.8.151
-mem.server.s1.port = 11211
-mem.server.s1.weight = 1
-
-mem.server.s2.host = 10.4.8.213
-mem.server.s2.port = 11211
-mem.server.s2.weight = 1
-
-
-# memcached parameters
-mem.initconn = 10
-mem.minconn = 5
-mem.maxconn = 250
-# seconds
-mem.maxidle = 3600000
-mem.timeout.read = 3000
-mem.timeout.conn = 3000
\ No newline at end of file
diff --git a/jframe-pay/release/jframe-pay/conf/payclient.properties b/jframe-pay/release/jframe-pay/conf/payclient.properties
deleted file mode 100755
index 284fd87..0000000
--- a/jframe-pay/release/jframe-pay/conf/payclient.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# http,https,ws,dono
-pay.connection = http
-pay.version = 1.0.0
-pay.charset = utf-8
-
-# http
-http.ip = 192.168.1.123
-http.port = 8028
-
-http.pay.path = /pay
-http.usr.path = /usr
-
-# ws
-# ws.ip =
-
-#
-ch.timeout = 5000
-ch.thread.count = 1
diff --git a/jframe-pay/release/jframe-pay/conf/task.properties b/jframe-pay/release/jframe-pay/conf/task.properties
deleted file mode 100755
index 9eb5acf..0000000
--- a/jframe-pay/release/jframe-pay/conf/task.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-#true or false ,default is true
-task.start = true
-# p,c,pc
-task.mode = p
-
-# default
-task.timeout = 120
-task.count = 30
-
-# TaskType
-task.types = 1,100
-
-# task 1 back url
-task.1.timeout = 120
-task.1.count = 30
-
-# task 100 upmp query order
-task.100.timeout = 180
-task.100.count = 20
diff --git a/jframe-pay/release/jframe-pay/conf/upmp.properties b/jframe-pay/release/jframe-pay/conf/upmp.properties
deleted file mode 100644
index cf633b1..0000000
--- a/jframe-pay/release/jframe-pay/conf/upmp.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-#group
-group.id = test run
-
-
-# test
-@test.mer.id = ***********
-@test.back.url = http://ip:port/pay/back/upmpback
-#@test.front.url= http://183.129.161.72:8018/pay/back/upmp
-@test.acp.sdk = ${app.home}/conf/acp_sdk_dev.properties
-
-# run
-@run.mer.id = ************
-@run.back.url = http://ip:port/pay/back/upmpback
-#@test.front.url= http://183.129.161.72:8018/pay/back/upmp
-@run.acp.sdk = ${app.home}/conf/acp_sdk_run.properties
-# 01-Debit Card 02-Credit Card
-# mer.reserved={cardType=02}
-
-# message info
-version=5.0.0
-charset=UTF-8
-
diff --git a/jframe-pay/release/jframe-pay/conf/wxpay.properties b/jframe-pay/release/jframe-pay/conf/wxpay.properties
deleted file mode 100644
index 12b46c1..0000000
--- a/jframe-pay/release/jframe-pay/conf/wxpay.properties
+++ /dev/null
@@ -1,27 +0,0 @@
-group.id = test
-
-# partner
-@test.partner = ******1212
-#@test.partner.key = *********22276e34a
-# app
-@test.app.id =
-@test.app.secret =
-@test.app.key =
-# message info
-version=1.0.0
-charset=UTF-8
-sign.method=sha1
-
-grant.type = client_credential
-
-# url
-token.url = https://api.weixin.qq.com/cgi-bin/token
-
-
-#gate.url = https://api.weixin.qq.com/pay/genprepay?access_token=
-gate.url = https://api.weixin.qq.com/pay/genprepay
-
-notify.url = http://ip:port/pay/ord/wxback
-
-# default is http
-use.https=false
\ No newline at end of file
diff --git a/jframe-pay/release/pom.xml b/jframe-pay/release/pom.xml
deleted file mode 100644
index 6acbd2d..0000000
--- a/jframe-pay/release/pom.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-
- 4.0.0
-
- cn
- jframe-pay
- 1.0.0
-
- release
- pom
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
- 2.10
-
-
- copy-lib
- package
-
- copy-dependencies
-
-
- ${project.basedir}/jframe-pay/lib/
- true
- true
- false
- compile
- plugin
-
-
-
- copy-plugin
- package
-
- copy-dependencies
-
-
- ${project.basedir}/jframe-pay/plugin/
- true
- true
- false
- compile
- plugin
-
-
-
-
-
-
-
-
- org.eclipse.m2e
- lifecycle-mapping
- 1.0.0
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
- [2.8,)
-
- copy-dependencies
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- cn
- jframe-launcher
- ${jframe.version}
-
-
- cn
- jframe-pay-http
- 1.0.0
- plugin
-
-
- cn
- jframe-pay-dao
- 1.0.0
- plugin
-
-
- cn
- jframe-pay-alipay
- 1.0.0
- plugin
-
-
- cn
- jframe-pay-upmp
- 1.0.0
- plugin
-
-
- cn
- jframe-pay-wx
- 1.0.0
- plugin
-
-
-
\ No newline at end of file
diff --git a/jframe-plugin/jframe-httpclient/pom.xml b/jframe-plugin/jframe-httpclient/pom.xml
index 917f582..45511bf 100644
--- a/jframe-plugin/jframe-httpclient/pom.xml
+++ b/jframe-plugin/jframe-httpclient/pom.xml
@@ -1,28 +1,28 @@
- 4.0.0
-
- jframe-plugin
- 2.0.0-SNAPSHOT
- io.github.dzh
-
- jframe-httpclient
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ jframe-plugin
+ 2.0.0-SNAPSHOT
+ io.github.dzh
+
+ jframe-httpclient
-
-
- org.apache.httpcomponents
- httpcore
- 4.4.10
-
-
- org.apache.httpcomponents
- httpclient
- 4.5.6
-
-
- com.google.code.gson
- gson
- 2.8.5
-
-
+
+
+ org.apache.httpcomponents
+ httpcore
+ 4.4.11
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.9
+
+
+ com.google.code.gson
+ gson
+ 2.8.5
+
+
\ No newline at end of file
From e14acfc70894619da74ad079a327e32125de3d6e Mon Sep 17 00:00:00 2001
From: dzh
Date: Sat, 3 Aug 2019 17:18:53 +0800
Subject: [PATCH 03/47] add jframe-alipay
---
jframe-plugin/jframe-alipay/pom.xml | 23 ++++
.../main/java/jframe/alipay/AlipayPlugin.java | 10 ++
.../jframe/alipay/service/AlipayService.java | 47 +++++++
.../alipay/service/AlipayServiceImpl.java | 124 ++++++++++++++++++
.../main/resources/META-INF/plugin.properties | 7 +
.../alipay/service/TestAlipayService.java | 10 ++
.../jframe/alipay/service/alipay.properties | 11 ++
.../aliyun/service/dm/DMServiceImpl.java | 33 ++---
.../aliyun/service/oss/OSSServiceImpl.java | 37 +++---
.../aliyun/service/sms/SMSServiceImpl.java | 37 +++---
.../aliyun/service/sts/STSServiceImpl.java | 34 ++---
jframe-plugin/pom.xml | 1 +
12 files changed, 304 insertions(+), 70 deletions(-)
create mode 100644 jframe-plugin/jframe-alipay/pom.xml
create mode 100644 jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/AlipayPlugin.java
create mode 100644 jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java
create mode 100644 jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java
create mode 100644 jframe-plugin/jframe-alipay/src/main/resources/META-INF/plugin.properties
create mode 100644 jframe-plugin/jframe-alipay/src/test/java/jframe/alipay/service/TestAlipayService.java
create mode 100644 jframe-plugin/jframe-alipay/src/test/java/jframe/alipay/service/alipay.properties
diff --git a/jframe-plugin/jframe-alipay/pom.xml b/jframe-plugin/jframe-alipay/pom.xml
new file mode 100644
index 0000000..380949c
--- /dev/null
+++ b/jframe-plugin/jframe-alipay/pom.xml
@@ -0,0 +1,23 @@
+
+
+
+ jframe-plugin
+ io.github.dzh
+ 2.0.0-SNAPSHOT
+
+ 4.0.0
+
+ jframe-alipay
+
+
+
+ com.alipay.sdk
+ alipay-sdk-java
+ 3.7.110.ALL
+
+
+
+
+
\ No newline at end of file
diff --git a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/AlipayPlugin.java b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/AlipayPlugin.java
new file mode 100644
index 0000000..e58270e
--- /dev/null
+++ b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/AlipayPlugin.java
@@ -0,0 +1,10 @@
+package jframe.alipay;
+
+import jframe.core.plugin.DefPlugin;
+
+/**
+ * @author dzh
+ * @date 2019-07-22 14:55
+ */
+public class AlipayPlugin extends DefPlugin {
+}
diff --git a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java
new file mode 100644
index 0000000..c314054
--- /dev/null
+++ b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java
@@ -0,0 +1,47 @@
+package jframe.alipay.service;
+
+import com.alipay.api.AlipayClient;
+import jframe.core.plugin.annotation.Service;
+
+import java.util.Map;
+
+/**
+ * https://docs.open.alipay.com/270/105899/
+ * https://docs.open.alipay.com/api_1/alipay.trade.page.pay/
+ *
+ * https://openhome.alipay.com/platform/demoManage.htm#/alipay.trade.page.pay
+ * https://openhome.alipay.com/platform/appDaily.htm?tab=info
+ *
+ * @author dzh
+ * @date 2019-07-22 14:56
+ */
+@Service(clazz = "jframe.alipay.service.AlipayServiceImpl", id = "jframe.service.alipay")
+public interface AlipayService {
+
+ String F_URL = "url";
+ String F_APP_ID = "app.id";
+ String F_PRIVATE_KEY = "private.key";
+ String F_PUBLIC_KEY = "public.key";
+ String F_FORMAT = "format";
+ String F_CHARSET = "charset";
+ String F_SIGN_TYPE = "sign.type";
+ String F_RETURN_URL = "return.url";
+ String F_NOTIFY_URL = "notify.url";
+
+ String TRADE_STATUS_WAIT = "WAIT_BUYER_PAY"; //交易创建,等待买家付款
+ String TRADE_STATUS_CLOSED = "TRADE_CLOSED"; //未付款交易超时关闭,或支付完成后全额退款
+ String TRADE_STATUS_SUCC = "TRADE_SUCCESS"; //交易支付成功
+ String TRADE_STATUS_FINISHED = "TRADE_FINISHED"; //交易结束,不可退款
+
+
+ AlipayClient getClient(String id);
+
+ /**
+ * @param id
+ * @param param 异步返回参数
+ * @return
+ */
+ boolean checkAsyncReturn(String id, Map param);
+
+ String getConf(String id, String key);
+}
diff --git a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java
new file mode 100644
index 0000000..3517fef
--- /dev/null
+++ b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java
@@ -0,0 +1,124 @@
+package jframe.alipay.service;
+
+import com.alipay.api.AlipayApiException;
+import com.alipay.api.AlipayClient;
+import com.alipay.api.DefaultAlipayClient;
+import com.alipay.api.internal.util.AlipaySignature;
+import jframe.alipay.AlipayPlugin;
+import jframe.core.conf.Config;
+import jframe.core.plugin.annotation.InjectPlugin;
+import jframe.core.plugin.annotation.Injector;
+import jframe.core.plugin.annotation.Start;
+import jframe.core.plugin.annotation.Stop;
+import jframe.core.util.PropsConf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author dzh
+ * @date 2019-07-22 14:58
+ */
+@Injector
+class AlipayServiceImpl implements AlipayService {
+ static Logger LOG = LoggerFactory.getLogger(AlipayServiceImpl.class);
+
+ @InjectPlugin
+ static AlipayPlugin plugin;
+
+ static String FILE_ALIPAY = "file.alipay";
+
+ //group id -> AlipayClient
+ private Map clients = new HashMap<>();
+
+ private PropsConf alipayConf;
+
+ @Start
+ void start() {
+ LOG.info("Start AlipayService");
+ try {
+ String file = plugin.getConfig(FILE_ALIPAY, plugin.getConfig(Config.APP_CONF) + "/alipay.properties");
+ if (!new File(file).exists()) {
+ throw new FileNotFoundException("not found " + file);
+ }
+ alipayConf = new PropsConf();
+ alipayConf.init(file);
+ for (String id : alipayConf.getGroupIds()) {
+ AlipayClient client = createAlipayClient(alipayConf, id);
+ clients.put(id, client);
+ }
+ LOG.info("Start AlipayService Successfully!");
+ } catch (Exception e) {
+ LOG.error("Start AlipayService Failed!" + e.getMessage(), e);
+ }
+ }
+
+ /**
+ * https://docs.open.alipay.com/270/105899/
+ *
+ * AlipayClient alipayClient = new DefaultAlipayClient(URL,APP_ID,APP_PRIVATE_KEY,FORMAT,CHARSET,ALIPAY_PUBLIC_KEY,SIGN_TYPE);
+ *
+ * 配置参数 示例值解释 获取方式/示例值
+ * URL 支付宝网关(固定) https://openapi.alipay.com/gateway.do
+ * APPID APPID 即创建应用后生成 获取见上方创建应用
+ * APP_PRIVATE_KEY 开发者私钥,由开发者自己生成 获取见配置密钥
+ * FORMAT 参数返回格式,只支持 json json(固定)
+ * CHARSET 编码集,支持 GBK/UTF-8 开发者根据实际工程编码配置
+ * ALIPAY_PUBLIC_KEY 支付宝公钥,由支付宝生成 获取详见配置密钥
+ * SIGN_TYPE 商户生成签名字符串所使用的签名算法类型,目前支持 RSA2 和 RSA,推荐使用 RSA2 RSA2
+ *
+ * @param conf
+ * @param id
+ * @return
+ */
+ private AlipayClient createAlipayClient(PropsConf conf, String id) {
+ String url = conf.getConf(id, F_URL);
+ String appId = conf.getConf(id, F_APP_ID);
+ String privateKey = conf.getConf(id, F_PRIVATE_KEY);
+ String format = conf.getConf(id, F_FORMAT);
+ String charset = conf.getConf(id, F_CHARSET);
+ String publicKey = conf.getConf(id, F_PUBLIC_KEY);
+ String signType = conf.getConf(id, F_SIGN_TYPE);
+ AlipayClient alipayClient = new DefaultAlipayClient(url, appId, privateKey, format, charset, publicKey, signType);
+ LOG.info("createAlipayClient {}", appId);
+ return alipayClient;
+ }
+
+ @Stop
+ void stop() {
+// if (clients != null) for (Map.Entry c : clients.entrySet()) {
+// try {
+// } catch (Exception e) {
+// LOG.error(e.getMessage(), e.fillInStackTrace());
+// }
+// }
+ clients.clear();
+ LOG.info("Stop AlipayService");
+ }
+
+ @Override
+ public AlipayClient getClient(String id) {
+ return clients.get(id);
+ }
+
+ @Override
+ public boolean checkAsyncReturn(String id, Map param) {
+ try {
+ return AlipaySignature.rsaCheckV2(param, getConf(id, F_PUBLIC_KEY), getConf(id, F_CHARSET), getConf(id, F_SIGN_TYPE));
+ } catch (AlipayApiException e) {
+ LOG.error(e.getErrMsg(), e);
+ }
+ return false;
+ }
+
+ @Override
+ public String getConf(String id, String key) {
+ return alipayConf.getConf(id, key);
+ }
+
+
+}
diff --git a/jframe-plugin/jframe-alipay/src/main/resources/META-INF/plugin.properties b/jframe-plugin/jframe-alipay/src/main/resources/META-INF/plugin.properties
new file mode 100644
index 0000000..c55908b
--- /dev/null
+++ b/jframe-plugin/jframe-alipay/src/main/resources/META-INF/plugin.properties
@@ -0,0 +1,7 @@
+Plugin-Name=jframe.alipay.AlipayPlugin
+Plugin-Class=jframe.alipay.AlipayPlugin
+#Default library path is META-INF/lib/
+#Plugin-Lib =
+#Default DLL path is META-INF/dll
+#Plugin-Dll =
+Plugin-Service=jframe.alipay.service.AlipayService
diff --git a/jframe-plugin/jframe-alipay/src/test/java/jframe/alipay/service/TestAlipayService.java b/jframe-plugin/jframe-alipay/src/test/java/jframe/alipay/service/TestAlipayService.java
new file mode 100644
index 0000000..07c1979
--- /dev/null
+++ b/jframe-plugin/jframe-alipay/src/test/java/jframe/alipay/service/TestAlipayService.java
@@ -0,0 +1,10 @@
+package jframe.alipay.service;
+
+/**
+ * @author dzh
+ * @date 2019-07-22 14:59
+ */
+public class TestAlipayService {
+
+
+}
diff --git a/jframe-plugin/jframe-alipay/src/test/java/jframe/alipay/service/alipay.properties b/jframe-plugin/jframe-alipay/src/test/java/jframe/alipay/service/alipay.properties
new file mode 100644
index 0000000..1441e6a
--- /dev/null
+++ b/jframe-plugin/jframe-alipay/src/test/java/jframe/alipay/service/alipay.properties
@@ -0,0 +1,11 @@
+group.id=test
+#
+@test.url=https://openapi.alipaydev.com/gateway.do
+@test.app.id=
+@test.private.key=
+@test.return.url=
+@test.notify.url=
+format=json
+sign.type=RSA2
+charset=UTF-8
+public.key=
\ No newline at end of file
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/dm/DMServiceImpl.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/dm/DMServiceImpl.java
index 4bac845..bf84f03 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/dm/DMServiceImpl.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/dm/DMServiceImpl.java
@@ -1,21 +1,11 @@
package jframe.aliyun.service.dm;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.dm.model.v20151123.SingleSendMailRequest;
import com.aliyuncs.dm.model.v20151123.SingleSendMailResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
-
import jframe.aliyun.AliyunField;
import jframe.aliyun.AliyunPlugin;
import jframe.aliyun.service.DMService;
@@ -25,11 +15,19 @@
import jframe.core.plugin.annotation.Start;
import jframe.core.plugin.annotation.Stop;
import jframe.core.util.PropsConf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
/**
* @author dzh
- * @date Dec 10, 2018 2:10:20 PM
* @version 0.0.1
+ * @date Dec 10, 2018 2:10:20 PM
*/
@Injector
public class DMServiceImpl implements DMService, AliyunField {
@@ -51,7 +49,9 @@ void start() {
try {
String file = plugin.getConfig(FILE_ALIDM, plugin.getConfig(Config.APP_CONF) + "/alidm.properties");
- if (!new File(file).exists()) { throw new FileNotFoundException("not found " + file); }
+ if (!new File(file).exists()) {
+ throw new FileNotFoundException("not found " + file);
+ }
_config.init(file);
for (String id : _config.getGroupIds()) {
// 创建一个 Aliyun Acs Client, 用于发起 OpenAPI 请求
@@ -66,11 +66,10 @@ void start() {
DefaultAcsClient client = new DefaultAcsClient(profile);
clients.put(id, client);
}
+ LOG.info("Start DMService Successfully!");
} catch (Exception e) {
- LOG.error("Start DMService Failure!" + e.getMessage(), e);
- return;
+ LOG.error("Start DMService Failed!" + e.getMessage(), e);
}
- LOG.info("Start DMService Successfully!");
}
@Stop
@@ -88,7 +87,9 @@ void stop() {
@Override
public SingleSendMailResponse singleSend(String id, SingleSendMailRequest request) throws ClientException {
DefaultAcsClient client = clients.get(id);
- if (client == null) { throw new NullPointerException("not found dm id:" + id); }
+ if (client == null) {
+ throw new NullPointerException("not found dm id:" + id);
+ }
return client.getAcsResponse(request);
}
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/oss/OSSServiceImpl.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/oss/OSSServiceImpl.java
index c37e820..a5b1bc8 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/oss/OSSServiceImpl.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/oss/OSSServiceImpl.java
@@ -1,19 +1,10 @@
/**
- *
+ *
*/
package jframe.aliyun.service.oss;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSSClient;
-
import jframe.aliyun.AliyunField;
import jframe.aliyun.AliyunPlugin;
import jframe.aliyun.service.OSSService;
@@ -22,24 +13,31 @@
import jframe.core.plugin.annotation.Injector;
import jframe.core.plugin.annotation.Start;
import jframe.core.plugin.annotation.Stop;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
/**
- *
+ *
* https://help.aliyun.com/document_detail/32010.html?spm=a2c4g.11186623.6.745.735dc06dS65fFb
- *
+ *
* // Endpoint以杭州为例,其它Region请按实际情况填写。
* String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
* // 阿里云主账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维,请登录 https://ram.console.aliyun.com 创建RAM账号。
* String accessKeyId = "";
* String accessKeySecret = "";
* String securityToken = "";
- *
+ *
* // 创建OSSClient实例。
* OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret, securityToken);
- *
+ *
* // 关闭OSSClient。
* ossClient.shutdown();
- *
+ *
* @author dzh
* @date Feb 26, 2016 11:59:58 AM
* @since 1.0
@@ -64,7 +62,9 @@ void start() {
try {
String file = plugin.getConfig(FILE_ALIOSS, plugin.getConfig(Config.APP_CONF) + "/alioss.properties");
- if (!new File(file).exists()) { throw new FileNotFoundException("not found " + file); }
+ if (!new File(file).exists()) {
+ throw new FileNotFoundException("not found " + file);
+ }
_config.init(file);
for (String id : _config.getGroupIds()) {
String endpoint = _config.getConf(id, AliyunField.K_endpoint);
@@ -76,11 +76,10 @@ void start() {
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret, conf);
clients.put(id, ossClient);
}
+ LOG.info("Start OSSService Successfully!");
} catch (Exception e) {
- LOG.error("Start OSSService Failure!" + e.getMessage(), e);
- return;
+ LOG.error("Start OSSService Failed!" + e.getMessage(), e);
}
- LOG.info("Start OSSService Successfully!");
}
@Stop
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sms/SMSServiceImpl.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sms/SMSServiceImpl.java
index 431178d..8e50e9b 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sms/SMSServiceImpl.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sms/SMSServiceImpl.java
@@ -1,21 +1,11 @@
package jframe.aliyun.service.sms;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile;
-
import jframe.aliyun.AliyunField;
import jframe.aliyun.AliyunPlugin;
import jframe.aliyun.service.SMSService;
@@ -25,15 +15,23 @@
import jframe.core.plugin.annotation.Start;
import jframe.core.plugin.annotation.Stop;
import jframe.core.util.PropsConf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
/**
* https://help.aliyun.com/document_detail/55284.html?spm=a2c4g.11186623.6.566.5d1b4175GzAYkw
- *
+ *
* https://helpcdn.aliyun.com/document_detail/68360.html
- *
+ *
* @author dzh
- * @date Nov 19, 2018 7:01:24 PM
* @version 0.0.1
+ * @date Nov 19, 2018 7:01:24 PM
*/
@Injector
public class SMSServiceImpl implements SMSService, AliyunField {
@@ -55,7 +53,9 @@ void start() {
try {
String file = plugin.getConfig(FILE_ALISMS, plugin.getConfig(Config.APP_CONF) + "/alisms.properties");
- if (!new File(file).exists()) { throw new FileNotFoundException("not found " + file); }
+ if (!new File(file).exists()) {
+ throw new FileNotFoundException("not found " + file);
+ }
_config.init(file);
for (String id : _config.getGroupIds()) {
// 创建一个 Aliyun Acs Client, 用于发起 OpenAPI 请求
@@ -69,11 +69,10 @@ void start() {
DefaultAcsClient client = new DefaultAcsClient(profile);
clients.put(id, client);
}
+ LOG.info("Start SMSService Successfully!");
} catch (Exception e) {
- LOG.error("Start SMSService Failure!" + e.getMessage(), e);
- return;
+ LOG.error("Start SMSService Failed!" + e.getMessage(), e);
}
- LOG.info("Start SMSService Successfully!");
}
@Stop
@@ -91,7 +90,9 @@ void stop() {
@Override
public SendSmsResponse send(String id, SendSmsRequest request) throws ClientException {
DefaultAcsClient client = clients.get(id);
- if (client == null) { throw new NullPointerException("not found sms id:" + id); }
+ if (client == null) {
+ throw new NullPointerException("not found sms id:" + id);
+ }
return client.getAcsResponse(request);// TODO async
}
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java
index 02ec68d..93657eb 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java
@@ -1,18 +1,8 @@
/**
- *
+ *
*/
package jframe.aliyun.service.sts;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
@@ -21,7 +11,6 @@
import com.aliyuncs.profile.IClientProfile;
import com.aliyuncs.sts.model.v20150401.AssumeRoleRequest;
import com.aliyuncs.sts.model.v20150401.AssumeRoleResponse;
-
import jframe.aliyun.AliyunField;
import jframe.aliyun.AliyunPlugin;
import jframe.aliyun.service.STSService;
@@ -30,10 +19,19 @@
import jframe.core.plugin.annotation.Injector;
import jframe.core.plugin.annotation.Start;
import jframe.core.plugin.annotation.Stop;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
/**
* https://help.aliyun.com/document_detail/28788.html?spm=a2c4g.11186623.6.695.uQYP1L
- *
+ *
* @author dzh
* @date Feb 29, 2016 12:44:39 PM
* @since 1.0
@@ -58,7 +56,9 @@ void start() {
try {
String file = plugin.getConfig(FILE_ALISTS, plugin.getConfig(Config.APP_CONF) + "/alists.properties");
- if (!new File(file).exists()) { throw new FileNotFoundException("not found " + file); }
+ if (!new File(file).exists()) {
+ throw new FileNotFoundException("not found " + file);
+ }
_config.init(file);
for (String id : _config.getGroupIds()) {
// 创建一个 Aliyun Acs Client, 用于发起 OpenAPI 请求
@@ -67,11 +67,11 @@ void start() {
DefaultAcsClient client = new DefaultAcsClient(profile);
clients.put(id, client);
}
+ LOG.info("Start STSService Successfully!");
} catch (Exception e) {
- LOG.error("Start STSService Failure!" + e.getMessage(), e);
- return;
+ LOG.error("Start STSService Failed!" + e.getMessage(), e);
}
- LOG.info("Start STSService Successfully!");
+
}
@Stop
diff --git a/jframe-plugin/pom.xml b/jframe-plugin/pom.xml
index 8940462..5bdd6c3 100644
--- a/jframe-plugin/pom.xml
+++ b/jframe-plugin/pom.xml
@@ -43,6 +43,7 @@
jframe-redisson
jframe-qcloud
jframe-google
+ jframe-alipay
From ec499e071ba2e9d98cfe8a40b11a593b06653784 Mon Sep 17 00:00:00 2001
From: dzh
Date: Tue, 13 Aug 2019 16:46:05 +0800
Subject: [PATCH 04/47] upg lib
---
.../jframe/alipay/service/AlipayService.java | 1 +
jframe-plugin/jframe-aliyun/pom.xml | 70 +++++++++----------
jframe-plugin/jframe-zk/pom.xml | 62 ++++++++--------
.../jframe/zk/service/CuratorService.java | 5 +-
.../zk/service/impl/CuratorServiceImpl.java | 33 ++++-----
5 files changed, 86 insertions(+), 85 deletions(-)
diff --git a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java
index c314054..dee0c21 100644
--- a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java
+++ b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java
@@ -11,6 +11,7 @@
*
* https://openhome.alipay.com/platform/demoManage.htm#/alipay.trade.page.pay
* https://openhome.alipay.com/platform/appDaily.htm?tab=info
+ * https://sandbox.alipaydev.com/user/accountDetails.htm?currentBar=1
*
* @author dzh
* @date 2019-07-22 14:56
diff --git a/jframe-plugin/jframe-aliyun/pom.xml b/jframe-plugin/jframe-aliyun/pom.xml
index e742611..d79fe4e 100644
--- a/jframe-plugin/jframe-aliyun/pom.xml
+++ b/jframe-plugin/jframe-aliyun/pom.xml
@@ -1,39 +1,39 @@
- 4.0.0
-
- io.github.dzh
- jframe-plugin
- 2.0.0-SNAPSHOT
-
- jframe-aliyun
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe-plugin
+ 2.0.0-SNAPSHOT
+
+ jframe-aliyun
-
-
- com.aliyun
- aliyun-java-sdk-core
- 4.2.1
-
+
+
+ com.aliyun
+ aliyun-java-sdk-core
+ 4.2.1
+
-
- com.aliyun.oss
- aliyun-sdk-oss
- 3.3.0
-
-
- com.aliyun
- aliyun-java-sdk-sts
- 3.0.0
-
-
- com.aliyun
- aliyun-java-sdk-dysmsapi
- 1.1.0
-
-
- com.aliyun
- aliyun-java-sdk-dm
- 3.3.1
-
-
+
+ com.aliyun.oss
+ aliyun-sdk-oss
+ 3.6.0
+
+
+ com.aliyun
+ aliyun-java-sdk-sts
+ 3.0.1
+
+
+ com.aliyun
+ aliyun-java-sdk-dysmsapi
+ 1.1.0
+
+
+ com.aliyun
+ aliyun-java-sdk-dm
+ 3.3.1
+
+
\ No newline at end of file
diff --git a/jframe-plugin/jframe-zk/pom.xml b/jframe-plugin/jframe-zk/pom.xml
index 5ab2f39..131eb1a 100644
--- a/jframe-plugin/jframe-zk/pom.xml
+++ b/jframe-plugin/jframe-zk/pom.xml
@@ -1,35 +1,35 @@
- 4.0.0
-
- jframe-plugin
- 2.0.0-SNAPSHOT
- io.github.dzh
-
- jframe-zk
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ jframe-plugin
+ 2.0.0-SNAPSHOT
+ io.github.dzh
+
+ jframe-zk
-
- 4.2.0
-
+
+ 4.2.0
+
-
-
- org.apache.curator
- curator-client
- ${curator.version}
-
-
- org.apache.curator
- curator-framework
- ${curator.version}
-
-
- org.apache.curator
- curator-recipes
- ${curator.version}
-
-
-
+
+
+ org.apache.curator
+ curator-client
+ ${curator.version}
+
+
+ org.apache.curator
+ curator-framework
+ ${curator.version}
+
+
+ org.apache.curator
+ curator-recipes
+ ${curator.version}
+
+
+
\ No newline at end of file
diff --git a/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/CuratorService.java b/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/CuratorService.java
index fff9b9c..fc771f4 100644
--- a/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/CuratorService.java
+++ b/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/CuratorService.java
@@ -1,13 +1,12 @@
package jframe.zk.service;
-import org.apache.curator.framework.CuratorFramework;
-
import jframe.core.plugin.annotation.Service;
+import org.apache.curator.framework.CuratorFramework;
/**
* @author dzh
- * @date Dec 12, 2018 7:12:56 PM
* @version 0.0.1
+ * @date Dec 12, 2018 7:12:56 PM
*/
@Service(clazz = "jframe.zk.service.impl.CuratorServiceImpl", id = "jframe.service.zk.curator")
public interface CuratorService {
diff --git a/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/impl/CuratorServiceImpl.java b/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/impl/CuratorServiceImpl.java
index b2e8399..0fbc37a 100644
--- a/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/impl/CuratorServiceImpl.java
+++ b/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/impl/CuratorServiceImpl.java
@@ -1,22 +1,8 @@
/**
- *
+ *
*/
package jframe.zk.service.impl;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.curator.RetryPolicy;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.framework.imps.CuratorFrameworkState;
-import org.apache.curator.retry.ExponentialBackoffRetry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import jframe.core.conf.Config;
import jframe.core.plugin.annotation.InjectPlugin;
import jframe.core.plugin.annotation.Injector;
@@ -26,6 +12,19 @@
import jframe.zk.ZkField;
import jframe.zk.ZkPlugin;
import jframe.zk.service.CuratorService;
+import org.apache.curator.RetryPolicy;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.framework.imps.CuratorFrameworkState;
+import org.apache.curator.retry.ExponentialBackoffRetry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
/**
* @author dzh
@@ -52,7 +51,9 @@ void start() {
try {
String file = Plugin.getConfig(FILE_CURATOR, Plugin.getConfig(Config.APP_CONF) + "/curator.properties");
- if (!new File(file).exists()) { throw new FileNotFoundException("not found " + file); }
+ if (!new File(file).exists()) {
+ throw new FileNotFoundException("not found " + file);
+ }
_config.init(file);
for (String id : _config.getGroupIds()) {
String connectString = _config.getConf(id, ZkField.ConnectString);
From 966e9eb7e5c3668c976257c69e5b7412160c4702 Mon Sep 17 00:00:00 2001
From: dzh
Date: Mon, 30 Dec 2019 16:50:24 +0800
Subject: [PATCH 05/47] add RmqDispatcher
---
jframe/jframe-ext/pom.xml | 7 +
.../ext/dispatch/kafka/KafkaDispatcher.java | 46 ++--
.../ext/dispatch/rocketmq/MsgCodec.java | 19 ++
.../rocketmq/RmqConsumerDispatcher.java | 19 ++
.../ext/dispatch/rocketmq/RmqDispatcher.java | 257 ++++++++++++++++++
.../rocketmq/RmqProducerDispatcher.java | 19 ++
.../ext/dispatch/rocketmq/TextMsgCodec.java | 29 ++
.../java/jframe/ext/plugin/KafkaPlugin.java | 2 +-
.../jframe/ext/plugin/RocketmqPlugin.java | 28 ++
9 files changed, 403 insertions(+), 23 deletions(-)
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/MsgCodec.java
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqConsumerDispatcher.java
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqDispatcher.java
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqProducerDispatcher.java
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/TextMsgCodec.java
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/plugin/RocketmqPlugin.java
diff --git a/jframe/jframe-ext/pom.xml b/jframe/jframe-ext/pom.xml
index 8507d0d..5825aae 100644
--- a/jframe/jframe-ext/pom.xml
+++ b/jframe/jframe-ext/pom.xml
@@ -39,5 +39,12 @@
2.1.0
+
+
+ org.apache.rocketmq
+ rocketmq-client
+ 4.6.0
+
+
\ No newline at end of file
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/kafka/KafkaDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/kafka/KafkaDispatcher.java
index 91f2f58..7d4a7f3 100644
--- a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/kafka/KafkaDispatcher.java
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/kafka/KafkaDispatcher.java
@@ -1,14 +1,8 @@
package jframe.ext.dispatch.kafka;
-import java.io.FileInputStream;
-import java.time.Duration;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Pattern;
-
+import jframe.core.conf.Config;
+import jframe.core.dispatch.AbstractDispatcher;
+import jframe.core.msg.Msg;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
@@ -18,9 +12,14 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import jframe.core.conf.Config;
-import jframe.core.dispatch.AbstractDispatcher;
-import jframe.core.msg.Msg;
+import java.io.FileInputStream;
+import java.time.Duration;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Objects;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Pattern;
/**
*
@@ -30,7 +29,7 @@
*
file.d.kafka.consumer=${app.home}/conf/d-kafka-consumer.properties
* d.kafka.subscribe=topicA topicB topicC
*
- *
+ *
*
* msg meta:
*
d.kafka.r.topic 对应{@link ProducerRecord}的topic
@@ -38,10 +37,10 @@
* d.kafka.r.partition
* d.kafka.r.timestamp
*
- *
+ *
* @author dzh
- * @date Dec 26, 2018 5:16:26 PM
* @version 0.0.1
+ * @date Dec 26, 2018 5:16:26 PM
*/
public class KafkaDispatcher extends AbstractDispatcher {
@@ -118,10 +117,10 @@ private void startProducer() {
/**
* http://kafka.apache.org/21/javadoc/index.html?org/apache/kafka/clients/producer/KafkaProducer.html
- *
+ *
* @param props
*/
- private void loadDefaultProducer(Properties props) {
+ protected void loadDefaultProducer(Properties props) {
props.put("bootstrap.servers", "localhost:9092");
props.put("acks", "all");
props.put("delivery.timeout.ms", 30000);
@@ -154,6 +153,7 @@ private void startConsumer() {
} catch (Exception e) {
LOG.error(e.getMessage(), e);
close();
+ return;
}
final boolean autoCommit = "true".equals(props.get("enable.auto.commit")) ? true : false;
this.dispatchT = new Thread(() -> {
@@ -185,10 +185,10 @@ protected Consumer> createConsumer(Properties props) {
Consumer> consumer = new KafkaConsumer<>(props);
String topics = DEFAULT_TOPIC;
if (getConfig().contain(D_KAFKA_SUBSCRIBE)) {
- topics = getConfig().getConfig(D_KAFKA_SUBSCRIBE);
+ topics = getConfig().getConfig(D_KAFKA_SUBSCRIBE); //todo put into props
consumer.subscribe(Arrays.asList(topics.split("\\s+")));
} else if (getConfig().contain(D_KAFKA_SUBSCRIBE_REGEX)) {
- topics = getConfig().getConfig(D_KAFKA_SUBSCRIBE_REGEX);
+ topics = getConfig().getConfig(D_KAFKA_SUBSCRIBE_REGEX); //todo put into props
consumer.subscribe(Pattern.compile(topics));
} else {
consumer.subscribe(Arrays.asList(topics));
@@ -199,10 +199,10 @@ protected Consumer> createConsumer(Properties props) {
/**
* http://kafka.apache.org/21/javadoc/index.html?org/apache/kafka/clients/consumer/KafkaConsumer.html
- *
+ *
* @param props
*/
- private void loadDefaultConsumer(Properties props) {
+ protected void loadDefaultConsumer(Properties props) {
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "jframe");
props.put("enable.auto.commit", "true");
@@ -254,6 +254,7 @@ public Consumer> getConsumer() {
@Override
public void close() {
+ if (closed) return;
// close producer
if (enableProducer()) producer.close(WAIT_CLOSED_SECOND, TimeUnit.SECONDS);
@@ -263,7 +264,8 @@ public void close() {
if (dispatchT != null) {
try {
dispatchT.join(WAIT_CLOSED_SECOND * 1000L);
- } catch (InterruptedException e) {}
+ } catch (InterruptedException e) {
+ }
}
}
super.close();
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/MsgCodec.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/MsgCodec.java
new file mode 100644
index 0000000..dc586da
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/MsgCodec.java
@@ -0,0 +1,19 @@
+package jframe.ext.dispatch.rocketmq;
+
+import jframe.core.msg.Msg;
+
+import java.io.IOException;
+
+/**
+ * ThreadSafe
+ *
+ * @author dzh
+ * @date 2019/12/25 21:11
+ */
+public interface MsgCodec {
+
+ byte[] encode(Msg> msg) throws IOException;
+
+ Msg decode(byte[] msg) throws IOException;
+
+}
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqConsumerDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqConsumerDispatcher.java
new file mode 100644
index 0000000..3883840
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqConsumerDispatcher.java
@@ -0,0 +1,19 @@
+package jframe.ext.dispatch.rocketmq;
+
+import jframe.core.conf.Config;
+
+/**
+ * @author dzh
+ * @date 2019/12/25 18:15
+ */
+public class RmqConsumerDispatcher extends RmqDispatcher {
+
+ public RmqConsumerDispatcher(String id, Config config) {
+ super(id, config);
+ }
+
+ @Override
+ protected boolean enableProducer() {
+ return false;
+ }
+}
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqDispatcher.java
new file mode 100644
index 0000000..abf3659
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqDispatcher.java
@@ -0,0 +1,257 @@
+package jframe.ext.dispatch.rocketmq;
+
+import jframe.core.conf.Config;
+import jframe.core.dispatch.AbstractDispatcher;
+import jframe.core.msg.Msg;
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.FileInputStream;
+import java.util.Objects;
+import java.util.Properties;
+
+/**
+ * @author dzh
+ * @date 2019/12/25 13:02
+ */
+public class RmqDispatcher extends AbstractDispatcher {
+
+ static Logger LOG = LoggerFactory.getLogger(RmqDispatcher.class);
+
+// private volatile boolean closed;
+
+ private DefaultMQProducer producer;
+ private DefaultMQPushConsumer consumer;
+
+ public static final String FILE_RMQ_PRODUCER = "file.rmq.producer";
+ public static final String FILE_RMQ_CONSUMER = "file.rmq.consumer";
+
+ public static final String D_RMQ_CODEC = "d.rmq.codec"; // MsgCodec
+
+ public static final String DEFAULT_TOPIC = "jframe";
+ public static final String D_RMQ_R_TOPIC = "d.rmq.r.topic";
+ public static final String D_RMQ_R_TAG = "d.rmq.r.tag";
+ public static final String D_RMQ_R_Key = "d.rmq.r.key";
+
+// private Thread dispatchT; // consume dispatch thread
+
+ private MsgCodec msgCodec;
+
+ public RmqDispatcher(String id, Config config) {
+ super(id, config);
+ }
+
+ protected boolean enableProducer() {
+ return true;
+ }
+
+ protected boolean enableConsumer() {
+ return true;
+ }
+
+ @Override
+ public void start() {
+ try {
+ initMsgCodec();
+ if (enableConsumer()) startConsumer();
+ if (enableProducer()) startProducer();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ close();
+ }
+ }
+
+ private void initMsgCodec() {
+ String clazz = getConfig().getConfig(D_RMQ_CODEC, TextMsgCodec.class.getName());
+ try {
+ msgCodec = (MsgCodec) Class.forName(clazz).newInstance();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+
+ private void startProducer() throws MQClientException {
+ String file = getConfig().getConfig(FILE_RMQ_PRODUCER);
+ if (Objects.isNull(file)) {
+ file = getConfig().getConfig(Config.APP_CONF) + "/rmq-producer.properties";
+ }
+ Properties props = new Properties();
+ try (FileInputStream fis = new FileInputStream(file)) {
+ props.load(fis);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ loadDefaultProducer(props);
+ }
+
+ LOG.info("start producer with {}", props);
+ producer = new DefaultMQProducer();
+ if (props.containsKey("producer.group")) {
+ producer.setProducerGroup(props.getProperty("producer.group"));
+ }
+ if (props.containsKey("namespace")) {
+ producer.setNamespace(props.getProperty("namespace"));
+ }
+ producer.setNamesrvAddr(props.getProperty("namesrv.addr", "localhost:9876"));
+ producer.setRetryTimesWhenSendFailed(Integer.parseInt(props.getProperty("retry.times", "3")));
+ producer.setVipChannelEnabled(Boolean.parseBoolean(props.getProperty("vipChannelEnabled", "false")));
+// LOG.info("start producer {} {}", producer.getProducerGroup(), producer.getNamesrvAddr());
+ producer.start();
+// List> mqList = producer.fetchPublishMessageQueues(topic());
+// if (mqList == null || mqList.isEmpty()) {
+// producer.createTopic(topicKey(), topic(), topicQueueNum());
+// }
+ }
+
+ private void loadDefaultProducer(Properties props) {
+ props.put("producer.group", getConfig().getConfig(Config.APP_NAME));
+ props.put("namesrv.addr", "localhost:9876");
+ props.put("retry.times", "3");
+ props.put("vipChannelEnabled", "false");
+ }
+
+ private void startConsumer() {
+ String file = getConfig().getConfig(FILE_RMQ_CONSUMER);
+ if (Objects.isNull(file)) {
+ file = getConfig().getConfig(Config.APP_CONF) + "/rmq-consumer.properties";
+ }
+ Properties props = new Properties();
+ try (FileInputStream fis = new FileInputStream(file)) {
+ props.load(fis);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ loadDefaultConsumer(props);
+ }
+ LOG.info("start consumer with {}", props);
+ try {
+ consumer = createConsumer(props);
+ consumer.start();
+// consumer.seekToEnd(Collections.emptyList());
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ close();
+ }
+
+ // pull mode
+// this.dispatchT = new Thread(() -> {
+// LOG.info("{} start", Thread.currentThread().getName());
+// while (true) {
+// if (closed) break;
+// try {
+// } catch (Exception e) {
+// LOG.warn(e.getMessage(), e);
+// continue;
+// }
+// dispatch(record.value());
+// }
+// LOG.info("{} closed", Thread.currentThread().getName());
+// }, "rocketmqConsumeThread");
+// dispatchT.start();
+ }
+
+ private void loadDefaultConsumer(Properties props) {
+ props.setProperty("consumer.group", getConfig().getConfig(Config.APP_NAME));
+ props.setProperty("namesrv.addr", "localhost:9876");
+
+ }
+
+ // todo multi topics
+ private DefaultMQPushConsumer createConsumer(Properties props) throws MQClientException {
+ DefaultMQPushConsumer consumer = new DefaultMQPushConsumer(props.getProperty("consumer.group"));
+ consumer.setNamesrvAddr(props.getProperty("namesrv.addr", "localhost:9876"));
+ String val = props.getProperty("consume.message.batch.maxsize", "1"); //[1,1024]
+// consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_TIMESTAMP);
+// consumer.setConsumeTimestamp(consumeTimestamp());
+ consumer.setConsumeMessageBatchMaxSize(Integer.parseInt(val));
+ val = props.getProperty("consume.timeout", "5"); //minutes
+ consumer.setConsumeTimeout(Long.parseLong(val));
+ consumer.subscribe(props.getProperty("consume.topic", "jframe"),
+ props.getProperty("consume.subExpression", "*"));
+ consumer.setVipChannelEnabled(false);
+ val = props.getProperty("consume.thread.max");
+ if (val != null)
+ consumer.setConsumeThreadMax(Integer.parseInt(val));
+ val = props.getProperty("consume.thread.min");
+ if (val != null)
+ consumer.setConsumeThreadMin(Integer.parseInt(val));
+ val = props.getProperty("consume.instance.name");
+ if (val != null)
+ consumer.setInstanceName(val);
+ val = props.getProperty("consume.pull.threshold");
+ if (val != null)
+ consumer.setPullThresholdForQueue(Integer.parseInt(val));
+ val = props.getProperty("consume.concurrently.max.span");
+ if (val != null)
+ consumer.setConsumeConcurrentlyMaxSpan(Integer.parseInt(val));// 2000
+ val = props.getProperty("consume.max.reconsume.times", "16");
+ consumer.setMaxReconsumeTimes(Integer.parseInt(val)); // 16
+ val = props.getProperty("consume.persist.consumer.offset.interval", "3000");
+ consumer.setPersistConsumerOffsetInterval(Integer.parseInt(val)); // ms
+
+ boolean ingoreTimeoutMsg = Boolean.parseBoolean(props.getProperty("consume.ignore.timeout.msg", "false"));
+ int ingoreTimeoutMsgMs = Integer.parseInt(props.getProperty("consume.ignore.timeout.msg.ms", "10000"));
+ consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {
+ for (MessageExt msg : msgs) {
+ try {
+ if (ingoreTimeoutMsg && (System.currentTimeMillis() - msg.getBornTimestamp()) >= ingoreTimeoutMsgMs) {
+ LOG.warn("discard rmq timeout msg-{}", msg);
+ continue;
+ }
+
+ LOG.info("recv rmq msg-{}", msg);
+ dispatch(msgCodec.decode(msg.getBody()));
+ } catch (Exception e) {
+ LOG.info(e.getMessage(), e);
+ if (msg.getReconsumeTimes() == consumer.getMaxReconsumeTimes()) {
+ LOG.warn("over MaxReconsumeTimes, discard msg-{}", msg);
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ }
+ return ConsumeConcurrentlyStatus.RECONSUME_LATER;
+ }
+ }
+ return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
+ });
+ return consumer;
+ }
+
+ @Override
+ public void receive(Msg> msg) {
+ if (producer != null) {
+ String topic = (String) msg.getMeta(D_RMQ_R_TOPIC);
+ if (Objects.isNull(topic)) {
+ topic = DEFAULT_TOPIC;
+ }
+
+ try {
+ Message rmqMsg = new Message(topic,
+ (String) msg.getMeta(D_RMQ_R_TAG), (String) msg.getMeta(D_RMQ_R_Key),
+ msgCodec.encode(msg));
+ SendResult r = producer.send(rmqMsg);
+ LOG.debug("receive {}, sendResult {}", msg, r);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);//todo
+ }
+ }
+ }
+
+// private int WAIT_CLOSED_SECOND = 60;
+
+ @Override
+ public void close() {
+ // close producer
+ if (enableProducer()) producer.shutdown();
+
+ // close dispatcher and consumer
+ if (enableConsumer()) {
+ consumer.shutdown();
+ }
+ super.close();
+ }
+}
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqProducerDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqProducerDispatcher.java
new file mode 100644
index 0000000..0c83a22
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqProducerDispatcher.java
@@ -0,0 +1,19 @@
+package jframe.ext.dispatch.rocketmq;
+
+import jframe.core.conf.Config;
+
+/**
+ * @author dzh
+ * @date 2019/12/25 18:16
+ */
+public class RmqProducerDispatcher extends RmqDispatcher {
+
+ public RmqProducerDispatcher(String id, Config config) {
+ super(id, config);
+ }
+
+ @Override
+ protected boolean enableConsumer() {
+ return false;
+ }
+}
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/TextMsgCodec.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/TextMsgCodec.java
new file mode 100644
index 0000000..edeca6a
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/TextMsgCodec.java
@@ -0,0 +1,29 @@
+package jframe.ext.dispatch.rocketmq;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import jframe.core.msg.Msg;
+import jframe.core.msg.TextMsg;
+
+import java.io.IOException;
+
+/**
+ * @author dzh
+ * @date 2019/12/25 21:13
+ */
+public class TextMsgCodec implements MsgCodec {
+
+ protected String encoding = "UTF8";
+
+ static final Gson GSON = new GsonBuilder().serializeNulls().create();
+
+ @Override
+ public byte[] encode(Msg> msg) throws IOException {
+ return GSON.toJson(msg).getBytes(encoding); //todo msg's data must be String
+ }
+
+ @Override
+ public Msg decode(byte[] msg) throws IOException {
+ return GSON.fromJson(new String(msg, encoding), TextMsg.class);
+ }
+}
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/plugin/KafkaPlugin.java b/jframe/jframe-ext/src/main/java/jframe/ext/plugin/KafkaPlugin.java
index 2311677..86dd0d0 100644
--- a/jframe/jframe-ext/src/main/java/jframe/ext/plugin/KafkaPlugin.java
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/plugin/KafkaPlugin.java
@@ -6,8 +6,8 @@
/**
* @author dzh
- * @date Dec 27, 2018 3:05:36 PM
* @version 0.0.1
+ * @date Dec 27, 2018 3:05:36 PM
*/
public abstract class KafkaPlugin extends PluginSender {
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/plugin/RocketmqPlugin.java b/jframe/jframe-ext/src/main/java/jframe/ext/plugin/RocketmqPlugin.java
new file mode 100644
index 0000000..610a76e
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/plugin/RocketmqPlugin.java
@@ -0,0 +1,28 @@
+package jframe.ext.plugin;
+
+import jframe.core.msg.Msg;
+import jframe.core.plugin.PluginSender;
+import jframe.ext.dispatch.rocketmq.RmqDispatcher;
+
+/**
+ * Rocketmq Plugin
+ *
+ * @author dzh
+ * @date 2019/12/25 15:22
+ */
+public abstract class RocketmqPlugin extends PluginSender {
+
+ public void send(Msg> msg, String topic, String tag, String key) {
+ if (msg == null) return;
+
+ msg.setMeta(RmqDispatcher.D_RMQ_R_TOPIC, topic);
+ msg.setMeta(RmqDispatcher.D_RMQ_R_TAG, tag);
+ msg.setMeta(RmqDispatcher.D_RMQ_R_Key, key);
+
+ send(msg);
+ }
+
+ public void send(Msg> msg, String topic) {
+ send(msg, topic, null, null);
+ }
+}
From 6fae126c1917de6030eb8c30761065643c329857 Mon Sep 17 00:00:00 2001
From: dzh
Date: Sun, 12 Jan 2020 18:14:38 +0800
Subject: [PATCH 06/47] add OnsDispatcher
---
jframe/jframe-ext/pom.xml | 91 ++++----
.../ext/dispatch/kafka/KafkaDispatcher.java | 6 +-
.../dispatch/ons/OnsConsumerDispatcher.java | 20 ++
.../ext/dispatch/ons/OnsDispatcher.java | 194 ++++++++++++++++++
.../dispatch/ons/OnsProducerDispatcher.java | 19 ++
.../ext/dispatch/rocketmq/RmqConst.java | 18 ++
.../ext/dispatch/rocketmq/RmqDispatcher.java | 20 +-
7 files changed, 308 insertions(+), 60 deletions(-)
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsConsumerDispatcher.java
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsDispatcher.java
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsProducerDispatcher.java
create mode 100644 jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqConst.java
diff --git a/jframe/jframe-ext/pom.xml b/jframe/jframe-ext/pom.xml
index 5825aae..c8c5d9f 100644
--- a/jframe/jframe-ext/pom.xml
+++ b/jframe/jframe-ext/pom.xml
@@ -1,50 +1,57 @@
- 4.0.0
-
- io.github.dzh
- jframe
- 2.0.0-SNAPSHOT
-
- jframe-ext
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
+
+ io.github.dzh
+ jframe
+ 2.0.0-SNAPSHOT
+
+ jframe-ext
-
-
- ${project.groupId}
- jframe-core
-
+
+
+ ${project.groupId}
+ jframe-core
+
-
- com.google.code.gson
- gson
- 2.8.5
-
+
+ com.google.code.gson
+ gson
+ 2.8.5
+
-
-
- org.apache.activemq
- activemq-client
- 5.10.0
-
-
- org.apache.activemq
- activemq-jms-pool
- 5.15.7
-
+
+
+ org.apache.activemq
+ activemq-client
+ 5.10.0
+
+
+ org.apache.activemq
+ activemq-jms-pool
+ 5.15.7
+
-
-
- org.apache.kafka
- kafka-clients
- 2.1.0
-
+
+
+ org.apache.kafka
+ kafka-clients
+ 2.1.0
+
-
-
- org.apache.rocketmq
- rocketmq-client
- 4.6.0
-
+
+
+ org.apache.rocketmq
+ rocketmq-client
+ 4.6.0
+
-
+
+
+ com.aliyun.openservices
+ ons-client
+ 1.8.4.Final
+
+
+
\ No newline at end of file
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/kafka/KafkaDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/kafka/KafkaDispatcher.java
index 7d4a7f3..4ee3550 100644
--- a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/kafka/KafkaDispatcher.java
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/kafka/KafkaDispatcher.java
@@ -152,8 +152,8 @@ private void startConsumer() {
consumer.seekToEnd(Collections.emptyList());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
- close();
- return;
+// close();
+// return;
}
final boolean autoCommit = "true".equals(props.get("enable.auto.commit")) ? true : false;
this.dispatchT = new Thread(() -> {
@@ -162,7 +162,7 @@ private void startConsumer() {
while (true) {
if (closed) break;
try {
- records = consumer.poll(Duration.ofMillis(1000L));
+ records = consumer.poll(Duration.ofMillis(1000L));//
} catch (Exception e) {
LOG.warn(e.getMessage(), e);
continue;
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsConsumerDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsConsumerDispatcher.java
new file mode 100644
index 0000000..e4627f7
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsConsumerDispatcher.java
@@ -0,0 +1,20 @@
+package jframe.ext.dispatch.ons;
+
+import jframe.core.conf.Config;
+
+/**
+ * @author dzh
+ * @date 2020/1/11 19:26
+ */
+public class OnsConsumerDispatcher extends OnsDispatcher {
+
+ public OnsConsumerDispatcher(String id, Config config) {
+ super(id, config);
+ }
+
+ @Override
+ protected boolean enableProducer() {
+ return false;
+ }
+
+}
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsDispatcher.java
new file mode 100644
index 0000000..41e91c0
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsDispatcher.java
@@ -0,0 +1,194 @@
+package jframe.ext.dispatch.ons;
+
+import com.aliyun.openservices.ons.api.*;
+import jframe.core.conf.Config;
+import jframe.core.dispatch.AbstractDispatcher;
+import jframe.core.msg.Msg;
+import jframe.ext.dispatch.rocketmq.MsgCodec;
+import jframe.ext.dispatch.rocketmq.RmqConst;
+import jframe.ext.dispatch.rocketmq.TextMsgCodec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.FileInputStream;
+import java.util.Objects;
+import java.util.Properties;
+
+/**
+ * aliyun rocketmq
+ * https://help.aliyun.com/document_detail/29547.html
+ *
+ * @author dzh
+ * @date 2020/1/11 19:17
+ */
+public class OnsDispatcher extends AbstractDispatcher implements RmqConst {
+
+ static Logger LOG = LoggerFactory.getLogger(OnsDispatcher.class);
+
+ private Producer producer;
+ private Consumer consumer;
+
+ private MsgCodec msgCodec;
+
+ public OnsDispatcher(String id, Config config) {
+ super(id, config);
+ }
+
+ protected boolean enableProducer() {
+ return true;
+ }
+
+ protected boolean enableConsumer() {
+ return true;
+ }
+
+ @Override
+ public void start() {
+ try {
+ initMsgCodec();
+ if (enableConsumer()) startConsumer();
+ if (enableProducer()) startProducer();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ close();
+ }
+ }
+
+ //https://help.aliyun.com/document_detail/29547.html?spm=a2c4g.11186623.6.575.73a8d54cqwV0z7
+ private void startProducer() {
+ String file = getConfig().getConfig(FILE_RMQ_PRODUCER);
+ if (Objects.isNull(file)) {
+ file = getConfig().getConfig(Config.APP_CONF) + "/rmq-producer.properties";
+ }
+ Properties props = new Properties();
+ try (FileInputStream fis = new FileInputStream(file)) {
+ props.load(fis);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return;
+ }
+
+ LOG.info("start producer with {}", props);
+
+// Properties properties = new Properties();
+// // AccessKey 阿里云身份验证,在阿里云用户信息管理控制台获取
+// properties.put(PropertyKeyConst.AccessKey, "XXX");
+// // SecretKey 阿里云身份验证,在阿里云用户信息管理控制台获取
+// properties.put(PropertyKeyConst.SecretKey, "XXX");
+// //设置发送超时时间,单位毫秒
+// properties.setProperty(PropertyKeyConst.SendMsgTimeoutMillis, "3000");
+// // 设置 TCP 接入域名,进入控制台的实例详情页面的获取接入点信息区域查看
+// properties.put(PropertyKeyConst.NAMESRV_ADDR,
+// "XXX");
+ Producer producer = ONSFactory.createProducer(props);
+ // 在发送消息前,必须调用 start 方法来启动 Producer,只需调用一次即可
+ producer.start();
+ }
+
+ private void startConsumer() {
+ String file = getConfig().getConfig(FILE_RMQ_CONSUMER);
+ if (Objects.isNull(file)) {
+ file = getConfig().getConfig(Config.APP_CONF) + "/rmq-consumer.properties";
+ }
+ Properties props = new Properties();
+ try (FileInputStream fis = new FileInputStream(file)) {
+ props.load(fis);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ return;
+ }
+ LOG.info("start consumer with {}", props);
+ try {
+ consumer = createConsumer(props);
+ consumer.start();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+// close();
+ }
+ }
+
+ //https://help.aliyun.com/document_detail/29551.html?spm=a2c4g.11186623.6.581.7c13d54cmyIEny
+ private Consumer createConsumer(Properties props) {
+// Properties properties = new Properties();
+// // 您在控制台创建的 Group ID
+// properties.put(PropertyKeyConst.GROUP_ID, "XXX");
+// // AccessKey 阿里云身份验证,在阿里云服务器管理控制台创建
+// properties.put(PropertyKeyConst.AccessKey, "XXX");
+// // SecretKey 阿里云身份验证,在阿里云服务器管理控制台创建
+// properties.put(PropertyKeyConst.SecretKey, "XXX");
+// // 设置 TCP 接入域名,进入控制台的实例管理页面的“获取接入点信息”区域查看
+// properties.put(PropertyKeyConst.NAMESRV_ADDR,
+// "XXX");
+ // 集群订阅方式 (默认)
+// properties.put(PropertyKeyConst.MessageModel, PropertyValueConst.CLUSTERING);
+ // 广播订阅方式
+ // properties.put(PropertyKeyConst.MessageModel, PropertyValueConst.BROADCASTING);
+
+ Consumer consumer = ONSFactory.createConsumer(props);
+
+ boolean ingoreTimeoutMsg = Boolean.parseBoolean(props.getProperty("consume.ignore.timeout.msg", "false"));
+ int ingoreTimeoutMsgMs = Integer.parseInt(props.getProperty("consume.ignore.timeout.msg.ms", "10000"));
+
+ //订阅多个 Tag
+ consumer.subscribe(props.getProperty("consume.topic", "jframe"),
+ props.getProperty("consume.subExpression", "*"), new MessageListener() {
+ public Action consume(Message msg, ConsumeContext context) {
+ LOG.debug("consume ons msg-{}", msg);
+ try {
+ if (ingoreTimeoutMsg && (System.currentTimeMillis() - msg.getBornTimestamp()) >= ingoreTimeoutMsgMs) {
+ LOG.warn("discard ons timeout msg-{}", msg);
+ return Action.CommitMessage;
+ }
+ LOG.info("dispatch ons msg-{}", msg.getKey());
+ dispatch(msgCodec.decode(msg.getBody()));
+ } catch (Exception e) {
+ LOG.info(e.getMessage(), e);
+ return Action.ReconsumeLater;
+ }
+ return Action.CommitMessage;
+ }
+ });
+ return consumer;
+ }
+
+ private void initMsgCodec() {
+ String clazz = getConfig().getConfig(D_RMQ_CODEC, TextMsgCodec.class.getName());
+ try {
+ msgCodec = (MsgCodec) Class.forName(clazz).newInstance();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ public void receive(Msg> msg) {
+ if (producer != null) {
+ String topic = (String) msg.getMeta(D_RMQ_R_TOPIC);
+ if (Objects.isNull(topic)) {
+ topic = DEFAULT_TOPIC;
+ }
+
+ try {
+ Message rmqMsg = new Message(topic,
+ (String) msg.getMeta(D_RMQ_R_TAG), (String) msg.getMeta(D_RMQ_R_Key),
+ msgCodec.encode(msg));
+ SendResult r = producer.send(rmqMsg);
+ LOG.debug("send msg {}, sendResult {}", msg, r);
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);//todo
+ }
+ }
+ }
+
+ @Override
+ public void close() {
+ // close producer
+ if (enableProducer()) producer.shutdown();
+
+ // close dispatcher and consumer
+ if (enableConsumer()) {
+ consumer.shutdown();
+ }
+ super.close();
+ }
+}
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsProducerDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsProducerDispatcher.java
new file mode 100644
index 0000000..476a6f2
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsProducerDispatcher.java
@@ -0,0 +1,19 @@
+package jframe.ext.dispatch.ons;
+
+import jframe.core.conf.Config;
+
+/**
+ * @author dzh
+ * @date 2020/1/11 19:29
+ */
+public class OnsProducerDispatcher extends OnsDispatcher {
+
+ public OnsProducerDispatcher(String id, Config config) {
+ super(id, config);
+ }
+
+ @Override
+ protected boolean enableConsumer() {
+ return false;
+ }
+}
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqConst.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqConst.java
new file mode 100644
index 0000000..ef59b7a
--- /dev/null
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqConst.java
@@ -0,0 +1,18 @@
+package jframe.ext.dispatch.rocketmq;
+
+/**
+ * @author dzh
+ * @date 2020/1/11 19:35
+ */
+public interface RmqConst {
+
+ public static final String FILE_RMQ_PRODUCER = "file.rmq.producer";
+ public static final String FILE_RMQ_CONSUMER = "file.rmq.consumer";
+
+ public static final String D_RMQ_CODEC = "d.rmq.codec"; // MsgCodec
+
+ public static final String DEFAULT_TOPIC = "jframe";
+ public static final String D_RMQ_R_TOPIC = "d.rmq.r.topic";
+ public static final String D_RMQ_R_TAG = "d.rmq.r.tag";
+ public static final String D_RMQ_R_Key = "d.rmq.r.key";
+}
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqDispatcher.java
index abf3659..4941e44 100644
--- a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqDispatcher.java
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/rocketmq/RmqDispatcher.java
@@ -22,7 +22,7 @@
* @author dzh
* @date 2019/12/25 13:02
*/
-public class RmqDispatcher extends AbstractDispatcher {
+public class RmqDispatcher extends AbstractDispatcher implements RmqConst {
static Logger LOG = LoggerFactory.getLogger(RmqDispatcher.class);
@@ -31,16 +31,6 @@ public class RmqDispatcher extends AbstractDispatcher {
private DefaultMQProducer producer;
private DefaultMQPushConsumer consumer;
- public static final String FILE_RMQ_PRODUCER = "file.rmq.producer";
- public static final String FILE_RMQ_CONSUMER = "file.rmq.consumer";
-
- public static final String D_RMQ_CODEC = "d.rmq.codec"; // MsgCodec
-
- public static final String DEFAULT_TOPIC = "jframe";
- public static final String D_RMQ_R_TOPIC = "d.rmq.r.topic";
- public static final String D_RMQ_R_TAG = "d.rmq.r.tag";
- public static final String D_RMQ_R_Key = "d.rmq.r.key";
-
// private Thread dispatchT; // consume dispatch thread
private MsgCodec msgCodec;
@@ -136,7 +126,7 @@ private void startConsumer() {
// consumer.seekToEnd(Collections.emptyList());
} catch (Exception e) {
LOG.error(e.getMessage(), e);
- close();
+// close();
}
// pull mode
@@ -199,13 +189,13 @@ private DefaultMQPushConsumer createConsumer(Properties props) throws MQClientEx
int ingoreTimeoutMsgMs = Integer.parseInt(props.getProperty("consume.ignore.timeout.msg.ms", "10000"));
consumer.registerMessageListener((MessageListenerConcurrently) (msgs, context) -> {
for (MessageExt msg : msgs) {
+ LOG.debug("consume rmq msg-{}", msg);
try {
if (ingoreTimeoutMsg && (System.currentTimeMillis() - msg.getBornTimestamp()) >= ingoreTimeoutMsgMs) {
LOG.warn("discard rmq timeout msg-{}", msg);
continue;
}
-
- LOG.info("recv rmq msg-{}", msg);
+ LOG.info("dispatch rmq msg-{}", msg.getKeys());
dispatch(msgCodec.decode(msg.getBody()));
} catch (Exception e) {
LOG.info(e.getMessage(), e);
@@ -234,7 +224,7 @@ public void receive(Msg> msg) {
(String) msg.getMeta(D_RMQ_R_TAG), (String) msg.getMeta(D_RMQ_R_Key),
msgCodec.encode(msg));
SendResult r = producer.send(rmqMsg);
- LOG.debug("receive {}, sendResult {}", msg, r);
+ LOG.debug("send msg {}, sendResult {}", msg, r);
} catch (Exception e) {
LOG.error(e.getMessage(), e);//todo
}
From 4f32c4abde23056b7a48931a9961f2ca88a5e631 Mon Sep 17 00:00:00 2001
From: dzh
Date: Mon, 20 Jan 2020 17:03:28 +0800
Subject: [PATCH 07/47] add OnsDispatcher
---
.../src/main/java/jframe/ext/dispatch/ons/OnsDispatcher.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsDispatcher.java b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsDispatcher.java
index 41e91c0..3ae239d 100644
--- a/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsDispatcher.java
+++ b/jframe/jframe-ext/src/main/java/jframe/ext/dispatch/ons/OnsDispatcher.java
@@ -80,7 +80,7 @@ private void startProducer() {
// // 设置 TCP 接入域名,进入控制台的实例详情页面的获取接入点信息区域查看
// properties.put(PropertyKeyConst.NAMESRV_ADDR,
// "XXX");
- Producer producer = ONSFactory.createProducer(props);
+ producer = ONSFactory.createProducer(props);
// 在发送消息前,必须调用 start 方法来启动 Producer,只需调用一次即可
producer.start();
}
From 122c4ce0b11385adb564f92003823cc593434d33 Mon Sep 17 00:00:00 2001
From: dzh
Date: Mon, 20 Jan 2020 21:22:36 +0800
Subject: [PATCH 08/47] add endpoint for sts
---
.../src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java
index 93657eb..baf0a9f 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java
@@ -111,6 +111,8 @@ AssumeRoleResponse assumeRole(String id, String roleArn, String roleSessionName,
// 创建一个 AssumeRoleRequest 并设置请求参数
final AssumeRoleRequest request = new AssumeRoleRequest();
+ // https://help.aliyun.com/document_detail/66053.html?spm=a2c4g.11186623.6.799.7c6d7074SK0BQS
+ request.setEncoding(_config.getConf(id, K_endpoint, "sts.aliyuncs.com"));
request.setVersion(_config.getConf(id, K_api_version));
request.setMethod(MethodType.POST);
request.setProtocol(protocolType);
From 202beb66b05159f3b6211e0b75d14d88ba63b96e Mon Sep 17 00:00:00 2001
From: dzh
Date: Mon, 20 Jan 2020 21:42:41 +0800
Subject: [PATCH 09/47] add endpoint for sts
---
.../src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java
index baf0a9f..21dc982 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/sts/STSServiceImpl.java
@@ -112,7 +112,7 @@ AssumeRoleResponse assumeRole(String id, String roleArn, String roleSessionName,
// 创建一个 AssumeRoleRequest 并设置请求参数
final AssumeRoleRequest request = new AssumeRoleRequest();
// https://help.aliyun.com/document_detail/66053.html?spm=a2c4g.11186623.6.799.7c6d7074SK0BQS
- request.setEncoding(_config.getConf(id, K_endpoint, "sts.aliyuncs.com"));
+ request.setEndpoint(_config.getConf(id, K_endpoint, "sts.aliyuncs.com"));
request.setVersion(_config.getConf(id, K_api_version));
request.setMethod(MethodType.POST);
request.setProtocol(protocolType);
From 3c7acb7bb08a7908a97fdb7a15afbd7bc86a54ba Mon Sep 17 00:00:00 2001
From: dzh
Date: Mon, 2 Mar 2020 22:40:24 +0800
Subject: [PATCH 10/47] opt service id
---
jframe-plugin/jframe-alipay/pom.xml | 2 +-
.../jframe/alipay/service/AlipayService.java | 7 +++-
.../alipay/service/AlipayServiceImpl.java | 7 ++--
.../jframe/aliyun/service/OSSService.java | 7 ++--
.../jframe/aliyun/service/SMSService.java | 9 ++---
.../jframe/aliyun/service/STSService.java | 4 ++-
jframe-plugin/jframe-httpclient/pom.xml | 4 +--
.../jframe/httpclient/HttpClientConfig.java | 12 +++----
.../httpclient/service/HttpClientService.java | 12 ++++---
.../java/test/client/httpclient.properties | 33 +++++++++----------
.../jframe/jedis/service/JedisService.java | 13 ++++----
11 files changed, 60 insertions(+), 50 deletions(-)
diff --git a/jframe-plugin/jframe-alipay/pom.xml b/jframe-plugin/jframe-alipay/pom.xml
index 380949c..9b51915 100644
--- a/jframe-plugin/jframe-alipay/pom.xml
+++ b/jframe-plugin/jframe-alipay/pom.xml
@@ -15,7 +15,7 @@
com.alipay.sdk
alipay-sdk-java
- 3.7.110.ALL
+ 4.9.28.ALL
diff --git a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java
index dee0c21..8b4648f 100644
--- a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java
+++ b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayService.java
@@ -6,6 +6,9 @@
import java.util.Map;
/**
+ * https://docs.open.alipay.com/204 App支付
+ * https://docs.open.alipay.com/291/105971 密钥配置
+ *
* https://docs.open.alipay.com/270/105899/
* https://docs.open.alipay.com/api_1/alipay.trade.page.pay/
*
@@ -16,9 +19,11 @@
* @author dzh
* @date 2019-07-22 14:56
*/
-@Service(clazz = "jframe.alipay.service.AlipayServiceImpl", id = "jframe.service.alipay")
+@Service(clazz = "jframe.alipay.service.AlipayServiceImpl", id = AlipayService.ID)
public interface AlipayService {
+ String ID = "jframe.service.alipay";
+
String F_URL = "url";
String F_APP_ID = "app.id";
String F_PRIVATE_KEY = "private.key";
diff --git a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java
index 3517fef..5b58e53 100644
--- a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java
+++ b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java
@@ -2,6 +2,7 @@
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
+import com.alipay.api.AlipayConstants;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipaySignature;
import jframe.alipay.AlipayPlugin;
@@ -79,10 +80,10 @@ private AlipayClient createAlipayClient(PropsConf conf, String id) {
String url = conf.getConf(id, F_URL);
String appId = conf.getConf(id, F_APP_ID);
String privateKey = conf.getConf(id, F_PRIVATE_KEY);
- String format = conf.getConf(id, F_FORMAT);
- String charset = conf.getConf(id, F_CHARSET);
+ String format = conf.getConf(id, F_FORMAT, AlipayConstants.FORMAT_JSON);
+ String charset = conf.getConf(id, F_CHARSET, AlipayConstants.CHARSET_UTF8);
String publicKey = conf.getConf(id, F_PUBLIC_KEY);
- String signType = conf.getConf(id, F_SIGN_TYPE);
+ String signType = conf.getConf(id, F_SIGN_TYPE, AlipayConstants.SIGN_TYPE_RSA2);
AlipayClient alipayClient = new DefaultAlipayClient(url, appId, privateKey, format, charset, publicKey, signType);
LOG.info("createAlipayClient {}", appId);
return alipayClient;
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/OSSService.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/OSSService.java
index 7c67095..4385f51 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/OSSService.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/OSSService.java
@@ -1,10 +1,9 @@
/**
- *
+ *
*/
package jframe.aliyun.service;
import com.aliyun.oss.OSSClient;
-
import jframe.core.plugin.annotation.Service;
/**
@@ -12,9 +11,11 @@
* @date Feb 22, 2016 11:07:15 AM
* @since 1.0
*/
-@Service(clazz = "jframe.aliyun.service.oss.OSSServiceImpl", id = "jframe.service.aliyun.oss")
+@Service(clazz = "jframe.aliyun.service.oss.OSSServiceImpl", id = OSSService.ID)
public interface OSSService {
+ String ID = "jframe.service.aliyun.oss";
+
OSSClient getOSSClient(String id);
}
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/SMSService.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/SMSService.java
index 32d8f8b..ed956ef 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/SMSService.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/SMSService.java
@@ -3,19 +3,20 @@
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
-
import jframe.core.plugin.annotation.Service;
/**
* 阿里云短信
- *
+ *
* @author dzh
- * @date Nov 19, 2018 7:00:39 PM
* @version 0.0.1
+ * @date Nov 19, 2018 7:00:39 PM
*/
-@Service(clazz = "jframe.aliyun.service.sms.SMSServiceImpl", id = "jframe.service.aliyun.sms")
+@Service(clazz = "jframe.aliyun.service.sms.SMSServiceImpl", id = SMSService.ID)
public interface SMSService {
+ String ID = "jframe.service.aliyun.sms";
+
SendSmsResponse send(String id, SendSmsRequest request) throws ClientException;
}
diff --git a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/STSService.java b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/STSService.java
index 62dd7c5..b4dfb33 100644
--- a/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/STSService.java
+++ b/jframe-plugin/jframe-aliyun/src/main/java/jframe/aliyun/service/STSService.java
@@ -12,9 +12,11 @@
* @date Feb 28, 2016 9:13:38 AM
* @since 1.0
*/
-@Service(clazz = "jframe.aliyun.service.sts.STSServiceImpl", id = "jframe.service.aliyun.sts")
+@Service(clazz = "jframe.aliyun.service.sts.STSServiceImpl", id = STSService.ID)
public interface STSService {
+ String ID = "jframe.service.aliyun.sts";
+
/**
* 获取临时访问权限
*
diff --git a/jframe-plugin/jframe-httpclient/pom.xml b/jframe-plugin/jframe-httpclient/pom.xml
index 45511bf..6580ad2 100644
--- a/jframe-plugin/jframe-httpclient/pom.xml
+++ b/jframe-plugin/jframe-httpclient/pom.xml
@@ -12,12 +12,12 @@
org.apache.httpcomponents
httpcore
- 4.4.11
+ 4.4.13
org.apache.httpcomponents
httpclient
- 4.5.9
+ 4.5.11
com.google.code.gson
diff --git a/jframe-plugin/jframe-httpclient/src/main/java/jframe/httpclient/HttpClientConfig.java b/jframe-plugin/jframe-httpclient/src/main/java/jframe/httpclient/HttpClientConfig.java
index 918d561..a0afba2 100644
--- a/jframe-plugin/jframe-httpclient/src/main/java/jframe/httpclient/HttpClientConfig.java
+++ b/jframe-plugin/jframe-httpclient/src/main/java/jframe/httpclient/HttpClientConfig.java
@@ -1,18 +1,18 @@
/**
- *
+ *
*/
package jframe.httpclient;
+import jframe.core.util.PropsConf;
+
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
-import jframe.core.util.PropsConf;
-
/**
* TODO 配置文件验证
- *
+ *
* @author dzh
* @date Dec 3, 2014 11:07:29 AM
* @since 1.0
@@ -59,12 +59,12 @@ public static String getConf(String group, String key) {
}
/**
- *
+ *
* @param gid
* @return
*/
public static List getHostByGroup(String gid) {
- List hosts = new LinkedList();
+ List hosts = new LinkedList<>();
for (String host : getHosts()) {
if (gid.equals(CONFIG.getConf(host, GROUP))) {
hosts.add(host);
diff --git a/jframe-plugin/jframe-httpclient/src/main/java/jframe/httpclient/service/HttpClientService.java b/jframe-plugin/jframe-httpclient/src/main/java/jframe/httpclient/service/HttpClientService.java
index 610bdd7..be2a8f4 100644
--- a/jframe-plugin/jframe-httpclient/src/main/java/jframe/httpclient/service/HttpClientService.java
+++ b/jframe-plugin/jframe-httpclient/src/main/java/jframe/httpclient/service/HttpClientService.java
@@ -1,12 +1,12 @@
/**
- *
+ *
*/
package jframe.httpclient.service;
-import java.util.Map;
-
import jframe.core.plugin.annotation.Service;
+import java.util.Map;
+
/**
*
* 特性:
@@ -15,14 +15,16 @@
*
TODO 支持https
* TODO 发送失败异常处理
*
- *
+ *
* @author dzh
* @date Dec 2, 2014 12:10:16 PM
* @since 1.0
*/
-@Service(clazz = "jframe.httpclient.service.impl.HttpClientServiceImpl", id = "jframe.service.httpclient")
+@Service(clazz = "jframe.httpclient.service.impl.HttpClientServiceImpl", id = HttpClientService.ID)
public interface HttpClientService {
+ String ID = "jframe.service.httpclient";
+
String P_MIMETYPE = "mimeType";
String P_METHOD = "method";
diff --git a/jframe-plugin/jframe-httpclient/src/test/java/test/client/httpclient.properties b/jframe-plugin/jframe-httpclient/src/test/java/test/client/httpclient.properties
index a9f5fe1..d6d9b16 100644
--- a/jframe-plugin/jframe-httpclient/src/test/java/test/client/httpclient.properties
+++ b/jframe-plugin/jframe-httpclient/src/test/java/test/client/httpclient.properties
@@ -1,22 +1,19 @@
-group.id = host1 host2
-
-@host1.ip = localhost
-@host1.port =
-@host1.scheme = http
-@host1.group =
+group.id=host1 host2
+@host1.ip=localhost
+@host1.port=
+@host1.scheme=http
+@host1.group=
#@host1.http.method = post
#@host1.http.max.conn.route = 60
#@host1.http.keep-alive = 5
-
-@host2.ip = 192.168.1.123
-@host2.port = 8038
-@host1.scheme = http
-@host2.group =
-
-http.method = post
-http.max.conn = 200
-http.max.conn.route = 50
-http.keep-alive = 5
+@host2.ip=192.168.1.123
+@host2.port=8038
+@host2.scheme=http
+@host2.group=
+http.method=post
+http.max.conn=200
+http.max.conn.route=50
+http.keep-alive=5
#second
-http.idle.conn.close = 30
-http.charset = utf-8
+http.idle.conn.close=30
+http.charset=utf-8
diff --git a/jframe-plugin/jframe-jedis/src/main/java/jframe/jedis/service/JedisService.java b/jframe-plugin/jframe-jedis/src/main/java/jframe/jedis/service/JedisService.java
index d146c31..2a0fa07 100644
--- a/jframe-plugin/jframe-jedis/src/main/java/jframe/jedis/service/JedisService.java
+++ b/jframe-plugin/jframe-jedis/src/main/java/jframe/jedis/service/JedisService.java
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package jframe.jedis.service;
@@ -12,11 +12,12 @@
* @date Dec 2, 2014 10:37:37 AM
* @since 1.0
*/
-@Service(clazz = "jframe.jedis.service.JedisServiceImpl", id = "jframe.service.jedis")
+@Service(clazz = "jframe.jedis.service.JedisServiceImpl", id = JedisService.ID)
public interface JedisService {
+ String ID = "jframe.service.jedis";
/**
- *
+ *
* @return jedis.host.default's jedis
*/
Jedis getJedis();
@@ -25,7 +26,7 @@ public interface JedisService {
/**
* use {@link redis.clients.jedis.Jedis#close()}
- *
+ *
* @param jedis
*/
@Deprecated
@@ -33,7 +34,7 @@ public interface JedisService {
/**
* use {@link redis.clients.jedis.Jedis#close()}
- *
+ *
* @param jedis
*/
@Deprecated
@@ -41,7 +42,7 @@ public interface JedisService {
/**
* unsupported
- *
+ *
* @param name
* @return
*/
From ebf9f0f53cd96fc5dcaa9a9fafd85cdb2b1394df Mon Sep 17 00:00:00 2001
From: dzh
Date: Fri, 13 Mar 2020 15:59:36 +0800
Subject: [PATCH 11/47] opt log
---
.../alipay/service/AlipayServiceImpl.java | 2 +-
.../jframe/umeng/service/UmengService.java | 12 +++---
.../umeng/service/impl/UmengServiceImpl.java | 39 +++++++++----------
3 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java
index 5b58e53..86065ea 100644
--- a/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java
+++ b/jframe-plugin/jframe-alipay/src/main/java/jframe/alipay/service/AlipayServiceImpl.java
@@ -82,7 +82,7 @@ private AlipayClient createAlipayClient(PropsConf conf, String id) {
String privateKey = conf.getConf(id, F_PRIVATE_KEY);
String format = conf.getConf(id, F_FORMAT, AlipayConstants.FORMAT_JSON);
String charset = conf.getConf(id, F_CHARSET, AlipayConstants.CHARSET_UTF8);
- String publicKey = conf.getConf(id, F_PUBLIC_KEY);
+ String publicKey = conf.getConf(id, F_PUBLIC_KEY); //alipay public key
String signType = conf.getConf(id, F_SIGN_TYPE, AlipayConstants.SIGN_TYPE_RSA2);
AlipayClient alipayClient = new DefaultAlipayClient(url, appId, privateKey, format, charset, publicKey, signType);
LOG.info("createAlipayClient {}", appId);
diff --git a/jframe-plugin/jframe-umeng/src/main/java/jframe/umeng/service/UmengService.java b/jframe-plugin/jframe-umeng/src/main/java/jframe/umeng/service/UmengService.java
index ed8b6c1..0682127 100644
--- a/jframe-plugin/jframe-umeng/src/main/java/jframe/umeng/service/UmengService.java
+++ b/jframe-plugin/jframe-umeng/src/main/java/jframe/umeng/service/UmengService.java
@@ -1,22 +1,24 @@
/**
- *
+ *
*/
package jframe.umeng.service;
-import java.util.Map;
-
import jframe.core.plugin.annotation.Service;
+import java.util.Map;
+
/**
* https://developer.umeng.com/docs/66632/detail/68343
- *
+ *
* @author dzh
* @date Mar 4, 2016 10:12:32 PM
* @since 1.0
*/
-@Service(clazz = "jframe.umeng.service.impl.UmengServiceImpl", id = "jframe.service.umeng")
+@Service(clazz = "jframe.umeng.service.impl.UmengServiceImpl", id = UmengService.ID)
public interface UmengService {
+ String ID = "jframe.service.umeng";
+
void sendAndBroadcast(String groupId, String token, String ticker, String title, String text, Map custom)
throws Exception;
diff --git a/jframe-plugin/jframe-umeng/src/main/java/jframe/umeng/service/impl/UmengServiceImpl.java b/jframe-plugin/jframe-umeng/src/main/java/jframe/umeng/service/impl/UmengServiceImpl.java
index cb5e883..50c9ed0 100644
--- a/jframe-plugin/jframe-umeng/src/main/java/jframe/umeng/service/impl/UmengServiceImpl.java
+++ b/jframe-plugin/jframe-umeng/src/main/java/jframe/umeng/service/impl/UmengServiceImpl.java
@@ -1,26 +1,16 @@
/**
- *
+ *
*/
package jframe.umeng.service.impl;
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.codec.digest.DigestUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import jframe.core.plugin.annotation.InjectPlugin;
-import jframe.core.plugin.annotation.InjectService;
-import jframe.core.plugin.annotation.Injector;
-import jframe.core.plugin.annotation.Start;
-import jframe.core.plugin.annotation.Stop;
+import jframe.core.plugin.annotation.*;
import jframe.httpclient.service.HttpClientService;
import jframe.umeng.UmengConfig;
import jframe.umeng.UmengPlugin;
import jframe.umeng.service.UmengService;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import push.AndroidNotification;
import push.AndroidNotification.DisplayType;
import push.UmengNotification;
@@ -29,8 +19,13 @@
import push.ios.IOSBroadcast;
import push.ios.IOSUnicast;
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.HashMap;
+import java.util.Map;
+
/**
- *
+ *
* @author dzh
* @date Mar 4, 2016 10:13:18 PM
* @since 1.0
@@ -79,7 +74,8 @@ public void start(String path) {
}
@Stop
- void stop() {}
+ void stop() {
+ }
/**
* "alert":""/{ // 当content-available=1时(静默推送),可选; 否则必填。
@@ -147,13 +143,14 @@ void sendUmengNotification(UmengNotification n, String groupId) throws Exception
String httpid = _config.getConf(null, UmengConfig.HttpId, "umeng");
String path = "/api/send?sign=" + sign;
- Map headers = new HashMap(1, 1);
+ Map headers = new HashMap<>(1, 1);
headers.put("User-Agent", "Mozilla/5.0");
Object rsp = _http.send(httpid, path, postBody, headers, null);
+ LOG.info("m->sendUmengNotification data->{} rsp->{}", postBody, rsp);
- if (LOG.isDebugEnabled()) {
- LOG.debug("m->sendUmengNotification data->{} rsp->{}", n.getPostBody(), rsp);
- }
+// if (LOG.isDebugEnabled()) {
+// LOG.debug("m->sendUmengNotification data->{} rsp->{}", postBody, rsp);
+// }
}
@Override
From 14fb8cc1dfd98699154cb491ce1ba7045d52e596 Mon Sep 17 00:00:00 2001
From: dzh
Date: Wed, 19 Aug 2020 15:55:37 +0800
Subject: [PATCH 12/47] add jframe-wxpay
---
.../freemarker/service/FreemarkerService.java | 6 +-
.../main/java/jframe/getui/GetuiService.java | 74 +-
.../java/jframe/getui/MultiGetuiService.java | 85 +--
.../jframe/mybatis/MultiMybatisService.java | 21 +-
.../jframe/qiniu/service/QiniuService.java | 7 +-
.../rongcloud/service/RongcloudService.java | 14 +-
jframe-plugin/jframe-wxpay/pom.xml | 36 +
.../com/github/wxpay/sdk/IWXPayDomain.java | 45 ++
.../github/wxpay/sdk/JframeWxpayConfig.java | 55 ++
.../main/java/com/github/wxpay/sdk/WXPay.java | 689 ++++++++++++++++++
.../com/github/wxpay/sdk/WXPayConfig.java | 103 +++
.../com/github/wxpay/sdk/WXPayConstants.java | 59 ++
.../com/github/wxpay/sdk/WXPayReport.java | 265 +++++++
.../com/github/wxpay/sdk/WXPayRequest.java | 258 +++++++
.../java/com/github/wxpay/sdk/WXPayUtil.java | 295 ++++++++
.../com/github/wxpay/sdk/WXPayXmlUtil.java | 30 +
.../src/main/java/jframe/wxpay/WxpayConf.java | 55 ++
.../main/java/jframe/wxpay/WxpayPlugin.java | 11 +
.../jframe/wxpay/service/WxpayService.java | 39 +
.../jframe/wxpay/service/WxpayServiceV2.java | 115 +++
.../jframe/wxpay/service/WxpayServiceV3.java | 86 +++
.../main/resources/META-INF/plugin.properties | 7 +
.../src/test/resources/wxpay.properties | 12 +
jframe-plugin/pom.xml | 1 +
24 files changed, 2268 insertions(+), 100 deletions(-)
create mode 100644 jframe-plugin/jframe-wxpay/pom.xml
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/IWXPayDomain.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/JframeWxpayConfig.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPay.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConfig.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConstants.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayReport.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayRequest.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayUtil.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayXmlUtil.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/WxpayConf.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/WxpayPlugin.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV3.java
create mode 100644 jframe-plugin/jframe-wxpay/src/main/resources/META-INF/plugin.properties
create mode 100644 jframe-plugin/jframe-wxpay/src/test/resources/wxpay.properties
diff --git a/jframe-plugin/jframe-freemarker/src/main/java/jframe/freemarker/service/FreemarkerService.java b/jframe-plugin/jframe-freemarker/src/main/java/jframe/freemarker/service/FreemarkerService.java
index eb6d7ef..97ad5a7 100644
--- a/jframe-plugin/jframe-freemarker/src/main/java/jframe/freemarker/service/FreemarkerService.java
+++ b/jframe-plugin/jframe-freemarker/src/main/java/jframe/freemarker/service/FreemarkerService.java
@@ -1,5 +1,5 @@
/**
- *
+ *
*/
package jframe.freemarker.service;
@@ -11,9 +11,11 @@
* @date Aug 25, 2016 1:50:52 PM
* @since 1.0
*/
-@Service(clazz = "jframe.freemarker.service.impl.FreemarkerServiceImpl", id = "jframe.service.freemarker")
+@Service(clazz = "jframe.freemarker.service.impl.FreemarkerServiceImpl", id = FreemarkerService.ID)
public interface FreemarkerService {
+ String ID = "jframe.service.freemarker";
+
Template getTemplate(String id, String ftl) throws Exception;
}
diff --git a/jframe-plugin/jframe-getui/src/main/java/jframe/getui/GetuiService.java b/jframe-plugin/jframe-getui/src/main/java/jframe/getui/GetuiService.java
index f3c9069..16d54c6 100644
--- a/jframe-plugin/jframe-getui/src/main/java/jframe/getui/GetuiService.java
+++ b/jframe-plugin/jframe-getui/src/main/java/jframe/getui/GetuiService.java
@@ -1,56 +1,56 @@
/**
- *
+ *
*/
package jframe.getui;
-import java.util.List;
-
-import jframe.core.plugin.annotation.Service;
-
import com.gexin.rp.sdk.base.IPushResult;
import com.gexin.rp.sdk.base.ITemplate;
import com.gexin.rp.sdk.base.impl.SingleMessage;
+import jframe.core.plugin.annotation.Service;
+
+import java.util.List;
/**
* @author dzh
* @date Sep 29, 2014 12:00:46 PM
* @since 1.0
*/
-@Service(clazz = "jframe.getui.andriod.GetuiServiceImpl", id = "jframe.service.getui")
+@Service(clazz = "jframe.getui.andriod.GetuiServiceImpl", id = GetuiService.ID)
public interface GetuiService {
+ String ID = "jframe.service.getui";
// IPushResult push2App(ITemplate data, boolean isOffline,
// long offlineExpireTime) throws Exception;
- IPushResult push2Single(ITemplate data, boolean isOffline,
- long offlineExpireTime, String token) throws Exception;
-
- public static class Utils {
-
- public SingleMessage createSingleMessage(boolean isOffline,
- long offlineExpireTime, ITemplate data) {
- SingleMessage message = new SingleMessage();
- message.setOffline(isOffline);
- message.setOfflineExpireTime(offlineExpireTime);
- message.setData(data);
- return message;
- }
-
- // public ITemplate createTemplate() {
- // PopupTransmissionTemplate template = new PopupTransmissionTemplate();
- // template.setAppId(GetuiConfig.APPID);
- // template.setAppkey(GetuiConfig.APPKEY);
- // template.setText("");
- // template.setTitle("");
- // template.setImg("");
- // template.setConfirmButtonText("");
- // template.setCancelButtonText("");
- // template.setTransmissionContent("111");
- // template.setTransmissionType(1);
- // }
-
- }
-
- IPushResult push2List(ITemplate data, boolean isOffline,
- long offlineExpireTime, List token);
+ IPushResult push2Single(ITemplate data, boolean isOffline,
+ long offlineExpireTime, String token) throws Exception;
+
+ public static class Utils {
+
+ public SingleMessage createSingleMessage(boolean isOffline,
+ long offlineExpireTime, ITemplate data) {
+ SingleMessage message = new SingleMessage();
+ message.setOffline(isOffline);
+ message.setOfflineExpireTime(offlineExpireTime);
+ message.setData(data);
+ return message;
+ }
+
+ // public ITemplate createTemplate() {
+ // PopupTransmissionTemplate template = new PopupTransmissionTemplate();
+ // template.setAppId(GetuiConfig.APPID);
+ // template.setAppkey(GetuiConfig.APPKEY);
+ // template.setText("");
+ // template.setTitle("");
+ // template.setImg("");
+ // template.setConfirmButtonText("");
+ // template.setCancelButtonText("");
+ // template.setTransmissionContent("111");
+ // template.setTransmissionType(1);
+ // }
+
+ }
+
+ IPushResult push2List(ITemplate data, boolean isOffline,
+ long offlineExpireTime, List token);
}
diff --git a/jframe-plugin/jframe-getui/src/main/java/jframe/getui/MultiGetuiService.java b/jframe-plugin/jframe-getui/src/main/java/jframe/getui/MultiGetuiService.java
index 2c99742..b9d91ff 100644
--- a/jframe-plugin/jframe-getui/src/main/java/jframe/getui/MultiGetuiService.java
+++ b/jframe-plugin/jframe-getui/src/main/java/jframe/getui/MultiGetuiService.java
@@ -1,59 +1,60 @@
/**
- *
+ *
*/
package jframe.getui;
-import java.util.List;
-
-import jframe.core.plugin.annotation.Service;
-
import com.gexin.rp.sdk.base.IPushResult;
import com.gexin.rp.sdk.base.ITemplate;
import com.gexin.rp.sdk.base.impl.SingleMessage;
+import jframe.core.plugin.annotation.Service;
+
+import java.util.List;
/**
* @author dzh
* @date Aug 20, 2015 3:52:51 PM
* @since 1.0
*/
-@Service(clazz = "jframe.getui.andriod.MultiGetuiServiceImpl", id = "jframe.service.multigetui")
+@Service(clazz = "jframe.getui.andriod.MultiGetuiServiceImpl", id = MultiGetuiService.ID)
public interface MultiGetuiService {
- // IPushResult push2App(ITemplate data, boolean isOffline,
- // long offlineExpireTime) throws Exception;
-
- IPushResult push2Single(String id, ITemplate data, boolean isOffline,
- long offlineExpireTime, String token) throws Exception;
-
- public static class Utils {
-
- public SingleMessage createSingleMessage(boolean isOffline,
- long offlineExpireTime, ITemplate data) {
- SingleMessage message = new SingleMessage();
- message.setOffline(isOffline);
- message.setOfflineExpireTime(offlineExpireTime);
- message.setData(data);
- return message;
- }
-
- // public ITemplate createTemplate() {
- // PopupTransmissionTemplate template = new PopupTransmissionTemplate();
- // template.setAppId(GetuiConfig.APPID);
- // template.setAppkey(GetuiConfig.APPKEY);
- // template.setText("");
- // template.setTitle("");
- // template.setImg("");
- // template.setConfirmButtonText("");
- // template.setCancelButtonText("");
- // template.setTransmissionContent("111");
- // template.setTransmissionType(1);
- // }
-
- }
-
- IPushResult push2List(String id, ITemplate data, boolean isOffline,
- long offlineExpireTime, List token);
-
- String getConf(String id, String key);
+ String ID = "jframe.service.multigetui";
+
+ // IPushResult push2App(ITemplate data, boolean isOffline,
+ // long offlineExpireTime) throws Exception;
+
+ IPushResult push2Single(String id, ITemplate data, boolean isOffline,
+ long offlineExpireTime, String token) throws Exception;
+
+ public static class Utils {
+
+ public SingleMessage createSingleMessage(boolean isOffline,
+ long offlineExpireTime, ITemplate data) {
+ SingleMessage message = new SingleMessage();
+ message.setOffline(isOffline);
+ message.setOfflineExpireTime(offlineExpireTime);
+ message.setData(data);
+ return message;
+ }
+
+ // public ITemplate createTemplate() {
+ // PopupTransmissionTemplate template = new PopupTransmissionTemplate();
+ // template.setAppId(GetuiConfig.APPID);
+ // template.setAppkey(GetuiConfig.APPKEY);
+ // template.setText("");
+ // template.setTitle("");
+ // template.setImg("");
+ // template.setConfirmButtonText("");
+ // template.setCancelButtonText("");
+ // template.setTransmissionContent("111");
+ // template.setTransmissionType(1);
+ // }
+
+ }
+
+ IPushResult push2List(String id, ITemplate data, boolean isOffline,
+ long offlineExpireTime, List token);
+
+ String getConf(String id, String key);
}
diff --git a/jframe-plugin/jframe-mybatis/src/main/java/jframe/mybatis/MultiMybatisService.java b/jframe-plugin/jframe-mybatis/src/main/java/jframe/mybatis/MultiMybatisService.java
index 1dc97f8..6993731 100644
--- a/jframe-plugin/jframe-mybatis/src/main/java/jframe/mybatis/MultiMybatisService.java
+++ b/jframe-plugin/jframe-mybatis/src/main/java/jframe/mybatis/MultiMybatisService.java
@@ -1,10 +1,9 @@
/**
- *
+ *
*/
package jframe.mybatis;
import jframe.core.plugin.annotation.Service;
-
import org.apache.ibatis.session.SqlSessionFactory;
/**
@@ -12,15 +11,17 @@
* @date Jul 17, 2015 11:36:43 AM
* @since 1.0
*/
-@Service(clazz = "jframe.mybatis.MultiMybatisServiceImpl", id = "jframe.service.multimybatis")
+@Service(clazz = "jframe.mybatis.MultiMybatisServiceImpl", id = MultiMybatisService.ID)
public interface MultiMybatisService {
- /**
- *
- * @param id
- * environment[@id] in mybatis-config.xml
- * @return
- */
- SqlSessionFactory getSqlSessionFactory(String id);
+ String ID = "jframe.service.multimybatis";
+
+ /**
+ *
+ * @param id
+ * environment[@id] in mybatis-config.xml
+ * @return
+ */
+ SqlSessionFactory getSqlSessionFactory(String id);
}
diff --git a/jframe-plugin/jframe-qiniu/src/main/java/jframe/qiniu/service/QiniuService.java b/jframe-plugin/jframe-qiniu/src/main/java/jframe/qiniu/service/QiniuService.java
index 1dd76e7..4326f12 100644
--- a/jframe-plugin/jframe-qiniu/src/main/java/jframe/qiniu/service/QiniuService.java
+++ b/jframe-plugin/jframe-qiniu/src/main/java/jframe/qiniu/service/QiniuService.java
@@ -1,12 +1,11 @@
/**
- *
+ *
*/
package jframe.qiniu.service;
import com.qiniu.storage.BucketManager;
import com.qiniu.util.Auth;
import com.qiniu.util.StringMap;
-
import jframe.core.plugin.annotation.Service;
/**
@@ -14,9 +13,11 @@
* @date Jul 28, 2015 10:09:03 AM
* @since 1.0
*/
-@Service(clazz = "jframe.qiniu.service.QiniuServiceImpl", id = "jframe.service.qiniu")
+@Service(clazz = "jframe.qiniu.service.QiniuServiceImpl", id = QiniuService.ID)
public interface QiniuService {
+ String ID = "jframe.service.qiniu";
+
String uploadToken(String id, String key);
String uploadToken(String id, String key, long expires);
diff --git a/jframe-plugin/jframe-rongcloud/src/main/java/jframe/rongcloud/service/RongcloudService.java b/jframe-plugin/jframe-rongcloud/src/main/java/jframe/rongcloud/service/RongcloudService.java
index 5767f72..2893290 100644
--- a/jframe-plugin/jframe-rongcloud/src/main/java/jframe/rongcloud/service/RongcloudService.java
+++ b/jframe-plugin/jframe-rongcloud/src/main/java/jframe/rongcloud/service/RongcloudService.java
@@ -1,24 +1,26 @@
/**
- *
+ *
*/
package jframe.rongcloud.service;
-import java.util.List;
-import java.util.Map;
-
import jframe.core.plugin.annotation.Service;
import jframe.rongcloud.Fields;
+import java.util.List;
+import java.util.Map;
+
/**
* http://www.rongcloud.cn/docs/server.html
- *
+ *
* @author dzh
* @date Feb 14, 2016 9:39:42 PM
* @since 1.0
*/
-@Service(clazz = "jframe.rongcloud.service.impl.RongcloudServiceImpl", id = "jframe.service.rongcloud")
+@Service(clazz = "jframe.rongcloud.service.impl.RongcloudServiceImpl", id = RongcloudService.ID)
public interface RongcloudService extends Fields {
+ String ID = "jframe.service.rongcloud";
+
String getToken(String id, Map req);
boolean refreshUsr(String id, Map req);
diff --git a/jframe-plugin/jframe-wxpay/pom.xml b/jframe-plugin/jframe-wxpay/pom.xml
new file mode 100644
index 0000000..a782915
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/pom.xml
@@ -0,0 +1,36 @@
+
+
+
+ jframe-plugin
+ io.github.dzh
+ 2.0.0-SNAPSHOT
+
+ 4.0.0
+
+ jframe-wxpay
+
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.5.11
+
+
+
+
+
+ com.github.wechatpay-apiv3
+ wechatpay-apache-httpclient
+ 0.2.1
+
+
+
+
\ No newline at end of file
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/IWXPayDomain.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/IWXPayDomain.java
new file mode 100644
index 0000000..aa9e6e6
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/IWXPayDomain.java
@@ -0,0 +1,45 @@
+package com.github.wxpay.sdk;
+
+/**
+ * 域名管理,实现主备域名自动切换
+ */
+public abstract interface IWXPayDomain {
+ /**
+ * 上报域名网络状况
+ *
+ * @param domain 域名。 比如:api.mch.weixin.qq.com
+ * @param elapsedTimeMillis 耗时
+ * @param ex 网络请求中出现的异常。
+ * null表示没有异常
+ * ConnectTimeoutException,表示建立网络连接异常
+ * UnknownHostException, 表示dns解析异常
+ */
+ abstract void report(final String domain, long elapsedTimeMillis, final Exception ex);
+
+ /**
+ * 获取域名
+ *
+ * @param config 配置
+ * @return 域名
+ */
+ abstract DomainInfo getDomain(final WXPayConfig config);
+
+ static class DomainInfo {
+ public String domain; //域名
+ public boolean primaryDomain; //该域名是否为主域名。例如:api.mch.weixin.qq.com为主域名
+
+ public DomainInfo(String domain, boolean primaryDomain) {
+ this.domain = domain;
+ this.primaryDomain = primaryDomain;
+ }
+
+ @Override
+ public String toString() {
+ return "DomainInfo{" +
+ "domain='" + domain + '\'' +
+ ", primaryDomain=" + primaryDomain +
+ '}';
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/JframeWxpayConfig.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/JframeWxpayConfig.java
new file mode 100644
index 0000000..d992c58
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/JframeWxpayConfig.java
@@ -0,0 +1,55 @@
+package com.github.wxpay.sdk;
+
+import java.io.InputStream;
+
+/**
+ * @author dzh
+ * @date 2020/8/18 19:21
+ */
+public class JframeWxpayConfig extends WXPayConfig {
+
+ private String appId;
+
+ private String mchId;
+ private String apikey;
+
+ private InputStream certStream;
+
+ public static JframeWxpayConfig create(String appId, String mchId, String apikey, InputStream certStream) {
+ JframeWxpayConfig conf = new JframeWxpayConfig();
+ conf.appId = appId;
+ conf.mchId = mchId;
+ conf.apikey = apikey;
+ conf.certStream = certStream;
+ return conf;
+ }
+
+ @Override
+ String getAppID() {
+ return appId;
+ }
+
+ @Override
+ String getMchID() {
+ return mchId;
+ }
+
+ @Override
+ String getKey() {
+ return apikey;
+ }
+
+ @Override
+ InputStream getCertStream() {
+ return certStream;
+ }
+
+ @Override
+ IWXPayDomain getWXPayDomain() {
+ return null;
+ }
+
+// public boolean shouldAutoReport() {
+// return false;
+// }
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPay.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPay.java
new file mode 100644
index 0000000..7f0fbcd
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPay.java
@@ -0,0 +1,689 @@
+package com.github.wxpay.sdk;
+
+import com.github.wxpay.sdk.WXPayConstants.SignType;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class WXPay {
+
+ private WXPayConfig config;
+ private SignType signType;
+ private boolean autoReport;
+ private boolean useSandbox;
+ private String notifyUrl;
+ private WXPayRequest wxPayRequest;
+
+ public WXPay(final WXPayConfig config) throws Exception {
+ this(config, null, true, false);
+ }
+
+ public WXPay(final WXPayConfig config, final boolean autoReport) throws Exception {
+ this(config, null, autoReport, false);
+ }
+
+
+ public WXPay(final WXPayConfig config, final boolean autoReport, final boolean useSandbox) throws Exception{
+ this(config, null, autoReport, useSandbox);
+ }
+
+ public WXPay(final WXPayConfig config, final String notifyUrl) throws Exception {
+ this(config, notifyUrl, true, false);
+ }
+
+ public WXPay(final WXPayConfig config, final String notifyUrl, final boolean autoReport) throws Exception {
+ this(config, notifyUrl, autoReport, false);
+ }
+
+ public WXPay(final WXPayConfig config, final String notifyUrl, final boolean autoReport, final boolean useSandbox) throws Exception {
+ this.config = config;
+ this.notifyUrl = notifyUrl;
+ this.autoReport = autoReport;
+ this.useSandbox = useSandbox;
+ if (useSandbox) {
+ this.signType = SignType.MD5; // 沙箱环境
+ }
+ else {
+ this.signType = SignType.HMACSHA256;
+ }
+ this.wxPayRequest = new WXPayRequest(config);
+ }
+
+ private void checkWXPayConfig() throws Exception {
+ if (this.config == null) {
+ throw new Exception("config is null");
+ }
+ if (this.config.getAppID() == null || this.config.getAppID().trim().length() == 0) {
+ throw new Exception("appid in config is empty");
+ }
+ if (this.config.getMchID() == null || this.config.getMchID().trim().length() == 0) {
+ throw new Exception("appid in config is empty");
+ }
+ if (this.config.getCertStream() == null) {
+ throw new Exception("cert stream in config is empty");
+ }
+ if (this.config.getWXPayDomain() == null){
+ throw new Exception("config.getWXPayDomain() is null");
+ }
+
+ if (this.config.getHttpConnectTimeoutMs() < 10) {
+ throw new Exception("http connect timeout is too small");
+ }
+ if (this.config.getHttpReadTimeoutMs() < 10) {
+ throw new Exception("http read timeout is too small");
+ }
+
+ }
+
+ /**
+ * 向 Map 中添加 appid、mch_id、nonce_str、sign_type、sign
+ * 该函数适用于商户适用于统一下单等接口,不适用于红包、代金券接口
+ *
+ * @param reqData
+ * @return
+ * @throws Exception
+ */
+ public Map fillRequestData(Map reqData) throws Exception {
+ reqData.put("appid", config.getAppID());
+ reqData.put("mch_id", config.getMchID());
+ reqData.put("nonce_str", WXPayUtil.generateNonceStr());
+ if (SignType.MD5.equals(this.signType)) {
+ reqData.put("sign_type", WXPayConstants.MD5);
+ }
+ else if (SignType.HMACSHA256.equals(this.signType)) {
+ reqData.put("sign_type", WXPayConstants.HMACSHA256);
+ }
+ reqData.put("sign", WXPayUtil.generateSignature(reqData, config.getKey(), this.signType));
+ return reqData;
+ }
+
+ /**
+ * 判断xml数据的sign是否有效,必须包含sign字段,否则返回false。
+ *
+ * @param reqData 向wxpay post的请求数据
+ * @return 签名是否有效
+ * @throws Exception
+ */
+ public boolean isResponseSignatureValid(Map reqData) throws Exception {
+ // 返回数据的签名方式和请求中给定的签名方式是一致的
+ return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), this.signType);
+ }
+
+ /**
+ * 判断支付结果通知中的sign是否有效
+ *
+ * @param reqData 向wxpay post的请求数据
+ * @return 签名是否有效
+ * @throws Exception
+ */
+ public boolean isPayResultNotifySignatureValid(Map reqData) throws Exception {
+ String signTypeInData = reqData.get(WXPayConstants.FIELD_SIGN_TYPE);
+ SignType signType;
+ if (signTypeInData == null) {
+ signType = SignType.MD5;
+ }
+ else {
+ signTypeInData = signTypeInData.trim();
+ if (signTypeInData.length() == 0) {
+ signType = SignType.MD5;
+ }
+ else if (WXPayConstants.MD5.equals(signTypeInData)) {
+ signType = SignType.MD5;
+ }
+ else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) {
+ signType = SignType.HMACSHA256;
+ }
+ else {
+ throw new Exception(String.format("Unsupported sign_type: %s", signTypeInData));
+ }
+ }
+ return WXPayUtil.isSignatureValid(reqData, this.config.getKey(), signType);
+ }
+
+
+ /**
+ * 不需要证书的请求
+ * @param urlSuffix String
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 超时时间,单位是毫秒
+ * @param readTimeoutMs 超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public String requestWithoutCert(String urlSuffix, Map reqData,
+ int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String msgUUID = reqData.get("nonce_str");
+ String reqBody = WXPayUtil.mapToXml(reqData);
+
+ String resp = this.wxPayRequest.requestWithoutCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, autoReport);
+ return resp;
+ }
+
+
+ /**
+ * 需要证书的请求
+ * @param urlSuffix String
+ * @param reqData 向wxpay post的请求数据 Map
+ * @param connectTimeoutMs 超时时间,单位是毫秒
+ * @param readTimeoutMs 超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public String requestWithCert(String urlSuffix, Map reqData,
+ int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String msgUUID= reqData.get("nonce_str");
+ String reqBody = WXPayUtil.mapToXml(reqData);
+
+ String resp = this.wxPayRequest.requestWithCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, this.autoReport);
+ return resp;
+ }
+
+ /**
+ * 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
+ * @param xmlStr API返回的XML格式数据
+ * @return Map类型数据
+ * @throws Exception
+ */
+ public Map processResponseXml(String xmlStr) throws Exception {
+ String RETURN_CODE = "return_code";
+ String return_code;
+ Map respData = WXPayUtil.xmlToMap(xmlStr);
+ if (respData.containsKey(RETURN_CODE)) {
+ return_code = respData.get(RETURN_CODE);
+ }
+ else {
+ throw new Exception(String.format("No `return_code` in XML: %s", xmlStr));
+ }
+
+ if (return_code.equals(WXPayConstants.FAIL)) {
+ return respData;
+ }
+ else if (return_code.equals(WXPayConstants.SUCCESS)) {
+ if (this.isResponseSignatureValid(respData)) {
+ return respData;
+ }
+ else {
+ throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr));
+ }
+ }
+ else {
+ throw new Exception(String.format("return_code value %s is invalid in XML: %s", return_code, xmlStr));
+ }
+ }
+
+ /**
+ * 作用:提交刷卡支付
+ * 场景:刷卡支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map microPay(Map reqData) throws Exception {
+ return this.microPay(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:提交刷卡支付
+ * 场景:刷卡支付
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map microPay(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_MICROPAY_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.MICROPAY_URL_SUFFIX;
+ }
+ String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return this.processResponseXml(respXml);
+ }
+
+ /**
+ * 提交刷卡支付,针对软POS,尽可能做成功
+ * 内置重试机制,最多60s
+ * @param reqData
+ * @return
+ * @throws Exception
+ */
+ public Map microPayWithPos(Map reqData) throws Exception {
+ return this.microPayWithPos(reqData, this.config.getHttpConnectTimeoutMs());
+ }
+
+ /**
+ * 提交刷卡支付,针对软POS,尽可能做成功
+ * 内置重试机制,最多60s
+ * @param reqData
+ * @param connectTimeoutMs
+ * @return
+ * @throws Exception
+ */
+ public Map microPayWithPos(Map reqData, int connectTimeoutMs) throws Exception {
+ int remainingTimeMs = 60*1000;
+ long startTimestampMs = 0;
+ Map lastResult = null;
+ Exception lastException = null;
+
+ while (true) {
+ startTimestampMs = WXPayUtil.getCurrentTimestampMs();
+ int readTimeoutMs = remainingTimeMs - connectTimeoutMs;
+ if (readTimeoutMs > 1000) {
+ try {
+ lastResult = this.microPay(reqData, connectTimeoutMs, readTimeoutMs);
+ String returnCode = lastResult.get("return_code");
+ if (returnCode.equals("SUCCESS")) {
+ String resultCode = lastResult.get("result_code");
+ String errCode = lastResult.get("err_code");
+ if (resultCode.equals("SUCCESS")) {
+ break;
+ }
+ else {
+ // 看错误码,若支付结果未知,则重试提交刷卡支付
+ if (errCode.equals("SYSTEMERROR") || errCode.equals("BANKERROR") || errCode.equals("USERPAYING")) {
+ remainingTimeMs = remainingTimeMs - (int)(WXPayUtil.getCurrentTimestampMs() - startTimestampMs);
+ if (remainingTimeMs <= 100) {
+ break;
+ }
+ else {
+ WXPayUtil.getLogger().info("microPayWithPos: try micropay again");
+ if (remainingTimeMs > 5*1000) {
+ Thread.sleep(5*1000);
+ }
+ else {
+ Thread.sleep(1*1000);
+ }
+ continue;
+ }
+ }
+ else {
+ break;
+ }
+ }
+ }
+ else {
+ break;
+ }
+ }
+ catch (Exception ex) {
+ lastResult = null;
+ lastException = ex;
+ }
+ }
+ else {
+ break;
+ }
+ }
+
+ if (lastResult == null) {
+ throw lastException;
+ }
+ else {
+ return lastResult;
+ }
+ }
+
+
+
+ /**
+ * 作用:统一下单
+ * 场景:公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map unifiedOrder(Map reqData) throws Exception {
+ return this.unifiedOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:统一下单
+ * 场景:公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map unifiedOrder(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_UNIFIEDORDER_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.UNIFIEDORDER_URL_SUFFIX;
+ }
+ if(this.notifyUrl != null) {
+ reqData.put("notify_url", this.notifyUrl);
+ }
+ String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return this.processResponseXml(respXml);
+ }
+
+
+ /**
+ * 作用:查询订单
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map orderQuery(Map reqData) throws Exception {
+ return this.orderQuery(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:查询订单
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据 int
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map orderQuery(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_ORDERQUERY_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.ORDERQUERY_URL_SUFFIX;
+ }
+ String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return this.processResponseXml(respXml);
+ }
+
+
+ /**
+ * 作用:撤销订单
+ * 场景:刷卡支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map reverse(Map reqData) throws Exception {
+ return this.reverse(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:撤销订单
+ * 场景:刷卡支付
+ * 其他:需要证书
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map reverse(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_REVERSE_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.REVERSE_URL_SUFFIX;
+ }
+ String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return this.processResponseXml(respXml);
+ }
+
+
+ /**
+ * 作用:关闭订单
+ * 场景:公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map closeOrder(Map reqData) throws Exception {
+ return this.closeOrder(reqData, config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:关闭订单
+ * 场景:公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map closeOrder(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_CLOSEORDER_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.CLOSEORDER_URL_SUFFIX;
+ }
+ String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return this.processResponseXml(respXml);
+ }
+
+
+ /**
+ * 作用:申请退款
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map refund(Map reqData) throws Exception {
+ return this.refund(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:申请退款
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * 其他:需要证书
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map refund(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_REFUND_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.REFUND_URL_SUFFIX;
+ }
+ String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return this.processResponseXml(respXml);
+ }
+
+
+ /**
+ * 作用:退款查询
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map refundQuery(Map reqData) throws Exception {
+ return this.refundQuery(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:退款查询
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map refundQuery(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_REFUNDQUERY_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.REFUNDQUERY_URL_SUFFIX;
+ }
+ String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return this.processResponseXml(respXml);
+ }
+
+
+ /**
+ * 作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map downloadBill(Map reqData) throws Exception {
+ return this.downloadBill(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:对账单下载
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * 其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data,
+ * 其中return_code为`SUCCESS`,data为对账单数据。
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return 经过封装的API返回数据
+ * @throws Exception
+ */
+ public Map downloadBill(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_DOWNLOADBILL_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.DOWNLOADBILL_URL_SUFFIX;
+ }
+ String respStr = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs).trim();
+ Map ret;
+ // 出现错误,返回XML数据
+ if (respStr.indexOf("<") == 0) {
+ ret = WXPayUtil.xmlToMap(respStr);
+ }
+ else {
+ // 正常返回csv数据
+ ret = new HashMap();
+ ret.put("return_code", WXPayConstants.SUCCESS);
+ ret.put("return_msg", "ok");
+ ret.put("data", respStr);
+ }
+ return ret;
+ }
+
+
+ /**
+ * 作用:交易保障
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map report(Map reqData) throws Exception {
+ return this.report(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:交易保障
+ * 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map report(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_REPORT_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.REPORT_URL_SUFFIX;
+ }
+ String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return WXPayUtil.xmlToMap(respXml);
+ }
+
+
+ /**
+ * 作用:转换短链接
+ * 场景:刷卡支付、扫码支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map shortUrl(Map reqData) throws Exception {
+ return this.shortUrl(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:转换短链接
+ * 场景:刷卡支付、扫码支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map shortUrl(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_SHORTURL_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.SHORTURL_URL_SUFFIX;
+ }
+ String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return this.processResponseXml(respXml);
+ }
+
+
+ /**
+ * 作用:授权码查询OPENID接口
+ * 场景:刷卡支付
+ * @param reqData 向wxpay post的请求数据
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map authCodeToOpenid(Map reqData) throws Exception {
+ return this.authCodeToOpenid(reqData, this.config.getHttpConnectTimeoutMs(), this.config.getHttpReadTimeoutMs());
+ }
+
+
+ /**
+ * 作用:授权码查询OPENID接口
+ * 场景:刷卡支付
+ * @param reqData 向wxpay post的请求数据
+ * @param connectTimeoutMs 连接超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @return API返回数据
+ * @throws Exception
+ */
+ public Map authCodeToOpenid(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ String url;
+ if (this.useSandbox) {
+ url = WXPayConstants.SANDBOX_AUTHCODETOOPENID_URL_SUFFIX;
+ }
+ else {
+ url = WXPayConstants.AUTHCODETOOPENID_URL_SUFFIX;
+ }
+ String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
+ return this.processResponseXml(respXml);
+ }
+
+
+} // end class
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConfig.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConfig.java
new file mode 100644
index 0000000..9af5dca
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConfig.java
@@ -0,0 +1,103 @@
+package com.github.wxpay.sdk;
+
+import java.io.InputStream;
+
+public abstract class WXPayConfig {
+
+
+
+ /**
+ * 获取 App ID
+ *
+ * @return App ID
+ */
+ abstract String getAppID();
+
+
+ /**
+ * 获取 Mch ID
+ *
+ * @return Mch ID
+ */
+ abstract String getMchID();
+
+
+ /**
+ * 获取 API 密钥
+ *
+ * @return API密钥
+ */
+ abstract String getKey();
+
+
+ /**
+ * 获取商户证书内容
+ *
+ * @return 商户证书内容
+ */
+ abstract InputStream getCertStream();
+
+ /**
+ * HTTP(S) 连接超时时间,单位毫秒
+ *
+ * @return
+ */
+ public int getHttpConnectTimeoutMs() {
+ return 6*1000;
+ }
+
+ /**
+ * HTTP(S) 读数据超时时间,单位毫秒
+ *
+ * @return
+ */
+ public int getHttpReadTimeoutMs() {
+ return 8*1000;
+ }
+
+ /**
+ * 获取WXPayDomain, 用于多域名容灾自动切换
+ * @return
+ */
+ abstract IWXPayDomain getWXPayDomain();
+
+ /**
+ * 是否自动上报。
+ * 若要关闭自动上报,子类中实现该函数返回 false 即可。
+ *
+ * @return
+ */
+ public boolean shouldAutoReport() {
+ return true;
+ }
+
+ /**
+ * 进行健康上报的线程的数量
+ *
+ * @return
+ */
+ public int getReportWorkerNum() {
+ return 6;
+ }
+
+
+ /**
+ * 健康上报缓存消息的最大数量。会有线程去独立上报
+ * 粗略计算:加入一条消息200B,10000消息占用空间 2000 KB,约为2MB,可以接受
+ *
+ * @return
+ */
+ public int getReportQueueMaxSize() {
+ return 10000;
+ }
+
+ /**
+ * 批量上报,一次最多上报多个数据
+ *
+ * @return
+ */
+ public int getReportBatchSize() {
+ return 10;
+ }
+
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConstants.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConstants.java
new file mode 100644
index 0000000..d4e6c87
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConstants.java
@@ -0,0 +1,59 @@
+package com.github.wxpay.sdk;
+
+import org.apache.http.client.HttpClient;
+
+/**
+ * 常量
+ */
+public class WXPayConstants {
+
+ public enum SignType {
+ MD5, HMACSHA256
+ }
+
+ public static final String DOMAIN_API = "api.mch.weixin.qq.com";
+ public static final String DOMAIN_API2 = "api2.mch.weixin.qq.com";
+ public static final String DOMAIN_APIHK = "apihk.mch.weixin.qq.com";
+ public static final String DOMAIN_APIUS = "apius.mch.weixin.qq.com";
+
+
+ public static final String FAIL = "FAIL";
+ public static final String SUCCESS = "SUCCESS";
+ public static final String HMACSHA256 = "HMAC-SHA256";
+ public static final String MD5 = "MD5";
+
+ public static final String FIELD_SIGN = "sign";
+ public static final String FIELD_SIGN_TYPE = "sign_type";
+
+ public static final String WXPAYSDK_VERSION = "WXPaySDK/3.0.9";
+ public static final String USER_AGENT = WXPAYSDK_VERSION +
+ " (" + System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version") +
+ ") Java/" + System.getProperty("java.version") + " HttpClient/" + HttpClient.class.getPackage().getImplementationVersion();
+
+ public static final String MICROPAY_URL_SUFFIX = "/pay/micropay";
+ public static final String UNIFIEDORDER_URL_SUFFIX = "/pay/unifiedorder";
+ public static final String ORDERQUERY_URL_SUFFIX = "/pay/orderquery";
+ public static final String REVERSE_URL_SUFFIX = "/secapi/pay/reverse";
+ public static final String CLOSEORDER_URL_SUFFIX = "/pay/closeorder";
+ public static final String REFUND_URL_SUFFIX = "/secapi/pay/refund";
+ public static final String REFUNDQUERY_URL_SUFFIX = "/pay/refundquery";
+ public static final String DOWNLOADBILL_URL_SUFFIX = "/pay/downloadbill";
+ public static final String REPORT_URL_SUFFIX = "/payitil/report";
+ public static final String SHORTURL_URL_SUFFIX = "/tools/shorturl";
+ public static final String AUTHCODETOOPENID_URL_SUFFIX = "/tools/authcodetoopenid";
+
+ // sandbox
+ public static final String SANDBOX_MICROPAY_URL_SUFFIX = "/sandboxnew/pay/micropay";
+ public static final String SANDBOX_UNIFIEDORDER_URL_SUFFIX = "/sandboxnew/pay/unifiedorder";
+ public static final String SANDBOX_ORDERQUERY_URL_SUFFIX = "/sandboxnew/pay/orderquery";
+ public static final String SANDBOX_REVERSE_URL_SUFFIX = "/sandboxnew/secapi/pay/reverse";
+ public static final String SANDBOX_CLOSEORDER_URL_SUFFIX = "/sandboxnew/pay/closeorder";
+ public static final String SANDBOX_REFUND_URL_SUFFIX = "/sandboxnew/secapi/pay/refund";
+ public static final String SANDBOX_REFUNDQUERY_URL_SUFFIX = "/sandboxnew/pay/refundquery";
+ public static final String SANDBOX_DOWNLOADBILL_URL_SUFFIX = "/sandboxnew/pay/downloadbill";
+ public static final String SANDBOX_REPORT_URL_SUFFIX = "/sandboxnew/payitil/report";
+ public static final String SANDBOX_SHORTURL_URL_SUFFIX = "/sandboxnew/tools/shorturl";
+ public static final String SANDBOX_AUTHCODETOOPENID_URL_SUFFIX = "/sandboxnew/tools/authcodetoopenid";
+
+}
+
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayReport.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayReport.java
new file mode 100644
index 0000000..88c411a
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayReport.java
@@ -0,0 +1,265 @@
+package com.github.wxpay.sdk;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
+import org.apache.http.util.EntityUtils;
+
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+
+/**
+ * 交易保障
+ */
+public class WXPayReport {
+
+ public static class ReportInfo {
+
+ /**
+ * 布尔变量使用int。0为false, 1为true。
+ */
+
+ // 基本信息
+ private String version = "v1";
+ private String sdk = WXPayConstants.WXPAYSDK_VERSION;
+ private String uuid; // 交易的标识
+ private long timestamp; // 上报时的时间戳,单位秒
+ private long elapsedTimeMillis; // 耗时,单位 毫秒
+
+ // 针对主域名
+ private String firstDomain; // 第1次请求的域名
+ private boolean primaryDomain; //是否主域名
+ private int firstConnectTimeoutMillis; // 第1次请求设置的连接超时时间,单位 毫秒
+ private int firstReadTimeoutMillis; // 第1次请求设置的读写超时时间,单位 毫秒
+ private int firstHasDnsError; // 第1次请求是否出现dns问题
+ private int firstHasConnectTimeout; // 第1次请求是否出现连接超时
+ private int firstHasReadTimeout; // 第1次请求是否出现连接超时
+
+ public ReportInfo(String uuid, long timestamp, long elapsedTimeMillis, String firstDomain, boolean primaryDomain, int firstConnectTimeoutMillis, int firstReadTimeoutMillis, boolean firstHasDnsError, boolean firstHasConnectTimeout, boolean firstHasReadTimeout) {
+ this.uuid = uuid;
+ this.timestamp = timestamp;
+ this.elapsedTimeMillis = elapsedTimeMillis;
+ this.firstDomain = firstDomain;
+ this.primaryDomain = primaryDomain;
+ this.firstConnectTimeoutMillis = firstConnectTimeoutMillis;
+ this.firstReadTimeoutMillis = firstReadTimeoutMillis;
+ this.firstHasDnsError = firstHasDnsError?1:0;
+ this.firstHasConnectTimeout = firstHasConnectTimeout?1:0;
+ this.firstHasReadTimeout = firstHasReadTimeout?1:0;
+ }
+
+ @Override
+ public String toString() {
+ return "ReportInfo{" +
+ "version='" + version + '\'' +
+ ", sdk='" + sdk + '\'' +
+ ", uuid='" + uuid + '\'' +
+ ", timestamp=" + timestamp +
+ ", elapsedTimeMillis=" + elapsedTimeMillis +
+ ", firstDomain='" + firstDomain + '\'' +
+ ", primaryDomain=" + primaryDomain +
+ ", firstConnectTimeoutMillis=" + firstConnectTimeoutMillis +
+ ", firstReadTimeoutMillis=" + firstReadTimeoutMillis +
+ ", firstHasDnsError=" + firstHasDnsError +
+ ", firstHasConnectTimeout=" + firstHasConnectTimeout +
+ ", firstHasReadTimeout=" + firstHasReadTimeout +
+ '}';
+ }
+
+ /**
+ * 转换成 csv 格式
+ *
+ * @return
+ */
+ public String toLineString(String key) {
+ String separator = ",";
+ Object[] objects = new Object[] {
+ version, sdk, uuid, timestamp, elapsedTimeMillis,
+ firstDomain, primaryDomain, firstConnectTimeoutMillis, firstReadTimeoutMillis,
+ firstHasDnsError, firstHasConnectTimeout, firstHasReadTimeout
+ };
+ StringBuffer sb = new StringBuffer();
+ for(Object obj: objects) {
+ sb.append(obj).append(separator);
+ }
+ try {
+ String sign = WXPayUtil.HMACSHA256(sb.toString(), key);
+ sb.append(sign);
+ return sb.toString();
+ }
+ catch (Exception ex) {
+ return null;
+ }
+
+ }
+
+ }
+
+ private static final String REPORT_URL = "http://report.mch.weixin.qq.com/wxpay/report/default";
+ // private static final String REPORT_URL = "http://127.0.0.1:5000/test";
+
+
+ private static final int DEFAULT_CONNECT_TIMEOUT_MS = 6*1000;
+ private static final int DEFAULT_READ_TIMEOUT_MS = 8*1000;
+
+ private LinkedBlockingQueue reportMsgQueue = null;
+ private WXPayConfig config;
+ private ExecutorService executorService;
+
+ private volatile static WXPayReport INSTANCE;
+
+ private WXPayReport(final WXPayConfig config) {
+ this.config = config;
+ reportMsgQueue = new LinkedBlockingQueue(config.getReportQueueMaxSize());
+
+ // 添加处理线程
+ executorService = Executors.newFixedThreadPool(config.getReportWorkerNum(), new ThreadFactory() {
+ public Thread newThread(Runnable r) {
+ Thread t = Executors.defaultThreadFactory().newThread(r);
+ t.setDaemon(true);
+ return t;
+ }
+ });
+
+ if (config.shouldAutoReport()) {
+ WXPayUtil.getLogger().info("report worker num: {}", config.getReportWorkerNum());
+ for (int i = 0; i < config.getReportWorkerNum(); ++i) {
+ executorService.execute(new Runnable() {
+ public void run() {
+ while (true) {
+ // 先用 take 获取数据
+ try {
+ StringBuffer sb = new StringBuffer();
+ String firstMsg = reportMsgQueue.take();
+ WXPayUtil.getLogger().info("get first report msg: {}", firstMsg);
+ String msg = null;
+ sb.append(firstMsg); //会阻塞至有消息
+ int remainNum = config.getReportBatchSize() - 1;
+ for (int j=0; jcreate()
+ .register("http", PlainConnectionSocketFactory.getSocketFactory())
+ .register("https", SSLConnectionSocketFactory.getSocketFactory())
+ .build(),
+ null,
+ null,
+ null
+ );
+ HttpClient httpClient = HttpClientBuilder.create()
+ .setConnectionManager(connManager)
+ .build();
+
+ HttpPost httpPost = new HttpPost(REPORT_URL);
+
+ RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeoutMs).setConnectTimeout(connectTimeoutMs).build();
+ httpPost.setConfig(requestConfig);
+
+ StringEntity postEntity = new StringEntity(data, "UTF-8");
+ httpPost.addHeader("Content-Type", "text/xml");
+ httpPost.addHeader("User-Agent", WXPayConstants.USER_AGENT);
+ httpPost.setEntity(postEntity);
+
+ HttpResponse httpResponse = httpClient.execute(httpPost);
+ HttpEntity httpEntity = httpResponse.getEntity();
+ return EntityUtils.toString(httpEntity, "UTF-8");
+ }
+
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayRequest.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayRequest.java
new file mode 100644
index 0000000..7209777
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayRequest.java
@@ -0,0 +1,258 @@
+package com.github.wxpay.sdk;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.ConnectTimeoutException;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.DefaultHostnameVerifier;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
+import org.apache.http.util.EntityUtils;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.SSLContext;
+import java.io.InputStream;
+import java.net.SocketTimeoutException;
+import java.net.UnknownHostException;
+import java.security.KeyStore;
+import java.security.SecureRandom;
+
+import static com.github.wxpay.sdk.WXPayConstants.USER_AGENT;
+
+public class WXPayRequest {
+ private WXPayConfig config;
+ public WXPayRequest(WXPayConfig config) throws Exception{
+
+ this.config = config;
+ }
+
+ /**
+ * 请求,只请求一次,不做重试
+ * @param domain
+ * @param urlSuffix
+ * @param uuid
+ * @param data
+ * @param connectTimeoutMs
+ * @param readTimeoutMs
+ * @param useCert 是否使用证书,针对退款、撤销等操作
+ * @return
+ * @throws Exception
+ */
+ private String requestOnce(final String domain, String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean useCert) throws Exception {
+ BasicHttpClientConnectionManager connManager;
+ if (useCert) {
+ // 证书
+ char[] password = config.getMchID().toCharArray();
+ InputStream certStream = config.getCertStream();
+ KeyStore ks = KeyStore.getInstance("PKCS12");
+ ks.load(certStream, password);
+
+ // 实例化密钥库 & 初始化密钥工厂
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ kmf.init(ks, password);
+
+ // 创建 SSLContext
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(kmf.getKeyManagers(), null, new SecureRandom());
+
+ SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(
+ sslContext,
+ new String[]{"TLSv1"},
+ null,
+ new DefaultHostnameVerifier());
+
+ connManager = new BasicHttpClientConnectionManager(
+ RegistryBuilder.create()
+ .register("http", PlainConnectionSocketFactory.getSocketFactory())
+ .register("https", sslConnectionSocketFactory)
+ .build(),
+ null,
+ null,
+ null
+ );
+ }
+ else {
+ connManager = new BasicHttpClientConnectionManager(
+ RegistryBuilder.create()
+ .register("http", PlainConnectionSocketFactory.getSocketFactory())
+ .register("https", SSLConnectionSocketFactory.getSocketFactory())
+ .build(),
+ null,
+ null,
+ null
+ );
+ }
+
+ HttpClient httpClient = HttpClientBuilder.create()
+ .setConnectionManager(connManager)
+ .build();
+
+ String url = "https://" + domain + urlSuffix;
+ HttpPost httpPost = new HttpPost(url);
+
+ RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeoutMs).setConnectTimeout(connectTimeoutMs).build();
+ httpPost.setConfig(requestConfig);
+
+ StringEntity postEntity = new StringEntity(data, "UTF-8");
+ httpPost.addHeader("Content-Type", "text/xml");
+ httpPost.addHeader("User-Agent", USER_AGENT + " " + config.getMchID());
+ httpPost.setEntity(postEntity);
+
+ HttpResponse httpResponse = httpClient.execute(httpPost);
+ HttpEntity httpEntity = httpResponse.getEntity();
+ return EntityUtils.toString(httpEntity, "UTF-8");
+
+ }
+
+
+ private String request(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean useCert, boolean autoReport) throws Exception {
+ Exception exception = null;
+ long elapsedTimeMillis = 0;
+ long startTimestampMs = WXPayUtil.getCurrentTimestampMs();
+ boolean firstHasDnsErr = false;
+ boolean firstHasConnectTimeout = false;
+ boolean firstHasReadTimeout = false;
+ IWXPayDomain.DomainInfo domainInfo = config.getWXPayDomain().getDomain(config);
+ if(domainInfo == null){
+ throw new Exception("WXPayConfig.getWXPayDomain().getDomain() is empty or null");
+ }
+ try {
+ String result = requestOnce(domainInfo.domain, urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, useCert);
+ elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+ config.getWXPayDomain().report(domainInfo.domain, elapsedTimeMillis, null);
+ WXPayReport.getInstance(config).report(
+ uuid,
+ elapsedTimeMillis,
+ domainInfo.domain,
+ domainInfo.primaryDomain,
+ connectTimeoutMs,
+ readTimeoutMs,
+ firstHasDnsErr,
+ firstHasConnectTimeout,
+ firstHasReadTimeout);
+ return result;
+ }
+ catch (UnknownHostException ex) { // dns 解析错误,或域名不存在
+ exception = ex;
+ firstHasDnsErr = true;
+ elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+ WXPayUtil.getLogger().warn("UnknownHostException for domainInfo {}", domainInfo);
+ WXPayReport.getInstance(config).report(
+ uuid,
+ elapsedTimeMillis,
+ domainInfo.domain,
+ domainInfo.primaryDomain,
+ connectTimeoutMs,
+ readTimeoutMs,
+ firstHasDnsErr,
+ firstHasConnectTimeout,
+ firstHasReadTimeout
+ );
+ }
+ catch (ConnectTimeoutException ex) {
+ exception = ex;
+ firstHasConnectTimeout = true;
+ elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+ WXPayUtil.getLogger().warn("connect timeout happened for domainInfo {}", domainInfo);
+ WXPayReport.getInstance(config).report(
+ uuid,
+ elapsedTimeMillis,
+ domainInfo.domain,
+ domainInfo.primaryDomain,
+ connectTimeoutMs,
+ readTimeoutMs,
+ firstHasDnsErr,
+ firstHasConnectTimeout,
+ firstHasReadTimeout
+ );
+ }
+ catch (SocketTimeoutException ex) {
+ exception = ex;
+ firstHasReadTimeout = true;
+ elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+ WXPayUtil.getLogger().warn("timeout happened for domainInfo {}", domainInfo);
+ WXPayReport.getInstance(config).report(
+ uuid,
+ elapsedTimeMillis,
+ domainInfo.domain,
+ domainInfo.primaryDomain,
+ connectTimeoutMs,
+ readTimeoutMs,
+ firstHasDnsErr,
+ firstHasConnectTimeout,
+ firstHasReadTimeout);
+ }
+ catch (Exception ex) {
+ exception = ex;
+ elapsedTimeMillis = WXPayUtil.getCurrentTimestampMs()-startTimestampMs;
+ WXPayReport.getInstance(config).report(
+ uuid,
+ elapsedTimeMillis,
+ domainInfo.domain,
+ domainInfo.primaryDomain,
+ connectTimeoutMs,
+ readTimeoutMs,
+ firstHasDnsErr,
+ firstHasConnectTimeout,
+ firstHasReadTimeout);
+ }
+ config.getWXPayDomain().report(domainInfo.domain, elapsedTimeMillis, exception);
+ throw exception;
+ }
+
+
+ /**
+ * 可重试的,非双向认证的请求
+ * @param urlSuffix
+ * @param uuid
+ * @param data
+ * @return
+ */
+ public String requestWithoutCert(String urlSuffix, String uuid, String data, boolean autoReport) throws Exception {
+ return this.request(urlSuffix, uuid, data, config.getHttpConnectTimeoutMs(), config.getHttpReadTimeoutMs(), false, autoReport);
+ }
+
+ /**
+ * 可重试的,非双向认证的请求
+ * @param urlSuffix
+ * @param uuid
+ * @param data
+ * @param connectTimeoutMs
+ * @param readTimeoutMs
+ * @return
+ */
+ public String requestWithoutCert(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean autoReport) throws Exception {
+ return this.request(urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, false, autoReport);
+ }
+
+ /**
+ * 可重试的,双向认证的请求
+ * @param urlSuffix
+ * @param uuid
+ * @param data
+ * @return
+ */
+ public String requestWithCert(String urlSuffix, String uuid, String data, boolean autoReport) throws Exception {
+ return this.request(urlSuffix, uuid, data, config.getHttpConnectTimeoutMs(), config.getHttpReadTimeoutMs(), true, autoReport);
+ }
+
+ /**
+ * 可重试的,双向认证的请求
+ * @param urlSuffix
+ * @param uuid
+ * @param data
+ * @param connectTimeoutMs
+ * @param readTimeoutMs
+ * @return
+ */
+ public String requestWithCert(String urlSuffix, String uuid, String data, int connectTimeoutMs, int readTimeoutMs, boolean autoReport) throws Exception {
+ return this.request(urlSuffix, uuid, data, connectTimeoutMs, readTimeoutMs, true, autoReport);
+ }
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayUtil.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayUtil.java
new file mode 100644
index 0000000..e893353
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayUtil.java
@@ -0,0 +1,295 @@
+package com.github.wxpay.sdk;
+
+import com.github.wxpay.sdk.WXPayConstants.SignType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.security.MessageDigest;
+import java.security.SecureRandom;
+import java.util.*;
+
+
+public class WXPayUtil {
+
+ private static final String SYMBOLS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ private static final Random RANDOM = new SecureRandom();
+
+ /**
+ * XML格式字符串转换为Map
+ *
+ * @param strXML XML字符串
+ * @return XML数据转换后的Map
+ * @throws Exception
+ */
+ public static Map xmlToMap(String strXML) throws Exception {
+ try {
+ Map data = new HashMap();
+ DocumentBuilder documentBuilder = WXPayXmlUtil.newDocumentBuilder();
+ InputStream stream = new ByteArrayInputStream(strXML.getBytes("UTF-8"));
+ org.w3c.dom.Document doc = documentBuilder.parse(stream);
+ doc.getDocumentElement().normalize();
+ NodeList nodeList = doc.getDocumentElement().getChildNodes();
+ for (int idx = 0; idx < nodeList.getLength(); ++idx) {
+ Node node = nodeList.item(idx);
+ if (node.getNodeType() == Node.ELEMENT_NODE) {
+ org.w3c.dom.Element element = (org.w3c.dom.Element) node;
+ data.put(element.getNodeName(), element.getTextContent());
+ }
+ }
+ try {
+ stream.close();
+ } catch (Exception ex) {
+ // do nothing
+ }
+ return data;
+ } catch (Exception ex) {
+ WXPayUtil.getLogger().warn("Invalid XML, can not convert to map. Error message: {}. XML content: {}", ex.getMessage(), strXML);
+ throw ex;
+ }
+
+ }
+
+ /**
+ * 将Map转换为XML格式的字符串
+ *
+ * @param data Map类型数据
+ * @return XML格式的字符串
+ * @throws Exception
+ */
+ public static String mapToXml(Map data) throws Exception {
+ org.w3c.dom.Document document = WXPayXmlUtil.newDocument();
+ org.w3c.dom.Element root = document.createElement("xml");
+ document.appendChild(root);
+ for (String key: data.keySet()) {
+ String value = data.get(key);
+ if (value == null) {
+ value = "";
+ }
+ value = value.trim();
+ org.w3c.dom.Element filed = document.createElement(key);
+ filed.appendChild(document.createTextNode(value));
+ root.appendChild(filed);
+ }
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer transformer = tf.newTransformer();
+ DOMSource source = new DOMSource(document);
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ StringWriter writer = new StringWriter();
+ StreamResult result = new StreamResult(writer);
+ transformer.transform(source, result);
+ String output = writer.getBuffer().toString(); //.replaceAll("\n|\r", "");
+ try {
+ writer.close();
+ }
+ catch (Exception ex) {
+ }
+ return output;
+ }
+
+
+ /**
+ * 生成带有 sign 的 XML 格式字符串
+ *
+ * @param data Map类型数据
+ * @param key API密钥
+ * @return 含有sign字段的XML
+ */
+ public static String generateSignedXml(final Map data, String key) throws Exception {
+ return generateSignedXml(data, key, SignType.MD5);
+ }
+
+ /**
+ * 生成带有 sign 的 XML 格式字符串
+ *
+ * @param data Map类型数据
+ * @param key API密钥
+ * @param signType 签名类型
+ * @return 含有sign字段的XML
+ */
+ public static String generateSignedXml(final Map data, String key, SignType signType) throws Exception {
+ String sign = generateSignature(data, key, signType);
+ data.put(WXPayConstants.FIELD_SIGN, sign);
+ return mapToXml(data);
+ }
+
+
+ /**
+ * 判断签名是否正确
+ *
+ * @param xmlStr XML格式数据
+ * @param key API密钥
+ * @return 签名是否正确
+ * @throws Exception
+ */
+ public static boolean isSignatureValid(String xmlStr, String key) throws Exception {
+ Map data = xmlToMap(xmlStr);
+ if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) {
+ return false;
+ }
+ String sign = data.get(WXPayConstants.FIELD_SIGN);
+ return generateSignature(data, key).equals(sign);
+ }
+
+ /**
+ * 判断签名是否正确,必须包含sign字段,否则返回false。使用MD5签名。
+ *
+ * @param data Map类型数据
+ * @param key API密钥
+ * @return 签名是否正确
+ * @throws Exception
+ */
+ public static boolean isSignatureValid(Map data, String key) throws Exception {
+ return isSignatureValid(data, key, SignType.MD5);
+ }
+
+ /**
+ * 判断签名是否正确,必须包含sign字段,否则返回false。
+ *
+ * @param data Map类型数据
+ * @param key API密钥
+ * @param signType 签名方式
+ * @return 签名是否正确
+ * @throws Exception
+ */
+ public static boolean isSignatureValid(Map data, String key, SignType signType) throws Exception {
+ if (!data.containsKey(WXPayConstants.FIELD_SIGN) ) {
+ return false;
+ }
+ String sign = data.get(WXPayConstants.FIELD_SIGN);
+ return generateSignature(data, key, signType).equals(sign);
+ }
+
+ /**
+ * 生成签名
+ *
+ * @param data 待签名数据
+ * @param key API密钥
+ * @return 签名
+ */
+ public static String generateSignature(final Map data, String key) throws Exception {
+ return generateSignature(data, key, SignType.MD5);
+ }
+
+ /**
+ * 生成签名. 注意,若含有sign_type字段,必须和signType参数保持一致。
+ *
+ * @param data 待签名数据
+ * @param key API密钥
+ * @param signType 签名方式
+ * @return 签名
+ */
+ public static String generateSignature(final Map data, String key, SignType signType) throws Exception {
+ Set keySet = data.keySet();
+ String[] keyArray = keySet.toArray(new String[keySet.size()]);
+ Arrays.sort(keyArray);
+ StringBuilder sb = new StringBuilder();
+ for (String k : keyArray) {
+ if (k.equals(WXPayConstants.FIELD_SIGN)) {
+ continue;
+ }
+ if (data.get(k).trim().length() > 0) // 参数值为空,则不参与签名
+ sb.append(k).append("=").append(data.get(k).trim()).append("&");
+ }
+ sb.append("key=").append(key);
+ if (SignType.MD5.equals(signType)) {
+ return MD5(sb.toString()).toUpperCase();
+ }
+ else if (SignType.HMACSHA256.equals(signType)) {
+ return HMACSHA256(sb.toString(), key);
+ }
+ else {
+ throw new Exception(String.format("Invalid sign_type: %s", signType));
+ }
+ }
+
+
+ /**
+ * 获取随机字符串 Nonce Str
+ *
+ * @return String 随机字符串
+ */
+ public static String generateNonceStr() {
+ char[] nonceChars = new char[32];
+ for (int index = 0; index < nonceChars.length; ++index) {
+ nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
+ }
+ return new String(nonceChars);
+ }
+
+
+ /**
+ * 生成 MD5
+ *
+ * @param data 待处理数据
+ * @return MD5结果
+ */
+ public static String MD5(String data) throws Exception {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] array = md.digest(data.getBytes("UTF-8"));
+ StringBuilder sb = new StringBuilder();
+ for (byte item : array) {
+ sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+ }
+ return sb.toString().toUpperCase();
+ }
+
+ /**
+ * 生成 HMACSHA256
+ * @param data 待处理数据
+ * @param key 密钥
+ * @return 加密结果
+ * @throws Exception
+ */
+ public static String HMACSHA256(String data, String key) throws Exception {
+ Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
+ SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256");
+ sha256_HMAC.init(secret_key);
+ byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8"));
+ StringBuilder sb = new StringBuilder();
+ for (byte item : array) {
+ sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3));
+ }
+ return sb.toString().toUpperCase();
+ }
+
+ /**
+ * 日志
+ * @return
+ */
+ public static Logger getLogger() {
+ Logger logger = LoggerFactory.getLogger("wxpay java sdk");
+ return logger;
+ }
+
+ /**
+ * 获取当前时间戳,单位秒
+ * @return
+ */
+ public static long getCurrentTimestamp() {
+ return System.currentTimeMillis()/1000;
+ }
+
+ /**
+ * 获取当前时间戳,单位毫秒
+ * @return
+ */
+ public static long getCurrentTimestampMs() {
+ return System.currentTimeMillis();
+ }
+
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayXmlUtil.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayXmlUtil.java
new file mode 100644
index 0000000..500d9a4
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayXmlUtil.java
@@ -0,0 +1,30 @@
+package com.github.wxpay.sdk;
+
+import org.w3c.dom.Document;
+
+import javax.xml.XMLConstants;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+/**
+ * 2018/7/3
+ */
+public final class WXPayXmlUtil {
+ public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+ documentBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
+ documentBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
+ documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
+ documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ documentBuilderFactory.setXIncludeAware(false);
+ documentBuilderFactory.setExpandEntityReferences(false);
+
+ return documentBuilderFactory.newDocumentBuilder();
+ }
+
+ public static Document newDocument() throws ParserConfigurationException {
+ return newDocumentBuilder().newDocument();
+ }
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/WxpayConf.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/WxpayConf.java
new file mode 100644
index 0000000..8e0ced6
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/WxpayConf.java
@@ -0,0 +1,55 @@
+package jframe.wxpay;
+
+import jframe.core.conf.Config;
+import jframe.core.plugin.annotation.InjectPlugin;
+import jframe.core.plugin.annotation.Injector;
+import jframe.core.util.PropsConf;
+
+import java.io.*;
+import java.nio.file.Paths;
+
+/**
+ * @author dzh
+ * @date 2020/8/18 19:39
+ */
+@Injector
+public class WxpayConf extends PropsConf {
+
+ @InjectPlugin
+ static WxpayPlugin plugin;
+
+ public static final String CERTNAME = "apiclient_cert.p12";
+
+ public static final String P_appId = "appId";
+ public static final String P_mchId = "mchId";
+ public static final String P_apiKey = "apiKey";
+ public static final String P_certPath = "certPath";
+ public static final String P_notifyUrl = "notifyUrl";
+ public static final String P_autoReport = "autoReport";
+ public static final String P_useSandbox = "useSandbox";
+
+ public synchronized void init(InputStream is) throws Exception {
+ super.init(is);
+ }
+
+ /**
+ * @param id groupid
+ * @return cert bytes
+ * @throws IOException
+ */
+ public byte[] loadCert(String id) throws IOException {
+ String certPath = this.getConf(id, P_certPath);
+ File file = new File(certPath);
+ if (!file.exists()) {
+ file = Paths.get(plugin.getConfig(Config.APP_CONF), CERTNAME).toFile();
+ }
+ if (!file.exists()) {
+ throw new FileNotFoundException(CERTNAME);
+ }
+ try (InputStream certStream = new FileInputStream(file)) {
+ byte[] certData = new byte[(int) file.length()];
+ certStream.read(certData);
+ return certData;
+ }
+ }
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/WxpayPlugin.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/WxpayPlugin.java
new file mode 100644
index 0000000..83fe5bb
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/WxpayPlugin.java
@@ -0,0 +1,11 @@
+package jframe.wxpay;
+
+import jframe.core.plugin.DefPlugin;
+
+/**
+ * @author dzh
+ * @date 2020/8/18 16:44
+ */
+public class WxpayPlugin extends DefPlugin {
+
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
new file mode 100644
index 0000000..8f27495
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
@@ -0,0 +1,39 @@
+package jframe.wxpay.service;
+
+import jframe.core.plugin.annotation.Service;
+
+import java.util.Map;
+
+/**
+ * @author dzh
+ * @date 2020/8/18 16:45
+ */
+@Service(clazz = "jframe.wxpay.service.WxpayServiceV2", id = WxpayService.ID)
+public interface WxpayService {
+
+ String ID = "jframe.service.wxpay";
+
+ String NOTIFY_SUCC = "";
+ String NOTIFY_FAIL = "";
+
+ /**
+ * @param id groupid
+ * @param key properties key
+ * @return properties value
+ */
+ String conf(String id, String key);
+
+ Map orderPrepay(String id, Map req) throws Exception;
+
+ Map orderClose(String id, Map req) throws Exception;
+
+ Map orderQuery(String id, Map req) throws Exception;
+
+ Map processResponseXml(String id, String xmlStr) throws Exception;
+
+ Map refund(String id, Map req) throws Exception;
+
+ Map refundQuery(String id, Map req) throws Exception;
+
+
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
new file mode 100644
index 0000000..e455e18
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
@@ -0,0 +1,115 @@
+package jframe.wxpay.service;
+
+import com.github.wxpay.sdk.JframeWxpayConfig;
+import com.github.wxpay.sdk.WXPay;
+import jframe.core.conf.Config;
+import jframe.core.plugin.annotation.InjectPlugin;
+import jframe.core.plugin.annotation.Injector;
+import jframe.core.plugin.annotation.Start;
+import jframe.core.plugin.annotation.Stop;
+import jframe.wxpay.WxpayConf;
+import jframe.wxpay.WxpayPlugin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * https://pay.weixin.qq.com/wiki/doc/api/index.html
+ * https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_1
+ *
+ * @author dzh
+ * @date 2020/8/18 17:40
+ */
+@Injector
+public class WxpayServiceV2 implements WxpayService {
+
+ static Logger LOG = LoggerFactory.getLogger(WxpayServiceV2.class);
+
+ @InjectPlugin
+ static WxpayPlugin plugin;
+
+ static String FILE_WXPAY = "file.wxpay";
+
+ //group id -> AlipayClient
+ private Map clients = new HashMap<>();
+
+ private WxpayConf wxpayConf;
+
+ @Start
+ void start() {
+ LOG.info("Start WxpayServiceV2");
+ try {
+ String file = plugin.getConfig(FILE_WXPAY, plugin.getConfig(Config.APP_CONF) + "/wxpay.properties");
+ if (!new File(file).exists()) {
+ throw new FileNotFoundException("not found " + file);
+ }
+ wxpayConf = new WxpayConf();
+ wxpayConf.init(file);
+ for (String id : wxpayConf.getGroupIds()) {
+ WXPay wxpay = createWxpay(wxpayConf, id);
+ clients.put(id, wxpay);
+ }
+ LOG.info("Start WxpayServiceV2 Successfully!");
+ } catch (Exception e) {
+ LOG.error("Start WxpayServiceV2 Failed!" + e.getMessage(), e);
+ }
+ }
+
+ @Stop
+ void stop() {
+ clients.clear();
+ LOG.info("Stop WxpayServiceV2");
+ }
+
+ private WXPay createWxpay(WxpayConf props, String id) throws Exception {
+ byte[] bytes = props.loadCert(id);
+ JframeWxpayConfig conf = JframeWxpayConfig.create(props.getConf(id, WxpayConf.P_appId),
+ props.getConf(id, WxpayConf.P_mchId), props.getConf(id, WxpayConf.P_appId), new ByteArrayInputStream(bytes));
+ return new WXPay(conf, props.getConf(id, WxpayConf.P_notifyUrl),
+ Boolean.parseBoolean(props.getConf(id, WxpayConf.P_autoReport, "true")),
+ Boolean.parseBoolean(props.getConf(id, WxpayConf.P_useSandbox, "false")));
+ }
+
+
+ @Override
+ public String conf(String id, String key) {
+ return wxpayConf.getConf(id, key);
+ }
+
+ @Override
+ public Map orderPrepay(String id, Map req) throws Exception {
+// req.putIfAbsent("appid", conf(id, WxpayConf.P_appId));
+// req.putIfAbsent("mch_id", conf(id, WxpayConf.P_mchId));
+ return clients.get(id).unifiedOrder(req);
+ }
+
+ @Override
+ public Map orderClose(String id, Map req) throws Exception {
+ return clients.get(id).closeOrder(req);
+ }
+
+ @Override
+ public Map orderQuery(String id, Map req) throws Exception {
+ return clients.get(id).orderQuery(req);
+ }
+
+ @Override
+ public Map processResponseXml(String id, String xmlStr) throws Exception {
+ return clients.get(id).processResponseXml(xmlStr);
+ }
+
+ @Override
+ public Map refund(String id, Map req) throws Exception {
+ return clients.get(id).refund(req);
+ }
+
+ @Override
+ public Map refundQuery(String id, Map req) throws Exception {
+ return clients.get(id).refundQuery(req);
+ }
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV3.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV3.java
new file mode 100644
index 0000000..33e90ff
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV3.java
@@ -0,0 +1,86 @@
+package jframe.wxpay.service;
+
+import jframe.core.conf.Config;
+import jframe.core.plugin.annotation.InjectPlugin;
+import jframe.core.plugin.annotation.Injector;
+import jframe.core.plugin.annotation.Start;
+import jframe.core.plugin.annotation.Stop;
+import jframe.wxpay.WxpayConf;
+import jframe.wxpay.WxpayPlugin;
+import org.apache.http.client.HttpClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * https://wechatpay-api.gitbook.io/wechatpay-api-v3/
+ * https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pages/transactions.shtml 接口文档
+ * https://github.com/wechatpay-apiv3/wechatpay-apache-httpclient
+ *
+ * 请求的唯一标示包含在应答的HTTP头Request-ID中
+ *
+ * User-Agent
+ * 使用HTTP客户端默认的User-Agent。
+ * 遵循HTTP协议,使用自身系统和应用的名称和版本等信息,组成自己独有的User-Agent。
+ *
+ * Accept-Language
+ * en
+ * zh-CN
+ * zh-HK
+ * zh-TW
+ *
+ * @author dzh
+ * @date 2020/8/18 17:38
+ */
+@Injector
+public class WxpayServiceV3 {
+
+ static Logger LOG = LoggerFactory.getLogger(WxpayServiceV3.class);
+
+ @InjectPlugin
+ static WxpayPlugin plugin;
+
+ static String FILE_WXPAY = "file.wxpay";
+
+ private WxpayConf wxpayConf;
+
+ private Map clients = new HashMap<>();
+
+ @Start
+ void start() {
+ LOG.info("Start {}", WxpayServiceV3.class.getSimpleName());
+ try {
+ String file = plugin.getConfig(FILE_WXPAY, plugin.getConfig(Config.APP_CONF) + "/wxpay.properties");
+ if (!new File(file).exists()) {
+ throw new FileNotFoundException("not found " + file);
+ }
+ wxpayConf = new WxpayConf();
+ wxpayConf.init(file);
+ for (String id : wxpayConf.getGroupIds()) {
+ HttpClient wxpay = createWxpay(wxpayConf, id);
+ clients.put(id, wxpay);
+ }
+ LOG.info("Start WxpayServiceV3 Successfully!");
+ } catch (Exception e) {
+ LOG.error("Start WxpayServiceV3 Failed!" + e.getMessage(), e);
+ }
+ }
+
+ private HttpClient createWxpay(WxpayConf wxpayConf, String id) {
+// WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
+// .withMerchant(merchantId, merchantSerialNumber, merchantPrivateKey)
+// .withWechatpay(wechatpayCertificates);
+ return null;
+ }
+
+ @Stop
+ void stop() {
+ clients.clear();
+ LOG.info("Stop WxpayServiceV3");
+ }
+
+}
diff --git a/jframe-plugin/jframe-wxpay/src/main/resources/META-INF/plugin.properties b/jframe-plugin/jframe-wxpay/src/main/resources/META-INF/plugin.properties
new file mode 100644
index 0000000..9df13fe
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/main/resources/META-INF/plugin.properties
@@ -0,0 +1,7 @@
+Plugin-Name=jframe.wxpay.WxpayPlugin
+Plugin-Class=jframe.wxpay.WxpayPlugin
+#Default library path is META-INF/lib/
+#Plugin-Lib =
+#Default DLL path is META-INF/dll
+#Plugin-Dll =
+Plugin-Service=jframe.wxpay.service.WxpayService
diff --git a/jframe-plugin/jframe-wxpay/src/test/resources/wxpay.properties b/jframe-plugin/jframe-wxpay/src/test/resources/wxpay.properties
new file mode 100644
index 0000000..32ee586
--- /dev/null
+++ b/jframe-plugin/jframe-wxpay/src/test/resources/wxpay.properties
@@ -0,0 +1,12 @@
+group.id=xxx
+#
+@xxx.appId=
+@xxx.mchId=
+@xxx.apiKey=
+@xxx.certPath=
+@xxx.notifyUrl=
+@xxx.autoReport=true
+@xxx.useSandbox=false
+# common
+
+
diff --git a/jframe-plugin/pom.xml b/jframe-plugin/pom.xml
index 5bdd6c3..c2a1212 100644
--- a/jframe-plugin/pom.xml
+++ b/jframe-plugin/pom.xml
@@ -44,6 +44,7 @@
jframe-qcloud
jframe-google
jframe-alipay
+ jframe-wxpay
From 268e8d2d0b1ca8c387b704f6b6feab31f348d3ee Mon Sep 17 00:00:00 2001
From: dzh
Date: Fri, 4 Sep 2020 14:23:53 +0800
Subject: [PATCH 13/47] add log
---
.../src/main/java/jframe/wxpay/service/WxpayServiceV2.java | 2 +-
.../src/main/java/jframe/zk/service/CuratorService.java | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
index e455e18..ec209db 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
@@ -54,7 +54,7 @@ void start() {
WXPay wxpay = createWxpay(wxpayConf, id);
clients.put(id, wxpay);
}
- LOG.info("Start WxpayServiceV2 Successfully!");
+ LOG.info("Start WxpayServiceV2 Successfully! ids:{}", wxpayConf.getGroupIds());
} catch (Exception e) {
LOG.error("Start WxpayServiceV2 Failed!" + e.getMessage(), e);
}
diff --git a/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/CuratorService.java b/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/CuratorService.java
index fc771f4..bc0d5cb 100644
--- a/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/CuratorService.java
+++ b/jframe-plugin/jframe-zk/src/main/java/jframe/zk/service/CuratorService.java
@@ -8,9 +8,11 @@
* @version 0.0.1
* @date Dec 12, 2018 7:12:56 PM
*/
-@Service(clazz = "jframe.zk.service.impl.CuratorServiceImpl", id = "jframe.service.zk.curator")
+@Service(clazz = "jframe.zk.service.impl.CuratorServiceImpl", id = CuratorService.ID)
public interface CuratorService {
+ String ID = "jframe.service.zk.curator";
+
CuratorFramework client(String id);
}
From 81714b2293eb6ee64e13965c20d0165e524d921d Mon Sep 17 00:00:00 2001
From: dzh
Date: Fri, 4 Sep 2020 14:47:51 +0800
Subject: [PATCH 14/47] fix wxpay domain
---
.../github/wxpay/sdk/JframeWxpayConfig.java | 19 ++++++++++++++++++-
.../jframe/wxpay/service/WxpayServiceV2.java | 2 +-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/JframeWxpayConfig.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/JframeWxpayConfig.java
index d992c58..78b85be 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/JframeWxpayConfig.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/JframeWxpayConfig.java
@@ -1,5 +1,8 @@
package com.github.wxpay.sdk;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.InputStream;
/**
@@ -8,6 +11,8 @@
*/
public class JframeWxpayConfig extends WXPayConfig {
+ static Logger LOG = LoggerFactory.getLogger(JframeWxpayConfig.class);
+
private String appId;
private String mchId;
@@ -46,7 +51,19 @@ InputStream getCertStream() {
@Override
IWXPayDomain getWXPayDomain() {
- return null;
+ return new IWXPayDomain() {
+
+ public void report(String domain, long elapsedTimeMillis, Exception ex) {
+ if (ex != null) {
+ LOG.info("{} {} {}", domain, elapsedTimeMillis, ex);
+ }
+ }
+
+ public DomainInfo getDomain(WXPayConfig config) {
+ return new DomainInfo(WXPayConstants.DOMAIN_API, true);
+ }
+ };
+
}
// public boolean shouldAutoReport() {
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
index ec209db..820000d 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
@@ -69,7 +69,7 @@ void stop() {
private WXPay createWxpay(WxpayConf props, String id) throws Exception {
byte[] bytes = props.loadCert(id);
JframeWxpayConfig conf = JframeWxpayConfig.create(props.getConf(id, WxpayConf.P_appId),
- props.getConf(id, WxpayConf.P_mchId), props.getConf(id, WxpayConf.P_appId), new ByteArrayInputStream(bytes));
+ props.getConf(id, WxpayConf.P_mchId), props.getConf(id, WxpayConf.P_apiKey), new ByteArrayInputStream(bytes));
return new WXPay(conf, props.getConf(id, WxpayConf.P_notifyUrl),
Boolean.parseBoolean(props.getConf(id, WxpayConf.P_autoReport, "true")),
Boolean.parseBoolean(props.getConf(id, WxpayConf.P_useSandbox, "false")));
From e81c60253cb357fb065c87f4c145a371d194b1d0 Mon Sep 17 00:00:00 2001
From: dzh
Date: Fri, 4 Sep 2020 17:28:07 +0800
Subject: [PATCH 15/47] add wx signPrepay
---
.../main/java/com/github/wxpay/sdk/WXPay.java | 207 +++++++++---------
.../com/github/wxpay/sdk/WXPayConstants.java | 46 ++--
.../jframe/wxpay/service/WxpayService.java | 13 ++
.../jframe/wxpay/service/WxpayServiceV2.java | 19 ++
4 files changed, 164 insertions(+), 121 deletions(-)
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPay.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPay.java
index 7f0fbcd..e9bc580 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPay.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPay.java
@@ -23,7 +23,7 @@ public WXPay(final WXPayConfig config, final boolean autoReport) throws Exceptio
}
- public WXPay(final WXPayConfig config, final boolean autoReport, final boolean useSandbox) throws Exception{
+ public WXPay(final WXPayConfig config, final boolean autoReport, final boolean useSandbox) throws Exception {
this(config, null, autoReport, useSandbox);
}
@@ -42,13 +42,17 @@ public WXPay(final WXPayConfig config, final String notifyUrl, final boolean aut
this.useSandbox = useSandbox;
if (useSandbox) {
this.signType = SignType.MD5; // 沙箱环境
- }
- else {
+ } else {
this.signType = SignType.HMACSHA256;
}
this.wxPayRequest = new WXPayRequest(config);
}
+ public SignType signType() {
+ return signType;
+ }
+
+
private void checkWXPayConfig() throws Exception {
if (this.config == null) {
throw new Exception("config is null");
@@ -62,7 +66,7 @@ private void checkWXPayConfig() throws Exception {
if (this.config.getCertStream() == null) {
throw new Exception("cert stream in config is empty");
}
- if (this.config.getWXPayDomain() == null){
+ if (this.config.getWXPayDomain() == null) {
throw new Exception("config.getWXPayDomain() is null");
}
@@ -89,8 +93,7 @@ public Map fillRequestData(Map reqData) throws E
reqData.put("nonce_str", WXPayUtil.generateNonceStr());
if (SignType.MD5.equals(this.signType)) {
reqData.put("sign_type", WXPayConstants.MD5);
- }
- else if (SignType.HMACSHA256.equals(this.signType)) {
+ } else if (SignType.HMACSHA256.equals(this.signType)) {
reqData.put("sign_type", WXPayConstants.HMACSHA256);
}
reqData.put("sign", WXPayUtil.generateSignature(reqData, config.getKey(), this.signType));
@@ -121,19 +124,15 @@ public boolean isPayResultNotifySignatureValid(Map reqData) thro
SignType signType;
if (signTypeInData == null) {
signType = SignType.MD5;
- }
- else {
+ } else {
signTypeInData = signTypeInData.trim();
if (signTypeInData.length() == 0) {
signType = SignType.MD5;
- }
- else if (WXPayConstants.MD5.equals(signTypeInData)) {
+ } else if (WXPayConstants.MD5.equals(signTypeInData)) {
signType = SignType.MD5;
- }
- else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) {
+ } else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) {
signType = SignType.HMACSHA256;
- }
- else {
+ } else {
throw new Exception(String.format("Unsupported sign_type: %s", signTypeInData));
}
}
@@ -143,10 +142,11 @@ else if (WXPayConstants.HMACSHA256.equals(signTypeInData)) {
/**
* 不需要证书的请求
- * @param urlSuffix String
- * @param reqData 向wxpay post的请求数据
+ *
+ * @param urlSuffix String
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 超时时间,单位是毫秒
- * @param readTimeoutMs 超时时间,单位是毫秒
+ * @param readTimeoutMs 超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
@@ -162,16 +162,17 @@ public String requestWithoutCert(String urlSuffix, Map reqData,
/**
* 需要证书的请求
- * @param urlSuffix String
- * @param reqData 向wxpay post的请求数据 Map
+ *
+ * @param urlSuffix String
+ * @param reqData 向wxpay post的请求数据 Map
* @param connectTimeoutMs 超时时间,单位是毫秒
- * @param readTimeoutMs 超时时间,单位是毫秒
+ * @param readTimeoutMs 超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
public String requestWithCert(String urlSuffix, Map reqData,
int connectTimeoutMs, int readTimeoutMs) throws Exception {
- String msgUUID= reqData.get("nonce_str");
+ String msgUUID = reqData.get("nonce_str");
String reqBody = WXPayUtil.mapToXml(reqData);
String resp = this.wxPayRequest.requestWithCert(urlSuffix, msgUUID, reqBody, connectTimeoutMs, readTimeoutMs, this.autoReport);
@@ -180,6 +181,7 @@ public String requestWithCert(String urlSuffix, Map reqData,
/**
* 处理 HTTPS API返回数据,转换成Map对象。return_code为SUCCESS时,验证签名。
+ *
* @param xmlStr API返回的XML格式数据
* @return Map类型数据
* @throws Exception
@@ -190,23 +192,19 @@ public Map processResponseXml(String xmlStr) throws Exception {
Map respData = WXPayUtil.xmlToMap(xmlStr);
if (respData.containsKey(RETURN_CODE)) {
return_code = respData.get(RETURN_CODE);
- }
- else {
+ } else {
throw new Exception(String.format("No `return_code` in XML: %s", xmlStr));
}
if (return_code.equals(WXPayConstants.FAIL)) {
return respData;
- }
- else if (return_code.equals(WXPayConstants.SUCCESS)) {
- if (this.isResponseSignatureValid(respData)) {
- return respData;
- }
- else {
- throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr));
- }
- }
- else {
+ } else if (return_code.equals(WXPayConstants.SUCCESS)) {
+ if (this.isResponseSignatureValid(respData)) {
+ return respData;
+ } else {
+ throw new Exception(String.format("Invalid sign value in XML: %s", xmlStr));
+ }
+ } else {
throw new Exception(String.format("return_code value %s is invalid in XML: %s", return_code, xmlStr));
}
}
@@ -214,6 +212,7 @@ else if (return_code.equals(WXPayConstants.SUCCESS)) {
/**
* 作用:提交刷卡支付
* 场景:刷卡支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -226,9 +225,10 @@ public Map microPay(Map reqData) throws Exceptio
/**
* 作用:提交刷卡支付
* 场景:刷卡支付
- * @param reqData 向wxpay post的请求数据
+ *
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
@@ -236,8 +236,7 @@ public Map microPay(Map reqData, int connectTime
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_MICROPAY_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.MICROPAY_URL_SUFFIX;
}
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -247,6 +246,7 @@ public Map microPay(Map reqData, int connectTime
/**
* 提交刷卡支付,针对软POS,尽可能做成功
* 内置重试机制,最多60s
+ *
* @param reqData
* @return
* @throws Exception
@@ -258,13 +258,14 @@ public Map microPayWithPos(Map reqData) throws E
/**
* 提交刷卡支付,针对软POS,尽可能做成功
* 内置重试机制,最多60s
+ *
* @param reqData
* @param connectTimeoutMs
* @return
* @throws Exception
*/
public Map microPayWithPos(Map reqData, int connectTimeoutMs) throws Exception {
- int remainingTimeMs = 60*1000;
+ int remainingTimeMs = 60 * 1000;
long startTimestampMs = 0;
Map lastResult = null;
Exception lastException = null;
@@ -281,57 +282,49 @@ public Map microPayWithPos(Map reqData, int conn
String errCode = lastResult.get("err_code");
if (resultCode.equals("SUCCESS")) {
break;
- }
- else {
+ } else {
// 看错误码,若支付结果未知,则重试提交刷卡支付
if (errCode.equals("SYSTEMERROR") || errCode.equals("BANKERROR") || errCode.equals("USERPAYING")) {
- remainingTimeMs = remainingTimeMs - (int)(WXPayUtil.getCurrentTimestampMs() - startTimestampMs);
+ remainingTimeMs = remainingTimeMs - (int) (WXPayUtil.getCurrentTimestampMs() - startTimestampMs);
if (remainingTimeMs <= 100) {
break;
- }
- else {
+ } else {
WXPayUtil.getLogger().info("microPayWithPos: try micropay again");
- if (remainingTimeMs > 5*1000) {
- Thread.sleep(5*1000);
- }
- else {
- Thread.sleep(1*1000);
+ if (remainingTimeMs > 5 * 1000) {
+ Thread.sleep(5 * 1000);
+ } else {
+ Thread.sleep(1 * 1000);
}
continue;
}
- }
- else {
+ } else {
break;
}
}
- }
- else {
+ } else {
break;
}
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
lastResult = null;
lastException = ex;
}
- }
- else {
+ } else {
break;
}
}
if (lastResult == null) {
throw lastException;
- }
- else {
+ } else {
return lastResult;
}
}
-
/**
* 作用:统一下单
* 场景:公共号支付、扫码支付、APP支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -344,21 +337,21 @@ public Map unifiedOrder(Map reqData) throws Exce
/**
* 作用:统一下单
* 场景:公共号支付、扫码支付、APP支付
- * @param reqData 向wxpay post的请求数据
+ *
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
- public Map unifiedOrder(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ public Map unifiedOrder(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_UNIFIEDORDER_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.UNIFIEDORDER_URL_SUFFIX;
}
- if(this.notifyUrl != null) {
+ if (this.notifyUrl != null) {
reqData.put("notify_url", this.notifyUrl);
}
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -369,6 +362,7 @@ public Map unifiedOrder(Map reqData, int connec
/**
* 作用:查询订单
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -381,9 +375,10 @@ public Map orderQuery(Map reqData) throws Except
/**
* 作用:查询订单
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
- * @param reqData 向wxpay post的请求数据 int
+ *
+ * @param reqData 向wxpay post的请求数据 int
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
@@ -391,8 +386,7 @@ public Map orderQuery(Map reqData, int connectTi
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_ORDERQUERY_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.ORDERQUERY_URL_SUFFIX;
}
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -403,6 +397,7 @@ public Map orderQuery(Map reqData, int connectTi
/**
* 作用:撤销订单
* 场景:刷卡支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -416,9 +411,10 @@ public Map reverse(Map reqData) throws Exception
* 作用:撤销订单
* 场景:刷卡支付
* 其他:需要证书
- * @param reqData 向wxpay post的请求数据
+ *
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
@@ -426,8 +422,7 @@ public Map reverse(Map reqData, int connectTimeo
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_REVERSE_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.REVERSE_URL_SUFFIX;
}
String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -438,6 +433,7 @@ public Map reverse(Map reqData, int connectTimeo
/**
* 作用:关闭订单
* 场景:公共号支付、扫码支付、APP支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -450,18 +446,18 @@ public Map closeOrder(Map reqData) throws Except
/**
* 作用:关闭订单
* 场景:公共号支付、扫码支付、APP支付
- * @param reqData 向wxpay post的请求数据
+ *
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
- public Map closeOrder(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
+ public Map closeOrder(Map reqData, int connectTimeoutMs, int readTimeoutMs) throws Exception {
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_CLOSEORDER_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.CLOSEORDER_URL_SUFFIX;
}
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -472,6 +468,7 @@ public Map closeOrder(Map reqData, int connectT
/**
* 作用:申请退款
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -485,9 +482,10 @@ public Map refund(Map reqData) throws Exception
* 作用:申请退款
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
* 其他:需要证书
- * @param reqData 向wxpay post的请求数据
+ *
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
@@ -495,8 +493,7 @@ public Map refund(Map reqData, int connectTimeou
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_REFUND_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.REFUND_URL_SUFFIX;
}
String respXml = this.requestWithCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -507,6 +504,7 @@ public Map refund(Map reqData, int connectTimeou
/**
* 作用:退款查询
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -519,9 +517,10 @@ public Map refundQuery(Map reqData) throws Excep
/**
* 作用:退款查询
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
- * @param reqData 向wxpay post的请求数据
+ *
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
@@ -529,8 +528,7 @@ public Map refundQuery(Map reqData, int connectT
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_REFUNDQUERY_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.REFUNDQUERY_URL_SUFFIX;
}
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -541,6 +539,7 @@ public Map refundQuery(Map reqData, int connectT
/**
* 作用:对账单下载(成功时返回对账单数据,失败时返回XML格式数据)
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -554,10 +553,11 @@ public Map downloadBill(Map reqData) throws Exce
* 作用:对账单下载
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
* 其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data,
- * 其中return_code为`SUCCESS`,data为对账单数据。
- * @param reqData 向wxpay post的请求数据
+ * 其中return_code为`SUCCESS`,data为对账单数据。
+ *
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return 经过封装的API返回数据
* @throws Exception
*/
@@ -565,8 +565,7 @@ public Map downloadBill(Map reqData, int connect
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_DOWNLOADBILL_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.DOWNLOADBILL_URL_SUFFIX;
}
String respStr = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs).trim();
@@ -574,8 +573,7 @@ public Map downloadBill(Map reqData, int connect
// 出现错误,返回XML数据
if (respStr.indexOf("<") == 0) {
ret = WXPayUtil.xmlToMap(respStr);
- }
- else {
+ } else {
// 正常返回csv数据
ret = new HashMap();
ret.put("return_code", WXPayConstants.SUCCESS);
@@ -589,6 +587,7 @@ public Map downloadBill(Map reqData, int connect
/**
* 作用:交易保障
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -601,9 +600,10 @@ public Map report(Map reqData) throws Exception
/**
* 作用:交易保障
* 场景:刷卡支付、公共号支付、扫码支付、APP支付
- * @param reqData 向wxpay post的请求数据
+ *
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
@@ -611,8 +611,7 @@ public Map report(Map reqData, int connectTimeou
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_REPORT_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.REPORT_URL_SUFFIX;
}
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -623,6 +622,7 @@ public Map report(Map reqData, int connectTimeou
/**
* 作用:转换短链接
* 场景:刷卡支付、扫码支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -635,6 +635,7 @@ public Map shortUrl(Map reqData) throws Exceptio
/**
* 作用:转换短链接
* 场景:刷卡支付、扫码支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -643,8 +644,7 @@ public Map shortUrl(Map reqData, int connectTime
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_SHORTURL_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.SHORTURL_URL_SUFFIX;
}
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
@@ -655,6 +655,7 @@ public Map shortUrl(Map reqData, int connectTime
/**
* 作用:授权码查询OPENID接口
* 场景:刷卡支付
+ *
* @param reqData 向wxpay post的请求数据
* @return API返回数据
* @throws Exception
@@ -667,9 +668,10 @@ public Map authCodeToOpenid(Map reqData) throws
/**
* 作用:授权码查询OPENID接口
* 场景:刷卡支付
- * @param reqData 向wxpay post的请求数据
+ *
+ * @param reqData 向wxpay post的请求数据
* @param connectTimeoutMs 连接超时时间,单位是毫秒
- * @param readTimeoutMs 读超时时间,单位是毫秒
+ * @param readTimeoutMs 读超时时间,单位是毫秒
* @return API返回数据
* @throws Exception
*/
@@ -677,8 +679,7 @@ public Map authCodeToOpenid(Map reqData, int con
String url;
if (this.useSandbox) {
url = WXPayConstants.SANDBOX_AUTHCODETOOPENID_URL_SUFFIX;
- }
- else {
+ } else {
url = WXPayConstants.AUTHCODETOOPENID_URL_SUFFIX;
}
String respXml = this.requestWithoutCert(url, this.fillRequestData(reqData), connectTimeoutMs, readTimeoutMs);
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConstants.java b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConstants.java
index d4e6c87..bb45a08 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConstants.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/com/github/wxpay/sdk/WXPayConstants.java
@@ -11,14 +11,24 @@ public enum SignType {
MD5, HMACSHA256
}
+ public static String signTypeName(SignType type) {
+ switch (type) {
+ case MD5:
+ return WXPayConstants.MD5;
+ case HMACSHA256:
+ return WXPayConstants.HMACSHA256;
+ }
+ return WXPayConstants.MD5;
+ }
+
public static final String DOMAIN_API = "api.mch.weixin.qq.com";
public static final String DOMAIN_API2 = "api2.mch.weixin.qq.com";
public static final String DOMAIN_APIHK = "apihk.mch.weixin.qq.com";
public static final String DOMAIN_APIUS = "apius.mch.weixin.qq.com";
- public static final String FAIL = "FAIL";
- public static final String SUCCESS = "SUCCESS";
+ public static final String FAIL = "FAIL";
+ public static final String SUCCESS = "SUCCESS";
public static final String HMACSHA256 = "HMAC-SHA256";
public static final String MD5 = "MD5";
@@ -30,29 +40,29 @@ public enum SignType {
" (" + System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version") +
") Java/" + System.getProperty("java.version") + " HttpClient/" + HttpClient.class.getPackage().getImplementationVersion();
- public static final String MICROPAY_URL_SUFFIX = "/pay/micropay";
+ public static final String MICROPAY_URL_SUFFIX = "/pay/micropay";
public static final String UNIFIEDORDER_URL_SUFFIX = "/pay/unifiedorder";
- public static final String ORDERQUERY_URL_SUFFIX = "/pay/orderquery";
- public static final String REVERSE_URL_SUFFIX = "/secapi/pay/reverse";
- public static final String CLOSEORDER_URL_SUFFIX = "/pay/closeorder";
- public static final String REFUND_URL_SUFFIX = "/secapi/pay/refund";
- public static final String REFUNDQUERY_URL_SUFFIX = "/pay/refundquery";
+ public static final String ORDERQUERY_URL_SUFFIX = "/pay/orderquery";
+ public static final String REVERSE_URL_SUFFIX = "/secapi/pay/reverse";
+ public static final String CLOSEORDER_URL_SUFFIX = "/pay/closeorder";
+ public static final String REFUND_URL_SUFFIX = "/secapi/pay/refund";
+ public static final String REFUNDQUERY_URL_SUFFIX = "/pay/refundquery";
public static final String DOWNLOADBILL_URL_SUFFIX = "/pay/downloadbill";
- public static final String REPORT_URL_SUFFIX = "/payitil/report";
- public static final String SHORTURL_URL_SUFFIX = "/tools/shorturl";
+ public static final String REPORT_URL_SUFFIX = "/payitil/report";
+ public static final String SHORTURL_URL_SUFFIX = "/tools/shorturl";
public static final String AUTHCODETOOPENID_URL_SUFFIX = "/tools/authcodetoopenid";
// sandbox
- public static final String SANDBOX_MICROPAY_URL_SUFFIX = "/sandboxnew/pay/micropay";
+ public static final String SANDBOX_MICROPAY_URL_SUFFIX = "/sandboxnew/pay/micropay";
public static final String SANDBOX_UNIFIEDORDER_URL_SUFFIX = "/sandboxnew/pay/unifiedorder";
- public static final String SANDBOX_ORDERQUERY_URL_SUFFIX = "/sandboxnew/pay/orderquery";
- public static final String SANDBOX_REVERSE_URL_SUFFIX = "/sandboxnew/secapi/pay/reverse";
- public static final String SANDBOX_CLOSEORDER_URL_SUFFIX = "/sandboxnew/pay/closeorder";
- public static final String SANDBOX_REFUND_URL_SUFFIX = "/sandboxnew/secapi/pay/refund";
- public static final String SANDBOX_REFUNDQUERY_URL_SUFFIX = "/sandboxnew/pay/refundquery";
+ public static final String SANDBOX_ORDERQUERY_URL_SUFFIX = "/sandboxnew/pay/orderquery";
+ public static final String SANDBOX_REVERSE_URL_SUFFIX = "/sandboxnew/secapi/pay/reverse";
+ public static final String SANDBOX_CLOSEORDER_URL_SUFFIX = "/sandboxnew/pay/closeorder";
+ public static final String SANDBOX_REFUND_URL_SUFFIX = "/sandboxnew/secapi/pay/refund";
+ public static final String SANDBOX_REFUNDQUERY_URL_SUFFIX = "/sandboxnew/pay/refundquery";
public static final String SANDBOX_DOWNLOADBILL_URL_SUFFIX = "/sandboxnew/pay/downloadbill";
- public static final String SANDBOX_REPORT_URL_SUFFIX = "/sandboxnew/payitil/report";
- public static final String SANDBOX_SHORTURL_URL_SUFFIX = "/sandboxnew/tools/shorturl";
+ public static final String SANDBOX_REPORT_URL_SUFFIX = "/sandboxnew/payitil/report";
+ public static final String SANDBOX_SHORTURL_URL_SUFFIX = "/sandboxnew/tools/shorturl";
public static final String SANDBOX_AUTHCODETOOPENID_URL_SUFFIX = "/sandboxnew/tools/authcodetoopenid";
}
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
index 8f27495..f4d503a 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
@@ -25,6 +25,19 @@ public interface WxpayService {
Map orderPrepay(String id, Map req) throws Exception;
+ /**
+ * 签名预支付信息,返回给前端
+ * https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=7_7&index=5
+ *
+ * Map{appId,timeStamp,nonceStr,package,signType}
+ *
+ * @param id group id
+ * @param prepareId orderPrepay response
+ * @return Map{timeStamp,nonceStr,package,package,signType,paySign}
+ * @throws Exception
+ */
+ Map signPrepay(String id, String prepareId) throws Exception;
+
Map orderClose(String id, Map req) throws Exception;
Map orderQuery(String id, Map req) throws Exception;
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
index 820000d..457216e 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
@@ -2,6 +2,8 @@
import com.github.wxpay.sdk.JframeWxpayConfig;
import com.github.wxpay.sdk.WXPay;
+import com.github.wxpay.sdk.WXPayConstants;
+import com.github.wxpay.sdk.WXPayUtil;
import jframe.core.conf.Config;
import jframe.core.plugin.annotation.InjectPlugin;
import jframe.core.plugin.annotation.Injector;
@@ -88,6 +90,23 @@ public Map orderPrepay(String id, Map req) throw
return clients.get(id).unifiedOrder(req);
}
+ @Override
+ public Map signPrepay(String id, String prepareId) throws Exception {
+ //appId,timeStamp,nonceStr,package,signType
+ Map data = new HashMap<>();
+ data.put("appId", conf(id, WxpayConf.P_appId));
+ data.put("timeStamp", String.valueOf(WXPayUtil.getCurrentTimestamp()));
+ data.put("nonceStr", WXPayUtil.generateNonceStr());
+ data.put("package", prepareId);
+ WXPayConstants.SignType signType = clients.get(id).signType();
+ String paySign = WXPayUtil.generateSignature(data, conf(id, WxpayConf.P_apiKey), signType);
+ //timeStamp,nonceStr,package,signType,paySign
+ data.put("signType", WXPayConstants.signTypeName(signType));
+ data.put("paySign", paySign);
+ data.remove("appId");
+ return data;
+ }
+
@Override
public Map orderClose(String id, Map req) throws Exception {
return clients.get(id).closeOrder(req);
From 2c2e3ad781a65aad1a396e945869b641fd54ffe9 Mon Sep 17 00:00:00 2001
From: dzh
Date: Fri, 4 Sep 2020 17:55:43 +0800
Subject: [PATCH 16/47] add wx signPrepay
---
.../src/main/java/jframe/wxpay/service/WxpayServiceV2.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
index 457216e..b993bc6 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
@@ -103,7 +103,6 @@ public Map signPrepay(String id, String prepareId) throws Except
//timeStamp,nonceStr,package,signType,paySign
data.put("signType", WXPayConstants.signTypeName(signType));
data.put("paySign", paySign);
- data.remove("appId");
return data;
}
From 57de3e805e8de002b7e222f50354e64d75779356 Mon Sep 17 00:00:00 2001
From: dzh
Date: Sat, 5 Sep 2020 21:45:21 +0800
Subject: [PATCH 17/47] fix wxpay prepay_id
---
.../src/main/java/jframe/wxpay/service/WxpayService.java | 8 ++++++++
.../main/java/jframe/wxpay/service/WxpayServiceV2.java | 6 +++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
index f4d503a..4eb06ac 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
@@ -40,6 +40,14 @@ public interface WxpayService {
Map orderClose(String id, Map req) throws Exception;
+ /**
+ * https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2
+ *
+ * @param id group id
+ * @param req map{transaction_id,out_trade_no}
+ * @return
+ * @throws Exception
+ */
Map orderQuery(String id, Map req) throws Exception;
Map processResponseXml(String id, String xmlStr) throws Exception;
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
index b993bc6..94840df 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
@@ -17,6 +17,7 @@
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -92,12 +93,15 @@ public Map orderPrepay(String id, Map req) throw
@Override
public Map signPrepay(String id, String prepareId) throws Exception {
+ if (prepareId == null) {
+ return Collections.emptyMap();
+ }
//appId,timeStamp,nonceStr,package,signType
Map data = new HashMap<>();
data.put("appId", conf(id, WxpayConf.P_appId));
data.put("timeStamp", String.valueOf(WXPayUtil.getCurrentTimestamp()));
data.put("nonceStr", WXPayUtil.generateNonceStr());
- data.put("package", prepareId);
+ data.put("package", prepareId.startsWith("prepay_id") ? prepareId : "prepay_id=" + prepareId);
WXPayConstants.SignType signType = clients.get(id).signType();
String paySign = WXPayUtil.generateSignature(data, conf(id, WxpayConf.P_apiKey), signType);
//timeStamp,nonceStr,package,signType,paySign
From f9198eb3281ec6b3ab0cebaa572630d9105a82f3 Mon Sep 17 00:00:00 2001
From: dzh
Date: Sun, 6 Sep 2020 00:47:05 +0800
Subject: [PATCH 18/47] fix signPrepay
---
.../src/main/java/jframe/wxpay/service/WxpayService.java | 4 ++--
.../main/java/jframe/wxpay/service/WxpayServiceV2.java | 9 +++++----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
index 4eb06ac..00adcf2 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayService.java
@@ -32,11 +32,11 @@ public interface WxpayService {
* Map{appId,timeStamp,nonceStr,package,signType}
*
* @param id group id
- * @param prepareId orderPrepay response
+ * @param req Map{prepareId,nonceStr}
* @return Map{timeStamp,nonceStr,package,package,signType,paySign}
* @throws Exception
*/
- Map signPrepay(String id, String prepareId) throws Exception;
+ Map signPrepay(String id, Map req) throws Exception;
Map orderClose(String id, Map req) throws Exception;
diff --git a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
index 94840df..def2067 100644
--- a/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
+++ b/jframe-plugin/jframe-wxpay/src/main/java/jframe/wxpay/service/WxpayServiceV2.java
@@ -92,16 +92,17 @@ public Map orderPrepay(String id, Map req) throw
}
@Override
- public Map signPrepay(String id, String prepareId) throws Exception {
- if (prepareId == null) {
+ public Map signPrepay(String id, Map req) throws Exception {
+ String prepayId = req.get("prepayId");
+ if (prepayId == null) {
return Collections.emptyMap();
}
//appId,timeStamp,nonceStr,package,signType
Map