Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
S
syyl
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
syyl
Commits
0c7e6cc7
提交
0c7e6cc7
authored
4月 13, 2020
作者:
renjiancai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
25a8fd20
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
44 个修改的文件
包含
151 行增加
和
2067 行删除
+151
-2067
.classpath
com.zrqx.third/.classpath
+1
-15
.project
com.zrqx.third/.project
+29
-0
org.eclipse.core.resources.prefs
com.zrqx.third/.settings/org.eclipse.core.resources.prefs
+1
-1
org.eclipse.jdt.core.prefs
com.zrqx.third/.settings/org.eclipse.jdt.core.prefs
+0
-3
pom.xml
com.zrqx.third/pom.xml
+89
-18
ThirdStart.java
com.zrqx.third/src/main/java/com/zrqx/ThirdStart.java
+0
-56
EmailController.java
...d/src/main/java/com/zrqx/third/email/EmailController.java
+11
-8
RandomUtil.java
....third/src/main/java/com/zrqx/third/email/RandomUtil.java
+4
-1
Express100Controller.java
.../java/com/zrqx/third/express100/Express100Controller.java
+0
-145
Express100Config.java
...va/com/zrqx/third/express100/config/Express100Config.java
+0
-22
InvoiceController.java
...c/main/java/com/zrqx/third/invoice/InvoiceController.java
+0
-176
Contants.java
...src/main/java/com/zrqx/third/invoice/config/Contants.java
+0
-15
WXPay.java
....third/src/main/java/com/zrqx/third/pay/config/WXPay.java
+0
-0
WXPayConfig.java
.../src/main/java/com/zrqx/third/pay/config/WXPayConfig.java
+0
-127
WXPayConstants.java
...c/main/java/com/zrqx/third/pay/config/WXPayConstants.java
+0
-59
WXPayReport.java
.../src/main/java/com/zrqx/third/pay/config/WXPayReport.java
+0
-0
WXPayRequest.java
...src/main/java/com/zrqx/third/pay/config/WXPayRequest.java
+0
-177
WXPayUtil.java
...rd/src/main/java/com/zrqx/third/pay/config/WXPayUtil.java
+0
-0
WXPayXmlUtil.java
...src/main/java/com/zrqx/third/pay/config/WXPayXmlUtil.java
+0
-31
PayController.java
...ain/java/com/zrqx/third/pay/controller/PayController.java
+0
-78
ReceiveController.java
...java/com/zrqx/third/pay/controller/ReceiveController.java
+0
-0
PayTypeAdapter.java
...com/zrqx/third/pay/interfaces/payType/PayTypeAdapter.java
+0
-43
PayTypeInterface.java
...m/zrqx/third/pay/interfaces/payType/PayTypeInterface.java
+0
-69
AliPayImpl.java
...om/zrqx/third/pay/interfaces/payType/impl/AliPayImpl.java
+0
-0
WeChatPayImpl.java
...zrqx/third/pay/interfaces/payType/impl/WeChatPayImpl.java
+0
-0
YeePayImpl.java
...om/zrqx/third/pay/interfaces/payType/impl/YeePayImpl.java
+0
-0
DigestUtil.java
...rd/src/main/java/com/zrqx/third/pay/utils/DigestUtil.java
+0
-130
HttpUtils.java
...ird/src/main/java/com/zrqx/third/pay/utils/HttpUtils.java
+0
-157
QQLoginController.java
...c/main/java/com/zrqx/third/qqlogin/QQLoginController.java
+0
-106
QQLoginConfig.java
...ain/java/com/zrqx/third/qqlogin/config/QQLoginConfig.java
+0
-25
SdkSmsController.java
...src/main/java/com/zrqx/third/sdksms/SdkSmsController.java
+9
-7
ALiDaYuMessageUtil.java
.../src/main/java/com/zrqx/third/sms/ALiDaYuMessageUtil.java
+0
-79
SmsController.java
...third/src/main/java/com/zrqx/third/sms/SmsController.java
+2
-2
WeChatLoginController.java
...ava/com/zrqx/third/wechatlogin/WeChatLoginController.java
+0
-74
WeChatLoginWapController.java
.../com/zrqx/third/wechatlogin/WeChatLoginWapController.java
+0
-74
WeChatLoginXcxController.java
.../com/zrqx/third/wechatlogin/WeChatLoginXcxController.java
+0
-85
AES.java
.../src/main/java/com/zrqx/third/wechatlogin/config/AES.java
+0
-77
WXCore.java
...c/main/java/com/zrqx/third/wechatlogin/config/WXCore.java
+0
-53
WeChatLoginConfig.java
.../com/zrqx/third/wechatlogin/config/WeChatLoginConfig.java
+0
-29
WeChatLoginWapConfig.java
...m/zrqx/third/wechatlogin/config/WeChatLoginWapConfig.java
+0
-29
WeChatLoginXcxConfig.java
...m/zrqx/third/wechatlogin/config/WeChatLoginXcxConfig.java
+0
-26
WxPKCS7Encoder.java
...ava/com/zrqx/third/wechatlogin/config/WxPKCS7Encoder.java
+0
-62
application.yml
com.zrqx.third/src/main/resources/application.yml
+0
-3
bootstrap.yml
com.zrqx.third/src/main/resources/bootstrap.yml
+5
-5
没有找到文件。
com.zrqx.third/.classpath
浏览文件 @
0c7e6cc7
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry
kind=
"src"
output=
"target/classes"
path=
"src/main/java"
>
<classpathentry
including=
"**/*.java"
kind=
"src"
output=
"target/classes"
path=
"src/main/java"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
...
...
@@ -15,13 +15,11 @@
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"test"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
excluding=
"**"
kind=
"src"
output=
"target/test-classes"
path=
"src/test/resources"
>
<attributes>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"test"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"con"
path=
"org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"
>
...
...
@@ -37,18 +35,6 @@
<classpathentry
kind=
"src"
path=
"target/generated-sources/annotations"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"ignore_optional_problems"
value=
"true"
/>
<attribute
name=
"m2e-apt"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"target/generated-test-sources/test-annotations"
>
<attributes>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"ignore_optional_problems"
value=
"true"
/>
<attribute
name=
"m2e-apt"
value=
"true"
/>
<attribute
name=
"test"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"output"
path=
"target/classes"
/>
...
...
com.zrqx.third/.project
浏览文件 @
0c7e6cc7
...
...
@@ -5,7 +5,36 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>
org.eclipse.wst.common.project.facet.core.builder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.jdt.core.javabuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
com.genuitec.eclipse.springframework.springbuilder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.eclipse.m2e.core.maven2Builder
</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>
org.springframework.ide.eclipse.boot.validation.springbootbuilder
</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>
com.genuitec.eclipse.springframework.springnature
</nature>
<nature>
org.eclipse.jdt.core.javanature
</nature>
<nature>
org.eclipse.m2e.core.maven2Nature
</nature>
<nature>
org.eclipse.wst.common.project.facet.core.nature
</nature>
</natures>
</projectDescription>
com.zrqx.third/.settings/org.eclipse.core.resources.prefs
浏览文件 @
0c7e6cc7
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF
-
8
encoding//src/test/java=UTF8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8
com.zrqx.third/.settings/org.eclipse.jdt.core.prefs
浏览文件 @
0c7e6cc7
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.processAnnotations=enabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
com.zrqx.third/pom.xml
浏览文件 @
0c7e6cc7
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
com.zrqx
</groupId>
<artifactId>
app
</artifactId>
<version>
5.0.0
</version>
<artifactId>
com.zrqx.pom
</artifactId>
<version>
4.0.0
</version>
<relativePath>
../com.zrqx.pom
</relativePath>
</parent>
<artifactId>
third
</artifactId>
<artifactId>
com.zrqx.
third
</artifactId>
<dependencies>
<!-- 跨服务调用 -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
<dependency>
<groupId>
com.zrqx
</groupId>
<artifactId>
com.zrqx.core
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-data-redis
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-zipkin
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-config
</artifactId>
</dependency>
<!--表示为web工程 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<!-- 用于健康监控 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-actuator
</artifactId>
</dependency>
<!--熔断器 -->
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-hystrix
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-hystrix-dashboard
</artifactId>
</dependency>
<!--swagger2 -->
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger2
</artifactId>
</dependency>
<dependency>
<groupId>
io.springfox
</groupId>
<artifactId>
springfox-swagger-ui
</artifactId>
</dependency>
<!-- Springsecurity给服务端提供安全访问 -->
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency> -->
<!--用于测试的 -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<!--支付宝支付 -->
<dependency>
<groupId>
com.alipay.sdk
</groupId>
<artifactId>
alipay-sdk-java
</artifactId>
<version>
3.1.0
</version>
</dependency>
<!--阿里大鱼短信接口 -->
<!--阿里短信接口 -->
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
4.0.3
</version>
</dependency>
<!-- <dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
3.2.3
</version>
</dependency>
-->
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-dysmsapi
</artifactId>
<version>
1.1.0
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-
thymeleaf
</artifactId>
<artifactId>
spring-boot-starter-
web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-thymeleaf
</artifactId>
</dependency>
<dependency>
<groupId>
baiwang
</groupId>
<artifactId>
baiwang
</artifactId>
<version>
1.0.0
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-dm
</artifactId>
<version>
3.1.0
</version>
</dependency>
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-dm
</artifactId>
<version>
3.1.0
</version>
</dependency>
<!-- 热部署工具 -->
<!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId>
</dependency> -->
</dependencies>
</project>
\ No newline at end of file
com.zrqx.third/src/main/java/com/zrqx/ThirdStart.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
;
import
javax.sql.DataSource
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
;
import
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
;
import
org.springframework.cloud.netflix.eureka.EnableEurekaClient
;
import
org.springframework.cloud.netflix.hystrix.EnableHystrix
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.Bean
;
import
com.alibaba.druid.pool.DruidDataSource
;
@EnableFeignClients
@EnableEurekaClient
@EnableHystrix
@SpringBootApplication
(
exclude
=
{
DataSourceAutoConfiguration
.
class
,
DataSourceTransactionManagerAutoConfiguration
.
class
})
// 系统会去入口类的同级包以及下级包中去扫描实体类,因此我们建议入口类的位置在groupId+arctifactID组合的包名下。
public
class
ThirdStart
{
@Value
(
"${spring.datasource.url}"
)
private
String
url
;
@Value
(
"${spring.datasource.username}"
)
private
String
username
;
@Value
(
"${spring.datasource.password}"
)
private
String
password
;
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ThirdStart
.
class
);
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
ThirdStart
.
class
,
args
);
logger
.
info
(
"thrid服务已启动....."
);
}
@Bean
public
DataSource
dataSource
()
{
DruidDataSource
dataSource
=
new
DruidDataSource
();
dataSource
.
setUrl
(
url
);
dataSource
.
setUsername
(
username
);
// 用户名
dataSource
.
setPassword
(
password
);
// 密码
dataSource
.
setInitialSize
(
10
);
dataSource
.
setMaxActive
(
200
);
dataSource
.
setMaxWait
(
60000
);
dataSource
.
setValidationQuery
(
"SELECT 1"
);
dataSource
.
setTestOnBorrow
(
false
);
dataSource
.
setTestWhileIdle
(
true
);
dataSource
.
setPoolPreparedStatements
(
false
);
return
dataSource
;
}
}
com.zrqx.third/src/main/java/com/zrqx/third/email/EmailController.java
浏览文件 @
0c7e6cc7
package
com
.
zrqx
.
third
.
email
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
java.util.concurrent.TimeUnit
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -16,22 +22,19 @@ import com.aliyuncs.exceptions.ClientException;
import
com.aliyuncs.exceptions.ServerException
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.IClientProfile
;
import
com.zrqx.core.client.form.third.email.EmailForm
;
import
com.zrqx.core.form.third.email.EmailForm
;
import
com.zrqx.third.constant.RequestPath
;
import
com.zrqx.third.email.config.EmailConfig
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
@RestController
@RequestMapping
(
"/email"
)
@RequestMapping
(
RequestPath
.
EMAIL
)
@Api
(
description
=
"邮件"
)
public
class
EmailController
{
@Autowired
StringRedisTemplate
stringRedisTemplate
;
@ApiOperation
(
value
=
"邮件验证"
,
notes
=
"邮件验证"
)
@PostMapping
(
value
=
"/verification_code"
)
@PostMapping
(
value
=
RequestPath
.
VERIFICATION
)
public
String
sample
(
@ApiParam
(
value
=
"邮箱号"
)
String
email
)
{
// 如果是除杭州region外的其它region(如新加坡、澳洲Region),需要将下面的"cn-hangzhou"替换为"ap-southeast-1"、或"ap-southeast-2"。
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
...
...
@@ -66,7 +69,7 @@ public class EmailController {
}
@ApiOperation
(
value
=
"邮件(自己发验证码)"
,
notes
=
"邮件(自己发验证码)"
)
@PostMapping
(
value
=
"/send"
)
@PostMapping
(
value
=
RequestPath
.
SEND
)
public
String
sendEmail
(
EmailForm
emailForm
)
{
// 如果是除杭州region外的其它region(如新加坡、澳洲Region),需要将下面的"cn-hangzhou"替换为"ap-southeast-1"、或"ap-southeast-2"。
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
...
...
com.zrqx.third/src/main/java/com/zrqx/third/email/RandomUtil.java
浏览文件 @
0c7e6cc7
/**
* @Title: SessionTools.java
* @Package com.book.util
* @author 段思铭
* @Description: TODO(用一句话描述该文件做什么)
* @author 段思铭
* @date 2015-6-17 上午11:09:22
* @version V5.0
*/
...
...
@@ -14,6 +15,7 @@ import java.util.concurrent.ThreadLocalRandom;
/**
*
* @ClassName: RandomUtil
* @Description: TODO(这里用一句话描述这个类的作用)
* @author 段思铭
* @date 2015-6-17 下午1:55:14
*
...
...
@@ -24,6 +26,7 @@ public class RandomUtil {
/**
*
* @Title: suijima
* @Description: TODO(生成数字随机数)
* @param num
* @return
* @return String 返回类型
...
...
com.zrqx.third/src/main/java/com/zrqx/third/express100/Express100Controller.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
express100
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zrqx.core.client.form.third.express100.ExpressInfoForm
;
import
com.zrqx.core.client.vo.third.express100.ExpressResponse
;
import
com.zrqx.core.client.vo.third.express100.LogisticsDetails
;
import
com.zrqx.core.client.vo.third.express100.LogisticsNewest
;
import
com.zrqx.core.client.vo.third.express100.LogisticsParam
;
import
com.zrqx.core.client.vo.third.express100.LogisticsRequsetParam
;
import
com.zrqx.core.client.vo.third.express100.SubscribeParam
;
import
com.zrqx.core.util.encry.MD5Util
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.third.express100.config.Express100Config
;
import
com.zrqx.third.util.HttpsUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@RestController
@RequestMapping
(
"/express100"
)
@Api
(
description
=
"快递100"
)
public
class
Express100Controller
{
@ApiOperation
(
value
=
"订阅物流信息(订阅后将会一直追踪物流单状态直至生命周期结束)"
,
notes
=
"订阅"
)
@PostMapping
(
value
=
"/subscribe"
)
public
CallBack
<?>
Subscribe
(
@RequestBody
ExpressInfoForm
form
){
form
=
mapCompany
(
form
);
SubscribeParam
requestParam
=
new
SubscribeParam
(
form
.
getCompany
(),
form
.
getNumber
(),
Express100Config
.
KEY
,
Express100Config
.
CALLBACK_URL
);
HashMap
<
String
,
String
>
requestMap
=
new
HashMap
<
String
,
String
>();
requestMap
.
put
(
"schema"
,
"json"
);
requestMap
.
put
(
"param"
,
JSONObject
.
toJSONString
(
requestParam
));
String
response
=
null
;
try
{
response
=
HttpsUtils
.
sendPost
(
Express100Config
.
SUBSCRIBE_URL
,
requestMap
);
System
.
out
.
println
(
response
);
}
catch
(
Exception
e
)
{
return
CallBack
.
fail
(
"对接快递100失败"
);
}
ExpressResponse
resp
=
JSONObject
.
toJavaObject
(
JSONObject
.
parseObject
(
response
),
ExpressResponse
.
class
);
return
resp
.
isResult
()
?
CallBack
.
success
()
:
CallBack
.
fail
(
resp
.
getMessage
());
}
@ApiOperation
(
value
=
"订阅物流回调"
,
notes
=
"回调"
)
@PostMapping
(
value
=
"/receive/subscribe"
)
public
void
ReceiveSubscribe
(
HttpServletRequest
request
,
HttpServletResponse
response
){
String
param
=
request
.
getParameter
(
"param"
);
LogisticsParam
logisticsParam
=
JSON
.
toJavaObject
(
JSONObject
.
parseObject
(
param
),
LogisticsParam
.
class
);
List
<
LogisticsDetails
>
details
=
logisticsParam
.
getLastResult
().
getData
();
//TODO 调用订单服务接口将物流信息推送给订单服务
System
.
out
.
println
(
details
.
toString
());
boolean
isSave
=
true
;
// 返回响应,告知快递100
String
resp
=
JSONObject
.
toJSONString
(
isSave
?
ExpressResponse
.
success
()
:
ExpressResponse
.
fail
());
System
.
out
.
println
(
"***************"
+
resp
+
"************"
);
try
{
response
.
getWriter
().
print
(
new
String
(
resp
.
getBytes
(
"UTF-8"
),
"ISO-8859-1"
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
@ApiOperation
(
value
=
"订阅物流实时查询"
)
@PostMapping
(
value
=
"/get"
)
public
CallBack
<
List
<
LogisticsDetails
>>
getLogistics
(
@RequestBody
ExpressInfoForm
form
){
form
=
mapCompany
(
form
);
LogisticsRequsetParam
logisticsRequsetParam
=
new
LogisticsRequsetParam
(
form
.
getCompany
(),
form
.
getNumber
());
String
param
=
JSONObject
.
toJSONString
(
logisticsRequsetParam
);
String
customer
=
Express100Config
.
CUSTOMER
;
String
key
=
Express100Config
.
KEY
;
String
sign
=
""
;
// 加密
try
{
sign
=
MD5Util
.
getEncoderByMd5
(
param
+
key
+
customer
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"param"
,
param
);
params
.
put
(
"sign"
,
sign
);
params
.
put
(
"customer"
,
customer
);
String
resp
=
""
;
try
{
resp
=
HttpsUtils
.
sendPost
(
Express100Config
.
URL
,
params
);
System
.
out
.
println
(
resp
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
LogisticsNewest
logisticsNewest
=
JSON
.
toJavaObject
(
JSONObject
.
parseObject
(
resp
),
LogisticsNewest
.
class
);
return
CallBack
.
success
(
logisticsNewest
.
getData
());
}
@ApiOperation
(
value
=
"物流是否签收实时查询ture:是、false:否"
)
@PostMapping
(
value
=
"/get/status"
)
public
CallBack
<
Boolean
>
getLogisticsStatus
(
@RequestBody
ExpressInfoForm
form
){
form
=
mapCompany
(
form
);
LogisticsRequsetParam
logisticsRequsetParam
=
new
LogisticsRequsetParam
(
form
.
getCompany
(),
form
.
getNumber
());
String
param
=
JSONObject
.
toJSONString
(
logisticsRequsetParam
);
String
customer
=
Express100Config
.
CUSTOMER
;
String
key
=
Express100Config
.
KEY
;
String
sign
=
""
;
// 加密
try
{
sign
=
MD5Util
.
getEncoderByMd5
(
param
+
key
+
customer
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
params
.
put
(
"param"
,
param
);
params
.
put
(
"sign"
,
sign
);
params
.
put
(
"customer"
,
customer
);
String
resp
=
""
;
try
{
resp
=
HttpsUtils
.
sendPost
(
Express100Config
.
URL
,
params
);
System
.
out
.
println
(
resp
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
LogisticsNewest
logisticsNewest
=
JSON
.
toJavaObject
(
JSONObject
.
parseObject
(
resp
),
LogisticsNewest
.
class
);
return
CallBack
.
success
(
"3"
.
equals
(
logisticsNewest
.
getState
()));
}
private
ExpressInfoForm
mapCompany
(
ExpressInfoForm
form
){
form
.
setCompany
(
"HTKY"
.
equals
(
form
.
getCompany
())
?
"huitongkuaidi"
:
form
.
getCompany
());
return
form
;
}
}
com.zrqx.third/src/main/java/com/zrqx/third/express100/config/Express100Config.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
express100
.
config
;
/**
* 快递100配置
* @author lw
* @date 2018年9月13日下午2:03:14
*/
public
class
Express100Config
{
/** key */
public
final
static
String
KEY
=
"FHcrxdcu8182"
;
/** 访问地址 */
public
final
static
String
SUBSCRIBE_URL
=
"http://www.kuaidi100.com/poll"
;
public
final
static
String
URL
=
"http://poll.kuaidi100.com/poll/query.do"
;
/** 回调地址 */
public
final
static
String
CALLBACK_URL
=
"http://122.14.50.6:8096/third/express100/receive/subscribe"
;
/** 客户id */
public
final
static
String
CUSTOMER
=
"7CF00D91B15F958A264A136720884994"
;
}
com.zrqx.third/src/main/java/com/zrqx/third/invoice/InvoiceController.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
invoice
;
import
java.io.IOException
;
import
java.security.GeneralSecurityException
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baiwang.bop.client.BopException
;
import
com.baiwang.bop.client.IBopClient
;
import
com.baiwang.bop.client.ILoginClient
;
import
com.baiwang.bop.client.impl.BopRestClient
;
import
com.baiwang.bop.client.impl.PostLogin
;
import
com.baiwang.bop.request.impl.LoginRequest
;
import
com.baiwang.bop.request.impl.invoice.common.InvoiceDetails
;
import
com.baiwang.bop.request.impl.invoice.impl.FormatfileBuildRequest
;
import
com.baiwang.bop.request.impl.invoice.impl.InvoiceInvalidRequest
;
import
com.baiwang.bop.request.impl.invoice.impl.InvoiceOpenRequest
;
import
com.baiwang.bop.request.impl.invoice.impl.InvoiceQueryRequest
;
import
com.baiwang.bop.respose.entity.FormatfileBuildResponse
;
import
com.baiwang.bop.respose.entity.InvoiceInvalidResponse
;
import
com.baiwang.bop.respose.entity.InvoiceOpenResponse
;
import
com.baiwang.bop.respose.entity.InvoiceQueryResponse
;
import
com.baiwang.bop.respose.entity.LoginResponse
;
import
com.zrqx.core.client.form.third.baiwang.BaiwangDestoryForm
;
import
com.zrqx.core.client.form.third.baiwang.BaiwangDetailForm
;
import
com.zrqx.core.client.form.third.baiwang.BaiwangDownloadForm
;
import
com.zrqx.core.client.form.third.baiwang.BaiwangForm
;
import
com.zrqx.core.client.form.third.baiwang.BaiwangQueryForm
;
import
com.zrqx.core.client.vo.third.baiwang.BaiwangDownloadReturn
;
import
com.zrqx.core.client.vo.third.baiwang.BaiwangPayReturn
;
import
com.zrqx.core.client.vo.third.baiwang.BaiwangQueryReturn
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.third.invoice.config.Contants
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@RestController
@RequestMapping
(
"/baiwang"
)
@Api
(
description
=
"百望云"
)
public
class
InvoiceController
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
InvoiceController
.
class
);
static
LoginRequest
loginRequest
=
new
LoginRequest
();
static
{
loginRequest
.
setAppkey
(
Contants
.
appkey
);
loginRequest
.
setAppSecret
(
Contants
.
appSecret
);
loginRequest
.
setUserName
(
Contants
.
userName
);
loginRequest
.
setPasswordMd5
(
Contants
.
password
);
loginRequest
.
setUserSalt
(
Contants
.
userSalt
);
}
@ApiOperation
(
value
=
"开发票和对冲发票"
,
notes
=
"开发票和对冲发票"
)
@PostMapping
(
"/pay"
)
public
CallBack
<
BaiwangPayReturn
>
pay
(
@RequestBody
BaiwangForm
baiwang
)
throws
GeneralSecurityException
,
IOException
{
BaiwangPayReturn
baiwangPayReturn
=
new
BaiwangPayReturn
();
IBopClient
client
=
new
BopRestClient
(
Contants
.
url
,
Contants
.
appkey
,
Contants
.
appSecret
);
ILoginClient
loginClient
=
new
PostLogin
(
Contants
.
url
);
LoginResponse
loginResponse
=
loginClient
.
login
(
loginRequest
);
String
token
=
loginResponse
.
getAccess_token
();
// 获取token
InvoiceOpenResponse
response
=
null
;
try
{
InvoiceOpenRequest
request
=
new
InvoiceOpenRequest
();
request
.
setSignatureParameter
(
"0000004282000000"
);
request
.
setDeviceType
(
"0"
);
// 设备类型 0税控服务器
request
.
setInvoiceTypeCode
(
"026"
);
// 发票种类编码,004:增值税专用发票,007:增值税普通发票,026:增值税电子发票,025:增值税卷式发票
request
.
setInvoiceSpecialMark
(
"00"
);
//特殊票种标记,00:普通发票
request
.
setTaxationMode
(
"0"
);
//征税方式 0:普通征税,2:差额征税,必填
request
.
setSellerTaxNo
(
Contants
.
sellerTaxNo
);
request
.
setInvoiceTerminalCode
(
Contants
.
invoiceTerminalCode
);
request
.
setDrawer
(
Contants
.
drawer
);
BeanUtils
.
copyProperties
(
baiwang
,
request
);
List
<
InvoiceDetails
>
invoiceDetailsList
=
new
ArrayList
<
InvoiceDetails
>();
if
(
baiwang
.
getInvoiceDetailsList
()!=
null
){
for
(
BaiwangDetailForm
bdf
:
baiwang
.
getInvoiceDetailsList
()){
InvoiceDetails
invoiceDetails
=
new
InvoiceDetails
();
BeanUtils
.
copyProperties
(
bdf
,
invoiceDetails
);
invoiceDetails
.
setFreeTaxMark
(
"1"
);
invoiceDetails
.
setPriceTaxMark
(
"1"
);
//含税
invoiceDetails
.
setPreferentialMark
(
"0"
);
//不使用优惠政策
invoiceDetails
.
setGoodsTaxRate
(
"0"
);
//税率0
invoiceDetailsList
.
add
(
invoiceDetails
);
}
request
.
setInvoiceDetailsList
(
invoiceDetailsList
);
}
response
=
client
.
execute
(
request
,
token
,
InvoiceOpenResponse
.
class
);
}
catch
(
BopException
e
)
{
logger
.
error
(
e
.
getMessage
());
baiwangPayReturn
.
setInvoiceCode
(
e
.
getMessage
());
return
CallBack
.
fail
(
baiwangPayReturn
.
toString
());
}
// BaiwangPayReturn baiwangPayReturn=JSONObject.toJavaObject(JSONObject.parseObject(response.toString()), BaiwangPayReturn.class);
BeanUtils
.
copyProperties
(
response
,
baiwangPayReturn
);
return
CallBack
.
success
(
baiwangPayReturn
);
}
@ApiOperation
(
value
=
"销毁发票(电子发票不能销毁)"
,
notes
=
"销毁发票(电子发票不能销毁)"
)
@PostMapping
(
"/destory"
)
public
String
destory
(
@RequestBody
BaiwangDestoryForm
baiwangDestoryForm
)
{
IBopClient
client
=
new
BopRestClient
(
Contants
.
url
,
Contants
.
appkey
,
Contants
.
appSecret
);
InvoiceInvalidResponse
response
=
null
;
ILoginClient
loginClient
=
new
PostLogin
(
Contants
.
url
);
LoginResponse
loginResponse
=
loginClient
.
login
(
loginRequest
);
String
token
=
loginResponse
.
getAccess_token
();
// 获取token
try
{
InvoiceInvalidRequest
request
=
new
InvoiceInvalidRequest
();
request
.
setDeviceType
(
"0"
);
// 设备类型 0税控服务器
request
.
setInvoiceTypeCode
(
"026"
);
// 发票种类编码,004:增值税专用发票,007:增值税普通发票,026:增值税电子发票,025:增值税卷式发票
BeanUtils
.
copyProperties
(
baiwangDestoryForm
,
request
);
response
=
client
.
execute
(
request
,
token
,
InvoiceInvalidResponse
.
class
);
}
catch
(
BopException
e
)
{
logger
.
error
(
e
.
getMessage
());
return
e
.
getMessage
();
}
return
response
.
toString
();
}
@ApiOperation
(
value
=
"查询发票"
,
notes
=
"查询发票"
)
@GetMapping
(
"/query"
)
public
CallBack
<
BaiwangQueryReturn
>
query
(
BaiwangQueryForm
baiwangQueryForm
)
{
IBopClient
client
=
new
BopRestClient
(
Contants
.
url
,
Contants
.
appkey
,
Contants
.
appSecret
);
InvoiceQueryResponse
response
=
null
;
ILoginClient
loginClient
=
new
PostLogin
(
Contants
.
url
);
LoginResponse
loginResponse
=
loginClient
.
login
(
loginRequest
);
String
token
=
loginResponse
.
getAccess_token
();
// 获取token
InvoiceQueryRequest
request
=
new
InvoiceQueryRequest
();
try
{
BeanUtils
.
copyProperties
(
baiwangQueryForm
,
request
);
response
=
client
.
execute
(
request
,
token
,
InvoiceQueryResponse
.
class
);
}
catch
(
BopException
e
)
{
logger
.
error
(
e
.
getMessage
());
return
CallBack
.
fail
();
}
BaiwangQueryReturn
baiwangQueryReturn
=
JSONObject
.
toJavaObject
(
JSONObject
.
parseObject
(
response
.
toString
()),
BaiwangQueryReturn
.
class
);
return
CallBack
.
success
(
baiwangQueryReturn
);
}
@ApiOperation
(
value
=
"下载发票"
,
notes
=
"下载发票"
)
@GetMapping
(
"/download"
)
public
CallBack
<
BaiwangDownloadReturn
>
download
(
BaiwangDownloadForm
baiwangDownloadForm
)
{
ILoginClient
loginClient
=
new
PostLogin
(
Contants
.
url
);
LoginResponse
loginResponse
=
loginClient
.
login
(
loginRequest
);
String
token
=
loginResponse
.
getAccess_token
();
// 获取token
FormatfileBuildRequest
request
=
new
FormatfileBuildRequest
();
request
.
setSellerTaxNo
(
Contants
.
sellerTaxNo
);
request
.
setPushType
(
"1"
);
// 推送
BeanUtils
.
copyProperties
(
baiwangDownloadForm
,
request
);
//同步请求
IBopClient
client
=
new
BopRestClient
(
Contants
.
url
,
Contants
.
appkey
,
Contants
.
appSecret
);
FormatfileBuildResponse
response
=
client
.
execute
(
request
,
token
,
FormatfileBuildResponse
.
class
);
BaiwangDownloadReturn
bdr
=
new
BaiwangDownloadReturn
();
bdr
.
setMessage
(
response
.
getData
());
return
CallBack
.
success
(
bdr
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/invoice/config/Contants.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
invoice
.
config
;
public
class
Contants
{
public
static
String
url
=
"http://openapi.baiwang.com/router/rest"
;
// 接口地址
public
static
String
appkey
=
"10000405"
;
// AppKey
public
static
String
appSecret
=
"101da9c0-3ac6-455d-b764-ef63cd7ebb15"
;
// AppSecrect
public
static
String
userName
=
"QY41"
;
// 用户名
public
static
String
password
=
"CLASS123456"
;
// 密码
public
static
String
userSalt
=
"aec6b4e005ff44638bb46c593025f9ef"
;
// 盐值
public
static
String
sellerTaxNo
=
"91110105801682806Q"
;
// 销方单位税号
public
static
String
invoiceTerminalCode
=
"class0508"
;
// 开票点编码
public
static
String
drawer
=
"郑莹"
;
// 开票人,电子发票8个字符
}
com.zrqx.third/src/main/java/com/zrqx/third/pay/config/WXPay.java
deleted
100644 → 0
浏览文件 @
25a8fd20
差异被折叠。
点击展开。
com.zrqx.third/src/main/java/com/zrqx/third/pay/config/WXPayConfig.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
pay
.
config
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.DefaultResourceLoader
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.stereotype.Component
;
@Component
public
class
WXPayConfig
{
private
ResourceLoader
resourceLoader
=
new
DefaultResourceLoader
();
// 公众账号id
@Value
(
"${pay.wechatpay.appID}"
)
private
String
appID
;
// 商户号
@Value
(
"${pay.wechatpay.mchID}"
)
private
String
mchID
;
// API密钥
@Value
(
"${pay.wechatpay.key}"
)
private
String
key
;
/**
* 公众账号ID
*
* @return App ID
*/
public
String
getAppID
()
{
return
this
.
appID
;
}
/**
* 商户号
*
* @return Mch ID
*/
public
String
getMchID
()
{
return
this
.
mchID
;
}
/**
* 获取 API 密钥
*
* @return API密钥
*/
public
String
getKey
()
{
return
this
.
key
;
}
/**
* 获取商户证书内容
*
* @return 商户证书内容
* @throws IOException
*/
public
InputStream
getCertStream
()
throws
IOException
{
Resource
resource
=
resourceLoader
.
getResource
(
"classpath:templates/apiclient_cert.p12"
);
InputStream
certStream
=
resource
.
getInputStream
();
// <-- this is the difference
return
certStream
;
}
/**
* HTTP(S) 连接超时时间,单位毫秒
*
* @return
*/
public
int
getHttpConnectTimeoutMs
()
{
return
6
*
1000
;
}
/**
* HTTP(S) 读数据超时时间,单位毫秒
*
* @return
*/
public
int
getHttpReadTimeoutMs
()
{
return
8
*
1000
;
}
/**
* 获取WXPayDomain, 用于多域名容灾自动切换
*
* @return
*/
// public 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
;
}
}
com.zrqx.third/src/main/java/com/zrqx/third/pay/config/WXPayConstants.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
pay
.
config
;
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"
;
}
com.zrqx.third/src/main/java/com/zrqx/third/pay/config/WXPayReport.java
deleted
100644 → 0
浏览文件 @
25a8fd20
差异被折叠。
点击展开。
com.zrqx.third/src/main/java/com/zrqx/third/pay/config/WXPayRequest.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
pay
.
config
;
import
java.io.InputStream
;
import
java.net.SocketTimeoutException
;
import
java.net.UnknownHostException
;
import
java.security.KeyStore
;
import
java.security.SecureRandom
;
import
javax.net.ssl.KeyManagerFactory
;
import
javax.net.ssl.SSLContext
;
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
static
com
.
zrqx
.
third
.
pay
.
config
.
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
.<
ConnectionSocketFactory
>
create
().
register
(
"http"
,
PlainConnectionSocketFactory
.
getSocketFactory
())
.
register
(
"https"
,
sslConnectionSocketFactory
).
build
(),
null
,
null
,
null
);
}
else
{
connManager
=
new
BasicHttpClientConnectionManager
(
RegistryBuilder
.<
ConnectionSocketFactory
>
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
;
try
{
String
result
=
requestOnce
(
"api.mch.weixin.qq.com"
,
urlSuffix
,
uuid
,
data
,
connectTimeoutMs
,
readTimeoutMs
,
useCert
);
elapsedTimeMillis
=
WXPayUtil
.
getCurrentTimestampMs
()
-
startTimestampMs
;
return
result
;
}
catch
(
UnknownHostException
ex
)
{
// dns 解析错误,或域名不存在
exception
=
ex
;
firstHasDnsErr
=
true
;
elapsedTimeMillis
=
WXPayUtil
.
getCurrentTimestampMs
()
-
startTimestampMs
;
}
catch
(
ConnectTimeoutException
ex
)
{
exception
=
ex
;
firstHasConnectTimeout
=
true
;
elapsedTimeMillis
=
WXPayUtil
.
getCurrentTimestampMs
()
-
startTimestampMs
;
}
catch
(
SocketTimeoutException
ex
)
{
exception
=
ex
;
firstHasReadTimeout
=
true
;
elapsedTimeMillis
=
WXPayUtil
.
getCurrentTimestampMs
()
-
startTimestampMs
;
}
catch
(
Exception
ex
)
{
exception
=
ex
;
elapsedTimeMillis
=
WXPayUtil
.
getCurrentTimestampMs
()
-
startTimestampMs
;
}
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
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/pay/config/WXPayUtil.java
deleted
100644 → 0
浏览文件 @
25a8fd20
差异被折叠。
点击展开。
com.zrqx.third/src/main/java/com/zrqx/third/pay/config/WXPayXmlUtil.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
pay
.
config
;
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"
,
false
);
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
();
}
}
com.zrqx.third/src/main/java/com/zrqx/third/pay/controller/PayController.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
pay
.
controller
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.zrqx.core.client.form.third.pay.CloseForm
;
import
com.zrqx.core.client.form.third.pay.RefundForm
;
import
com.zrqx.core.client.form.third.pay.RefundQueryForm
;
import
com.zrqx.core.client.form.third.pay.ToPayForm
;
import
com.zrqx.core.client.vo.third.pay.payquery.PayQueryReturnVo
;
import
com.zrqx.core.client.vo.third.pay.refundquery.BaseRefundQueryReturnVo
;
import
com.zrqx.core.enums.third.pay.PayTypeEnum
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.core.util.spring.SpringContextUtils
;
import
com.zrqx.third.pay.interfaces.payType.PayTypeInterface
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@RestController
@RequestMapping
(
"/pay"
)
@Api
(
description
=
"支付"
)
public
class
PayController
{
@Autowired
private
SpringContextUtils
springContext
;
@ApiOperation
(
"测试"
)
@GetMapping
(
"/test"
)
public
BaseRefundQueryReturnVo
test
(
String
payType
){
return
springContext
.
getEnumsBindBean
(
PayTypeEnum
.
class
,
payType
,
PayTypeInterface
.
class
).
test
();
}
/**
* 去支付
* @param toPayForm
* @return
* @author lw
* @date: 2019年1月15日 上午9:43:22
*/
@ApiOperation
(
"去支付"
)
@PostMapping
(
"/to_pay"
)
public
CallBack
<
String
>
toPay
(
@RequestBody
ToPayForm
toPayForm
){
return
springContext
.
getEnumsBindBean
(
PayTypeEnum
.
class
,
toPayForm
.
getPayType
(),
PayTypeInterface
.
class
).
toPay
(
toPayForm
);
}
@ApiOperation
(
"支付查询 "
)
@GetMapping
(
"/query"
)
public
CallBack
<
PayQueryReturnVo
>
query
(
String
out_trade_no
,
String
payType
){
return
springContext
.
getEnumsBindBean
(
PayTypeEnum
.
class
,
payType
,
PayTypeInterface
.
class
).
query
(
out_trade_no
);
}
@ApiOperation
(
"退款 "
)
@PostMapping
(
"/refund"
)
public
CallBack
<
Boolean
>
refund
(
RefundForm
refundForm
){
return
springContext
.
getEnumsBindBean
(
PayTypeEnum
.
class
,
refundForm
.
getPayType
(),
PayTypeInterface
.
class
).
refund
(
refundForm
);
}
@ApiOperation
(
"退款查询 "
)
@PostMapping
(
"/refund/query"
)
public
CallBack
<
BaseRefundQueryReturnVo
>
refundQuery
(
RefundQueryForm
refundQueryForm
){
return
springContext
.
getEnumsBindBean
(
PayTypeEnum
.
class
,
refundQueryForm
.
getPayType
(),
PayTypeInterface
.
class
).
refundQuery
(
refundQueryForm
);
}
@ApiOperation
(
"关闭订单 "
)
@PostMapping
(
"/close"
)
public
CallBack
<
Boolean
>
close
(
CloseForm
closeForm
){
return
springContext
.
getEnumsBindBean
(
PayTypeEnum
.
class
,
closeForm
.
getPayType
(),
PayTypeInterface
.
class
).
close
(
closeForm
);
};
}
com.zrqx.third/src/main/java/com/zrqx/third/pay/controller/ReceiveController.java
deleted
100644 → 0
浏览文件 @
25a8fd20
差异被折叠。
点击展开。
com.zrqx.third/src/main/java/com/zrqx/third/pay/interfaces/payType/PayTypeAdapter.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
pay
.
interfaces
.
payType
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
com.zrqx.core.client.third.PayClient
;
import
com.zrqx.core.client.vo.order.OrderPayVo
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.util.response.CallBack
;
/**
* @author lw
* @date 2019年1月15日上午9:29:09
*/
public
abstract
class
PayTypeAdapter
implements
PayTypeInterface
{
@Autowired
private
PayClient
payClient
;
protected
abstract
Logger
getLogger
();
/**
* 支付功能获取订单支付信息
* @param code
* @return
* @author lpf
* @date: 2019年1月18日 下午3:24:08
*/
protected
OrderPayVo
getOrderPayVo
(
String
code
)
{
if
(
StringUtils
.
isBlank
(
code
))
{
throw
new
BaseException
(
"PayTypeAdapter#getOrderPayVo 订单编号不能为空"
);
}
Logger
logger
=
getLogger
();
logger
.
info
(
"zzzzzzzz支付功能获取订单支付信息,code:"
+
code
);
CallBack
<
OrderPayVo
>
call
=
payClient
.
getOrderPayVo
(
code
);
logger
.
info
(
code
+
"获取订单支付信息callback:"
+
call
);
if
(
call
!=
null
&&
call
.
hasEntity
())
{
return
call
.
getData
();
}
throw
new
BaseException
(
"PayTypeAdapter#getOrderPayVo Error,callback:"
+
call
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/pay/interfaces/payType/PayTypeInterface.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
pay
.
interfaces
.
payType
;
import
com.zrqx.core.client.form.third.pay.CloseForm
;
import
com.zrqx.core.client.form.third.pay.RefundForm
;
import
com.zrqx.core.client.form.third.pay.RefundQueryForm
;
import
com.zrqx.core.client.form.third.pay.ToPayForm
;
import
com.zrqx.core.client.vo.third.pay.payquery.PayQueryReturnVo
;
import
com.zrqx.core.client.vo.third.pay.refundquery.BaseRefundQueryReturnVo
;
import
com.zrqx.core.enums.interfaces.EnumsBindBean
;
import
com.zrqx.core.enums.third.pay.PayTypeEnum
;
import
com.zrqx.core.util.response.CallBack
;
/**
* 支付枚举(所有)要绑定的操作
* @author lw
* @date 2019年1月15日上午9:29:18
*/
public
interface
PayTypeInterface
extends
EnumsBindBean
<
PayTypeEnum
>{
/**
* 测试
* @return
* @author lw
* @date: 2019年1月15日 上午10:06:36
*/
BaseRefundQueryReturnVo
test
();
/**
* 去支付
* @return 跳转到的支付页面或二维码的url
*/
CallBack
<
String
>
toPay
(
ToPayForm
toPayForm
);
/**
* 查询是否支付
* @param out_trade_no 店铺订单号
* @return
* @author lw
* @date: 2019年1月15日 上午10:38:32
*/
CallBack
<
PayQueryReturnVo
>
query
(
String
out_trade_no
);
/**
* 退款
* @param refundForm
* @return
* @author lw
* @date: 2019年1月15日 上午10:54:09
*/
CallBack
<
Boolean
>
refund
(
RefundForm
refundForm
);
/**
* 退款查询
* @param refundQueryForm
* @return
* @author lw
* @date: 2019年1月15日 上午11:15:08
*/
CallBack
<
BaseRefundQueryReturnVo
>
refundQuery
(
RefundQueryForm
refundQueryForm
);
/**
* 关闭订单
* @param closeForm
* @return
* @author lw
* @date: 2019年1月15日 上午11:24:41
*/
CallBack
<
Boolean
>
close
(
CloseForm
closeForm
);
}
com.zrqx.third/src/main/java/com/zrqx/third/pay/interfaces/payType/impl/AliPayImpl.java
deleted
100644 → 0
浏览文件 @
25a8fd20
差异被折叠。
点击展开。
com.zrqx.third/src/main/java/com/zrqx/third/pay/interfaces/payType/impl/WeChatPayImpl.java
deleted
100644 → 0
浏览文件 @
25a8fd20
差异被折叠。
点击展开。
com.zrqx.third/src/main/java/com/zrqx/third/pay/interfaces/payType/impl/YeePayImpl.java
deleted
100644 → 0
浏览文件 @
25a8fd20
差异被折叠。
点击展开。
com.zrqx.third/src/main/java/com/zrqx/third/pay/utils/DigestUtil.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
pay
.
utils
;
import
java.io.UnsupportedEncodingException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.Arrays
;
public
class
DigestUtil
{
private
static
String
encodingCharset
=
"UTF-8"
;
/**
* @param aValue
* @param aKey
* @return
*/
public
static
String
hmacSign
(
String
aValue
,
String
aKey
)
{
byte
k_ipad
[]
=
new
byte
[
64
];
byte
k_opad
[]
=
new
byte
[
64
];
byte
keyb
[];
byte
value
[];
try
{
keyb
=
aKey
.
getBytes
(
encodingCharset
);
value
=
aValue
.
getBytes
(
encodingCharset
);
}
catch
(
UnsupportedEncodingException
e
)
{
keyb
=
aKey
.
getBytes
();
value
=
aValue
.
getBytes
();
}
Arrays
.
fill
(
k_ipad
,
keyb
.
length
,
64
,
(
byte
)
54
);
Arrays
.
fill
(
k_opad
,
keyb
.
length
,
64
,
(
byte
)
92
);
for
(
int
i
=
0
;
i
<
keyb
.
length
;
i
++)
{
k_ipad
[
i
]
=
(
byte
)
(
keyb
[
i
]
^
0x36
);
k_opad
[
i
]
=
(
byte
)
(
keyb
[
i
]
^
0x5c
);
}
MessageDigest
md
=
null
;
try
{
md
=
MessageDigest
.
getInstance
(
"MD5"
);
}
catch
(
NoSuchAlgorithmException
e
)
{
return
null
;
}
md
.
update
(
k_ipad
);
md
.
update
(
value
);
byte
dg
[]
=
md
.
digest
();
md
.
reset
();
md
.
update
(
k_opad
);
md
.
update
(
dg
,
0
,
16
);
dg
=
md
.
digest
();
return
toHex
(
dg
);
}
public
static
String
toHex
(
byte
input
[])
{
if
(
input
==
null
)
return
null
;
StringBuffer
output
=
new
StringBuffer
(
input
.
length
*
2
);
for
(
int
i
=
0
;
i
<
input
.
length
;
i
++)
{
int
current
=
input
[
i
]
&
0xff
;
if
(
current
<
16
)
output
.
append
(
"0"
);
output
.
append
(
Integer
.
toString
(
current
,
16
));
}
return
output
.
toString
();
}
/**
*
* @param args
* @param key
* @return
*/
public
static
String
getHmac
(
String
[]
args
,
String
key
)
{
if
(
args
==
null
||
args
.
length
==
0
)
{
return
(
null
);
}
StringBuffer
str
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
str
.
append
(
args
[
i
]);
}
return
(
hmacSign
(
str
.
toString
(),
key
));
}
/**
* 生成hmac_safe
* @param args
* @param key
* @return
*/
public
static
String
getHmac_safe
(
String
[]
args
,
String
key
)
{
if
(
args
==
null
||
args
.
length
==
0
)
{
return
(
null
);
}
StringBuffer
hmac_safe
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
args
[
i
].
length
()!=
0
&&!
args
[
i
].
equals
(
""
)){
hmac_safe
.
append
(
args
[
i
]).
append
(
"#"
);
}
}
hmac_safe
=
hmac_safe
.
deleteCharAt
(
hmac_safe
.
length
()-
1
);
System
.
out
.
println
(
"hmac_safe串: "
+
hmac_safe
.
toString
());
return
(
hmacSign
(
hmac_safe
.
toString
(),
key
));
}
/**
* @param aValue
* @return
*/
public
static
String
digest
(
String
aValue
)
{
aValue
=
aValue
.
trim
();
byte
value
[];
try
{
value
=
aValue
.
getBytes
(
encodingCharset
);
}
catch
(
UnsupportedEncodingException
e
)
{
value
=
aValue
.
getBytes
();
}
MessageDigest
md
=
null
;
try
{
md
=
MessageDigest
.
getInstance
(
"SHA"
);
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
return
null
;
}
return
toHex
(
md
.
digest
(
value
));
}
}
com.zrqx.third/src/main/java/com/zrqx/third/pay/utils/HttpUtils.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
pay
.
utils
;
import
java.io.BufferedReader
;
import
java.io.BufferedWriter
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.io.UnsupportedEncodingException
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.net.URLEncoder
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
/**
*
* <p>Title: </p>
* <p>Description: http utils </p>
* <p>Copyright: Copyright (c) 2006</p>
* <p>Company: </p>
* @author LiLu
* @version 1.0
*/
public
class
HttpUtils
{
private
static
final
String
URL_PARAM_CONNECT_FLAG
=
"&"
;
private
static
final
int
SIZE
=
1024
*
1024
;
private
static
Log
log
=
LogFactory
.
getLog
(
HttpUtils
.
class
);
private
HttpUtils
()
{
}
/**
* GET METHOD
* @param strUrl String
* @param map Map
* @throws IOException
* @return List
*/
public
static
List
URLGet
(
String
strUrl
,
Map
map
)
throws
IOException
{
String
strtTotalURL
=
""
;
List
result
=
new
ArrayList
();
if
(
strtTotalURL
.
indexOf
(
"?"
)
==
-
1
)
{
strtTotalURL
=
strUrl
+
"?"
+
getUrl
(
map
);
}
else
{
strtTotalURL
=
strUrl
+
"&"
+
getUrl
(
map
);
}
log
.
debug
(
"strtTotalURL:"
+
strtTotalURL
);
System
.
out
.
println
(
"strtTotalURL="
+
strtTotalURL
);
URL
url
=
new
URL
(
strtTotalURL
);
HttpURLConnection
con
=
(
HttpURLConnection
)
url
.
openConnection
();
con
.
setUseCaches
(
false
);
con
.
setFollowRedirects
(
true
);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
con
.
getInputStream
()),
SIZE
);
while
(
true
)
{
String
line
=
in
.
readLine
();
if
(
line
==
null
)
{
break
;
}
else
{
result
.
add
(
line
);
}
}
in
.
close
();
return
(
result
);
}
/**
* POST METHOD
* @param strUrl String
* @param content Map
* @throws IOException
* @return List
*/
public
static
List
URLPost
(
String
strUrl
,
Map
map
)
throws
IOException
{
String
content
=
""
;
content
=
getUrl
(
map
);
String
totalURL
=
null
;
if
(
strUrl
.
indexOf
(
"?"
)
==
-
1
)
{
totalURL
=
strUrl
+
"?"
+
content
;
}
else
{
totalURL
=
strUrl
+
"&"
+
content
;
}
System
.
out
.
println
(
"totalURL : "
+
totalURL
);
URL
url
=
new
URL
(
strUrl
);
HttpURLConnection
con
=
(
HttpURLConnection
)
url
.
openConnection
();
con
.
setDoInput
(
true
);
con
.
setDoOutput
(
true
);
con
.
setAllowUserInteraction
(
false
);
con
.
setUseCaches
(
false
);
con
.
setRequestMethod
(
"POST"
);
con
.
setRequestProperty
(
"Content-Type"
,
"application/x-www-form-urlencoded;charset=GBK"
);
BufferedWriter
bout
=
new
BufferedWriter
(
new
OutputStreamWriter
(
con
.
getOutputStream
()));
bout
.
write
(
content
);
bout
.
flush
();
bout
.
close
();
BufferedReader
bin
=
new
BufferedReader
(
new
InputStreamReader
(
con
.
getInputStream
()),
SIZE
);
List
result
=
new
ArrayList
();
while
(
true
)
{
String
line
=
bin
.
readLine
();
if
(
line
==
null
)
{
break
;
}
else
{
result
.
add
(
line
);
}
}
return
(
result
);
}
/**
* 锟斤拷锟経RL
* @param map Map
* @return String
*/
private
static
String
getUrl
(
Map
map
)
{
if
(
null
==
map
||
map
.
keySet
().
size
()
==
0
)
{
return
(
""
);
}
StringBuffer
url
=
new
StringBuffer
();
Set
keys
=
map
.
keySet
();
for
(
Iterator
i
=
keys
.
iterator
();
i
.
hasNext
();
)
{
String
key
=
String
.
valueOf
(
i
.
next
());
if
(
map
.
containsKey
(
key
))
{
Object
val
=
map
.
get
(
key
);
String
str
=
val
!=
null
?
val
.
toString
():
""
;
try
{
str
=
URLEncoder
.
encode
(
str
,
"GBK"
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
url
.
append
(
key
).
append
(
"="
).
append
(
str
).
append
(
URL_PARAM_CONNECT_FLAG
);
}
}
String
strURL
=
""
;
strURL
=
url
.
toString
();
if
(
URL_PARAM_CONNECT_FLAG
.
equals
(
""
+
strURL
.
charAt
(
strURL
.
length
()
-
1
)))
{
strURL
=
strURL
.
substring
(
0
,
strURL
.
length
()
-
1
);
}
return
(
strURL
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/qqlogin/QQLoginController.java
deleted
100644 → 0
浏览文件 @
25a8fd20
/**
* @author ray
* @date 2018年8月24日 下午3:30:26
*/
package
com
.
zrqx
.
third
.
qqlogin
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zrqx.core.client.vo.third.qqlogin.QQThirdReturn
;
import
com.zrqx.core.enums.ResponseCodeEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.third.qqlogin.config.QQLoginConfig
;
import
com.zrqx.third.util.HttpsUtils
;
import
com.zrqx.third.util.SplitUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
/**
* @author ray
* @date 2018年8月24日下午3:30:26
*/
@RestController
@RequestMapping
(
"/qq-login"
)
@Api
(
description
=
"qq登录"
)
public
class
QQLoginController
{
// @ApiOperation(value = "qq登录", notes = "QQ登录")
// @GetMapping(RequestPath.QUERY)
// public CallBack<QQThirdReturn> query(String openid,String accessToken) throws Exception{
// String appid=QQLoginConfig.APPID;
// //模拟get请求调用官方接口
// String param="access_token="+accessToken+"&openid="+openid+"&oauth_consumer_key="+appid;
// String result=HttpsUtils.sendGet("https://graph.qq.com/user/get_user_info", param);
// JSONObject object=(JSONObject)JSON.parse(result);
//
// //用户昵称
// String nickname=object.get("nickname").toString();
// //用户头像
// String headimgurl=object.get("figureurl_qq_1").toString();
//
// QQThirdReturn user=new QQThirdReturn();
// user.setOpenid(openid);
// user.setNickname(nickname);
// user.setHeadImgUrl(headimgurl);
// return CallBack.success(user);
// }
@ApiOperation
(
value
=
"qq登录"
,
notes
=
"QQ登录"
)
@GetMapping
(
"/query"
)
public
CallBack
<
QQThirdReturn
>
query
(
String
code
,
HttpServletRequest
request
)
throws
Exception
{
String
appid
=
QQLoginConfig
.
APPID
;
String
appkey
=
QQLoginConfig
.
APPKEY
;
String
redirectURI
=
QQLoginConfig
.
REDIRECTURI
;
//根据code获取Access Token
String
param1
=
"grant_type=authorization_code&client_id="
+
appid
+
"&client_secret="
+
appkey
+
"&code="
+
code
+
"&redirect_uri="
+
redirectURI
;
String
result1
=
HttpsUtils
.
sendGet
(
"https://graph.qq.com/oauth2.0/token"
,
param1
);
//正确返回形式 : access_token=986A0E8DE045BFD2B94689F6D7F3CFCD&expires_in=7776000&refresh_token=E476F1B911CE70E1F0C1A9B84EE181A7
//错误返回形式: callback( {"error":100019,"error_description":"code to access token error"} );
//判断是否是错误返回
if
(
result1
.
indexOf
(
"callback"
)>-
1
){
String
newResult1
=
result1
.
substring
(
result1
.
indexOf
(
"("
)+
1
,
result1
.
lastIndexOf
(
")"
));
JSONObject
object1
=(
JSONObject
)
JSON
.
parse
(
newResult1
);
throw
new
BaseException
(
ResponseCodeEnum
.
EXCEPTION
.
getCode
(),
object1
.
get
(
"error"
).
toString
());
}
//正确返回解析出 access_token
Map
<
String
,
String
>
map
=
SplitUtil
.
splitBody
(
result1
);
String
accessToken
=
map
.
get
(
"access_token"
);
//根据 Access Token 获取openid
String
param2
=
"access_token="
+
accessToken
;
String
result2
=
HttpsUtils
.
sendGet
(
"https://graph.qq.com/oauth2.0/me"
,
param2
);
String
newResult2
=
result2
.
substring
(
result2
.
indexOf
(
"("
)+
1
,
result2
.
lastIndexOf
(
")"
));
JSONObject
object2
=(
JSONObject
)
JSON
.
parse
(
newResult2
);
String
openid
=
object2
.
get
(
"openid"
).
toString
();
//获得用户详情
String
param
=
"access_token="
+
accessToken
+
"&openid="
+
openid
+
"&oauth_consumer_key="
+
appid
;
String
result
=
HttpsUtils
.
sendGet
(
"https://graph.qq.com/user/get_user_info"
,
param
);
JSONObject
object
=(
JSONObject
)
JSON
.
parse
(
result
);
//用户昵称
String
nickname
=
object
.
get
(
"nickname"
).
toString
();
//用户头像
String
headimgurl
=
object
.
get
(
"figureurl_qq_1"
).
toString
();
QQThirdReturn
user
=
new
QQThirdReturn
();
user
.
setOpenid
(
openid
);
user
.
setNickname
(
nickname
);
user
.
setHeadImgUrl
(
headimgurl
);
return
CallBack
.
success
(
user
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/qqlogin/config/QQLoginConfig.java
deleted
100644 → 0
浏览文件 @
25a8fd20
/**
* @author ray
* @date 2018年8月24日 下午3:29:56
*/
package
com
.
zrqx
.
third
.
qqlogin
.
config
;
/** qq登录
* @author ray
* @date 2018年8月24日下午3:29:56
*/
public
class
QQLoginConfig
{
/**
* appid
*/
public
final
static
String
APPID
=
"101239483"
;
//public final static String APPID = "101502595";
public
final
static
String
APPKEY
=
"380e85587c92d5c77c1e5c6101c167fa"
;
//public final static String APPKEY="786496018f7747d51efe6311df644cd4";
/**
* 回调地址
*/
public
final
static
String
REDIRECTURI
=
"http%3a%2f%2frsks.class.com.cn%2f%23%2findex"
;
//public final static String REDIRECTURI = "http%3a%2f%2frsks.class.com.cn%2ffg%2findex.html%23%2flogin";
}
com.zrqx.third/src/main/java/com/zrqx/third/sdksms/SdkSmsController.java
浏览文件 @
0c7e6cc7
package
com
.
zrqx
.
third
.
sdksms
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
...
...
@@ -11,22 +14,20 @@ import org.springframework.web.bind.annotation.RequestBody;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.zrqx.core.client.form.third.sdksms.SdkSmsForm
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.
util.encry.MD5Util
;
import
com.zrqx.core.
form.third.sdksms.SdkSmsForm
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.core.util.encry.MD5Util
;
import
com.zrqx.third.constant.RequestPath
;
import
com.zrqx.third.sdksms.config.SdkSmsConfig
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@RestController
@RequestMapping
(
"/sdksms"
)
@RequestMapping
(
RequestPath
.
SDKSMS
)
@Api
(
description
=
"sdk发送短信"
)
public
class
SdkSmsController
{
@ApiOperation
(
value
=
"sdk发送短信"
,
notes
=
"sdk发送短信"
)
@PostMapping
(
"/send"
)
@PostMapping
(
RequestPath
.
SEND
)
public
CallBack
<
String
>
send
(
@RequestBody
SdkSmsForm
ssf
)
{
//http://sdk.entinfo.cn:8061/mdsmssend.ashx?sn=SDK-XAR-010-00044&pwd=D86555F4EA11EFFA57E8F7DF7AAFFD3F&mobile=13716135661&content=测试【签名】&ext=&stime=&rrid=&msgfmt=
// 创建httpclient对象
...
...
@@ -36,6 +37,7 @@ public class SdkSmsController {
try
{
pwd
=
MD5Util
.
getEncoderByMd5
(
SdkSmsConfig
.
sn
+
SdkSmsConfig
.
pwd
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
throw
new
BaseException
(
"加密异常"
);
}
String
url
=
SdkSmsConfig
.
url
+
"sn="
+
SdkSmsConfig
.
sn
+
"&pwd="
+
pwd
+
"&mobile="
+
ssf
.
getMobile
()
+
"&content="
...
...
com.zrqx.third/src/main/java/com/zrqx/third/sms/ALiDaYuMessageUtil.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
sms
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.aliyuncs.CommonRequest
;
import
com.aliyuncs.CommonResponse
;
import
com.aliyuncs.DefaultAcsClient
;
import
com.aliyuncs.IAcsClient
;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.exceptions.ServerException
;
import
com.aliyuncs.http.MethodType
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.zrqx.core.client.form.third.sdksms.SdkSmsForm
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.third.commons.form.sms.SmsForm
;
import
com.zrqx.third.sms.config.ALiDaYuConfig
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
@RestController
@RequestMapping
(
"/alidayu"
)
@Api
(
description
=
"alidayu发送短信"
)
public
class
ALiDaYuMessageUtil
{
@ApiOperation
(
value
=
"sdk发送短信"
,
notes
=
"sdk发送短信"
)
@PostMapping
(
"/send"
)
public
CallBack
<
String
>
sendVarifyMessage
(
@RequestBody
SmsForm
ssf
)
{
String
result
=
""
;
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
ALiDaYuConfig
.
accessKeyId
,
ALiDaYuConfig
.
accessKeySecret
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
CommonRequest
request
=
new
CommonRequest
();
request
.
setMethod
(
MethodType
.
POST
);
request
.
setDomain
(
"dysmsapi.aliyuncs.com"
);
request
.
setVersion
(
"2017-05-25"
);
request
.
setAction
(
"SendSms"
);
request
.
putQueryParameter
(
"RegionId"
,
"cn-hangzhou"
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
ssf
.
getPhone
());
request
.
putQueryParameter
(
"SignName"
,
"北京中软启信技术有限公司"
);
request
.
putQueryParameter
(
"TemplateCode"
,
ssf
.
getCode
());
try
{
CommonResponse
response
=
client
.
getCommonResponse
(
request
);
System
.
out
.
println
(
response
.
getData
());
}
catch
(
ServerException
e
)
{
e
.
printStackTrace
();
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
}
/*
* try { //初始化acsClient,暂不支持region化 IClientProfile profile =
* DefaultProfile.getProfile("cn-hangzhou", ALiDaYuConfig.accessKeyId,
* ALiDaYuConfig.accessKeyId); DefaultProfile.addEndpoint("cn-hangzhou",
* "cn-hangzhou", ALiDaYuConfig.product, ALiDaYuConfig.domain); IAcsClient
* acsClient = new DefaultAcsClient(profile);
*
* //组装请求对象-具体描述见控制台-文档部分内容 SendSmsRequest request = new SendSmsRequest();
* //必填:待发送手机号 request.setPhoneNumbers(ssf.getMobile()); //必填:短信签名-可在短信控制台中找到
* request.setSignName("知了"); //必填:短信模板-可在短信控制台中找到 String msg = "{\"code\":\"" +
* ssf.getCode() + "\",\"product\":\""+ALiDaYuConfig.product+"\"}";
* request.setTemplateParam(msg); request.setTemplateCode("SMS_***");
*
* //request.setTemplateCode("SMS_***");
* //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
* //request.setTemplateParam("{\"name\":\"Tom\", \"code\":\"123\"}");
*
* //选填-上行短信扩展码(无特殊需求用户请忽略此字段) //request.setSmsUpExtendCode("90997");
*
* //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者 //request.setOutId("yourOutId");
*
* //hint 此处可能会抛出异常,注意catch SendSmsResponse sendSmsResponse =
* acsClient.getAcsResponse(request); if
* (sendSmsResponse.getCode().equals("OK")) { result = "0";//成功 } else { result
* = "1";//失败 } } catch (Exception e) { throw new BaseException("发送失败"); }
*/
return
CallBack
.
success
(
result
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/sms/SmsController.java
浏览文件 @
0c7e6cc7
...
...
@@ -19,8 +19,8 @@ import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import
com.aliyuncs.exceptions.ClientException
;
import
com.aliyuncs.profile.DefaultProfile
;
import
com.aliyuncs.profile.IClientProfile
;
import
com.zrqx.core.
client.
form.third.sms.SmsForm
;
import
com.zrqx.core.
client.
form.third.sms.SmsQueryForm
;
import
com.zrqx.core.form.third.sms.SmsForm
;
import
com.zrqx.core.form.third.sms.SmsQueryForm
;
import
com.zrqx.third.sms.config.SmsConfig
;
import
com.zrqx.third.sms.config.SmsEnum
;
...
...
com.zrqx.third/src/main/java/com/zrqx/third/wechatlogin/WeChatLoginController.java
deleted
100644 → 0
浏览文件 @
25a8fd20
/**
* @author ray
* @date 2018年8月24日 下午4:33:31
*/
package
com
.
zrqx
.
third
.
wechatlogin
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zrqx.core.client.vo.third.wechartlogin.WeChartThirdReturn
;
import
com.zrqx.core.enums.ResponseCodeEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.third.util.HttpsUtils
;
import
com.zrqx.third.wechatlogin.config.WeChatLoginConfig
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
/** 微信登录
* @author ray
* @date 2018年8月24日下午4:33:31
*/
@RestController
@RequestMapping
(
"/wechat-login"
)
@Api
(
description
=
"微信登录"
)
public
class
WeChatLoginController
{
@ApiOperation
(
value
=
"微信登录"
,
notes
=
"微信登录"
)
@GetMapping
(
"/query"
)
public
CallBack
<
WeChartThirdReturn
>
query
(
String
code
,
HttpServletRequest
request
)
throws
Exception
{
String
appid
=
"appid="
+
WeChatLoginConfig
.
APPID
;
String
secret
=
"&secret="
+
WeChatLoginConfig
.
SECRET
;
String
code1
=
"&code="
+
code
;
String
grant_type
=
"&grant_type="
+
WeChatLoginConfig
.
GRANT_TYPE
;
//调用微信接口获得openid和access_token
String
param
=
appid
+
secret
+
code1
+
grant_type
;
String
result
=
HttpsUtils
.
sendGet
(
"https://api.weixin.qq.com/sns/oauth2/access_token"
,
param
);
JSONObject
object
=
(
JSONObject
)
JSON
.
parse
(
result
);
//判断接口是否调用成功
if
(
object
.
containsKey
(
"errcode"
)){
throw
new
BaseException
(
ResponseCodeEnum
.
EXCEPTION
.
getCode
(),
object
.
get
(
"errcode"
).
toString
());
}
//唯一标识用户的 openId
String
openId
=
object
.
get
(
"openid"
).
toString
();
//凭证
String
access_token
=
object
.
get
(
"access_token"
).
toString
();
//调用微信接口获得用户信息
String
param1
=
"access_token="
+
access_token
+
"&openid="
+
openId
;
String
result1
=
HttpsUtils
.
sendGet
(
"https://api.weixin.qq.com/sns/userinfo"
,
param1
);
JSONObject
object1
=(
JSONObject
)
JSON
.
parse
(
result1
);
//判断接口是否调用成功
if
(
object1
.
containsKey
(
"errcode"
)){
throw
new
BaseException
(
ResponseCodeEnum
.
EXCEPTION
.
getCode
(),
object1
.
get
(
"errcode"
).
toString
());
}
//用户昵称
String
nickname
=
object1
.
get
(
"nickname"
).
toString
();
//用户头像
String
headimgurl
=
object1
.
get
(
"headimgurl"
).
toString
();
WeChartThirdReturn
user
=
new
WeChartThirdReturn
();
user
.
setOpenid
(
openId
);
user
.
setNickname
(
nickname
);
user
.
setHeadImgUrl
(
headimgurl
);
return
CallBack
.
success
(
user
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/wechatlogin/WeChatLoginWapController.java
deleted
100644 → 0
浏览文件 @
25a8fd20
/**
* @author ray
* @date 2018年9月7日 下午3:05:11
*/
package
com
.
zrqx
.
third
.
wechatlogin
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zrqx.core.client.vo.third.wechartlogin.WeChartThirdReturn
;
import
com.zrqx.core.enums.ResponseCodeEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.third.util.HttpsUtils
;
import
com.zrqx.third.wechatlogin.config.WeChatLoginWapConfig
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
/** 微信客户端内访问第三方页面授权登录
* @author ray
* @date 2018年9月7日下午3:05:11
*/
@RestController
@RequestMapping
(
"/wechat-wap-login"
)
@Api
(
description
=
"微信客户端内访问第三方页面授权登录"
)
public
class
WeChatLoginWapController
{
@ApiOperation
(
value
=
"微信登录"
,
notes
=
"微信登录"
)
@GetMapping
(
"/query"
)
public
CallBack
<
WeChartThirdReturn
>
query
(
String
code
,
HttpServletRequest
request
)
throws
Exception
{
String
appid
=
"appid="
+
WeChatLoginWapConfig
.
APPID
;
String
secret
=
"&secret="
+
WeChatLoginWapConfig
.
SECRET
;
String
code1
=
"&code="
+
code
;
String
grant_type
=
"&grant_type="
+
WeChatLoginWapConfig
.
GRANT_TYPE
;
//调用微信接口获得openid和access_token
String
param
=
appid
+
secret
+
code1
+
grant_type
;
String
result
=
HttpsUtils
.
sendGet
(
"https://api.weixin.qq.com/sns/oauth2/access_token"
,
param
);
JSONObject
object
=
(
JSONObject
)
JSON
.
parse
(
result
);
//判断接口是否调用成功
if
(
object
.
containsKey
(
"errcode"
)){
throw
new
BaseException
(
ResponseCodeEnum
.
EXCEPTION
.
getCode
(),
object
.
get
(
"errcode"
).
toString
());
}
//唯一标识用户的 openId
String
openId
=
object
.
get
(
"openid"
).
toString
();
//凭证
String
access_token
=
object
.
get
(
"access_token"
).
toString
();
//调用微信接口获得用户信息
String
param1
=
"access_token="
+
access_token
+
"&openid="
+
openId
;
String
result1
=
HttpsUtils
.
sendGet
(
"https://api.weixin.qq.com/sns/userinfo"
,
param1
);
JSONObject
object1
=(
JSONObject
)
JSON
.
parse
(
result1
);
//判断接口是否调用成功
if
(
object1
.
containsKey
(
"errcode"
)){
throw
new
BaseException
(
ResponseCodeEnum
.
EXCEPTION
.
getCode
(),
object1
.
get
(
"errcode"
).
toString
());
}
//用户昵称
String
nickname
=
object1
.
get
(
"nickname"
).
toString
();
//用户头像
String
headimgurl
=
object1
.
get
(
"headimgurl"
).
toString
();
WeChartThirdReturn
user
=
new
WeChartThirdReturn
();
user
.
setOpenid
(
openId
);
user
.
setNickname
(
nickname
);
user
.
setHeadImgUrl
(
headimgurl
);
return
CallBack
.
success
(
user
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/wechatlogin/WeChatLoginXcxController.java
deleted
100644 → 0
浏览文件 @
25a8fd20
/**
* @author ray
* @date 2018年8月24日 下午4:33:31
*/
package
com
.
zrqx
.
third
.
wechatlogin
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.http.server.RequestPath
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.zrqx.core.client.vo.third.wechartlogin.WeChartThirdReturn
;
import
com.zrqx.core.commons.form.wecharlogin.WecharXcxGetPhoneForm
;
import
com.zrqx.core.enums.ResponseCodeEnum
;
import
com.zrqx.core.exception.BaseException
;
import
com.zrqx.core.util.datatype.StringUtils
;
import
com.zrqx.core.util.response.CallBack
;
import
com.zrqx.third.util.HttpsUtils
;
import
com.zrqx.third.wechatlogin.config.WXCore
;
import
com.zrqx.third.wechatlogin.config.WeChatLoginXcxConfig
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
/** 微信登录
* @author ray
* @date 2018年8月24日下午4:33:31
*/
@RestController
@RequestMapping
(
"/wechat-xcx-login"
)
@Api
(
description
=
"微信登录"
)
public
class
WeChatLoginXcxController
{
@ApiOperation
(
value
=
"微信登录"
,
notes
=
"微信登录"
)
@GetMapping
(
"/query"
)
public
CallBack
<
WeChartThirdReturn
>
query
(
String
code
,
HttpServletRequest
request
)
throws
Exception
{
String
appid
=
"appid="
+
WeChatLoginXcxConfig
.
APPID
;
String
secret
=
"&secret="
+
WeChatLoginXcxConfig
.
SECRET
;
String
code1
=
"&code="
+
code
;
String
grant_type
=
"&grant_type="
+
WeChatLoginXcxConfig
.
GRANT_TYPE
;
//调用微信接口获得openid和access_token
String
param
=
appid
+
secret
+
code1
+
grant_type
;
String
result
=
HttpsUtils
.
sendGet
(
WeChatLoginXcxConfig
.
CODE2SESSION
,
param
);
JSONObject
object
=
(
JSONObject
)
JSON
.
parse
(
result
);
//判断接口是否调用成功
if
(
object
.
containsKey
(
"errcode"
)){
throw
new
BaseException
(
ResponseCodeEnum
.
EXCEPTION
.
getCode
(),
object
.
get
(
"errcode"
).
toString
());
}
//唯一标识用户的 openId
String
openId
=
object
.
get
(
"openid"
).
toString
();
//用户昵称
String
nickname
=
object
.
get
(
"nickname"
).
toString
();
//用户头像
String
headimgurl
=
object
.
get
(
"headimgurl"
).
toString
();
WeChartThirdReturn
user
=
new
WeChartThirdReturn
();
user
.
setOpenid
(
openId
);
user
.
setNickname
(
nickname
);
user
.
setHeadImgUrl
(
headimgurl
);
return
CallBack
.
success
(
user
);
}
//获取手机号,解密
@ApiOperation
(
value
=
"获取手机号"
,
notes
=
"获取手机号"
)
@PostMapping
(
"/get/phone"
)
private
CallBack
<
String
>
getPhoneNumber
(
@RequestBody
WecharXcxGetPhoneForm
form
){
String
appId
=
WeChatLoginXcxConfig
.
APPID
;
String
sessionKey
=
form
.
getSession_key
();
String
encryptedData
=
form
.
getEncryptedData
();
String
iv
=
form
.
getIv
();
String
str
=
WXCore
.
decrypt
(
appId
,
encryptedData
,
sessionKey
,
iv
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
str
);
String
phone
=
jsonObject
.
getString
(
"phoneNumber"
);
if
(
StringUtils
.
isBlank
(
phone
)){
return
CallBack
.
fail
(
"获取失败"
);
}
return
CallBack
.
success
(
phone
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/wechatlogin/config/AES.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
wechatlogin
.
config
;
import
java.security.AlgorithmParameters
;
import
java.security.InvalidAlgorithmParameterException
;
import
java.security.InvalidKeyException
;
import
java.security.Key
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchProviderException
;
import
java.security.Security
;
import
javax.crypto.BadPaddingException
;
import
javax.crypto.Cipher
;
import
javax.crypto.IllegalBlockSizeException
;
import
javax.crypto.NoSuchPaddingException
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
org.bouncycastle.jce.provider.BouncyCastleProvider
;
/**
* AES加密
*
*/
public
class
AES
{
public
static
boolean
initialized
=
false
;
/**
* AES解密
*
* @param content
* 密文
* @return
* @throws InvalidAlgorithmParameterException
* @throws NoSuchProviderException
*/
public
byte
[]
decrypt
(
byte
[]
content
,
byte
[]
keyByte
,
byte
[]
ivByte
)
throws
InvalidAlgorithmParameterException
{
initialize
();
try
{
Cipher
cipher
=
Cipher
.
getInstance
(
"AES/CBC/PKCS7Padding"
);
Key
sKeySpec
=
new
SecretKeySpec
(
keyByte
,
"AES"
);
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
sKeySpec
,
generateIV
(
ivByte
));
// 初始化
byte
[]
result
=
cipher
.
doFinal
(
content
);
return
result
;
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
}
catch
(
NoSuchPaddingException
e
)
{
e
.
printStackTrace
();
}
catch
(
InvalidKeyException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalBlockSizeException
e
)
{
e
.
printStackTrace
();
}
catch
(
BadPaddingException
e
)
{
e
.
printStackTrace
();
}
catch
(
NoSuchProviderException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
null
;
}
public
static
void
initialize
()
{
if
(
initialized
)
return
;
Security
.
addProvider
(
new
BouncyCastleProvider
());
initialized
=
true
;
}
// 生成iv
public
static
AlgorithmParameters
generateIV
(
byte
[]
iv
)
throws
Exception
{
AlgorithmParameters
params
=
AlgorithmParameters
.
getInstance
(
"AES"
);
params
.
init
(
new
IvParameterSpec
(
iv
));
return
params
;
}
}
com.zrqx.third/src/main/java/com/zrqx/third/wechatlogin/config/WXCore.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
wechatlogin
.
config
;
import
org.apache.commons.codec.binary.Base64
;
import
com.alibaba.fastjson.JSONObject
;
/**
* 封装对外访问方法
*
*/
public
class
WXCore
{
private
static
final
String
WATERMARK
=
"watermark"
;
private
static
final
String
APPID
=
"appid"
;
/**
* 解密数据
* @return
* @throws Exception
*/
public
static
String
decrypt
(
String
appId
,
String
encryptedData
,
String
sessionKey
,
String
iv
){
String
result
=
""
;
try
{
AES
aes
=
new
AES
();
byte
[]
resultByte
=
aes
.
decrypt
(
Base64
.
decodeBase64
(
encryptedData
),
Base64
.
decodeBase64
(
sessionKey
),
Base64
.
decodeBase64
(
iv
));
if
(
null
!=
resultByte
&&
resultByte
.
length
>
0
){
result
=
new
String
(
WxPKCS7Encoder
.
decode
(
resultByte
));
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
result
);
String
decryptAppid
=
jsonObject
.
getJSONObject
(
WATERMARK
).
getString
(
APPID
);
if
(!
appId
.
equals
(
decryptAppid
)){
result
=
""
;
}
}
}
catch
(
Exception
e
)
{
result
=
""
;
e
.
printStackTrace
();
}
return
result
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
appId
=
"wx8be2cb2a503c6bad"
;
String
encryptedData
=
"rxOMA/+mOM+O1TL4ami24Ek4oh1HVKaDWhrLdHRHKqldw0M8HK46VD1YcOGJPBedH2D8zyKR4dx5gmNmcF1W42tHwhd+Q7jFxZ0HuIPdZcKaQ8LVl1ADLemoqHVeErheoICBySxiEHEuwVwV4BfiBpzDnprDrXfqJAUsRpN6TqdCqzmBJyZhO5sV13wRCGXXe8QuFbPomMuj75OqY5NC/w=="
;
String
sessionKey
=
"G/VGyQV+yt7kE8fCtuBsMA=="
;
String
iv
=
"OZ8lmwEyzueW92osjXGJgA=="
;
String
str
=
decrypt
(
appId
,
encryptedData
,
sessionKey
,
iv
);
System
.
out
.
println
(
str
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
str
);
String
phoneNumber
=
jsonObject
.
getString
(
"phoneNumber"
);
System
.
out
.
println
(
phoneNumber
);
}
}
com.zrqx.third/src/main/java/com/zrqx/third/wechatlogin/config/WeChatLoginConfig.java
deleted
100644 → 0
浏览文件 @
25a8fd20
/**
* @author ray
* @date 2018年8月24日 下午4:44:24
*/
package
com
.
zrqx
.
third
.
wechatlogin
.
config
;
/**
* @author ray
* @date 2018年8月24日下午4:44:24
*/
public
class
WeChatLoginConfig
{
// appid 应用唯一标识
public
final
static
String
APPID
=
"wx08cb076475201636"
;
//密钥AppSecret
public
final
static
String
SECRET
=
"b0ff9c17ec7d6ae540e517fdb8fa1228"
;
//固定值 填写 authorization_code
public
final
static
String
GRANT_TYPE
=
"authorization_code"
;
// 固定值 填写code
public
final
static
String
RESPONSE_TYPE
=
"code"
;
// 固定值 填写snsapi_login
public
final
static
String
SCOPE
=
"snsapi_login"
;
//回调域
public
final
static
String
REDIRECTURI
=
"rsks.class.com.cn"
;
}
com.zrqx.third/src/main/java/com/zrqx/third/wechatlogin/config/WeChatLoginWapConfig.java
deleted
100644 → 0
浏览文件 @
25a8fd20
/**
* @author ray
* @date 2018年9月7日 下午2:48:04
*/
package
com
.
zrqx
.
third
.
wechatlogin
.
config
;
/**
* @author ray
* @date 2018年9月7日下午2:48:04
*/
public
class
WeChatLoginWapConfig
{
// appid 应用唯一标识
public
final
static
String
APPID
=
"wxdee4149de87badc3"
;
//public final static String APPID = "wx7b8af63db794b9be";
//密钥AppSecret
public
final
static
String
SECRET
=
"5b9b0597f3c8aacb00dd54ea51eb05c3"
;
//public final static String SECRET = "2d5b7993d880c5250b967893635824e4";
//固定值 填写 authorization_code
public
final
static
String
GRANT_TYPE
=
"authorization_code"
;
// 固定值 填写code
public
final
static
String
RESPONSE_TYPE
=
"code"
;
// 固定值 填写snsapi_login
public
final
static
String
SCOPE
=
"snsapi_login"
;
//回调域
public
final
static
String
REDIRECTURI
=
" "
;
}
com.zrqx.third/src/main/java/com/zrqx/third/wechatlogin/config/WeChatLoginXcxConfig.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
wechatlogin
.
config
;
public
class
WeChatLoginXcxConfig
{
// appid 应用唯一标识
public
final
static
String
APPID
=
"wx8be2cb2a503c6bad"
;
//密钥AppSecret
public
final
static
String
SECRET
=
"ea31181b8ee6714a3fc9f2462eef7bb8"
;
//固定值 填写 authorization_code
public
final
static
String
GRANT_TYPE
=
"authorization_code"
;
// 微信小程序登录接口
public
final
static
String
CODE2SESSION
=
"https://api.weixin.qq.com/sns/jscode2session"
;
//回调域
public
final
static
String
REDIRECTURI
=
"rsks.class.com.cn"
;
public
static
String
getParam
(
String
code
)
{
String
appid
=
"appid="
+
WeChatLoginXcxConfig
.
APPID
;
String
secret
=
"&secret="
+
WeChatLoginXcxConfig
.
SECRET
;
String
code1
=
"&js_code="
+
code
;
String
grant_type
=
"&grant_type="
+
WeChatLoginXcxConfig
.
GRANT_TYPE
;
String
param
=
appid
+
secret
+
code1
+
grant_type
;
return
param
;
}
}
com.zrqx.third/src/main/java/com/zrqx/third/wechatlogin/config/WxPKCS7Encoder.java
deleted
100644 → 0
浏览文件 @
25a8fd20
package
com
.
zrqx
.
third
.
wechatlogin
.
config
;
import
java.nio.charset.Charset
;
import
java.util.Arrays
;
/**
* 微信小程序加解密
*
*/
public
class
WxPKCS7Encoder
{
private
static
final
Charset
CHARSET
=
Charset
.
forName
(
"utf-8"
);
private
static
final
int
BLOCK_SIZE
=
32
;
/**
* 获得对明文进行补位填充的字节.
*
* @param count
* 需要进行填充补位操作的明文字节个数
* @return 补齐用的字节数组
*/
public
static
byte
[]
encode
(
int
count
)
{
// 计算需要填充的位数
int
amountToPad
=
BLOCK_SIZE
-
(
count
%
BLOCK_SIZE
);
if
(
amountToPad
==
0
)
{
amountToPad
=
BLOCK_SIZE
;
}
// 获得补位所用的字符
char
padChr
=
chr
(
amountToPad
);
String
tmp
=
new
String
();
for
(
int
index
=
0
;
index
<
amountToPad
;
index
++)
{
tmp
+=
padChr
;
}
return
tmp
.
getBytes
(
CHARSET
);
}
/**
* 删除解密后明文的补位字符
*
* @param decrypted
* 解密后的明文
* @return 删除补位字符后的明文
*/
public
static
byte
[]
decode
(
byte
[]
decrypted
)
{
int
pad
=
decrypted
[
decrypted
.
length
-
1
];
if
(
pad
<
1
||
pad
>
32
)
{
pad
=
0
;
}
return
Arrays
.
copyOfRange
(
decrypted
,
0
,
decrypted
.
length
-
pad
);
}
/**
* 将数字转化成ASCII码对应的字符,用于对明文进行补码
*
* @param a
* 需要转化的数字
* @return 转化得到的字符
*/
public
static
char
chr
(
int
a
)
{
byte
target
=
(
byte
)
(
a
&
0xFF
);
return
(
char
)
target
;
}
}
com.zrqx.third/src/main/resources/application.yml
浏览文件 @
0c7e6cc7
...
...
@@ -14,9 +14,6 @@ hystrix:
timeoutInMilliseconds
:
120000
mybatis
:
type-aliases-package
:
com.zrqx.core.model
configuration
:
default-scripting-language
:
com.zrqx.core.mapper.SqlXMLLanguageDriver
mapper
:
mappers
:
-
com.zrqx.core.mapper.BaseMapper
...
...
com.zrqx.third/src/main/resources/bootstrap.yml
浏览文件 @
0c7e6cc7
...
...
@@ -3,7 +3,7 @@ server:
spring
:
cloud
:
config
:
uri
:
http://localhost:8688
#配置中心地址
name
:
third
profile
:
prod
label
:
master
\ No newline at end of file
uri
:
http://localhost:8688
#配置中心地址
name
:
third
profile
:
prod
label
:
master
\ No newline at end of file
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论