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
e4df144b
Commit
e4df144b
authored
Apr 27, 2022
by
胡建龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
20220427 封装cmb.properties文件
parent
b014a6af
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
100 deletions
+108
-100
HclcCmbPolyServiceImpl.java
...com/hand/app/cmb/service/impl/HclcCmbPolyServiceImpl.java
+46
-97
Utils.java
core/src/main/java/com/hand/app/cmb/util/Utils.java
+35
-3
cmb.properties
core/src/main/resources/cmb.properties
+27
-0
No files found.
core/src/main/java/com/hand/app/cmb/service/impl/HclcCmbPolyServiceImpl.java
View file @
e4df144b
...
...
@@ -36,20 +36,14 @@ import java.util.stream.Collectors;
@Service
public
class
HclcCmbPolyServiceImpl
implements
HclcCmbPolyService
{
private
static
final
String
url
=
"https://api.cmburl.cn:8065/polypay/v1.0/mchorders/qrcodeapply"
;
//UAT
private
static
final
String
closeUrl
=
"https://api.cmburl.cn:8065/polypay/v1.0/mchorders/qrcodeapply"
;
//UAT
private
static
final
String
queryUrl
=
"https://api.cmburl.cn:8065/polypay/v1.0/mchorders/orderquery"
;
//uat环境商户国密私钥
public
static
final
String
privateKey
=
"D5F2AFA24E6BA9071B54A8C9AD735F9A1DE9C4657FA386C09B592694BC118B38"
;
//uat环境招行国密公钥
public
static
final
String
publicKey
=
"MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE6Q+fktsnY9OFP+LpSR5Udbxf5zHCFO0PmOKlFNTxDIGl8jsPbbB/9ET23NV+acSz4FEkzD74sW2iiNVHRLiKHg=="
;
public
static
final
String
appId
=
"8ab74856-8772-45c9-96db-54cb30ab9f74"
;
public
static
final
String
appSecret
=
"5b96f20a-011f-4254-8be8-9a5ceb2f317f"
;
static
{
String
path
=
Thread
.
currentThread
().
getContextClassLoader
().
getResource
(
""
).
getPath
().
substring
(
1
);
Properties
pro
=
Utils
.
loadProp
(
path
+
"cmb.properties"
);
if
(
Objects
.
isNull
(
pro
)){
LoggerFactory
.
getLogger
(
HclcCmbPolyServiceImpl
.
class
).
error
(
"配置文件初始化异常"
);
}
}
/*接口区分*/
public
static
final
String
getQrCode
=
"GET_QR_CODE"
;
public
static
final
String
queryQrState
=
"QUERY_QR_STATE"
;
...
...
@@ -69,21 +63,6 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
public
static
final
String
orderCancel
=
"C"
;
public
static
final
String
orderPass
=
"P"
;
@Value
(
"${cmb.version}"
)
private
String
version
;
@Value
(
"${cmb.encoding}"
)
private
String
encoding
;
@Value
(
"${cmb.signMethod}"
)
private
String
signMethod
;
/*币种,非必传,默认156人民币*/
@Value
(
"${cmb.currencyCode}"
)
private
String
currencyCode
;
@Value
(
"${cmb.user.id}"
)
private
String
cmbUserId
;
@Value
(
"${cmb.mer.id}"
)
private
String
cmbMerId
;
@Autowired
private
HlsEbankCcbTransactionMapper
hlsEbankCcbTransactionMapper
;
...
...
@@ -97,6 +76,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
private
HlsEbankCmbTransqryMapper
hlsEbankCmbTransqryMapper
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
private
static
Properties
pro
=
null
;
@Override
public
JSONObject
getQrcode
(
IRequest
iRequest
,
JSONObject
params
)
{
...
...
@@ -152,8 +132,8 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
// 组apiSign加密Map
Map
<
String
,
String
>
apiSign
=
new
TreeMap
<>();
apiSign
.
put
(
"appid"
,
appId
);
apiSign
.
put
(
"secret"
,
appSecret
);
apiSign
.
put
(
"appid"
,
pro
.
getProperty
(
"cmb.appId"
)
);
apiSign
.
put
(
"secret"
,
pro
.
getProperty
(
"cmb.appSecret"
)
);
apiSign
.
put
(
"sign"
,
signResultMap
.
get
(
"sign"
));
apiSign
.
put
(
"timestamp"
,
""
+
currentTimeMills
);
...
...
@@ -163,17 +143,17 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
// 组request头部Map
Map
<
String
,
String
>
apiHeader
=
new
HashMap
<>();
apiHeader
.
put
(
"appid"
,
appId
);
apiHeader
.
put
(
"appid"
,
pro
.
getProperty
(
"cmb.appId"
)
);
apiHeader
.
put
(
"timestamp"
,
""
+
currentTimeMills
);
apiHeader
.
put
(
"apisign"
,
apiSignString
);
//初始化日志
HlsWsRequests
hlsWsRequests
=
logInterfaceRequest
(
getQrCode
,
url
,
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
HlsWsRequests
hlsWsRequests
=
logInterfaceRequest
(
getQrCode
,
pro
.
getProperty
(
"qrCodeapplyUrl"
)
,
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
logger
.
info
(
"发送收款码申请请求,请求参数: {}"
,
mapper
.
writeValueAsString
(
apiHeader
));
try
{
// 发送HTTP post请求
response
=
Utils
.
postForEntity
(
url
,
signResult
,
apiHeader
);
response
=
Utils
.
postForEntity
(
pro
.
getProperty
(
"cmb.qrCodeapplyUrl"
)
,
signResult
,
apiHeader
);
//处理接口日志
logger
.
info
(
"收款码申请返回结果:"
+
mapper
.
writeValueAsString
(
response
));
...
...
@@ -352,9 +332,9 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//生成招行扫码交易业务批次数据
private
HlsEbankCcbTransaction
createTransaction
(
IRequest
iRequest
,
Ld037
ld037
)
{
HlsEbankCcbTransaction
ccbTransaction
=
new
HlsEbankCcbTransaction
();
ccbTransaction
.
setMerId
(
"3089991701201D0"
);
ccbTransaction
.
setVersion
(
"0.0.1"
);
ccbTransaction
.
setUserId
(
"N003574551"
);
ccbTransaction
.
setMerId
(
pro
.
getProperty
(
"cmb.mer.id"
)
);
ccbTransaction
.
setVersion
(
pro
.
getProperty
(
"cmb.version"
)
);
ccbTransaction
.
setUserId
(
pro
.
getProperty
(
"cmb.user.id"
)
);
ccbTransaction
.
setStatus
(
transNew
);
ccbTransaction
.
setBankType
(
"CMB"
);
ccbTransaction
.
setCount
(
1L
);
...
...
@@ -383,9 +363,9 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
String
requestStr
=
null
;
try
{
//公共请求参数
requestPublicParams
.
put
(
"version"
,
version
);
//版本号,固定为0.0.1(必传字段)
requestPublicParams
.
put
(
"encoding"
,
encoding
);
//编码方式,固定为UTF-8(必传)
requestPublicParams
.
put
(
"signMethod"
,
signMethod
);
//签名方法,固定为02,表示签名方式为国密(必传)
requestPublicParams
.
put
(
"version"
,
pro
.
getProperty
(
"cmb.version"
)
);
//版本号,固定为0.0.1(必传字段)
requestPublicParams
.
put
(
"encoding"
,
pro
.
getProperty
(
"cmb.encoding"
)
);
//编码方式,固定为UTF-8(必传)
requestPublicParams
.
put
(
"signMethod"
,
pro
.
getProperty
(
"cmb.signMethod"
)
);
//签名方法,固定为02,表示签名方式为国密(必传)
//业务要素
Map
<
String
,
String
>
requestTransactionParams
=
new
HashMap
<>();
...
...
@@ -393,14 +373,14 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
requestTransactionParams
.
put
(
"orderId"
,
hlsEbankCcbTransaction
.
getTransactionNumber
());
//商户订单号(必传)
requestTransactionParams
.
put
(
"userId"
,
hlsEbankCcbTransaction
.
getUserId
());
//收银员
// requestTransactionParams.put("termId", "00774411"); //终端号
requestTransactionParams
.
put
(
"payValidTime"
,
"900"
);
//支付有效时间,默认15分钟
requestTransactionParams
.
put
(
"notifyUrl"
,
"http://sign.hitachics.com/core/api/public/cmb/get/qr/code/listen"
);
//交易通知地址(必传)
requestTransactionParams
.
put
(
"mchReserved"
,
ld037
.
getId
().
toString
());
//
交易通知地址(必传)
requestTransactionParams
.
put
(
"payValidTime"
,
pro
.
getProperty
(
"cmb.payValidTime"
)
);
//支付有效时间,默认15分钟
requestTransactionParams
.
put
(
"notifyUrl"
,
pro
.
getProperty
(
"cmb.notifyUrl"
)
);
//交易通知地址(必传)
requestTransactionParams
.
put
(
"mchReserved"
,
ld037
.
getId
().
toString
());
//
保留字段
BigDecimal
a1
=
new
BigDecimal
(
Double
.
toString
(
hlsEbankCcbTransaction
.
getAmount
()));
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
100
));
requestTransactionParams
.
put
(
"txnAmt"
,
a1
.
multiply
(
b1
).
stripTrailingZeros
().
toPlainString
());
//交易金额,单位为分(必传)
requestTransactionParams
.
put
(
"currencyCode"
,
currencyCode
);
//交易币种,默认156,目前只支持人民币(156)
requestTransactionParams
.
put
(
"currencyCode"
,
pro
.
getProperty
(
"cmb.currencyCode"
)
);
//交易币种,默认156,目前只支持人民币(156)
// requestTransactionParams.put("body", "聚合支付测试"); //商户号(必传)
//商户保留域
...
...
@@ -416,7 +396,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//对待加签内容进行排序拼接
String
signContent
=
SignatureUtil
.
getSignContent
(
requestPublicParams
);
//加签
requestPublicParams
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
privateKey
));
requestPublicParams
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
pro
.
getProperty
(
"cmb.privateKey"
)
));
requestStr
=
mapper
.
writeValueAsString
(
requestPublicParams
);
logger
.
info
(
"收款码申请加签后的报文内容:"
+
requestStr
);
...
...
@@ -437,7 +417,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
Map
<
String
,
String
>
responseBodyMap
=
objectMapper
.
readValue
(
string
,
Map
.
class
);
String
sign
=
responseBodyMap
.
remove
(
"sign"
);
String
contentStr
=
SignatureUtil
.
getSignContent
(
responseBodyMap
);
boolean
result
=
SM2Util
.
sm2Check
(
contentStr
,
sign
,
p
ublicKey
);
boolean
result
=
SM2Util
.
sm2Check
(
contentStr
,
sign
,
p
ro
.
getProperty
(
"cmb.publicKey"
)
);
if
(
result
)
{
System
.
out
.
println
(
"报文验签成功!"
);
...
...
@@ -452,29 +432,6 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
}
private
Properties
loadProp
(
String
propPath
)
{
Properties
props
=
new
Properties
();
FileInputStream
is
=
null
;
try
{
is
=
new
FileInputStream
(
propPath
);
props
.
load
(
is
);
return
props
;
}
catch
(
Exception
var13
)
{
LogUtil
.
writeErrorLog
(
"加载配置文件失败"
,
var13
);
}
finally
{
if
(
is
!=
null
)
{
try
{
is
.
close
();
}
catch
(
IOException
var12
)
{
;
}
}
}
return
null
;
}
public
HlsWsRequests
logInterfaceRequest
(
String
functionName
,
String
url
,
String
request
,
Long
pkValue
)
{
HlsWsRequests
hlsWsRequests
=
new
HlsWsRequests
();
...
...
@@ -510,7 +467,6 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//返回结果标志
String
resultType
=
null
;
JSONObject
result
=
new
JSONObject
();
final
String
url
=
"https://api.cmburl.cn:8065/polypay/v1.0/mchorders/orderquery"
;
HlsEbankCmbTransqry
hlsEbankCmbTransqry
=
new
HlsEbankCmbTransqry
();
//去ld037中查找对应的记录的receiptcfmstatus,
if
(
Objects
.
isNull
(
params
.
get
(
"recamt_id"
)))
{
...
...
@@ -554,8 +510,8 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
// 组apiSign加密Map
Map
<
String
,
String
>
apiSign
=
new
TreeMap
<>();
apiSign
.
put
(
"appid"
,
appId
);
apiSign
.
put
(
"secret"
,
appSecret
);
apiSign
.
put
(
"appid"
,
pro
.
getProperty
(
"cmb.appId"
)
);
apiSign
.
put
(
"secret"
,
pro
.
getProperty
(
"cmb.appSecret"
)
);
apiSign
.
put
(
"sign"
,
signResultMap
.
get
(
"sign"
));
apiSign
.
put
(
"timestamp"
,
""
+
currentTimeMills
);
...
...
@@ -565,14 +521,14 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
// 组request头部Map
Map
<
String
,
String
>
apiHeader
=
new
HashMap
<>();
apiHeader
.
put
(
"appid"
,
appId
);
apiHeader
.
put
(
"appid"
,
pro
.
getProperty
(
"cmb.appId"
)
);
apiHeader
.
put
(
"timestamp"
,
""
+
currentTimeMills
);
apiHeader
.
put
(
"apisign"
,
apiSignString
);
hlsWsRequests
=
logInterfaceRequest
(
queryQrState
,
url
,
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
hlsWsRequests
=
logInterfaceRequest
(
queryQrState
,
pro
.
getProperty
(
"cmb.orderQueryUrl"
)
,
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
//发送http请求
responseMap
=
Utils
.
postForEntity
(
url
,
signResult
,
apiHeader
);
responseMap
=
Utils
.
postForEntity
(
queryQrState
,
signResult
,
apiHeader
);
if
(
null
==
responseMap
){
resultType
=
"3"
;
logger
.
info
(
"响应的内容为空"
);
...
...
@@ -659,9 +615,9 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
String
requestStr
=
null
;
try
{
//公共请求参数
requestPublicParams
.
put
(
"version"
,
"0.0.1"
);
//版本号,固定为0.0.1(必传字段)
requestPublicParams
.
put
(
"encoding"
,
"UTF-8"
);
//编码方式,固定为UTF-8(必传)
requestPublicParams
.
put
(
"signMethod"
,
"02"
);
//签名方法,固定为02,表示签名方式为国密(必传)
requestPublicParams
.
put
(
"version"
,
pro
.
getProperty
(
"cmb.version"
)
);
//版本号,固定为0.0.1(必传字段)
requestPublicParams
.
put
(
"encoding"
,
pro
.
getProperty
(
"cmb.encoding"
)
);
//编码方式,固定为UTF-8(必传)
requestPublicParams
.
put
(
"signMethod"
,
pro
.
getProperty
(
"cmb.signMethod"
)
);
//签名方法,固定为02,表示签名方式为国密(必传)
//业务要素
Map
<
String
,
String
>
requestTransactionParams
=
new
HashMap
<>();
requestTransactionParams
.
put
(
"merId"
,
hlsEbankCcbTransaction
.
getMerId
());
//商户号(必传)
...
...
@@ -677,7 +633,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//对待加签内容进行排序拼接
String
signContent
=
SignatureUtil
.
getSignContent
(
requestPublicParams
);
//加签
requestPublicParams
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
pr
ivateKey
));
requestPublicParams
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
pr
o
.
getProperty
(
"cmb.privateKey"
)
));
requestStr
=
mapper
.
writeValueAsString
(
requestPublicParams
);
...
...
@@ -700,13 +656,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
* @return
*/
private
HlsEbankCcbTransaction
setEbankTransactionQR
(
HlsEbankCcbTransaction
hlsEbankCcbTransaction
,
Map
<
String
,
String
>
response
,
String
type
)
{
// C - 订单已关闭
// D - 交易已撤销
// P - 交易在进行
// F - 交易失败
// S - 交易成功
// R - 转入退款
//
//接口请求成功
if
(
"1"
.
equalsIgnoreCase
(
type
))
{
if
(
response
.
get
(
"tradeState"
).
equalsIgnoreCase
(
"P"
)){
...
...
@@ -811,9 +761,9 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
Map
<
String
,
String
>
respData
=
new
HashMap
<>();
//设置响应数据
respData
.
put
(
"version"
,
"0.0.1"
);
//版本号,固定为0.0.1(必传)
respData
.
put
(
"encoding"
,
"UTF-8"
);
//编码方式,固定为UTF-8(必传)
respData
.
put
(
"signMethod"
,
"02"
);
//签名方法,固定为02,国密
respData
.
put
(
"version"
,
pro
.
getProperty
(
"cmb.version"
)
);
//版本号,固定为0.0.1(必传)
respData
.
put
(
"encoding"
,
pro
.
getProperty
(
"cmb.encoding"
)
);
//编码方式,固定为UTF-8(必传)
respData
.
put
(
"signMethod"
,
pro
.
getProperty
(
"cmb.signMethod"
)
);
//签名方法,固定为02,国密
try
{
respData
.
put
(
"returnCode"
,
"SUCCESS"
);
//SUCCESS表示商户接收通知成功并校验成功
...
...
@@ -832,7 +782,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//对待加签内容进行排序拼接
String
contentStr
=
SignatureUtil
.
getSignContent
(
resultMap
);
//验证签名-使用招行公钥进行验签
boolean
flag
=
SM2Util
.
sm2Check
(
contentStr
,
sign
,
p
ublicKey
);
boolean
flag
=
SM2Util
.
sm2Check
(
contentStr
,
sign
,
p
ro
.
getProperty
(
"cmb.publicKey"
)
);
if
(!
flag
)
{
//验签失败
System
.
out
.
println
(
"验签失败"
);
...
...
@@ -851,7 +801,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
hlsEbankCcbTransaction
.
setStatus
(
tranSuccess
);
hlsEbankCcbTransaction
.
setOrderStatus
(
"S"
);
hlsEbankCcbTransactionMapper
.
updateByPrimaryKeySelective
(
hlsEbankCcbTransaction
);
hlsWsRequestsMapper
.
updateByPrimaryKey
(
logInterfaceRequest
(
queryQrState
,
url
,
new
ObjectMapper
().
writeValueAsString
(
respData
),
hlsEbankCcbTransaction
.
getTransactionId
()));
hlsWsRequestsMapper
.
updateByPrimaryKey
(
logInterfaceRequest
(
queryQrState
,
pro
.
getProperty
(
"cmb.server"
)
,
new
ObjectMapper
().
writeValueAsString
(
respData
),
hlsEbankCcbTransaction
.
getTransactionId
()));
respData
.
put
(
"respCode"
,
"SUCCESS"
);
//业务错误码,成功为SUCCESS,失败为FAIL
/*如果处理自身业务逻辑发生错误,返回
respData.put("respCode","FAIL");
...
...
@@ -860,7 +810,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//对待加签内容进行排序拼接
String
signContent
=
SignatureUtil
.
getSignContent
(
respData
);
//加签-使用商户私钥加签
respData
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
pr
ivateKey
));
respData
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
pr
o
.
getProperty
(
"cmb.privateKey"
)
));
System
.
out
.
println
(
"加签成功"
);
return
respData
;
}
catch
(
Exception
e
)
{
...
...
@@ -906,8 +856,8 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
// 组apiSign加密Map
Map
<
String
,
String
>
apiSign
=
new
TreeMap
<>();
apiSign
.
put
(
"appid"
,
appId
);
apiSign
.
put
(
"secret"
,
appSecret
);
apiSign
.
put
(
"appid"
,
pro
.
getProperty
(
"cmb.appId"
)
);
apiSign
.
put
(
"secret"
,
pro
.
getProperty
(
"cmb.privateKey"
)
);
apiSign
.
put
(
"sign"
,
signResultMap
.
get
(
"sign"
));
apiSign
.
put
(
"timestamp"
,
""
+
currentTimeMills
);
...
...
@@ -917,7 +867,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
// 组request头部Map
apiHeader
=
new
HashMap
<>();
apiHeader
.
put
(
"appid"
,
appId
);
apiHeader
.
put
(
"appid"
,
pro
.
getProperty
(
"cmb.appId"
)
);
apiHeader
.
put
(
"timestamp"
,
""
+
currentTimeMills
);
apiHeader
.
put
(
"apisign"
,
apiSignString
);
...
...
@@ -929,8 +879,8 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
HlsWsRequests
hlsWsRequests
=
null
;
try
{
hlsWsRequests
=
logInterfaceRequest
(
queryQrState
,
url
,
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
Map
<
String
,
String
>
responseMap
=
Utils
.
postForEntity
(
closeUrl
,
signResult
,
apiHeader
);
hlsWsRequests
=
logInterfaceRequest
(
closeOrder
,
pro
.
getProperty
(
"cmb.closeUrl"
)
,
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
Map
<
String
,
String
>
responseMap
=
Utils
.
postForEntity
(
pro
.
getProperty
(
"cmb.closeUrl"
)
,
signResult
,
apiHeader
);
//处理响应报文
Boolean
checkResponse
=
checkSign
(
mapper
.
writeValueAsString
(
responseMap
));
//数据验签成功
...
...
@@ -1020,5 +970,4 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
return
result
;
}
}
core/src/main/java/com/hand/app/cmb/util/Utils.java
View file @
e4df144b
package
com
.
hand
.
app
.
cmb
.
util
;
import
com.alibaba.fastjson.JSONObject
;
import
com.chinapay.secss.LogUtil
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.HttpClient
;
...
...
@@ -18,9 +19,7 @@ import org.springframework.http.converter.StringHttpMessageConverter;
import
org.springframework.web.client.RestTemplate
;
import
javax.net.ssl.*
;
import
java.io.BufferedReader
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.io.*
;
import
java.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.security.KeyManagementException
;
...
...
@@ -39,13 +38,16 @@ public class Utils {
try
{
// Create a trust manager that does not validate certificate chains
TrustManager
[]
trustAllCerts
=
new
TrustManager
[]{
new
X509TrustManager
()
{
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
certs
,
String
authType
)
{
}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
certs
,
String
authType
)
{
}
}
...
...
@@ -57,6 +59,7 @@ public class Utils {
// Create all-trusting host name verifier
HostnameVerifier
allHostsValid
=
new
HostnameVerifier
()
{
@Override
public
boolean
verify
(
String
hostname
,
SSLSession
session
)
{
return
true
;
}
...
...
@@ -168,4 +171,33 @@ public class Utils {
return
paramMap
;
}
/**
* 加载properties配置文件
* @param propPath
* @return
*/
public
static
Properties
loadProp
(
String
propPath
)
{
Properties
props
=
new
Properties
();
FileInputStream
is
=
null
;
try
{
is
=
new
FileInputStream
(
propPath
);
props
.
load
(
is
);
return
props
;
}
catch
(
Exception
var13
)
{
LogUtil
.
writeErrorLog
(
"加载配置文件失败"
,
var13
);
}
finally
{
if
(
is
!=
null
)
{
try
{
is
.
close
();
}
catch
(
IOException
var12
)
{
;
}
}
}
return
null
;
}
}
core/src/main/resources/cmb.properties
0 → 100644
View file @
e4df144b
#招行获取二维码接口
cmb.qrCodeapplyUrl
=
https://api.cmburl.cn:8065/polypay/v1.0/mchorders/qrcodeapply
#招行查询订单状态接口
cmb.orderQueryUrl
=
https://api.cmburl.cn:8065/polypay/v1.0/mchorders/orderquery
#招行关闭订单接口
cmb.closeUrl
=
https://api.cmburl.cn:8065/polypay/v1.0/mchorders/qrcodeapply
#uat环境商户国密私钥
cmb.privateKey
=
D5F2AFA24E6BA9071B54A8C9AD735F9A1DE9C4657FA386C09B592694BC118B38
#uat环境招行国密公钥
cmb.publicKey
=
MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE6Q+fktsnY9OFP+LpSR5Udbxf5zHCFO0PmOKlFNTxDIGl8jsPbbB/9ET23NV+acSz4FEkzD74sW2iiNVHRLiKHg==
cmb.appId
=
8ab74856-8772-45c9-96db-54cb30ab9f74
cmb.appSecret
=
5b96f20a-011f-4254-8be8-9a5ceb2f317f
cmb.server
=
cmbServer
cmb.version
=
0.0.1
cmb.encoding
=
UTF-8
cmb.signMethod
=
02
cmb.currencyCode
=
156
cmb.user.id
=
N003574551
cmb.mer.id
=
3089991701201D0
cmb.payValidTime
=
900
cmb.notifyUrl
=
http://sign.hitachics.com/core/api/public/cmb/get/qr/code/listen
\ No newline at end of file
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