记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
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
董敬伟
liquidnet-bus-v1
Commits
9fb463ab
Commit
9fb463ab
authored
Jul 16, 2021
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改通知逻辑
parent
c8c39892
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
119 additions
and
26 deletions
+119
-26
DragonConstant.java
...com/liquidnet/service/dragon/constant/DragonConstant.java
+5
-3
DragonPayBiz.java
...net/service/dragon/channel/strategy/biz/DragonPayBiz.java
+109
-19
AbstractPayChannelStrategyImpl.java
...channel/strategy/impl/AbstractPayChannelStrategyImpl.java
+5
-4
No files found.
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/constant/DragonConstant.java
View file @
9fb463ab
...
...
@@ -56,9 +56,11 @@ public class DragonConstant {
public
enum
PayStatusEnum
{
STATUS_UNPAID
(
"0"
,
"未支付,或支付中"
),
STATUS_PAID
(
"1"
,
"已支付"
),
STATUS_SUCCESS
(
"2"
,
"已支付,通知成功,交易结束"
),
STATUS_FAIL
(
"3"
,
"已支付,通知失败,交易结束"
),
STATUS_EXPIRE
(
"4"
,
"已支付,通知超时,交易结束"
);
STATUS_PAY_FAIL
(
"2"
,
"支付失败"
),
STATUS_SUCCESS
(
"3"
,
"已支付,通知成功,交易结束"
),
STATUS_FAIL
(
"4"
,
"已支付,通知失败,交易结束"
),
STATUS_EXPIRE
(
"5"
,
"已支付,通知超时,交易结束"
);
private
String
code
;
private
String
message
;
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/biz/DragonPayBiz.java
View file @
9fb463ab
...
...
@@ -2,7 +2,6 @@ package com.liquidnet.service.dragon.channel.strategy.biz;
import
com.alibaba.fastjson.JSON
;
import
com.liquidnet.commons.lang.util.BeanUtil
;
import
com.liquidnet.commons.lang.util.HttpUtil
;
import
com.liquidnet.commons.lang.util.IDGenerator
;
import
com.liquidnet.service.base.SqlMapping
;
import
com.liquidnet.service.dragon.bo.PayNotifyReqBo
;
...
...
@@ -15,12 +14,24 @@ import com.liquidnet.service.dragon.entity.DragonOrders;
import
com.liquidnet.service.dragon.utils.DataUtils
;
import
com.liquidnet.service.dragon.utils.MqHandleUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.ClientProtocolException
;
import
org.apache.http.client.config.RequestConfig
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.conn.ConnectTimeoutException
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
java.io.IOException
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
...
...
@@ -218,26 +229,105 @@ public class DragonPayBiz {
}
// public void sendNotifyBackup(PayNotifyReqBo payNotifyReqBo){
// PayNotifyDto payNotifyDto = payNotifyReqBo.getPayNotifyDto();
// LocalDateTime nowTime = LocalDateTime.now();
// MultiValueMap<String, String> params = new LinkedMultiValueMap();
// params.add("status", payNotifyDto.getStatus().toString());
// params.add("type", payNotifyDto.getType());
// params.add("code", payNotifyDto.getCode());
// params.add("paymentId", payNotifyDto.getPaymentId());
// params.add("orderCode", payNotifyDto.getOrderCode());
// params.add("price", payNotifyDto.getPrice().toString());
// params.add("paymentType", payNotifyDto.getPaymentType());
// String jsonData = JSON.toJSONString(params);
// log.info("dragon:notify:post url:{}",payNotifyReqBo.getNotifyUrl());
// log.info("dragon:notify:post data:{}",jsonData);
// try {
// String response = HttpUtil.post(payNotifyReqBo.getNotifyUrl(), params);
// log.debug("PAY RESPONSE=" + response);
// if (response.equals("success")) {
// this.createDragonPayNotify(payNotifyReqBo,jsonData);
// //更新通知状态-通知成功
// this.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayStatusEnum.STATUS_SUCCESS.getCode()));
// } else {
// this.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
// //更新通知状态-通知失败
// this.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayStatusEnum.STATUS_FAIL.getCode()));
// }
//
// if(true){
// throw new ConnectTimeoutException();
// }
// } catch (ConnectTimeoutException e) {
// System.out.println("请求超时");
//
// }catch (Exception e){
// e.printStackTrace();
// }
// }
public
void
sendNotify
(
PayNotifyReqBo
payNotifyReqBo
){
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
();
params
.
add
(
"status"
,
payNotifyDto
.
getStatus
().
toString
());
params
.
add
(
"type"
,
payNotifyDto
.
getType
());
params
.
add
(
"code"
,
payNotifyDto
.
getCode
());
params
.
add
(
"paymentId"
,
payNotifyDto
.
getPaymentId
());
params
.
add
(
"orderCode"
,
payNotifyDto
.
getOrderCode
());
params
.
add
(
"price"
,
payNotifyDto
.
getPrice
().
toString
());
params
.
add
(
"paymentType"
,
payNotifyDto
.
getPaymentType
());
String
jsonData
=
JSON
.
toJSONString
(
params
);
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
String
jsonData
=
""
;
try
{
HttpPost
httpPost
=
new
HttpPost
(
payNotifyReqBo
.
getNotifyUrl
());
//配置超时
RequestConfig
requestConfig
=
RequestConfig
.
custom
()
.
setConnectTimeout
(
5000
).
setConnectionRequestTimeout
(
5000
)
.
setSocketTimeout
(
5000
).
build
();
httpPost
.
setConfig
(
requestConfig
);
//设置post请求参数
List
<
NameValuePair
>
nvps
=
new
ArrayList
<
NameValuePair
>();
nvps
.
add
(
new
BasicNameValuePair
(
"status"
,
payNotifyDto
.
getStatus
().
toString
()));
nvps
.
add
(
new
BasicNameValuePair
(
"type"
,
payNotifyDto
.
getType
()));
nvps
.
add
(
new
BasicNameValuePair
(
"code"
,
payNotifyDto
.
getCode
()));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentId"
,
payNotifyDto
.
getPaymentId
()));
nvps
.
add
(
new
BasicNameValuePair
(
"orderCode"
,
payNotifyDto
.
getOrderCode
()));
nvps
.
add
(
new
BasicNameValuePair
(
"price"
,
payNotifyDto
.
getPrice
().
toString
()));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentType"
,
payNotifyDto
.
getPaymentType
()));
jsonData
=
JSON
.
toJSONString
(
nvps
);
log
.
info
(
"dragon:notify:post url:{}"
,
payNotifyReqBo
.
getNotifyUrl
());
log
.
info
(
"dragon:notify:post data:{}"
,
jsonData
);
String
response
=
HttpUtil
.
post
(
payNotifyReqBo
.
getNotifyUrl
(),
params
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
));
//执行post请求
CloseableHttpResponse
responseObj
=
httpclient
.
execute
(
httpPost
);
String
response
=
EntityUtils
.
toString
(
responseObj
.
getEntity
(),
"utf-8"
);
log
.
debug
(
"PAY RESPONSE="
+
response
);
if
(
response
.
equals
(
"success"
))
{
this
.
createDragonPayNotify
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知成功
this
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_SUCCESS
.
getCode
()));
}
else
{
this
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知失败
this
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_FAIL
.
getCode
()));
}
}
catch
(
ConnectTimeoutException
e
)
{
log
.
error
(
"dragon:sendNotify 请求超时"
,
e
);
this
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知失败
this
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_EXPIRE
.
getCode
()));
}
catch
(
Exception
e
)
{
log
.
error
(
"dragon:sendNotify 请求失败"
,
e
);
this
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知失败
this
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayStatusEnum
.
STATUS_FAIL
.
getCode
()));
}
finally
{
//释放连接
try
{
if
(
httpclient
!=
null
)
{
httpclient
.
close
();
}
}
catch
(
IOException
e
)
{
log
.
error
(
"连接无法关闭"
,
e
);
}
}
}
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/impl/AbstractPayChannelStrategyImpl.java
View file @
9fb463ab
...
...
@@ -66,11 +66,12 @@ public abstract class AbstractPayChannelStrategyImpl implements IPayChannelStrat
*/
protected
void
completeFailOrder
(
DragonOrdersDto
dragonOrdersDto
,
String
bankReturnMsg
)
{
log
.
info
(
"订单支付失败!"
);
// DragonOrdersDto.(bankReturnMsg);
dragonOrdersDto
.
setStatus
(
Integer
.
parseInt
(
DragonConstant
.
PayStatusEnum
.
STATUS_PAID
.
getCode
()));
// dragonOrdersDto.setPaymentAt(timeEnd);
// dragonOrdersDto.setPaymentId(bankTrxNo);// 设置银行流水号
dragonOrdersDto
.
setStatus
(
Integer
.
parseInt
(
DragonConstant
.
PayStatusEnum
.
STATUS_UNPAID
.
getCode
()));
dataUtils
.
updateOrderStatus
(
dragonOrdersDto
.
getCode
(),
dragonOrdersDto
);
String
notifyUrl
=
dragonOrdersDto
.
getNotifyUrl
(
);
//通知商户
dragonPayBiz
.
sendNotify
(
dragonPayBiz
.
buildPayNotifyReqBo
(
dragonOrdersDto
)
);
}
}
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