Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hls-support-rlwx
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rl
hls-support-rlwx
Commits
7b2af1cc
Commit
7b2af1cc
authored
Apr 21, 2022
by
胡建龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20220415 未整理接口
parent
95a9ed4a
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
359 additions
and
8 deletions
+359
-8
pom.xml
core/pom.xml
+1
-0
HclcCmbPolyController.java
.../main/java/com/cmb/controllers/HclcCmbPolyController.java
+37
-0
HclcCmbPolyService.java
core/src/main/java/com/cmb/service/HclcCmbPolyService.java
+5
-0
HclcCmbPolyServiceImpl.java
...ain/java/com/cmb/service/impl/HclcCmbPolyServiceImpl.java
+207
-4
GenerateUtil.java
core/src/main/java/com/cmb/util/GenerateUtil.java
+90
-0
Pojo.java
core/src/main/java/com/cmb/util/Pojo.java
+5
-0
SignatureUtil.java
core/src/main/java/com/cmb/util/SignatureUtil.java
+14
-4
No files found.
core/pom.xml
View file @
7b2af1cc
...
...
@@ -264,6 +264,7 @@
<groupId>
org.bouncycastle
</groupId>
<artifactId>
bcprov-jdk15on
</artifactId>
<version>
1.65.01
</version>
<!-- <version>1.47</version>-->
<scope>
system
</scope>
<systemPath>
${project.basedir}/src/main/webapp/WEB-INF/lib/bcprov-jdk15on-1.65.01.jar
...
...
core/src/main/java/com/cmb/controllers/HclcCmbPolyController.java
View file @
7b2af1cc
...
...
@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Map
;
/*
* 〈〉
...
...
@@ -53,4 +54,40 @@ public class HclcCmbPolyController extends BaseController {
return
jsonResult
;
}
/**
* 主动请求订单状态结果
* @param request
* @param params
* @return
*/
@ResponseBody
@RequestMapping
(
"/cmb/poly/query/order/status"
)
public
JSONObject
queryOrderStatus
(
HttpServletRequest
request
,
@RequestBody
(
required
=
true
)
JSONObject
params
)
{
JSONObject
jsonResult
=
new
JSONObject
();
IRequest
iRequest
=
createRequestContext
(
request
);
jsonResult
=
hclcCmbPolyService
.
queryOrderStatus
(
iRequest
,
params
);
return
jsonResult
;
}
/**
* 暴露出去的回调地址,被动获取订单状态结果
* @param request
* @param params
* @return
*/
@ResponseBody
@RequestMapping
(
"/cmb/poly/order/notify"
)
public
Map
<
String
,
String
>
orderStatusNotify
(
HttpServletRequest
request
,
@RequestBody
(
required
=
true
)
JSONObject
params
)
{
IRequest
iRequest
=
createRequestContext
(
request
);
return
hclcCmbPolyService
.
orderNotify
(
iRequest
,
params
);
}
//订单关闭 4.7.1
}
\ No newline at end of file
core/src/main/java/com/cmb/service/HclcCmbPolyService.java
View file @
7b2af1cc
...
...
@@ -3,9 +3,14 @@ package com.cmb.service;
import
com.alibaba.fastjson.JSONObject
;
import
com.hand.hap.core.IRequest
;
import
java.util.Map
;
public
interface
HclcCmbPolyService
{
JSONObject
getQrcode
(
IRequest
iRequest
,
JSONObject
params
);
JSONObject
queryOrderStatus
(
IRequest
iRequest
,
JSONObject
params
);
Map
orderNotify
(
IRequest
iRequest
,
JSONObject
params
);
}
core/src/main/java/com/cmb/service/impl/HclcCmbPolyServiceImpl.java
View file @
7b2af1cc
This diff is collapsed.
Click to expand it.
core/src/main/java/com/cmb/util/GenerateUtil.java
0 → 100644
View file @
7b2af1cc
package
com
.
cmb
.
util
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Value
;
import
java.util.HashMap
;
import
java.util.Map
;
//构造请求报文工具类
public
class
GenerateUtil
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
GenerateUtil
.
class
);
@Value
(
"${cmb.version}"
)
private
static
String
version
;
@Value
(
"${cmb.encoding}"
)
private
static
String
encoding
;
@Value
(
"${cmb.signMethod}"
)
private
static
String
signMethod
;
public
static
final
String
privateKey
=
"D5F2AFA24E6BA9071B54A8C9AD735F9A1DE9C4657FA386C09B592694BC118B38"
;
public
static
final
String
publicKey
=
"MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE6Q+fktsnY9OFP+LpSR5Udbxf5zHCFO0PmOKlFNTxDIGl8jsPbbB/9ET23NV+acSz4FEkzD74sW2iiNVHRLiKHg=="
;
public
static
String
initRequestParam
(
Pojo
pojo
){
//设置公共请求参数
Map
<
String
,
String
>
resultPublicParam
=
new
HashMap
<>();
resultPublicParam
.
put
(
"version"
,
version
);
resultPublicParam
.
put
(
"encoding"
,
encoding
);
resultPublicParam
.
put
(
"sign_method"
,
signMethod
);
//初始化业务请求参数
try
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
String
bizContent
=
objectMapper
.
writeValueAsString
(
pojo
);
System
.
out
.
println
(
bizContent
);
resultPublicParam
.
put
(
"biz_content"
,
bizContent
);
//对待加签内容进行排序拼接
String
signStr
=
SignatureUtil
.
getSignContent
(
resultPublicParam
);
//加签
String
sign
=
SM2Util
.
sm2Sign
(
signStr
,
privateKey
);
resultPublicParam
.
put
(
"sign"
,
sign
);
String
requestStr
=
objectMapper
.
writeValueAsString
(
resultPublicParam
);
LOGGER
.
info
(
"加签后的报文内容:"
+
requestStr
);
return
requestStr
;
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
return
null
;
}
}
/**
* 处理响应报文
* @param responseMap
* @return
*/
public
static
void
handleResponse
(
Map
<
String
,
String
>
responseMap
){
if
(
null
==
responseMap
){
LOGGER
.
equals
(
"响应的内容为空"
);
return
;
}
try
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
LOGGER
.
info
(
"收到响应的内容为:"
+
objectMapper
.
writeValueAsString
(
responseMap
));
//验签
String
sign
=
responseMap
.
remove
(
"sign"
);
//生成验签字符串
String
signStr
=
SignatureUtil
.
getSignContent
(
responseMap
);
boolean
flag
=
SM2Util
.
sm2Check
(
signStr
,
sign
,
publicKey
);
if
(
flag
){
LOGGER
.
info
(
"验签成功!"
);
}
else
{
LOGGER
.
error
(
"验签失败!"
);
}
return
;
}
catch
(
Exception
ex
){
LOGGER
.
equals
(
"系统异常"
);
return
;
}
}
}
core/src/main/java/com/cmb/util/Pojo.java
0 → 100644
View file @
7b2af1cc
package
com
.
cmb
.
util
;
public
class
Pojo
{
public
Pojo
(){}
}
core/src/main/java/com/cmb/util/SignatureUtil.java
View file @
7b2af1cc
...
...
@@ -5,10 +5,8 @@ package com.cmb.util;
import
org.apache.commons.codec.binary.Base64
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.*
;
import
java.net.URLDecoder
;
import
java.nio.charset.Charset
;
import
java.security.KeyFactory
;
import
java.security.PrivateKey
;
...
...
@@ -87,6 +85,18 @@ public class SignatureUtil {
return
content
.
toString
();
}
public
static
String
decode
(
String
str
)
{
String
result
=
null
;
if
(
str
!=
null
)
{
try
{
result
=
URLDecoder
.
decode
(
str
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
var4
)
{
throw
new
RuntimeException
(
var4
);
}
}
return
result
;
}
public
static
boolean
rsaCheck
(
String
content
,
String
sign
,
String
publicKey
,
String
charset
)
throws
Exception
{
try
{
PublicKey
pubKey
=
getPublicKeyFromX509
(
"RSA"
,
new
ByteArrayInputStream
(
publicKey
.
getBytes
()));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment