记得上下班打卡 | 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
b18e3bff
Commit
b18e3bff
authored
Jul 29, 2021
by
anjiabin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交notify配置
parent
17d68a41
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
198 additions
and
174 deletions
+198
-174
DragonPayBiz.java
...net/service/dragon/channel/strategy/biz/DragonPayBiz.java
+91
-86
ObjectUtil.java
...n/java/com/liquidnet/service/dragon/utils/ObjectUtil.java
+8
-1
DragonPayBiz.java
...net/service/dragon/channel/strategy/biz/DragonPayBiz.java
+91
-86
ObjectUtil.java
...n/java/com/liquidnet/service/dragon/utils/ObjectUtil.java
+8
-1
No files found.
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/biz/DragonPayBiz.java
View file @
b18e3bff
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
biz
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
biz
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.HttpUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
...
@@ -12,21 +13,11 @@ import com.liquidnet.service.dragon.dto.PayNotifyDto;
...
@@ -12,21 +13,11 @@ import com.liquidnet.service.dragon.dto.PayNotifyDto;
import
com.liquidnet.service.dragon.utils.ObjectUtil
;
import
com.liquidnet.service.dragon.utils.ObjectUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.NameValuePair
;
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.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.MultiValueMap
;
import
java.io.IOException
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -84,74 +75,27 @@ public class DragonPayBiz {
...
@@ -84,74 +75,27 @@ 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
boolean
sendNotify
(
PayNotifyReqBo
payNotifyReqBo
){
public
boolean
sendNotify
(
PayNotifyReqBo
payNotifyReqBo
){
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
String
jsonData
=
""
;
String
jsonData
=
""
;
try
{
try
{
HttpPost
httpPost
=
new
HttpPost
(
payNotifyReqBo
.
getNotifyUrl
());
MultiValueMap
<
String
,
String
>
params
=
ObjectUtil
.
cloneLinkedMultiValueMapStringAndString
();
//配置超时
params
.
add
(
"status"
,
payNotifyDto
.
getStatus
().
toString
());
RequestConfig
requestConfig
=
RequestConfig
.
custom
()
params
.
add
(
"type"
,
payNotifyDto
.
getType
());
.
setConnectTimeout
(
5000
).
setConnectionRequestTimeout
(
5000
)
params
.
add
(
"code"
,
payNotifyDto
.
getCode
());
.
setSocketTimeout
(
5000
).
build
();
params
.
add
(
"paymentId"
,
payNotifyDto
.
getPaymentId
());
httpPost
.
setConfig
(
requestConfig
);
params
.
add
(
"orderCode"
,
payNotifyDto
.
getOrderCode
());
params
.
add
(
"price"
,
payNotifyDto
.
getPrice
().
toString
());
//设置post请求参数
params
.
add
(
"paymentType"
,
payNotifyDto
.
getPaymentType
());
List
<
NameValuePair
>
nvps
=
new
ArrayList
<
NameValuePair
>();
params
.
add
(
"paymentAt"
,
payNotifyDto
.
getPaymentAt
());
nvps
.
add
(
new
BasicNameValuePair
(
"status"
,
payNotifyDto
.
getStatus
().
toString
()));
jsonData
=
JsonUtils
.
toJson
(
params
);
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
()));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentAt"
,
payNotifyDto
.
getPaymentAt
()));
jsonData
=
JsonUtils
.
toJson
(
covertNVPS2Params
(
nvps
));
log
.
info
(
"dragon:notify:post url:{}"
,
payNotifyReqBo
.
getNotifyUrl
());
log
.
info
(
"dragon:notify:post url:{}"
,
payNotifyReqBo
.
getNotifyUrl
());
log
.
info
(
"dragon:notify:post data:{}"
,
jsonData
);
log
.
info
(
"dragon:notify:post data:{}"
,
jsonData
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
));
//执行post请求
//执行post请求
CloseableHttpResponse
responseObj
=
httpclient
.
execute
(
httpPost
);
String
response
=
HttpUtil
.
post
(
payNotifyReqBo
.
getNotifyUrl
(),
params
);
String
response
=
EntityUtils
.
toString
(
responseObj
.
getEntity
(),
"utf-8"
);
log
.
debug
(
"PAY RESPONSE="
+
response
);
log
.
debug
(
"PAY RESPONSE="
+
response
);
if
(
response
.
equalsIgnoreCase
(
"success"
))
{
if
(
response
.
equalsIgnoreCase
(
"success"
))
{
dragonServiceCommonBiz
.
createDragonPayNotify
(
payNotifyReqBo
,
jsonData
);
dragonServiceCommonBiz
.
createDragonPayNotify
(
payNotifyReqBo
,
jsonData
);
...
@@ -165,29 +109,90 @@ public class DragonPayBiz {
...
@@ -165,29 +109,90 @@ public class DragonPayBiz {
return
false
;
return
false
;
}
}
}
catch
(
ConnectTimeoutException
e
)
{
}
log
.
error
(
"dragon:sendNotify 请求超时"
,
e
);
// catch (ConnectTimeoutException e) {
dragonServiceCommonBiz
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
// log.error("dragon:sendNotify 请求超时",e);
//更新通知状态-通知失败
// dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_EXPIRE
.
getCode
()));
// //更新通知状态-通知失败
return
false
;
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_EXPIRE.getCode()));
}
catch
(
Exception
e
)
{
// return false;
// }
catch
(
Exception
e
)
{
log
.
error
(
"dragon:sendNotify 请求失败"
,
e
);
log
.
error
(
"dragon:sendNotify 请求失败"
,
e
);
dragonServiceCommonBiz
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
dragonServiceCommonBiz
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知失败
//更新通知状态-通知失败
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_FAIL
.
getCode
()));
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_FAIL
.
getCode
()));
return
false
;
return
false
;
}
finally
{
//释放连接
try
{
if
(
httpclient
!=
null
)
{
httpclient
.
close
();
}
}
catch
(
IOException
e
)
{
log
.
error
(
"连接无法关闭"
,
e
);
}
}
}
}
}
// public boolean sendNotifyBackup(PayNotifyReqBo payNotifyReqBo){
// PayNotifyDto payNotifyDto = payNotifyReqBo.getPayNotifyDto();
// LocalDateTime nowTime = LocalDateTime.now();
//
// 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()));
// nvps.add(new BasicNameValuePair("paymentAt", payNotifyDto.getPaymentAt()));
// jsonData = JsonUtils.toJson(covertNVPS2Params(nvps));
// log.info("dragon:notify:post url:{}",payNotifyReqBo.getNotifyUrl());
// log.info("dragon:notify:post data:{}",jsonData);
// 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.equalsIgnoreCase("success")) {
// dragonServiceCommonBiz.createDragonPayNotify(payNotifyReqBo,jsonData);
// //更新通知状态-通知成功
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_SUCCESS.getCode()));
// return true;
// } else {
// dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
// //更新通知状态-通知失败
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_FAIL.getCode()));
// return false;
// }
//
// } catch (ConnectTimeoutException e) {
// log.error("dragon:sendNotify 请求超时",e);
// dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
// //更新通知状态-通知失败
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_EXPIRE.getCode()));
// return false;
// } catch (Exception e) {
// log.error("dragon:sendNotify 请求失败",e);
// dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
// //更新通知状态-通知失败
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_FAIL.getCode()));
// return false;
// }finally {
// //释放连接
// try {
// if (httpclient != null) {
// httpclient.close();
// }
// } catch (IOException e) {
// log.error("连接无法关闭",e);
// }
// }
// }
public
String
getPaymentType
(
String
payType
,
String
deviceFrom
){
public
String
getPaymentType
(
String
payType
,
String
deviceFrom
){
return
(
deviceFrom
+
payType
).
toUpperCase
();
return
(
deviceFrom
+
payType
).
toUpperCase
();
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/utils/ObjectUtil.java
View file @
b18e3bff
...
@@ -3,8 +3,10 @@ package com.liquidnet.service.dragon.utils;
...
@@ -3,8 +3,10 @@ package com.liquidnet.service.dragon.utils;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alipay.api.request.AlipayTradeWapPayRequest
;
import
com.alipay.api.request.AlipayTradeWapPayRequest
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.LinkedMultiValueMap
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
/**
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @author AnJiabin <anjiabin@zhengzai.tv>
...
@@ -23,6 +25,7 @@ public class ObjectUtil {
...
@@ -23,6 +25,7 @@ public class ObjectUtil {
private
static
final
HashMap
<
String
,
Object
>
hashMapStringAndObj
=
new
HashMap
<>();
private
static
final
HashMap
<
String
,
Object
>
hashMapStringAndObj
=
new
HashMap
<>();
private
static
final
AlipayTradeWapPayRequest
alipayTradeWapPayRequest
=
new
AlipayTradeWapPayRequest
();
private
static
final
AlipayTradeWapPayRequest
alipayTradeWapPayRequest
=
new
AlipayTradeWapPayRequest
();
private
static
final
JSONObject
jsonObjectObj
=
new
JSONObject
();
private
static
final
JSONObject
jsonObjectObj
=
new
JSONObject
();
private
static
final
LinkedMultiValueMap
<
String
,
String
>
linkedMultiValueMapStringAndString
=
new
LinkedMultiValueMap
<
String
,
String
>();
public
static
LinkedList
<
Object
[]>
cloneLinkedListObj
()
{
public
static
LinkedList
<
Object
[]>
cloneLinkedListObj
()
{
return
(
LinkedList
<
Object
[]>)
linkedListObj
.
clone
();
return
(
LinkedList
<
Object
[]>)
linkedListObj
.
clone
();
...
@@ -47,4 +50,8 @@ public class ObjectUtil {
...
@@ -47,4 +50,8 @@ public class ObjectUtil {
public
static
JSONObject
cloneJsonObjectObj
()
{
public
static
JSONObject
cloneJsonObjectObj
()
{
return
(
JSONObject
)
jsonObjectObj
.
clone
();
return
(
JSONObject
)
jsonObjectObj
.
clone
();
}
}
public
static
LinkedMultiValueMap
<
String
,
String
>
cloneLinkedMultiValueMapStringAndString
()
{
return
linkedMultiValueMapStringAndString
.
clone
();
}
}
}
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/channel/strategy/biz/DragonPayBiz.java
View file @
b18e3bff
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
biz
;
package
com
.
liquidnet
.
service
.
dragon
.
channel
.
strategy
.
biz
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.DateUtil
;
import
com.liquidnet.commons.lang.util.HttpUtil
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.commons.lang.util.StringUtil
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
import
com.liquidnet.service.dragon.biz.DragonServiceCommonBiz
;
...
@@ -12,21 +13,11 @@ import com.liquidnet.service.dragon.dto.PayNotifyDto;
...
@@ -12,21 +13,11 @@ import com.liquidnet.service.dragon.dto.PayNotifyDto;
import
com.liquidnet.service.dragon.utils.ObjectUtil
;
import
com.liquidnet.service.dragon.utils.ObjectUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.NameValuePair
;
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.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.MultiValueMap
;
import
java.io.IOException
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -84,74 +75,27 @@ public class DragonPayBiz {
...
@@ -84,74 +75,27 @@ 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
boolean
sendNotify
(
PayNotifyReqBo
payNotifyReqBo
){
public
boolean
sendNotify
(
PayNotifyReqBo
payNotifyReqBo
){
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
PayNotifyDto
payNotifyDto
=
payNotifyReqBo
.
getPayNotifyDto
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
LocalDateTime
nowTime
=
LocalDateTime
.
now
();
CloseableHttpClient
httpclient
=
HttpClients
.
createDefault
();
String
jsonData
=
""
;
String
jsonData
=
""
;
try
{
try
{
HttpPost
httpPost
=
new
HttpPost
(
payNotifyReqBo
.
getNotifyUrl
());
MultiValueMap
<
String
,
String
>
params
=
ObjectUtil
.
cloneLinkedMultiValueMapStringAndString
();
//配置超时
params
.
add
(
"status"
,
payNotifyDto
.
getStatus
().
toString
());
RequestConfig
requestConfig
=
RequestConfig
.
custom
()
params
.
add
(
"type"
,
payNotifyDto
.
getType
());
.
setConnectTimeout
(
5000
).
setConnectionRequestTimeout
(
5000
)
params
.
add
(
"code"
,
payNotifyDto
.
getCode
());
.
setSocketTimeout
(
5000
).
build
();
params
.
add
(
"paymentId"
,
payNotifyDto
.
getPaymentId
());
httpPost
.
setConfig
(
requestConfig
);
params
.
add
(
"orderCode"
,
payNotifyDto
.
getOrderCode
());
params
.
add
(
"price"
,
payNotifyDto
.
getPrice
().
toString
());
//设置post请求参数
params
.
add
(
"paymentType"
,
payNotifyDto
.
getPaymentType
());
List
<
NameValuePair
>
nvps
=
new
ArrayList
<
NameValuePair
>();
params
.
add
(
"paymentAt"
,
payNotifyDto
.
getPaymentAt
());
nvps
.
add
(
new
BasicNameValuePair
(
"status"
,
payNotifyDto
.
getStatus
().
toString
()));
jsonData
=
JsonUtils
.
toJson
(
params
);
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
()));
nvps
.
add
(
new
BasicNameValuePair
(
"paymentAt"
,
payNotifyDto
.
getPaymentAt
()));
jsonData
=
JsonUtils
.
toJson
(
covertNVPS2Params
(
nvps
));
log
.
info
(
"dragon:notify:post url:{}"
,
payNotifyReqBo
.
getNotifyUrl
());
log
.
info
(
"dragon:notify:post url:{}"
,
payNotifyReqBo
.
getNotifyUrl
());
log
.
info
(
"dragon:notify:post data:{}"
,
jsonData
);
log
.
info
(
"dragon:notify:post data:{}"
,
jsonData
);
httpPost
.
setEntity
(
new
UrlEncodedFormEntity
(
nvps
));
//执行post请求
//执行post请求
CloseableHttpResponse
responseObj
=
httpclient
.
execute
(
httpPost
);
String
response
=
HttpUtil
.
post
(
payNotifyReqBo
.
getNotifyUrl
(),
params
);
String
response
=
EntityUtils
.
toString
(
responseObj
.
getEntity
(),
"utf-8"
);
log
.
debug
(
"PAY RESPONSE="
+
response
);
log
.
debug
(
"PAY RESPONSE="
+
response
);
if
(
response
.
equalsIgnoreCase
(
"success"
))
{
if
(
response
.
equalsIgnoreCase
(
"success"
))
{
dragonServiceCommonBiz
.
createDragonPayNotify
(
payNotifyReqBo
,
jsonData
);
dragonServiceCommonBiz
.
createDragonPayNotify
(
payNotifyReqBo
,
jsonData
);
...
@@ -165,29 +109,90 @@ public class DragonPayBiz {
...
@@ -165,29 +109,90 @@ public class DragonPayBiz {
return
false
;
return
false
;
}
}
}
catch
(
ConnectTimeoutException
e
)
{
}
log
.
error
(
"dragon:sendNotify 请求超时"
,
e
);
// catch (ConnectTimeoutException e) {
dragonServiceCommonBiz
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
// log.error("dragon:sendNotify 请求超时",e);
//更新通知状态-通知失败
// dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_EXPIRE
.
getCode
()));
// //更新通知状态-通知失败
return
false
;
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_EXPIRE.getCode()));
}
catch
(
Exception
e
)
{
// return false;
// }
catch
(
Exception
e
)
{
log
.
error
(
"dragon:sendNotify 请求失败"
,
e
);
log
.
error
(
"dragon:sendNotify 请求失败"
,
e
);
dragonServiceCommonBiz
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
dragonServiceCommonBiz
.
createDragonPayNotifyFail
(
payNotifyReqBo
,
jsonData
);
//更新通知状态-通知失败
//更新通知状态-通知失败
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_FAIL
.
getCode
()));
dragonServiceCommonBiz
.
updateNotifyStatus
(
payNotifyDto
.
getCode
(),
Integer
.
valueOf
(
DragonConstant
.
PayNotifyStatusEnum
.
NOTIFY_FAIL
.
getCode
()));
return
false
;
return
false
;
}
finally
{
//释放连接
try
{
if
(
httpclient
!=
null
)
{
httpclient
.
close
();
}
}
catch
(
IOException
e
)
{
log
.
error
(
"连接无法关闭"
,
e
);
}
}
}
}
}
// public boolean sendNotifyBackup(PayNotifyReqBo payNotifyReqBo){
// PayNotifyDto payNotifyDto = payNotifyReqBo.getPayNotifyDto();
// LocalDateTime nowTime = LocalDateTime.now();
//
// 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()));
// nvps.add(new BasicNameValuePair("paymentAt", payNotifyDto.getPaymentAt()));
// jsonData = JsonUtils.toJson(covertNVPS2Params(nvps));
// log.info("dragon:notify:post url:{}",payNotifyReqBo.getNotifyUrl());
// log.info("dragon:notify:post data:{}",jsonData);
// 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.equalsIgnoreCase("success")) {
// dragonServiceCommonBiz.createDragonPayNotify(payNotifyReqBo,jsonData);
// //更新通知状态-通知成功
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_SUCCESS.getCode()));
// return true;
// } else {
// dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
// //更新通知状态-通知失败
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_FAIL.getCode()));
// return false;
// }
//
// } catch (ConnectTimeoutException e) {
// log.error("dragon:sendNotify 请求超时",e);
// dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
// //更新通知状态-通知失败
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_EXPIRE.getCode()));
// return false;
// } catch (Exception e) {
// log.error("dragon:sendNotify 请求失败",e);
// dragonServiceCommonBiz.createDragonPayNotifyFail(payNotifyReqBo,jsonData);
// //更新通知状态-通知失败
// dragonServiceCommonBiz.updateNotifyStatus(payNotifyDto.getCode(),Integer.valueOf(DragonConstant.PayNotifyStatusEnum.NOTIFY_FAIL.getCode()));
// return false;
// }finally {
// //释放连接
// try {
// if (httpclient != null) {
// httpclient.close();
// }
// } catch (IOException e) {
// log.error("连接无法关闭",e);
// }
// }
// }
public
String
getPaymentType
(
String
payType
,
String
deviceFrom
){
public
String
getPaymentType
(
String
payType
,
String
deviceFrom
){
return
(
deviceFrom
+
payType
).
toUpperCase
();
return
(
deviceFrom
+
payType
).
toUpperCase
();
...
...
liquidnet-bus-service/liquidnet-service-notify/liquidnet-service-notify-impl/src/main/java/com/liquidnet/service/dragon/utils/ObjectUtil.java
View file @
b18e3bff
...
@@ -3,8 +3,10 @@ package com.liquidnet.service.dragon.utils;
...
@@ -3,8 +3,10 @@ package com.liquidnet.service.dragon.utils;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alipay.api.request.AlipayTradeWapPayRequest
;
import
com.alipay.api.request.AlipayTradeWapPayRequest
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.LinkedMultiValueMap
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
/**
/**
* @author AnJiabin <anjiabin@zhengzai.tv>
* @author AnJiabin <anjiabin@zhengzai.tv>
...
@@ -23,6 +25,7 @@ public class ObjectUtil {
...
@@ -23,6 +25,7 @@ public class ObjectUtil {
private
static
final
HashMap
<
String
,
Object
>
hashMapStringAndObj
=
new
HashMap
<>();
private
static
final
HashMap
<
String
,
Object
>
hashMapStringAndObj
=
new
HashMap
<>();
private
static
final
AlipayTradeWapPayRequest
alipayTradeWapPayRequest
=
new
AlipayTradeWapPayRequest
();
private
static
final
AlipayTradeWapPayRequest
alipayTradeWapPayRequest
=
new
AlipayTradeWapPayRequest
();
private
static
final
JSONObject
jsonObjectObj
=
new
JSONObject
();
private
static
final
JSONObject
jsonObjectObj
=
new
JSONObject
();
private
static
final
LinkedMultiValueMap
<
String
,
String
>
linkedMultiValueMapStringAndString
=
new
LinkedMultiValueMap
<
String
,
String
>();
public
static
LinkedList
<
Object
[]>
cloneLinkedListObj
()
{
public
static
LinkedList
<
Object
[]>
cloneLinkedListObj
()
{
return
(
LinkedList
<
Object
[]>)
linkedListObj
.
clone
();
return
(
LinkedList
<
Object
[]>)
linkedListObj
.
clone
();
...
@@ -47,4 +50,8 @@ public class ObjectUtil {
...
@@ -47,4 +50,8 @@ public class ObjectUtil {
public
static
JSONObject
cloneJsonObjectObj
()
{
public
static
JSONObject
cloneJsonObjectObj
()
{
return
(
JSONObject
)
jsonObjectObj
.
clone
();
return
(
JSONObject
)
jsonObjectObj
.
clone
();
}
}
public
static
LinkedMultiValueMap
<
String
,
String
>
cloneLinkedMultiValueMapStringAndString
()
{
return
linkedMultiValueMapStringAndString
.
clone
();
}
}
}
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