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
91385585
Commit
91385585
authored
Apr 24, 2022
by
5359
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
正式环境参数修改
parent
ffded0b9
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
165 additions
and
93 deletions
+165
-93
StringUtil.java
core/src/main/java/com/chinapay/util/StringUtil.java
+43
-4
Ld037.java
core/src/main/java/com/hand/app/cmb/dto/Ld037.java
+18
-18
HclcCmbPolyServiceImpl.java
...com/hand/app/cmb/service/impl/HclcCmbPolyServiceImpl.java
+7
-1
Utils.java
core/src/main/java/com/hand/app/cmb/util/Utils.java
+94
-9
Ld037Mapper.xml
core/src/main/resources/app/cmb/mapper/Ld037Mapper.xml
+2
-1
Ld037Mapper.xml
core/src/main/resources/com/cmb/mapper/Ld037Mapper.xml
+0
-58
logback.xml
core/src/main/resources/logback.xml
+1
-2
No files found.
core/src/main/java/com/chinapay/util/StringUtil.java
View file @
91385585
...
...
@@ -9,9 +9,13 @@ import java.util.*;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
com.alibaba.fastjson.JSONObject
;
import
com.chinapay.comm.Constants
;
import
com.chinapay.secss.SecssConstants
;
import
com.chinapay.secss.SecssUtil
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.hand.app.cmb.util.SM2Util
;
import
com.hand.app.cmb.util.SignatureUtil
;
import
com.hand.hap.system.dto.BaseDTO
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang.time.DateUtils
;
...
...
@@ -168,10 +172,45 @@ public class StringUtil {
// System.out.println(secssUtil.getErrCode());
// System.out.println(secssUtil.getErrCode());
// System.out.println(secssUtil.getEncValue());
Double
amount
=
106.02
D
;
BigDecimal
a1
=
new
BigDecimal
(
Double
.
toString
(
amount
));
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
100
));
System
.
out
.
println
(
a1
.
multiply
(
b1
).
stripTrailingZeros
());
//对待加签内容进行排序拼接
Map
<
String
,
String
>
requestPublicParams
=
new
TreeMap
<>();
ObjectMapper
mapper
=
new
ObjectMapper
();
//公共请求参数
requestPublicParams
.
put
(
"version"
,
"0.0.1"
);
//版本号,固定为0.0.1(必传字段)
requestPublicParams
.
put
(
"encoding"
,
"UTF-8"
);
//编码方式,固定为UTF-8(必传)
requestPublicParams
.
put
(
"signMethod"
,
"02"
);
//签名方法,固定为02,表示签名方式为国密(必传)
requestPublicParams
.
put
(
"biz_content"
,
"{\"tradeScene\":\"OFFLINE\",\"orderId\":\"2022042400000390\",\"notifyUrl\":\"http://sign.hitachics.com/core/api/public/cmb/get/qr/code/listen\",\"merId\":\"3089991701201D0\",\"body\":\"聚合支付测试\",\"userId\":\"N003574551\",\"payValidTime\":\"900\",\"currencyCode\":\"156\",\"txnAmt\":\"200000\"}"
);
String
signContent
=
SignatureUtil
.
getSignContent
(
requestPublicParams
);
System
.
out
.
println
(
"签名signContent:"
+
signContent
);
//加签
requestPublicParams
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
"D5F2AFA24E6BA9071B54A8C9AD735F9A1DE9C4657FA386C09B592694BC118B38"
));
System
.
out
.
println
(
requestPublicParams
.
get
(
"sign"
).
toString
());
// System.out.println(checkSign(JSONObject.parseObject(mapper.writeValueAsString(requestPublicParams)).toJSONString()));
}
private
static
Boolean
checkSign
(
String
string
)
{
System
.
out
.
println
(
"要验签的报文内容:"
+
string
);
try
{
//验签
ObjectMapper
objectMapper
=
new
ObjectMapper
();
Map
<
String
,
String
>
responseBodyMap
=
objectMapper
.
readValue
(
string
,
Map
.
class
);
String
sign
=
responseBodyMap
.
remove
(
"sign"
);
String
contentStr
=
SignatureUtil
.
getSignContent
(
responseBodyMap
);
System
.
out
.
println
(
"验签contentStr:"
+
contentStr
);
boolean
result
=
SM2Util
.
sm2Check
(
contentStr
,
sign
,
"MFkwEwYHKoZIzj0CAQYIKoEcz1UBgi0DQgAE6Q+fktsnY9OFP+LpSR5Udbxf5zHCFO0PmOKlFNTxDIGl8jsPbbB/9ET23NV+acSz4FEkzD74sW2iiNVHRLiKHg=="
);
if
(
result
)
{
System
.
out
.
println
(
"报文验签成功!"
);
}
else
{
System
.
out
.
println
(
"报文验签失败!"
);
}
return
result
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"验签发生异常!"
);
e
.
printStackTrace
();
return
false
;
}
}
/**
...
...
core/src/main/java/com/hand/app/cmb/dto/Ld037.java
View file @
91385585
...
...
@@ -81,11 +81,11 @@ public class Ld037 {
private
String
ctino
;
private
String
cup
_p
in
;
private
String
cup
P
in
;
private
String
phone
;
private
Long
transaction
_i
d
;
private
Long
transaction
I
d
;
private
Long
num
;
...
...
@@ -303,14 +303,6 @@ public class Ld037 {
this
.
ctino
=
ctino
;
}
public
String
getCup_pin
()
{
return
cup_pin
;
}
public
void
setCup_pin
(
String
cup_pin
)
{
this
.
cup_pin
=
cup_pin
;
}
public
String
getPhone
()
{
return
phone
;
}
...
...
@@ -319,14 +311,6 @@ public class Ld037 {
this
.
phone
=
phone
;
}
public
Long
getTransaction_id
()
{
return
transaction_id
;
}
public
void
setTransaction_id
(
Long
transaction_id
)
{
this
.
transaction_id
=
transaction_id
;
}
public
Long
getNum
()
{
return
num
;
}
...
...
@@ -358,4 +342,20 @@ public class Ld037 {
public
void
setRecbatchdt
(
Date
recbatchdt
)
{
this
.
recbatchdt
=
recbatchdt
;
}
public
Long
getTransactionId
()
{
return
transactionId
;
}
public
void
setTransactionId
(
Long
transactionId
)
{
this
.
transactionId
=
transactionId
;
}
public
String
getCupPin
()
{
return
cupPin
;
}
public
void
setCupPin
(
String
cupPin
)
{
this
.
cupPin
=
cupPin
;
}
}
\ No newline at end of file
core/src/main/java/com/hand/app/cmb/service/impl/HclcCmbPolyServiceImpl.java
View file @
91385585
...
...
@@ -102,6 +102,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
createTransaction
(
iRequest
,
ld037
);
ld037
.
setTransactionId
(
hlsEbankCcbTransaction
.
getTransactionId
());
//生成单据编号 日期+id
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
...
...
@@ -146,7 +147,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
logger
.
info
(
"发送收款码申请请求,请求参数: {}"
,
mapper
.
writeValueAsString
(
apiHeader
));
try
{
// 发送HTTP post请求
response
=
Utils
.
post
ForEntity
(
url
,
signResult
,
apiHeader
);
response
=
Utils
.
post
String
(
url
,
signResult
,
apiHeader
);
//处理接口日志
logger
.
info
(
"收款码申请返回结果:"
+
mapper
.
writeValueAsString
(
response
));
...
...
@@ -241,6 +242,8 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//更新现金事务表ld037失败处理
if
(
Objects
.
nonNull
(
errorCd
))
{
updateLd037Fail
(
ld037
,
errorCd
);
}
else
{
ld037Mapper
.
updateByPrimaryKeySelective
(
ld037
);
}
result
=
putResult
(
result
,
response
,
resultType
);
...
...
@@ -393,6 +396,9 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//对待加签内容进行排序拼接
String
signContent
=
SignatureUtil
.
getSignContent
(
requestPublicParams
);
//签名内容
logger
.
info
(
"签名内容:"
+
signContent
);
//加签
requestPublicParams
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
privateKey
));
...
...
core/src/main/java/com/hand/app/cmb/util/Utils.java
View file @
91385585
package
com
.
hand
.
app
.
cmb
.
util
;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.apache.http.message.BasicHeader
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.springframework.http.HttpEntity
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.HttpMessageConverter
;
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.nio.charset.Charset
;
import
java.nio.charset.StandardCharsets
;
import
java.security.KeyManagementException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.cert.X509Certificate
;
import
java.util.
Map
;
import
java.util.
*
;
public
class
Utils
{
...
...
@@ -21,15 +36,16 @@ public class Utils {
}
private
static
void
disableSslVerification
()
{
try
{
try
{
// Create a trust manager that does not validate certificate chains
TrustManager
[]
trustAllCerts
=
new
TrustManager
[]
{
new
X509TrustManager
()
{
TrustManager
[]
trustAllCerts
=
new
TrustManager
[]{
new
X509TrustManager
()
{
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
public
void
checkClientTrusted
(
X509Certificate
[]
certs
,
String
authType
)
{
}
public
void
checkServerTrusted
(
X509Certificate
[]
certs
,
String
authType
)
{
}
}
...
...
@@ -56,13 +72,22 @@ public class Utils {
}
public
static
Map
<
String
,
String
>
postForEntity
(
String
url
,
String
requestBody
,
Map
<
String
,
String
>
apiHeader
)
{
public
static
Map
<
String
,
String
>
postForEntity
(
String
url
,
String
requestBody
,
Map
<
String
,
String
>
apiHeader
)
{
RestTemplate
client
=
getRestTemplate
();
client
.
getMessageConverters
().
add
(
0
,
new
StringHttpMessageConverter
(
Charset
.
forName
(
"UTF-8"
)));
List
<
HttpMessageConverter
<?>>
httpMessageConverters
=
client
.
getMessageConverters
();
httpMessageConverters
.
stream
().
forEach
(
httpMessageConverter
->
{
if
(
httpMessageConverter
instanceof
StringHttpMessageConverter
)
{
StringHttpMessageConverter
messageConverter
=
(
StringHttpMessageConverter
)
httpMessageConverter
;
messageConverter
.
setDefaultCharset
(
Charset
.
forName
(
"UTF-8"
));
}
});
HttpHeaders
headers
=
getHttpHeaders
();
// 以json的方式提交
headers
.
setContentType
(
MediaType
.
APPLICATION_JSON
);
List
<
Charset
>
acceptCharset
=
Collections
.
singletonList
(
StandardCharsets
.
UTF_8
);
headers
.
setAcceptCharset
(
acceptCharset
);
headers
.
add
(
"appid"
,
apiHeader
.
get
(
"appid"
));
headers
.
add
(
"timestamp"
,
apiHeader
.
get
(
"timestamp"
));
headers
.
add
(
"apisign"
,
apiHeader
.
get
(
"apisign"
));
...
...
@@ -70,17 +95,77 @@ public class Utils {
// 将请求头部和参数合成一个请求
HttpEntity
<
String
>
requestEntity
=
new
HttpEntity
<>(
requestBody
,
headers
);
// 执行HTTP请求
Map
<
String
,
String
>
response
=
client
.
postForEntity
(
url
,
requestEntity
,
Map
.
class
).
getBody
();
Map
<
String
,
String
>
response
=
client
.
postForEntity
(
url
,
requestEntity
,
Map
.
class
).
getBody
();
return
response
;
}
public
static
RestTemplate
getRestTemplate
(){
/**
* 向指定URL发送POST方法的请求
*
* @param urls 发送请求的URL
* @param params 请求参数,请求参数应该是 JSON 的形式。
* @return URL 所代表远程资源的响应结果
*/
public
static
Map
<
String
,
String
>
postString
(
String
urls
,
String
params
,
Map
<
String
,
String
>
headInfo
)
{
HttpClient
client
=
HttpClientBuilder
.
create
().
build
();
HttpPost
post
=
new
HttpPost
(
urls
);
String
result
=
""
;
try
{
if
(
Objects
.
nonNull
(
headInfo
))
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
headInfo
.
entrySet
())
{
post
.
setHeader
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
StringEntity
s
=
new
StringEntity
(
params
,
"utf-8"
);
s
.
setContentEncoding
(
new
BasicHeader
(
"Content-Type"
,
"application/json"
));
post
.
setHeader
(
"Content-Type"
,
"application/json"
);
post
.
setEntity
(
s
);
HttpResponse
httpResponse
=
client
.
execute
(
post
);
InputStream
inStream
=
httpResponse
.
getEntity
().
getContent
();
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
inStream
,
"utf-8"
));
StringBuilder
strber
=
new
StringBuilder
();
String
line
=
null
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
strber
.
append
(
line
+
"\n"
);
}
inStream
.
close
();
result
=
strber
.
toString
();
//解析返回结果
JSONObject
jsonResult
=
JSONObject
.
parseObject
(
result
);
return
JsonToMap
(
jsonResult
);
}
catch
(
Exception
var12
)
{
var12
.
printStackTrace
();
throw
new
RuntimeException
(
var12
);
}
}
public
static
RestTemplate
getRestTemplate
()
{
return
new
RestTemplate
();
}
public
static
HttpHeaders
getHttpHeaders
(){
public
static
HttpHeaders
getHttpHeaders
()
{
return
new
HttpHeaders
();
}
public
static
Map
<
String
,
String
>
JsonToMap
(
JSONObject
params
)
{
Map
<
String
,
String
>
paramMap
=
new
HashMap
<>();
//循环转换
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
params
.
entrySet
())
{
paramMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
().
toString
());
}
return
paramMap
;
}
}
core/src/main/resources/app/cmb/mapper/Ld037Mapper.xml
View file @
91385585
...
...
@@ -50,7 +50,8 @@
t.ErrorCd = #{errorcd,jdbcType=VARCHAR},
t.UPDATEDDT = SYSDATE,
t.UPDATEDPERSON = 'CMB',
t.Actdbtamount = 0
t.Actdbtamount = 0,
t.transaction_id = #{transactionId,jdbcType=DECIMAL}
WHERE t.id = #{id,jdbcType=DECIMAL}
</update>
...
...
core/src/main/resources/com/cmb/mapper/Ld037Mapper.xml
deleted
100644 → 0
View file @
ffded0b9
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.cmb.mapper.Ld037Mapper"
>
<!--获取角色下的模块-->
<resultMap
id=
"AppLd037Map"
type=
"com.cmb.dto.Ld037"
>
<result
column=
"ID"
property=
"id"
jdbcType=
"VARCHAR"
/>
<result
column=
"CONTRACTNO"
property=
"contractno"
jdbcType=
"VARCHAR"
/>
<result
column=
"TIMES"
property=
"times"
jdbcType=
"DECIMAL"
/>
<result
column=
"generatedt"
property=
"generatedt"
jdbcType=
"Date"
/>
<result
column=
"recamtno"
property=
"recamtno"
jdbcType=
"VARCHAR"
/>
<result
column=
"recduedt"
property=
"recduedt"
jdbcType=
"Date"
/>
<result
column=
"bankname"
property=
"bankname"
jdbcType=
"VARCHAR"
/>
<result
column=
"accountid"
property=
"accountid"
jdbcType=
"VARCHAR"
/>
<result
column=
"accountname"
property=
"accountname"
jdbcType=
"VARCHAR"
/>
<result
column=
"amount"
property=
"amount"
jdbcType=
"DECIMAL"
/>
<result
column=
"filestatus"
property=
"filestatus"
jdbcType=
"VARCHAR"
/>
<result
column=
"receiptstatus"
property=
"receiptstatus"
jdbcType=
"VARCHAR"
/>
<result
column=
"receiptcfmstatus"
property=
"receiptcfmstatus"
jdbcType=
"VARCHAR"
/>
<result
column=
"errorcd"
property=
"errorcd"
jdbcType=
"VARCHAR"
/>
<result
column=
"dealercd"
property=
"dealercd"
jdbcType=
"VARCHAR"
/>
<result
column=
"branchcd"
property=
"branchcd"
jdbcType=
"VARCHAR"
/>
<result
column=
"customercd"
property=
"customercd"
jdbcType=
"VARCHAR"
/>
<result
column=
"customername"
property=
"customername"
jdbcType=
"VARCHAR"
/>
<result
column=
"outfilename"
property=
"outfilename"
jdbcType=
"VARCHAR"
/>
<result
column=
"infilename"
property=
"infilename"
jdbcType=
"VARCHAR"
/>
<result
column=
"characterid"
property=
"characterid"
jdbcType=
"VARCHAR"
/>
<result
column=
"errormsg"
property=
"errormsg"
jdbcType=
"VARCHAR"
/>
<result
column=
"chargeaccountno"
property=
"chargeaccountno"
jdbcType=
"VARCHAR"
/>
<result
column=
"actdbtamount"
property=
"actdbtamount"
jdbcType=
"DECIMAL"
/>
<result
column=
"version"
property=
"version"
jdbcType=
"VARCHAR"
/>
<result
column=
"ctino"
property=
"ctino"
jdbcType=
"VARCHAR"
/>
<result
column=
"cup_pin"
property=
"cup_pin"
jdbcType=
"VARCHAR"
/>
<result
column=
"phone"
property=
"phone"
jdbcType=
"VARCHAR"
/>
<result
column=
"transaction_id"
property=
"transaction_id"
jdbcType=
"DECIMAL"
/>
<result
column=
"num"
property=
"num"
jdbcType=
"DECIMAL"
/>
<result
column=
"procdt"
property=
"procdt"
jdbcType=
"Date"
/>
<result
column=
"recdt"
property=
"recdt"
jdbcType=
"Date"
/>
<result
column=
"recbatchdt"
property=
"recbatchdt"
jdbcType=
"Date"
/>
</resultMap>
<update
id=
"updateLd037Fail"
parameterType=
"com.cmb.dto.Ld037"
>
UPDATE LD037
SET LD037.ProcDt = sysdate, /*文件处理日期*/
LD037.RecDt = sysdate, /*文件返回系统日期*/
LD037.RecBatchDt = sysdate, /*文件返回批处理日期*/
LD037.ReceiptStatus = '0', /*扣款失败状态*/
LD037.ReceiptCfmStatus = '1', /*扣款结果确认失败状态*/
LD037.ERRORMSG = (select h.description from hls_ebank_cmb_recode h where h.code=#{errorcd}), /*错误代码*/
LD037.ErrorCd = #{errorcd}, /*错误信息*/
LD037.UPDATEDDT = SYSDATE, /*更新日期*/
LD037.UPDATEDPERSON = 'CMB', /*更新者*/
LD037.Actdbtamount = 0 /* 实际扣款金额 */
WHERE LD037.id = #{id};
</update>
</mapper>
core/src/main/resources/logback.xml
View file @
91385585
...
...
@@ -133,7 +133,6 @@
<logger
name=
"com.timevale"
level=
"INFO"
additivity=
"false"
>
<appender-ref
ref=
"STDOUT"
/>
</logger>
<logger
name=
"com.chinapay.mapper.HlsEbankCcbTransactionMapper"
level=
"DEBUG"
/>
<logger
name=
"com.hand.app.zhongDengWang.mapper"
level=
"DEBUG"
/>
<logger
name=
"com.chinapay.service.impl.HclcChinaPayServiceImpl"
level=
"INFO"
additivity=
"false"
>
<appender-ref
ref=
"CUP-FILE"
/>
...
...
@@ -141,7 +140,7 @@
<logger
name=
"com.chinapay.util.HttpUtils"
level=
"INFO"
additivity=
"false"
>
<appender-ref
ref=
"CUP-FILE"
/>
</logger>
<logger
name=
"com.cmb.service.impl.HclcCmbPolyServiceImpl"
level=
"INFO"
additivity=
"false"
>
<logger
name=
"com.
hand.app.
cmb.service.impl.HclcCmbPolyServiceImpl"
level=
"INFO"
additivity=
"false"
>
<appender-ref
ref=
"CMB-FILE"
/>
</logger>
</configuration>
\ 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