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
5965c219
Commit
5965c219
authored
May 31, 2022
by
5359
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单结果查询接口代码调整
parent
43d19182
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
252 additions
and
206 deletions
+252
-206
pom.xml
core/pom.xml
+0
-1
HlsEbankCcbTransactionServiceImpl.java
...napay/service/impl/HlsEbankCcbTransactionServiceImpl.java
+0
-21
HclcCmbPolyListenController.java
...hand/app/cmb/controllers/HclcCmbPolyListenController.java
+3
-3
HclcCmbPolyService.java
...ain/java/com/hand/app/cmb/service/HclcCmbPolyService.java
+1
-1
IHlsEbankCmbTransqryService.java
...com/hand/app/cmb/service/IHlsEbankCmbTransqryService.java
+15
-0
HclcCmbPolyServiceImpl.java
...com/hand/app/cmb/service/impl/HclcCmbPolyServiceImpl.java
+200
-180
HlsEbankCmbTransqryServiceImpl.java
.../app/cmb/service/impl/HlsEbankCmbTransqryServiceImpl.java
+18
-0
Utils.java
core/src/main/java/com/hand/app/cmb/util/Utils.java
+15
-0
No files found.
core/pom.xml
View file @
5965c219
...
@@ -264,7 +264,6 @@
...
@@ -264,7 +264,6 @@
<groupId>
org.bouncycastle
</groupId>
<groupId>
org.bouncycastle
</groupId>
<artifactId>
bcprov-jdk15on
</artifactId>
<artifactId>
bcprov-jdk15on
</artifactId>
<version>
1.65.01
</version>
<version>
1.65.01
</version>
<!-- <version>1.47</version>-->
<scope>
system
</scope>
<scope>
system
</scope>
<systemPath>
<systemPath>
${project.basedir}/src/main/webapp/WEB-INF/lib/bcprov-jdk15on-1.65.01.jar
${project.basedir}/src/main/webapp/WEB-INF/lib/bcprov-jdk15on-1.65.01.jar
...
...
core/src/main/java/com/chinapay/service/impl/HlsEbankCcbTransactionServiceImpl.java
View file @
5965c219
package
com
.
chinapay
.
service
.
impl
;
package
com
.
chinapay
.
service
.
impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.chinapay.comm.Constants
;
import
com.chinapay.dto.HclcCupSignInfo
;
import
com.chinapay.dto.HlsEbankCcbTransaction
;
import
com.chinapay.dto.HlsEbankCcbTransaction
;
import
com.chinapay.dto.HlsWsConfig
;
import
com.chinapay.mapper.HclcCupSignInfoMapper
;
import
com.chinapay.mapper.HlsEbankCcbTransactionMapper
;
import
com.chinapay.mapper.HlsWsConfigMapper
;
import
com.chinapay.secss.SecssConstants
;
import
com.chinapay.secss.SecssUtil
;
import
com.chinapay.service.IHclcChinaPayService
;
import
com.chinapay.service.IHlsEbankCcbTransactionService
;
import
com.chinapay.service.IHlsEbankCcbTransactionService
;
import
com.chinapay.util.HttpUtils
;
import
com.chinapay.util.StringUtil
;
import
com.hand.app.zhongDengWang.dto.HlsWsRequests
;
import
com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper
;
import
com.hand.hap.core.IRequest
;
import
com.hand.hap.intergration.service.IHapInterfaceHeaderService
;
import
com.hand.hap.system.service.impl.BaseServiceImpl
;
import
com.hand.hap.system.service.impl.BaseServiceImpl
;
import
org.apache.commons.codec.binary.Base64
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.io.*
;
import
java.io.*
;
...
...
core/src/main/java/com/hand/app/cmb/controllers/HclcCmbPolyListenController.java
View file @
5965c219
...
@@ -41,9 +41,9 @@ public class HclcCmbPolyListenController extends BaseController {
...
@@ -41,9 +41,9 @@ public class HclcCmbPolyListenController extends BaseController {
* @return
* @return
*/
*/
@ResponseBody
@ResponseBody
@RequestMapping
(
"
core
/api/public/cmb/get/qr/code/listen"
)
@RequestMapping
(
"/api/public/cmb/get/qr/code/listen"
)
public
Map
<
String
,
String
>
orderStatusNotify
(
HttpServletRequest
request
,
public
JSONObject
orderStatusNotify
(
HttpServletRequest
request
,
@RequestBody
(
required
=
true
)
JSONObject
params
)
{
@RequestBody
String
params
)
{
IRequest
iRequest
=
createRequestContext
(
request
);
IRequest
iRequest
=
createRequestContext
(
request
);
return
hclcCmbPolyService
.
orderNotify
(
iRequest
,
params
);
return
hclcCmbPolyService
.
orderNotify
(
iRequest
,
params
);
...
...
core/src/main/java/com/hand/app/cmb/service/HclcCmbPolyService.java
View file @
5965c219
...
@@ -11,7 +11,7 @@ public interface HclcCmbPolyService {
...
@@ -11,7 +11,7 @@ public interface HclcCmbPolyService {
JSONObject
queryOrderStatus
(
IRequest
iRequest
,
JSONObject
params
);
JSONObject
queryOrderStatus
(
IRequest
iRequest
,
JSONObject
params
);
Map
orderNotify
(
IRequest
iRequest
,
JSONObject
params
);
JSONObject
orderNotify
(
IRequest
iRequest
,
String
params
);
JSONObject
closeOrder
(
IRequest
iRequest
,
JSONObject
params
);
JSONObject
closeOrder
(
IRequest
iRequest
,
JSONObject
params
);
...
...
core/src/main/java/com/hand/app/cmb/service/IHlsEbankCmbTransqryService.java
0 → 100644
View file @
5965c219
package
com
.
hand
.
app
.
cmb
.
service
;
import
com.hand.app.cmb.dto.HlsEbankCmbTransqry
;
import
com.hand.hap.core.ProxySelf
;
import
com.hand.hap.system.service.IBaseService
;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
public
interface
IHlsEbankCmbTransqryService
extends
IBaseService
<
HlsEbankCmbTransqry
>,
ProxySelf
<
IHlsEbankCmbTransqryService
>
{
}
core/src/main/java/com/hand/app/cmb/service/impl/HclcCmbPolyServiceImpl.java
View file @
5965c219
...
@@ -6,12 +6,11 @@ import com.chinapay.dto.HlsEbankCcbTransaction;
...
@@ -6,12 +6,11 @@ import com.chinapay.dto.HlsEbankCcbTransaction;
import
com.chinapay.mapper.HlsEbankCcbTransactionMapper
;
import
com.chinapay.mapper.HlsEbankCcbTransactionMapper
;
import
com.chinapay.service.IHlsEbankCcbTransactionService
;
import
com.chinapay.service.IHlsEbankCcbTransactionService
;
import
com.chinapay.util.StringUtil
;
import
com.chinapay.util.StringUtil
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.hand.app.cmb.dto.HlsEbankCmbTransqry
;
import
com.hand.app.cmb.dto.HlsEbankCmbTransqry
;
import
com.hand.app.cmb.dto.Ld037
;
import
com.hand.app.cmb.dto.Ld037
;
import
com.hand.app.cmb.mapper.HlsEbankCmbTransqryMapper
;
import
com.hand.app.cmb.mapper.Ld037Mapper
;
import
com.hand.app.cmb.mapper.Ld037Mapper
;
import
com.hand.app.cmb.service.HclcCmbPolyService
;
import
com.hand.app.cmb.service.HclcCmbPolyService
;
import
com.hand.app.cmb.service.IHlsEbankCmbTransqryService
;
import
com.hand.app.cmb.util.MD5Utils
;
import
com.hand.app.cmb.util.MD5Utils
;
import
com.hand.app.cmb.util.SM2Util
;
import
com.hand.app.cmb.util.SM2Util
;
import
com.hand.app.cmb.util.SignatureUtil
;
import
com.hand.app.cmb.util.SignatureUtil
;
...
@@ -20,10 +19,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
...
@@ -20,10 +19,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import
com.hand.app.esignHclc.utils.SignHclcUtils
;
import
com.hand.app.esignHclc.utils.SignHclcUtils
;
import
com.hand.app.zhongDengWang.dto.HlsWsRequests
;
import
com.hand.app.zhongDengWang.dto.HlsWsRequests
;
import
com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper
;
import
com.hand.app.zhongDengWang.mapper.HlsWsRequestsMapper
;
import
com.hand.app.zhongDengWang.service.IHlsWsRequestsService
;
import
com.hand.hap.core.IRequest
;
import
com.hand.hap.core.IRequest
;
import
com.hand.hap.intergration.dto.HapInterfaceHeader
;
import
com.hand.hap.intergration.dto.HapInterfaceHeader
;
import
com.hand.hap.intergration.service.IHapInterfaceHeaderService
;
import
com.hand.hap.intergration.service.IHapInterfaceHeaderService
;
import
org.apache.poi.hssf.record.DVALRecord
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -78,13 +77,13 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -78,13 +77,13 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
@Autowired
@Autowired
private
IHlsEbankCcbTransactionService
hlsEbankCcbTransactionService
;
private
IHlsEbankCcbTransactionService
hlsEbankCcbTransactionService
;
@Autowired
@Autowired
private
HlsWsRequestsMapper
hlsWsRequestsMapper
;
private
IHlsWsRequestsService
hlsWsRequestsService
;
@Autowired
@Autowired
private
Ld037Mapper
ld037Mapper
;
private
Ld037Mapper
ld037Mapper
;
@Autowired
@Autowired
private
HlsEbankCmbTransqryMapper
hlsEbankCmbTransqryMapper
;
private
IHlsEbankCmbTransqryService
hlsEbankCmbTransqryService
;
@Autowired
@Autowired
IHapInterfaceHeaderService
headerService
;
private
IHapInterfaceHeaderService
headerService
;
@Autowired
@Autowired
private
DataSourceTransactionManager
transactionManager
;
private
DataSourceTransactionManager
transactionManager
;
...
@@ -97,19 +96,17 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -97,19 +96,17 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
String
errorCd
=
null
;
String
errorCd
=
null
;
if
(
Objects
.
isNull
(
params
.
get
(
"recamt_id"
)))
{
if
(
Objects
.
isNull
(
params
.
get
(
"recamt_id"
)))
{
result
.
put
(
Constants
.
RESP_CODE
,
"E"
);
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
result
.
put
(
"respMsg"
,
"请求必须参数recamt_id缺失,请检查!"
);
result
.
put
(
"respMsg"
,
"请求必须参数recamt_id缺失,请检查!"
);
return
result
;
return
result
;
}
}
//根据recamt_id查询ld037数据生成hls_ebank_ccb_transaction批次记录
//根据recamt_id查询ld037数据生成hls_ebank_ccb_transaction批次记录
Long
recamtId
=
params
.
getLong
(
"recamt_id"
);
Long
recamtId
=
params
.
getLong
(
"recamt_id"
);
Ld037
ld037
=
new
Ld037
();
Ld037
ld037
=
ld037Mapper
.
selectByPrimaryKey
(
recamtId
);
ld037
.
setId
(
recamtId
);
ld037
=
ld037Mapper
.
selectByPrimaryKey
(
ld037
);
if
(
Objects
.
nonNull
(
ld037
.
getReceiptstatus
()))
{
if
(
Objects
.
nonNull
(
ld037
.
getReceiptstatus
()))
{
result
.
put
(
Constants
.
RESP_CODE
,
"E"
);
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
result
.
put
(
"respMsg"
,
"支付订单状态异常,请检查!"
);
result
.
put
(
"respMsg"
,
"支付订单状态异常,请检查!"
);
return
result
;
return
result
;
}
}
...
@@ -117,11 +114,6 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -117,11 +114,6 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
createTransaction
(
iRequest
,
ld037
);
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
createTransaction
(
iRequest
,
ld037
);
ld037
.
setTransactionId
(
hlsEbankCcbTransaction
.
getTransactionId
());
ld037
.
setTransactionId
(
hlsEbankCcbTransaction
.
getTransactionId
());
//生成单据编号 日期+id
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
String
dateString
=
formatter
.
format
(
new
Date
());
hlsEbankCcbTransaction
.
setTransactionNumber
(
dateString
+
String
.
format
(
"%08d"
,
hlsEbankCcbTransaction
.
getTransactionId
()));
Map
<
String
,
String
>
response
=
null
;
Map
<
String
,
String
>
response
=
null
;
try
{
try
{
...
@@ -153,7 +145,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -153,7 +145,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
apiHeader
.
put
(
"apisign"
,
apiSignString
);
apiHeader
.
put
(
"apisign"
,
apiSignString
);
//初始化日志
//初始化日志
HlsWsRequests
hlsWsRequests
=
logInterfaceRequest
(
getQrCode
,
pro
.
getProperty
(
"cmb.qrCodeapplyUrl"
),
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
HlsWsRequests
hlsWsRequests
=
logInterfaceRequest
(
iRequest
,
getQrCode
,
pro
.
getProperty
(
"cmb.qrCodeapplyUrl"
),
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
logger
.
info
(
"发送收款码申请请求,请求参数: {}"
,
mapper
.
writeValueAsString
(
apiHeader
));
logger
.
info
(
"发送收款码申请请求,请求参数: {}"
,
mapper
.
writeValueAsString
(
apiHeader
));
try
{
try
{
...
@@ -215,7 +207,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -215,7 +207,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
resultType
=
"5"
;
resultType
=
"5"
;
}
}
hlsWsRequests
Mapper
.
updateByPrimaryKeySelective
(
hlsWsRequests
);
hlsWsRequests
Service
.
updateByPrimaryKeySelective
(
iRequest
,
hlsWsRequests
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
logger
.
info
(
"组装请求报文信息失败: {} "
,
e
.
getMessage
());
logger
.
info
(
"组装请求报文信息失败: {} "
,
e
.
getMessage
());
...
@@ -226,11 +218,11 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -226,11 +218,11 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
errorCd
=
"MESSAGE_ERROR"
;
errorCd
=
"MESSAGE_ERROR"
;
resultType
=
"5"
;
resultType
=
"5"
;
}
finally
{
hlsEbankCcbTransaction
=
setEbankTransaction
(
hlsEbankCcbTransaction
,
response
,
resultType
);
hlsEbankCcbTransactionService
.
updateByPrimaryKey
(
iRequest
,
hlsEbankCcbTransaction
);
}
}
hlsEbankCcbTransaction
=
setEbankTransaction
(
hlsEbankCcbTransaction
,
response
,
resultType
);
hlsEbankCcbTransactionMapper
.
updateByPrimaryKey
(
hlsEbankCcbTransaction
);
//更新现金事务表ld037失败处理
//更新现金事务表ld037失败处理
if
(
Objects
.
nonNull
(
errorCd
))
{
if
(
Objects
.
nonNull
(
errorCd
))
{
updateLd037Fail
(
ld037
,
errorCd
);
updateLd037Fail
(
ld037
,
errorCd
);
...
@@ -326,6 +318,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -326,6 +318,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
ccbTransaction
.
setVersion
(
pro
.
getProperty
(
"cmb.version"
));
ccbTransaction
.
setVersion
(
pro
.
getProperty
(
"cmb.version"
));
ccbTransaction
.
setUserId
(
pro
.
getProperty
(
"cmb.user.id"
));
ccbTransaction
.
setUserId
(
pro
.
getProperty
(
"cmb.user.id"
));
ccbTransaction
.
setStatus
(
transNew
);
ccbTransaction
.
setStatus
(
transNew
);
ccbTransaction
.
setOrderStatus
(
orderNo
);
ccbTransaction
.
setBankType
(
"CMB"
);
ccbTransaction
.
setBankType
(
"CMB"
);
ccbTransaction
.
setCount
(
1L
);
ccbTransaction
.
setCount
(
1L
);
ccbTransaction
.
setAmount
(
ld037
.
getAmount
());
ccbTransaction
.
setAmount
(
ld037
.
getAmount
());
...
@@ -337,15 +330,14 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -337,15 +330,14 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
ccbTransaction
.
setTranTime
(
StringUtil
.
getRelevantTime
(
new
Date
()));
ccbTransaction
.
setTranTime
(
StringUtil
.
getRelevantTime
(
new
Date
()));
ccbTransaction
.
setTranType
(
"APPLY"
);
ccbTransaction
.
setTranType
(
"APPLY"
);
hlsEbankCcbTransactionMapper
.
insert
(
ccbTransaction
);
ccbTransaction
=
hlsEbankCcbTransactionService
.
insertSelective
(
iRequest
,
ccbTransaction
);
// //生成单据编号 日期+id
//生成单据编号 日期+id
// SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
// String dateString = formatter.format(new Date());
String
dateString
=
formatter
.
format
(
new
Date
());
// ccbTransaction.setTransactionNumber(dateString + String.format("%08d", ccbTransaction.getTransactionId()));
ccbTransaction
.
setTransactionNumber
(
dateString
+
String
.
format
(
"%08d"
,
ccbTransaction
.
getTransactionId
()));
// ccbTransaction = hlsEbankCcbTransactionService.updateByPrimaryKeySelective(iRequest, ccbTransaction);
return
hlsEbankCcbTransactionMapper
.
selectByPrimaryKey
(
ccbTransaction
)
;
return
ccbTransaction
;
}
}
private
String
getQrRequestParams
(
HlsEbankCcbTransaction
hlsEbankCcbTransaction
,
Ld037
ld037
)
{
private
String
getQrRequestParams
(
HlsEbankCcbTransaction
hlsEbankCcbTransaction
,
Ld037
ld037
)
{
...
@@ -371,7 +363,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -371,7 +363,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
100
));
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
100
));
requestTransactionParams
.
put
(
"txnAmt"
,
a1
.
multiply
(
b1
).
stripTrailingZeros
().
toPlainString
());
//交易金额,单位为分(必传)
requestTransactionParams
.
put
(
"txnAmt"
,
a1
.
multiply
(
b1
).
stripTrailingZeros
().
toPlainString
());
//交易金额,单位为分(必传)
requestTransactionParams
.
put
(
"currencyCode"
,
pro
.
getProperty
(
"cmb.currencyCode"
));
//交易币种,默认156,目前只支持人民币(156)
requestTransactionParams
.
put
(
"currencyCode"
,
pro
.
getProperty
(
"cmb.currencyCode"
));
//交易币种,默认156,目前只支持人民币(156)
requestTransactionParams
.
put
(
"body"
,
"聚合支付测试"
);
//商户号(必传)
requestTransactionParams
.
put
(
"body"
,
ld037
.
getContractno
()
);
//商户号(必传)
//商户保留域
//商户保留域
JSONObject
mchReserved
=
new
JSONObject
();
JSONObject
mchReserved
=
new
JSONObject
();
...
@@ -406,26 +398,22 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -406,26 +398,22 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
JSONObject
result
=
new
JSONObject
();
JSONObject
result
=
new
JSONObject
();
//去ld037中查找对应的记录的receiptcfmstatus,
//去ld037中查找对应的记录的receiptcfmstatus,
if
(
Objects
.
isNull
(
params
.
get
(
"recamt_id"
)))
{
if
(
Objects
.
isNull
(
params
.
get
(
"recamt_id"
)))
{
result
.
put
(
Constants
.
RESP_CODE
,
"E"
);
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
result
.
put
(
"respMsg"
,
"请求必须参数recamt_id缺失,请检查!"
);
result
.
put
(
"respMsg"
,
"请求必须参数recamt_id缺失,请检查!"
);
return
result
;
return
result
;
}
}
//根据recamt_id查询ld037数据生成hls_ebank_ccb_transaction批次记录
//根据recamt_id查询ld037数据生成hls_ebank_ccb_transaction批次记录
Long
recamtId
=
params
.
getLong
(
"recamt_id"
);
Long
recamtId
=
params
.
getLong
(
"recamt_id"
);
Ld037
ld037
=
new
Ld037
();
Ld037
ld037
=
ld037Mapper
.
selectByPrimaryKey
(
recamtId
);
ld037
.
setId
(
recamtId
);
ld037
=
ld037Mapper
.
selectByPrimaryKey
(
ld037
);
//与查询二维码有区别,查询二维码时订单并未创建,但查询订单状态时,订单记录已经在数据库中有记录,
//与查询二维码有区别,查询二维码时订单并未创建,但查询订单状态时,订单记录已经在数据库中有记录,
// 所以只需要通过recamt_id在ld037表中查到对应的订单记录,
// 所以只需要通过recamt_id在ld037表中查到对应的订单记录,
// 然后通过ld037表中的transaction_id找到对应的hlsEbankCcbTransaction对象
// 然后通过ld037表中的transaction_id找到对应的hlsEbankCcbTransaction对象
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
new
HlsEbankCcbTransaction
();
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
hlsEbankCcbTransactionMapper
.
selectByPrimaryKey
(
ld037
.
getTransactionId
());
hlsEbankCcbTransaction
.
setTransactionId
(
ld037
.
getTransactionId
());
hlsEbankCcbTransaction
=
hlsEbankCcbTransactionMapper
.
selectByPrimaryKey
(
hlsEbankCcbTransaction
);
if
(
Objects
.
isNull
(
hlsEbankCcbTransaction
)
||
"CMB"
.
equalsIgnoreCase
(
hlsEbankCcbTransaction
.
getBankType
()))
{
if
(
Objects
.
isNull
(
hlsEbankCcbTransaction
)
||
!
"CMB"
.
equalsIgnoreCase
(
hlsEbankCcbTransaction
.
getBankType
()))
{
result
.
put
(
Constants
.
RESP_CODE
,
"S"
);
result
.
put
(
Constants
.
RESP_CODE
,
tranSuccess
);
result
.
put
(
Constants
.
RESP_MSG
,
"订单不存在"
);
result
.
put
(
Constants
.
RESP_MSG
,
"订单不存在"
);
//给到前端订单的状态
//给到前端订单的状态
result
.
put
(
"tradeState"
,
orderNo
);
result
.
put
(
"tradeState"
,
orderNo
);
...
@@ -433,7 +421,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -433,7 +421,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
}
if
(!
transDeal
.
equalsIgnoreCase
(
hlsEbankCcbTransaction
.
getStatus
()))
{
if
(!
transDeal
.
equalsIgnoreCase
(
hlsEbankCcbTransaction
.
getStatus
()))
{
result
.
put
(
Constants
.
RESP_CODE
,
"S"
);
result
.
put
(
Constants
.
RESP_CODE
,
tranSuccess
);
result
.
put
(
Constants
.
RESP_MSG
,
"查询成功"
);
result
.
put
(
Constants
.
RESP_MSG
,
"查询成功"
);
//给到前端订单的状态
//给到前端订单的状态
result
.
put
(
"tradeState"
,
hlsEbankCcbTransaction
.
getOrderStatus
());
result
.
put
(
"tradeState"
,
hlsEbankCcbTransaction
.
getOrderStatus
());
...
@@ -447,12 +435,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -447,12 +435,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
TransactionStatus
transactionStatus
=
transactionManager
.
getTransaction
(
def
);
TransactionStatus
transactionStatus
=
transactionManager
.
getTransaction
(
def
);
//创建订单查询记录
//创建订单查询记录
HlsEbankCmbTransqry
hlsEbankCmbTransqry
=
createTransqry
(
hlsEbankCcbTransaction
.
getTransactionId
(),
"GET"
);
HlsEbankCmbTransqry
hlsEbankCmbTransqry
=
createTransqry
(
iRequest
,
hlsEbankCcbTransaction
.
getTransactionId
(),
"GET"
);
//生成单据编号 日期+id
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
String
dateString
=
formatter
.
format
(
new
Date
());
hlsEbankCmbTransqry
.
setTransqryNumber
(
dateString
+
String
.
format
(
"%08d"
,
hlsEbankCcbTransaction
.
getTransactionId
()));
Map
<
String
,
String
>
responseMap
=
null
;
Map
<
String
,
String
>
responseMap
=
null
;
try
{
try
{
...
@@ -483,7 +466,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -483,7 +466,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
apiHeader
.
put
(
"apisign"
,
apiSignString
);
apiHeader
.
put
(
"apisign"
,
apiSignString
);
//初始化日志
//初始化日志
HlsWsRequests
hlsWsRequests
=
logInterfaceRequest
(
queryQrState
,
pro
.
getProperty
(
"cmb.orderQueryUrl"
),
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
HlsWsRequests
hlsWsRequests
=
logInterfaceRequest
(
iRequest
,
queryQrState
,
pro
.
getProperty
(
"cmb.orderQueryUrl"
),
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
try
{
try
{
//发送http请求
//发送http请求
responseMap
=
Utils
.
postForEntity
(
pro
.
getProperty
(
"cmb.orderQueryUrl"
),
signResult
,
apiHeader
);
responseMap
=
Utils
.
postForEntity
(
pro
.
getProperty
(
"cmb.orderQueryUrl"
),
signResult
,
apiHeader
);
...
@@ -504,7 +487,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -504,7 +487,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
String
respCode
=
responseMap
.
get
(
"respCode"
);
String
respCode
=
responseMap
.
get
(
"respCode"
);
if
(
"SUCCESS"
.
equalsIgnoreCase
(
respCode
))
{
if
(
"SUCCESS"
.
equalsIgnoreCase
(
respCode
))
{
//成功拿到订单状态请求的响应
//成功拿到订单状态请求的响应
hlsEbankCmbTransqry
=
finishTransaction
(
responseMap
,
hlsEbankCcbTransaction
,
hlsEbankCmbTransqry
);
hlsEbankCmbTransqry
=
finishTransaction
(
iRequest
,
responseMap
,
hlsEbankCcbTransaction
,
hlsEbankCmbTransqry
);
resultType
=
"7"
;
resultType
=
"7"
;
}
else
{
}
else
{
...
@@ -520,6 +503,14 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -520,6 +503,14 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
resultType
=
"6"
;
resultType
=
"6"
;
}
}
}
else
{
}
else
{
if
(
"CMBORDERID_NOT_EXIST"
.
equalsIgnoreCase
(
responseMap
.
get
(
"errCode"
))){
//关闭订单
hlsEbankCcbTransaction
.
setStatus
(
transClose
);
hlsEbankCcbTransaction
.
setOrderStatus
(
"C"
);
hlsEbankCcbTransactionMapper
.
updateByPrimaryKey
(
hlsEbankCcbTransaction
);
//更新
updateLd037Fail
(
ld037
,
responseMap
.
get
(
"errCode"
));
}
//请求成功,但是响应结果为失败,传给前端失败原因就行
//请求成功,但是响应结果为失败,传给前端失败原因就行
resultType
=
"2"
;
resultType
=
"2"
;
}
}
...
@@ -550,7 +541,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -550,7 +541,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//更新log日志表
//更新log日志表
hlsWsRequests
.
setResponsedDate
(
new
Date
());
hlsWsRequests
.
setResponsedDate
(
new
Date
());
hlsWsRequests
Mapper
.
updateByPrimaryKeySelective
(
hlsWsRequests
);
hlsWsRequests
Service
.
updateByPrimaryKeySelective
(
iRequest
,
hlsWsRequests
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -565,8 +556,10 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -565,8 +556,10 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
}
//设置查询失败结果信息
//设置查询失败结果信息
hlsEbankCmbTransqry
=
setEbankTransqry
(
hlsEbankCmbTransqry
,
responseMap
,
resultType
);
if
(!
"7"
.
equalsIgnoreCase
(
resultType
))
{
hlsEbankCmbTransqryMapper
.
updateByPrimaryKeySelective
(
hlsEbankCmbTransqry
);
hlsEbankCmbTransqry
=
setEbankTransqry
(
hlsEbankCmbTransqry
,
responseMap
,
resultType
);
}
hlsEbankCmbTransqryService
.
updateByPrimaryKeySelective
(
iRequest
,
hlsEbankCmbTransqry
);
//状态刷新
//状态刷新
transactionStatus
.
flush
();
transactionStatus
.
flush
();
...
@@ -585,7 +578,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -585,7 +578,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
}
//生成招行扫码交易业务批次数据
//生成招行扫码交易业务批次数据
private
HlsEbankCmbTransqry
createTransqry
(
Long
transactionId
,
String
queryCategory
)
{
private
HlsEbankCmbTransqry
createTransqry
(
IRequest
iRequest
,
Long
transactionId
,
String
queryCategory
)
{
HlsEbankCmbTransqry
cmbTransqry
=
new
HlsEbankCmbTransqry
();
HlsEbankCmbTransqry
cmbTransqry
=
new
HlsEbankCmbTransqry
();
cmbTransqry
.
setMerId
(
pro
.
getProperty
(
"cmb.mer.id"
));
cmbTransqry
.
setMerId
(
pro
.
getProperty
(
"cmb.mer.id"
));
cmbTransqry
.
setVersion
(
pro
.
getProperty
(
"cmb.version"
));
cmbTransqry
.
setVersion
(
pro
.
getProperty
(
"cmb.version"
));
...
@@ -595,9 +588,14 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -595,9 +588,14 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
cmbTransqry
.
setCreationDate
(
new
Date
());
cmbTransqry
.
setCreationDate
(
new
Date
());
cmbTransqry
.
setLastUpdatedBy
(
1L
);
cmbTransqry
.
setLastUpdatedBy
(
1L
);
cmbTransqry
.
setQueryCategory
(
queryCategory
);
cmbTransqry
.
setQueryCategory
(
queryCategory
);
hlsEbankCmbTransqryMapper
.
insert
(
cmbTransqry
);
cmbTransqry
=
hlsEbankCmbTransqryService
.
insert
(
iRequest
,
cmbTransqry
);
return
hlsEbankCmbTransqryMapper
.
selectByPrimaryKey
(
cmbTransqry
);
//生成单据编号 日期+id
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
String
dateString
=
formatter
.
format
(
new
Date
());
cmbTransqry
.
setTransqryNumber
(
dateString
+
String
.
format
(
"%08d"
,
cmbTransqry
.
getTransqryId
()));
return
cmbTransqry
;
}
}
private
String
postWriteLd037
(
JSONObject
params
)
{
private
String
postWriteLd037
(
JSONObject
params
)
{
...
@@ -638,22 +636,23 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -638,22 +636,23 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
}
//订单完成通用接口
//订单完成通用接口
private
HlsEbankCmbTransqry
finishTransaction
(
Map
<
String
,
String
>
responseMap
,
HlsEbankCcbTransaction
hlsEbankCcbTransaction
,
HlsEbankCmbTransqry
hlsEbankCmbTransqry
)
{
private
HlsEbankCmbTransqry
finishTransaction
(
IRequest
iRequest
,
Map
<
String
,
String
>
responseMap
,
HlsEbankCcbTransaction
hlsEbankCcbTransaction
,
HlsEbankCmbTransqry
hlsEbankCmbTransqry
)
{
//更新交易事务表数据
//更新交易事务表数据
JSONObject
bizContent
=
JSONObject
.
parseObject
(
responseMap
.
get
(
"biz_content"
));
JSONObject
bizContent
=
JSONObject
.
parseObject
(
responseMap
.
get
(
"biz_content"
));
if
(
Objects
.
nonNull
(
bizContent
.
getString
(
"tradeState"
)))
{
if
(
Objects
.
nonNull
(
bizContent
.
getString
(
"tradeState"
)))
{
if
(!
"P"
.
equalsIgnoreCase
(
bizContent
.
getString
(
"tradeState"
)))
{
if
(!
orderPass
.
equalsIgnoreCase
(
bizContent
.
getString
(
"tradeState"
)))
{
hlsEbankCcbTransaction
.
setStatus
(
tranSuccess
);
hlsEbankCcbTransaction
.
setStatus
(
tranSuccess
);
hlsEbankCcbTransaction
.
setSuccessDate
(
new
Date
());
hlsEbankCcbTransaction
.
setSuccessDate
(
new
Date
());
}
if
(
orderSuccess
.
equalsIgnoreCase
(
bizContent
.
getString
(
"tradeState"
)))
{
if
(
"S"
.
equalsIgnoreCase
(
bizContent
.
getString
(
"tradeState"
)))
{
hlsEbankCcbTransaction
.
setSuccessAmount
(
hlsEbankCcbTransaction
.
getAmount
());
hlsEbankCcbTransaction
.
setSuccessAmount
(
hlsEbankCcbTransaction
.
getAmount
());
hlsEbankCcbTransaction
.
setSuccessCount
(
hlsEbankCcbTransaction
.
getCount
());
hlsEbankCcbTransaction
.
setSuccessCount
(
hlsEbankCcbTransaction
.
getCount
());
}
hlsEbankCcbTransaction
.
setOrderStatus
(
bizContent
.
getString
(
"tradeState"
));
hlsEbankCcbTransactionService
.
updateByPrimaryKeySelective
(
iRequest
,
hlsEbankCcbTransaction
);
}
}
}
}
hlsEbankCcbTransaction
.
setOrderStatus
(
bizContent
.
getString
(
"tradeState"
));
hlsEbankCcbTransactionMapper
.
updateByPrimaryKeySelective
(
hlsEbankCcbTransaction
);
//更新查询表数据
//更新查询表数据
hlsEbankCmbTransqry
.
setReturnCode
(
responseMap
.
get
(
"respCode"
));
hlsEbankCmbTransqry
.
setReturnCode
(
responseMap
.
get
(
"respCode"
));
...
@@ -808,12 +807,10 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -808,12 +807,10 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
}
@Override
@Override
public
Map
<
String
,
String
>
orderNotify
(
IRequest
iRequest
,
JSONObject
params
)
{
public
JSONObject
orderNotify
(
IRequest
iRequest
,
String
requestBodyString
)
{
JSONObject
result
=
new
JSONObject
();
JSONObject
respData
=
new
JSONObject
();
System
.
out
.
println
(
params
);
String
requestBodyString
=
params
.
toJSONString
();
Map
<
String
,
String
>
respData
=
new
HashMap
<>();
logger
.
info
(
"支付结果通知,通知信息requestBodyString:"
+
requestBodyString
);
//设置响应数据
//设置响应数据
respData
.
put
(
"version"
,
pro
.
getProperty
(
"cmb.version"
));
//版本号,固定为0.0.1(必传)
respData
.
put
(
"version"
,
pro
.
getProperty
(
"cmb.version"
));
//版本号,固定为0.0.1(必传)
respData
.
put
(
"encoding"
,
pro
.
getProperty
(
"cmb.encoding"
));
//编码方式,固定为UTF-8(必传)
respData
.
put
(
"encoding"
,
pro
.
getProperty
(
"cmb.encoding"
));
//编码方式,固定为UTF-8(必传)
...
@@ -825,7 +822,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -825,7 +822,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
respData
.
put
(
"returnCode"
,
"FAIL"
);
respData
.
put
(
"returnCode"
,
"FAIL"
);
return
respData
;
return
respData
;
}
}
Map
<
String
,
String
>
requestBodyMap
=
str2Map
(
requestBodyString
);
Map
<
String
,
String
>
requestBodyMap
=
Utils
.
str2Map
(
SignatureUtil
.
decode
(
requestBodyString
)
);
Map
<
String
,
String
>
resultMap
=
requestBodyMap
.
entrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
SignatureUtil
.
decode
(
e
.
getKey
()),
e
->
SignatureUtil
.
decode
(
e
.
getValue
())));
Map
<
String
,
String
>
resultMap
=
requestBodyMap
.
entrySet
().
stream
().
collect
(
Collectors
.
toMap
(
e
->
SignatureUtil
.
decode
(
e
.
getKey
()),
e
->
SignatureUtil
.
decode
(
e
.
getValue
())));
if
(
resultMap
==
null
)
{
if
(
resultMap
==
null
)
{
respData
.
put
(
"returnCode"
,
"FAIL"
);
respData
.
put
(
"returnCode"
,
"FAIL"
);
...
@@ -838,77 +835,98 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -838,77 +835,98 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
boolean
flag
=
SM2Util
.
sm2Check
(
contentStr
,
sign
,
pro
.
getProperty
(
"cmb.publicKey"
));
boolean
flag
=
SM2Util
.
sm2Check
(
contentStr
,
sign
,
pro
.
getProperty
(
"cmb.publicKey"
));
if
(!
flag
)
{
if
(!
flag
)
{
//验签失败
//验签失败
System
.
out
.
println
(
"验签失败"
);
logger
.
info
(
"验签失败"
);
respData
.
put
(
"returnCode"
,
"FAIL"
);
respData
.
put
(
"returnCode"
,
"FAIL"
);
return
respData
;
return
respData
;
}
}
System
.
out
.
println
(
"验签成功"
);
logger
.
info
(
"验签成功"
);
JSONObject
mchReserved
=
params
.
getJSONObject
(
"mchReserved"
);
JSONObject
mchReserved
=
JSONObject
.
parseObject
(
resultMap
.
get
(
"biz_content"
))
.
getJSONObject
(
"mchReserved"
);
Long
recamtId
=
mchReserved
.
getLong
(
"recamt_id"
);
Long
recamtId
=
mchReserved
.
getLong
(
"recamt_id"
);
Ld037
ld037
=
new
Ld037
();
Ld037
ld037
=
ld037Mapper
.
selectByPrimaryKey
(
recamtId
);
ld037
.
setId
(
recamtId
);
ld037
=
ld037Mapper
.
selectByPrimaryKey
(
ld037
);
/*对请求结果进行保存*/
/*对请求结果进行保存*/
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
hlsEbankCcbTransactionMapper
.
selectByPrimaryKey
(
ld037
.
getTransactionId
());
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
hlsEbankCcbTransactionMapper
.
selectByPrimaryKey
(
ld037
.
getTransactionId
());
DefaultTransactionDefinition
def
=
new
DefaultTransactionDefinition
();
// 事务隔离级别:开启新事务
def
.
setPropagationBehavior
(
TransactionDefinition
.
PROPAGATION_REQUIRES_NEW
);
//对于每次请求都开启一个事物
TransactionStatus
transactionStatus
=
transactionManager
.
getTransaction
(
def
);
//创建订单查询记录
//创建订单查询记录
HlsEbankCmbTransqry
hlsEbankCmbTransqry
=
createTransqry
(
hlsEbankCcbTransaction
.
getTransactionId
(),
"POST"
);
HlsEbankCmbTransqry
hlsEbankCmbTransqry
=
createTransqry
(
iRequest
,
hlsEbankCcbTransaction
.
getTransactionId
(),
"POST"
);
//生成单据编号 日期+id
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
JSONObject
biz_content
=
JSONObject
.
parseObject
(
resultMap
.
get
(
"biz_content"
));
String
dateString
=
formatter
.
format
(
new
Date
());
biz_content
.
put
(
"tradeState"
,
orderSuccess
);
hlsEbankCmbTransqry
.
setTransqryNumber
(
dateString
+
String
.
format
(
"%08d"
,
hlsEbankCcbTransaction
.
getTransactionId
()));
resultMap
.
put
(
"biz_content"
,
biz_content
.
toJSONString
());
hlsEbankCmbTransqry
=
finishTransaction
(
resultMap
,
hlsEbankCcbTransaction
,
hlsEbankCmbTransqry
);
hlsEbankCmbTransqryMapper
.
updateByPrimaryKey
(
hlsEbankCmbTransqry
);
hlsEbankCmbTransqry
=
finishTransaction
(
iRequest
,
resultMap
,
hlsEbankCcbTransaction
,
hlsEbankCmbTransqry
);
hlsWsRequestsMapper
.
updateByPrimaryKey
(
logInterfaceRequest
(
queryQrState
,
pro
.
getProperty
(
"cmb.server"
),
new
ObjectMapper
().
writeValueAsString
(
respData
),
hlsEbankCcbTransaction
.
getTransactionId
()));
//设置结果信息
hlsEbankCmbTransqryService
.
updateByPrimaryKeySelective
(
iRequest
,
hlsEbankCmbTransqry
);
//状态刷新
transactionStatus
.
flush
();
//事务提交
transactionManager
.
commit
(
transactionStatus
);
JSONObject
ld037Param
=
new
JSONObject
();
ld037Param
.
put
(
"transaction_id"
,
hlsEbankCcbTransaction
.
getTransactionId
());
postWriteLd037
(
ld037Param
);
respData
.
put
(
"respCode"
,
"SUCCESS"
);
//业务错误码,成功为SUCCESS,失败为FAIL
respData
.
put
(
"respCode"
,
"SUCCESS"
);
//业务错误码,成功为SUCCESS,失败为FAIL
/*如果处理自身业务逻辑发生错误,返回
/*如果处理自身业务逻辑发生错误,返回
respData.put("respCode","FAIL");
respData.put("respCode","FAIL");
respData.put("respMsg","error_msg");
respData.put("respMsg","error_msg");
*/
*/
//对待加签内容进行排序拼接
//对待加签内容进行排序拼接
String
signContent
=
SignatureUtil
.
getSignContent
(
respData
);
String
signContent
=
SignatureUtil
.
getSignContent
(
Utils
.
JsonToMap
(
respData
)
);
//加签-使用商户私钥加签
//加签-使用商户私钥加签
respData
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
pro
.
getProperty
(
"cmb.privateKey"
)));
respData
.
put
(
"sign"
,
SM2Util
.
sm2Sign
(
signContent
,
pro
.
getProperty
(
"cmb.privateKey"
)));
return
respData
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
respData
.
put
(
"returnCode"
,
"FAIL"
);
respData
.
put
(
"returnCode"
,
"FAIL"
);
return
respData
;
}
}
return
respData
;
}
}
@Override
@Override
public
JSONObject
closeOrder
(
IRequest
iRequest
,
JSONObject
params
)
{
public
JSONObject
closeOrder
(
IRequest
iRequest
,
JSONObject
params
)
{
JSONObject
result
=
new
JSONObject
();
JSONObject
result
=
new
JSONObject
();
if
(
Objects
.
isNull
(
params
.
get
(
"recamt_id"
)))
{
if
(
Objects
.
isNull
(
params
.
get
(
"recamt_id"
)))
{
result
.
put
(
Constants
.
RESP_CODE
,
"E"
);
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
result
.
put
(
"respMsg"
,
"请求必须参数recamt_id缺失,请检查!"
);
result
.
put
(
"respMsg"
,
"请求必须参数recamt_id缺失,请检查!"
);
return
result
;
return
result
;
}
}
//根据recamt_id查询ld037数据生成hls_ebank_ccb_transaction批次记录
//根据recamt_id查询ld037数据生成hls_ebank_ccb_transaction批次记录
Long
recamtId
=
params
.
getLong
(
"recamt_id"
);
Long
recamtId
=
params
.
getLong
(
"recamt_id"
);
Ld037
ld037
=
new
Ld037
(
);
Ld037
ld037
=
ld037Mapper
.
selectByPrimaryKey
(
recamtId
);
ld037
.
setId
(
recamtId
);
ld037
=
ld037Mapper
.
selectByPrimaryKey
(
ld037
);
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
hlsEbankCcbTransactionMapper
.
selectByPrimaryKey
(
ld037
.
getTransactionId
());
HlsEbankCcbTransaction
hlsEbankCcbTransaction
=
hlsEbankCcbTransactionMapper
.
selectByPrimaryKey
(
ld037
.
getTransactionId
());
if
(
Objects
.
isNull
(
hlsEbankCcbTransaction
)
||
!
"CMB"
.
equalsIgnoreCase
(
hlsEbankCcbTransaction
.
getBankType
()))
{
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
result
.
put
(
Constants
.
RESP_MSG
,
"订单不存在"
);
return
result
;
}
/**
/**
*
支付成功
的订单不允许关单,需要修改返回代码
*
非交易在进行
的订单不允许关单,需要修改返回代码
*/
*/
if
(
"SUCCESS"
.
equalsIgnoreCase
(
hlsEbankCcbTransaction
.
get
Status
()))
{
if
(
orderPass
.
equalsIgnoreCase
(
hlsEbankCcbTransaction
.
getOrder
Status
()))
{
result
.
put
(
Constants
.
RESP_CODE
,
"E"
);
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
result
.
put
(
"respMsg"
,
"订单
已经支付成功
!"
);
result
.
put
(
"respMsg"
,
"订单
状态异常,无法关闭
!"
);
return
result
;
return
result
;
}
}
//开始封装请求部分
Map
<
String
,
String
>
responseMap
=
null
;
String
signResult
=
getOrderCloseParameter
(
hlsEbankCcbTransaction
);
ObjectMapper
mapper
=
new
ObjectMapper
();
Map
<
String
,
String
>
apiHeader
=
null
;
try
{
try
{
//开始封装请求部分
String
signResult
=
getOrderCloseParameter
(
hlsEbankCcbTransaction
);
ObjectMapper
mapper
=
new
ObjectMapper
();
Map
<
String
,
String
>
signResultMap
=
mapper
.
readValue
(
signResult
,
Map
.
class
);
Map
<
String
,
String
>
signResultMap
=
mapper
.
readValue
(
signResult
,
Map
.
class
);
long
currentTimeMills
=
System
.
currentTimeMillis
()
/
1000
;
long
currentTimeMills
=
System
.
currentTimeMillis
()
/
1000
;
...
@@ -924,78 +942,93 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -924,78 +942,93 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
String
apiSignString
=
MD5Utils
.
getMD5Content
(
MD5Content
).
toLowerCase
();
String
apiSignString
=
MD5Utils
.
getMD5Content
(
MD5Content
).
toLowerCase
();
// 组request头部Map
// 组request头部Map
apiHeader
=
new
HashMap
<>();
Map
<
String
,
String
>
apiHeader
=
new
HashMap
<>();
apiHeader
.
put
(
"appid"
,
pro
.
getProperty
(
"cmb.appId"
));
apiHeader
.
put
(
"appid"
,
pro
.
getProperty
(
"cmb.appId"
));
apiHeader
.
put
(
"timestamp"
,
""
+
currentTimeMills
);
apiHeader
.
put
(
"timestamp"
,
""
+
currentTimeMills
);
apiHeader
.
put
(
"apisign"
,
apiSignString
);
apiHeader
.
put
(
"apisign"
,
apiSignString
);
}
catch
(
IOException
e
)
{
/// resultType = "5";
HlsWsRequests
hlsWsRequests
=
logInterfaceRequest
(
iRequest
,
closeOrder
,
pro
.
getProperty
(
"cmb.closeUrl"
),
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
e
.
printStackTrace
();
try
{
}
//发送http请求
HlsWsRequests
hlsWsRequests
=
null
;
responseMap
=
Utils
.
postForEntity
(
pro
.
getProperty
(
"cmb.closeUrl"
),
signResult
,
apiHeader
);
try
{
//处理接口日志
hlsWsRequests
=
logInterfaceRequest
(
closeOrder
,
pro
.
getProperty
(
"cmb.closeUrl"
),
mapper
.
writeValueAsString
(
apiHeader
),
hlsEbankCcbTransaction
.
getTransactionId
());
logger
.
info
(
"关闭订单返回结果:"
+
mapper
.
writeValueAsString
(
responseMap
));
Map
<
String
,
String
>
responseMap
=
Utils
.
postForEntity
(
pro
.
getProperty
(
"cmb.closeUrl"
),
signResult
,
apiHeader
);
//处理响应报文
Boolean
checkResponse
=
checkSign
(
mapper
.
writeValueAsString
(
responseMap
));
//数据验签成功
if
(
checkResponse
)
{
hlsWsRequests
.
setResponseClob
(
mapper
.
writeValueAsString
(
responseMap
));
hlsWsRequests
.
setResponseClob
(
mapper
.
writeValueAsString
(
responseMap
));
hlsWsRequests
.
setReturnStatus
(
"S"
);
hlsWsRequests
.
setReturnStatus
(
"S"
);
hlsWsRequests
.
setResponsedDate
(
new
Date
());
//获取返回码,返回码不为SUCCESS表示报文内的字段不符合规范
//处理响应报文
String
returnCode
=
responseMap
.
get
(
"returnCode"
);
Boolean
checkResponse
=
checkSign
(
mapper
.
writeValueAsString
(
responseMap
));
if
(
"SUCCESS"
.
equalsIgnoreCase
(
returnCode
))
{
//数据验签成功
//响应码
if
(
checkResponse
)
{
String
respCode
=
responseMap
.
get
(
"respCode"
);
//获取返回码,返回码不为SUCCESS表示报文内的字段不符合规范
if
(
"ORDER_PAID"
.
equalsIgnoreCase
(
respCode
))
{
String
returnCode
=
responseMap
.
get
(
"returnCode"
);
//需要调用退款接口
if
(
"SUCCESS"
.
equalsIgnoreCase
(
returnCode
))
{
result
.
put
(
Constants
.
RESP_CODE
,
"E"
);
//响应码
result
.
put
(
"respMsg"
,
"需要调用退款接口!"
);
String
respCode
=
responseMap
.
get
(
"respCode"
);
return
result
;
if
(
"ORDER_PAID"
.
equalsIgnoreCase
(
respCode
))
{
}
else
if
(
"SUCCESS"
.
equalsIgnoreCase
(
respCode
))
{
//需要调用退款接口
//订单关闭成功
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
if
(
"C"
.
equalsIgnoreCase
(
responseMap
.
get
(
"closeState"
)))
{
result
.
put
(
"respMsg"
,
"订单已支付,无法关闭!"
);
hlsEbankCcbTransaction
.
setStatus
(
transClose
);
return
result
;
hlsEbankCcbTransaction
.
setOrderStatus
(
"C"
);
}
else
if
(
"SUCCESS"
.
equalsIgnoreCase
(
respCode
))
{
result
.
put
(
Constants
.
RESP_CODE
,
responseMap
.
get
(
"respCode"
));
//订单关闭成功
result
.
put
(
Constants
.
RESP_MSG
,
"请求成功"
);
if
(
"C"
.
equalsIgnoreCase
(
responseMap
.
get
(
"closeState"
)))
{
result
.
put
(
"cmborderid"
,
responseMap
.
get
(
"origOrderId"
));
//关闭订单
result
.
put
(
"closeState"
,
responseMap
.
get
(
"closeState"
));
hlsEbankCcbTransaction
.
setStatus
(
transClose
);
result
.
put
(
"txnTime"
,
responseMap
.
get
(
"txnTime"
));
hlsEbankCcbTransaction
.
setOrderStatus
(
"C"
);
}
hlsEbankCcbTransactionMapper
.
updateByPrimaryKey
(
hlsEbankCcbTransaction
);
//关单失败处理
//更新
else
{
updateLd037Fail
(
ld037
,
"ORDERID_INVALID"
);
hlsEbankCcbTransaction
.
setOrderStatus
(
"F"
);
result
.
put
(
Constants
.
RESP_CODE
,
responseMap
.
get
(
"respCode"
));
result
.
put
(
Constants
.
RESP_CODE
,
responseMap
.
get
(
"respCode"
));
result
.
put
(
Constants
.
RESP_MSG
,
"请求成功"
);
result
.
put
(
Constants
.
RESP_MSG
,
"订单关闭成功"
);
result
.
put
(
"cmborderid"
,
responseMap
.
get
(
"origOrderId"
));
// result.put("cmborderid", responseMap.get("origOrderId"));
result
.
put
(
"closeState"
,
responseMap
.
get
(
"closeState"
));
// result.put("closeState", responseMap.get("closeState"));
result
.
put
(
"txnTime"
,
responseMap
.
get
(
"txnTime"
));
// result.put("txnTime", responseMap.get("txnTime"));
}
//关单失败处理
else
{
// hlsEbankCcbTransaction.setOrderStatus("F");
result
.
put
(
Constants
.
RESP_CODE
,
responseMap
.
get
(
"respCode"
));
result
.
put
(
Constants
.
RESP_MSG
,
"被关闭交易为失败状态,关单失败"
);
// result.put("cmborderid", responseMap.get("origOrderId"));
// result.put("closeState", responseMap.get("closeState"));
// result.put("txnTime", responseMap.get("txnTime"));
}
}
else
if
(
"FAIL"
.
equalsIgnoreCase
(
respCode
))
{
result
.
put
(
Constants
.
RESP_CODE
,
responseMap
.
get
(
"errCode"
));
result
.
put
(
Constants
.
RESP_MSG
,
responseMap
.
get
(
"respMsg"
));
}
}
}
else
if
(
"SYSTERM_ERROR"
.
equalsIgnoreCase
(
respCode
))
{
}
else
{
//请求成功,但是响应结果为失败,传给前端失败原因就行
//返回码都失败
result
.
put
(
Constants
.
RESP_CODE
,
"E"
);
result
.
put
(
Constants
.
RESP_CODE
,
responseMap
.
get
(
"errCode"
));
result
.
put
(
"respMsg"
,
"需要重新调用查询接口!"
);
result
.
put
(
Constants
.
RESP_MSG
,
responseMap
.
get
(
"respMsg"
));
}
else
if
(
"FAIL"
.
equalsIgnoreCase
(
respCode
))
{
result
.
put
(
"errCode"
,
responseMap
.
get
(
"errCode"
));
result
.
put
(
"respMsg"
,
responseMap
.
get
(
"respMsg"
));
}
}
}
else
{
}
else
{
//返回码都失败
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
result
.
put
(
"errCode"
,
responseMap
.
get
(
"errCode"
));
result
.
put
(
Constants
.
RESP_MSG
,
"数据验签失败"
);
result
.
put
(
"respMsg"
,
responseMap
.
get
(
"respMsg"
));
}
}
}
catch
(
Exception
e
)
{
hlsWsRequests
.
setReturnStatus
(
"E"
);
hlsWsRequests
.
setResponsedDate
(
new
Date
());
e
.
printStackTrace
();
logger
.
info
(
"发送请求异常: {} "
,
e
.
getMessage
());
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
result
.
put
(
Constants
.
RESP_MSG
,
"发送请求异常,"
+
e
.
getMessage
());
}
}
}
catch
(
JsonProcessingException
e
)
{
result
.
put
(
Constants
.
RESP_CODE
,
"E"
);
//更新log日志表
result
.
put
(
"respMsg"
,
"数据验签失败"
);
hlsWsRequests
.
setReturnStatus
(
"E"
);
hlsWsRequests
.
setResponsedDate
(
new
Date
());
hlsWsRequests
.
setResponsedDate
(
new
Date
());
hlsWsRequestsService
.
updateByPrimaryKeySelective
(
iRequest
,
hlsWsRequests
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
logger
.
info
(
"组装请求报文信息失败: {} "
,
e
.
getMessage
());
result
.
put
(
Constants
.
RESP_CODE
,
transFail
);
result
.
put
(
Constants
.
RESP_MSG
,
"组装请求报文信息失败,请查看日志!"
);
}
}
hlsEbankCcbTransactionMapper
.
updateByPrimaryKey
(
hlsEbankCcbTransaction
);
return
result
;
return
result
;
}
}
...
@@ -1010,12 +1043,13 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -1010,12 +1043,13 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
//业务要素
//业务要素
Map
<
String
,
String
>
requestTransactionParams
=
new
HashMap
<>();
Map
<
String
,
String
>
requestTransactionParams
=
new
HashMap
<>();
requestTransactionParams
.
put
(
"merId"
,
hlsEbankCcbTransaction
.
getMerId
());
//商户号(必传)
requestTransactionParams
.
put
(
"merId"
,
hlsEbankCcbTransaction
.
getMerId
());
//商户号(必传)
requestTransactionParams
.
put
(
"origOrderId"
,
hlsEbankCcbTransaction
.
getTransactionNumber
());
//原交易商户订单号(必传)
requestTransactionParams
.
put
(
"userId"
,
hlsEbankCcbTransaction
.
getUserId
());
//收银员
requestTransactionParams
.
put
(
"userId"
,
hlsEbankCcbTransaction
.
getUserId
());
//收银员
ObjectMapper
mapper
=
new
ObjectMapper
();
ObjectMapper
mapper
=
new
ObjectMapper
();
requestPublicParams
.
put
(
"biz_content"
,
mapper
.
writeValueAsString
(
requestTransactionParams
));
requestPublicParams
.
put
(
"biz_content"
,
mapper
.
writeValueAsString
(
requestTransactionParams
));
requestTransactionParams
.
put
(
"origOrderId"
,
hlsEbankCcbTransaction
.
getTransactionNumber
());
//商户订单号(必传)
System
.
out
.
println
(
"加签前的报文内容:"
+
mapper
.
writeValueAsString
(
requestPublicParams
));
logger
.
info
(
"加签前的报文内容:"
+
mapper
.
writeValueAsString
(
requestPublicParams
));
//对待加签内容进行排序拼接
//对待加签内容进行排序拼接
String
signContent
=
SignatureUtil
.
getSignContent
(
requestPublicParams
);
String
signContent
=
SignatureUtil
.
getSignContent
(
requestPublicParams
);
...
@@ -1024,32 +1058,16 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -1024,32 +1058,16 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
requestStr
=
mapper
.
writeValueAsString
(
requestPublicParams
);
requestStr
=
mapper
.
writeValueAsString
(
requestPublicParams
);
System
.
out
.
println
(
"加签后的报文内容:"
+
requestStr
);
logger
.
info
(
"加签后的报文内容:"
+
requestStr
);
return
requestStr
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"加签发生异常!"
);
logger
.
info
(
"加签发生异常!"
+
e
.
getMessage
()
);
e
.
printStackTrace
();
e
.
printStackTrace
();
}
finally
{
return
requestStr
;
return
requestStr
;
}
}
}
}
private
Map
<
String
,
String
>
str2Map
(
String
str
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<>();
String
[]
results
=
str
.
split
(
"&"
);
if
(
results
!=
null
&&
results
.
length
>
0
)
{
for
(
int
var
=
0
;
var
<
results
.
length
;
++
var
)
{
String
pair
=
results
[
var
];
String
[]
kv
=
pair
.
split
(
"="
,
2
);
if
(
kv
!=
null
&&
kv
.
length
==
2
)
{
result
.
put
(
kv
[
0
],
kv
[
1
]);
}
}
}
return
result
;
}
private
Boolean
checkSign
(
String
string
)
{
private
Boolean
checkSign
(
String
string
)
{
System
.
out
.
println
(
"要验签的报文内容:"
+
string
);
System
.
out
.
println
(
"要验签的报文内容:"
+
string
);
try
{
try
{
...
@@ -1073,7 +1091,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -1073,7 +1091,7 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
}
}
}
}
public
HlsWsRequests
logInterfaceRequest
(
String
functionName
,
String
url
,
String
request
,
Long
pkValue
)
{
public
HlsWsRequests
logInterfaceRequest
(
IRequest
iRequest
,
String
functionName
,
String
url
,
String
request
,
Long
pkValue
)
{
HlsWsRequests
hlsWsRequests
=
new
HlsWsRequests
();
HlsWsRequests
hlsWsRequests
=
new
HlsWsRequests
();
hlsWsRequests
.
setRequestDate
(
new
Date
());
hlsWsRequests
.
setRequestDate
(
new
Date
());
...
@@ -1086,17 +1104,19 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
...
@@ -1086,17 +1104,19 @@ public class HclcCmbPolyServiceImpl implements HclcCmbPolyService {
hlsWsRequests
.
setStatusDate
(
new
Date
());
hlsWsRequests
.
setStatusDate
(
new
Date
());
hlsWsRequests
.
setPkValue
(
pkValue
);
hlsWsRequests
.
setPkValue
(
pkValue
);
hlsWsRequests
.
setRequestClob
(
request
);
hlsWsRequests
.
setRequestClob
(
request
);
hlsWsRequests
Mapper
.
insertSelective
(
hlsWsRequests
);
hlsWsRequests
=
hlsWsRequestsService
.
insertSelective
(
iRequest
,
hlsWsRequests
);
return
hlsWsRequests
;
return
hlsWsRequests
;
}
}
private
String
getTableName
(
String
functionName
)
{
private
String
getTableName
(
String
functionName
)
{
String
tableName
=
""
;
String
tableName
=
""
;
if
(
"GET_QR_CODE"
.
equalsIgnoreCase
(
functionName
))
{
if
(
getQrCode
.
equalsIgnoreCase
(
functionName
))
{
tableName
=
"HLS_EBANK_CCB_TRANSACTION"
;
tableName
=
"HLS_EBANK_CCB_TRANSACTION"
;
}
else
if
(
"QUERY_PAY_RESULT"
.
equalsIgnoreCase
(
functionName
))
{
}
else
if
(
queryQrState
.
equalsIgnoreCase
(
functionName
))
{
tableName
=
"HLS_EBANK_CMB_QUERY"
;
tableName
=
"HLS_EBANK_CMB_QUERY"
;
}
else
if
(
closeOrder
.
equalsIgnoreCase
(
functionName
))
{
tableName
=
"HLS_EBANK_CMB_CLOSE"
;
}
}
return
tableName
;
return
tableName
;
...
...
core/src/main/java/com/hand/app/cmb/service/impl/HlsEbankCmbTransqryServiceImpl.java
0 → 100644
View file @
5965c219
package
com
.
hand
.
app
.
cmb
.
service
.
impl
;
import
com.chinapay.service.IHlsEbankCcbTransactionService
;
import
com.hand.app.cmb.dto.HlsEbankCmbTransqry
;
import
com.hand.app.cmb.service.IHlsEbankCmbTransqryService
;
import
com.hand.hap.system.service.impl.BaseServiceImpl
;
import
org.springframework.stereotype.Service
;
/**
* Created with IntelliJ IDEA.
* User: lsy
* Date: 2020/2/24
* Time: 9:08
*/
@Service
public
class
HlsEbankCmbTransqryServiceImpl
extends
BaseServiceImpl
<
HlsEbankCmbTransqry
>
implements
IHlsEbankCmbTransqryService
{
}
\ No newline at end of file
core/src/main/java/com/hand/app/cmb/util/Utils.java
View file @
5965c219
...
@@ -171,6 +171,21 @@ public class Utils {
...
@@ -171,6 +171,21 @@ public class Utils {
return
paramMap
;
return
paramMap
;
}
}
public
static
Map
<
String
,
String
>
str2Map
(
String
str
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<>();
String
[]
results
=
str
.
split
(
"&"
);
if
(
results
!=
null
&&
results
.
length
>
0
)
{
for
(
int
var
=
0
;
var
<
results
.
length
;
++
var
)
{
String
pair
=
results
[
var
];
String
[]
kv
=
pair
.
split
(
"="
,
2
);
if
(
kv
!=
null
&&
kv
.
length
==
2
)
{
result
.
put
(
kv
[
0
],
kv
[
1
]);
}
}
}
return
result
;
}
/**
/**
* 加载properties配置文件
* 加载properties配置文件
* @param propPath
* @param propPath
...
...
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