记得上下班打卡 | 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
afe680b6
Commit
afe680b6
authored
Jul 08, 2021
by
张国柄
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test'
parents
3dd62637
88341c18
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
131 additions
and
395 deletions
+131
-395
IDragonOrderRefundsService.java
...et/service/dragon/service/IDragonOrderRefundsService.java
+16
-0
HttpClientUtils.java
...et/client/admin/zhengzai/kylin/utils/HttpClientUtils.java
+0
-314
ShunfengSignUtils.java
.../client/admin/zhengzai/kylin/utils/ShunfengSignUtils.java
+0
-48
pom.xml
...dnet-service-dragon/liquidnet-service-dragon-impl/pom.xml
+5
-0
RefundController.java
...liquidnet/service/dragon/controller/RefundController.java
+9
-10
DragonOrderRefundsServiceImpl.java
...ce/dragon/service/impl/DragonOrderRefundsServiceImpl.java
+39
-9
PayAlipayUtils.java
...va/com/liquidnet/service/dragon/utils/PayAlipayUtils.java
+45
-0
PayWepayUtils.java
...ava/com/liquidnet/service/dragon/utils/PayWepayUtils.java
+11
-8
OrderUtils.java
...in/java/com/liquidnet/service/order/utils/OrderUtils.java
+6
-6
No files found.
liquidnet-bus-api/liquidnet-service-dragon-api/src/main/java/com/liquidnet/service/dragon/service/IDragonOrderRefundsService.java
View file @
afe680b6
package
com
.
liquidnet
.
service
.
dragon
.
service
;
package
com
.
liquidnet
.
service
.
dragon
.
service
;
import
java.math.BigDecimal
;
public
interface
IDragonOrderRefundsService
{
public
interface
IDragonOrderRefundsService
{
void
sendRedisQueue
();
void
sendRedisQueue
();
/**
*
* @param trade_no => refund_code
* @param out_trade_no => pay_code
* @param reason
* @param returnUrl
* @param price 退款金额
*/
void
dragonRefund
(
String
trade_no
,
String
out_trade_no
,
String
reason
,
String
returnUrl
,
BigDecimal
price
);
void
weyPayRefund
();
void
aliPayRefund
(
String
trade_no
,
String
out_trade_no
,
String
reason
,
String
returnUrl
,
BigDecimal
price
);
}
}
liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/kylin/utils/HttpClientUtils.java
deleted
100644 → 0
View file @
3dd62637
package
com
.
liquidnet
.
client
.
admin
.
zhengzai
.
kylin
.
utils
;
import
com.liquidnet.client.admin.common.utils.StringUtils
;
import
org.springframework.stereotype.Component
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
import
java.security.KeyManagementException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.cert.X509Certificate
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
javax.net.ssl.SSLContext
;
import
javax.net.ssl.TrustManager
;
import
javax.net.ssl.X509TrustManager
;
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.HttpDelete
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.methods.HttpPut
;
import
org.apache.http.conn.ClientConnectionManager
;
import
org.apache.http.conn.scheme.Scheme
;
import
org.apache.http.conn.scheme.SchemeRegistry
;
import
org.apache.http.conn.ssl.SSLSocketFactory
;
import
org.apache.http.entity.ByteArrayEntity
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.message.BasicNameValuePair
;
/**
* <p>
* HttpClientUtils
* </p>
*
* @author jiangxiulong
* @since 2021-07-07
*/
@Component
public
class
HttpClientUtils
{
public
static
HttpResponse
doGet
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpGet
request
=
new
HttpGet
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
return
httpClient
.
execute
(
request
);
}
/**
* post form
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param bodys
* @return
* @throws Exception
*/
public
static
HttpResponse
doPost
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
Map
<
String
,
String
>
bodys
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPost
request
=
new
HttpPost
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
bodys
!=
null
)
{
List
<
NameValuePair
>
nameValuePairList
=
new
ArrayList
<
NameValuePair
>();
for
(
String
key
:
bodys
.
keySet
())
{
nameValuePairList
.
add
(
new
BasicNameValuePair
(
key
,
bodys
.
get
(
key
)));
}
UrlEncodedFormEntity
formEntity
=
new
UrlEncodedFormEntity
(
nameValuePairList
,
"utf-8"
);
formEntity
.
setContentType
(
"application/x-www-form-urlencoded; charset=UTF-8"
);
request
.
setEntity
(
formEntity
);
}
return
httpClient
.
execute
(
request
);
}
/**
* Post String
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public
static
HttpResponse
doPost
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
String
body
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPost
request
=
new
HttpPost
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
StringUtils
.
isNotBlank
(
body
))
{
request
.
setEntity
(
new
StringEntity
(
body
,
"utf-8"
));
}
return
httpClient
.
execute
(
request
);
}
/**
* Post stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public
static
HttpResponse
doPost
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
byte
[]
body
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPost
request
=
new
HttpPost
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
body
!=
null
)
{
request
.
setEntity
(
new
ByteArrayEntity
(
body
));
}
return
httpClient
.
execute
(
request
);
}
/**
* Put String
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public
static
HttpResponse
doPut
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
String
body
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPut
request
=
new
HttpPut
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
StringUtils
.
isNotBlank
(
body
))
{
request
.
setEntity
(
new
StringEntity
(
body
,
"utf-8"
));
}
return
httpClient
.
execute
(
request
);
}
/**
* Put stream
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @param body
* @return
* @throws Exception
*/
public
static
HttpResponse
doPut
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
,
byte
[]
body
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpPut
request
=
new
HttpPut
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
if
(
body
!=
null
)
{
request
.
setEntity
(
new
ByteArrayEntity
(
body
));
}
return
httpClient
.
execute
(
request
);
}
/**
* Delete
*
* @param host
* @param path
* @param method
* @param headers
* @param querys
* @return
* @throws Exception
*/
public
static
HttpResponse
doDelete
(
String
host
,
String
path
,
String
method
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
String
>
querys
)
throws
Exception
{
HttpClient
httpClient
=
wrapClient
(
host
);
HttpDelete
request
=
new
HttpDelete
(
buildUrl
(
host
,
path
,
querys
));
for
(
Map
.
Entry
<
String
,
String
>
e
:
headers
.
entrySet
())
{
request
.
addHeader
(
e
.
getKey
(),
e
.
getValue
());
}
return
httpClient
.
execute
(
request
);
}
private
static
String
buildUrl
(
String
host
,
String
path
,
Map
<
String
,
String
>
querys
)
throws
UnsupportedEncodingException
{
StringBuilder
sbUrl
=
new
StringBuilder
();
sbUrl
.
append
(
host
);
if
(!
StringUtils
.
isBlank
(
path
))
{
sbUrl
.
append
(
path
);
}
if
(
null
!=
querys
)
{
StringBuilder
sbQuery
=
new
StringBuilder
();
for
(
Map
.
Entry
<
String
,
String
>
query
:
querys
.
entrySet
())
{
if
(
0
<
sbQuery
.
length
())
{
sbQuery
.
append
(
"&"
);
}
if
(
StringUtils
.
isBlank
(
query
.
getKey
())
&&
!
StringUtils
.
isBlank
(
query
.
getValue
()))
{
sbQuery
.
append
(
query
.
getValue
());
}
if
(!
StringUtils
.
isBlank
(
query
.
getKey
()))
{
sbQuery
.
append
(
query
.
getKey
());
if
(!
StringUtils
.
isBlank
(
query
.
getValue
()))
{
sbQuery
.
append
(
"="
);
sbQuery
.
append
(
URLEncoder
.
encode
(
query
.
getValue
(),
"utf-8"
));
}
}
}
if
(
0
<
sbQuery
.
length
())
{
sbUrl
.
append
(
"?"
).
append
(
sbQuery
);
}
}
return
sbUrl
.
toString
();
}
private
static
HttpClient
wrapClient
(
String
host
)
{
HttpClient
httpClient
=
new
DefaultHttpClient
();
if
(
host
.
startsWith
(
"https://"
))
{
//根据传来的URL 进行生产对应的Httpclient
sslClient
(
httpClient
);
}
return
httpClient
;
}
private
static
void
sslClient
(
HttpClient
httpClient
)
{
try
{
SSLContext
ctx
=
SSLContext
.
getInstance
(
"TLSv1.2"
);
X509TrustManager
tm
=
new
X509TrustManager
()
{
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
public
void
checkClientTrusted
(
X509Certificate
[]
xcs
,
String
str
)
{
}
public
void
checkServerTrusted
(
X509Certificate
[]
xcs
,
String
str
)
{
}
};
ctx
.
init
(
null
,
new
TrustManager
[]{
tm
},
null
);
SSLSocketFactory
ssf
=
new
SSLSocketFactory
(
ctx
);
ssf
.
setHostnameVerifier
(
SSLSocketFactory
.
ALLOW_ALL_HOSTNAME_VERIFIER
);
ClientConnectionManager
ccm
=
httpClient
.
getConnectionManager
();
SchemeRegistry
registry
=
ccm
.
getSchemeRegistry
();
registry
.
register
(
new
Scheme
(
"https"
,
443
,
ssf
));
}
catch
(
KeyManagementException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
catch
(
NoSuchAlgorithmException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
\ No newline at end of file
liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/kylin/utils/ShunfengSignUtils.java
View file @
afe680b6
package
com
.
liquidnet
.
client
.
admin
.
zhengzai
.
kylin
.
utils
;
package
com
.
liquidnet
.
client
.
admin
.
zhengzai
.
kylin
.
utils
;
import
com.liquidnet.client.admin.common.utils.http.HttpUtils
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.commons.lang.util.JsonUtils
;
import
com.liquidnet.service.base.UserPathDto
;
import
com.liquidnet.service.base.UserPathDto
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -8,20 +7,15 @@ import org.apache.commons.codec.binary.Base64;
...
@@ -8,20 +7,15 @@ import org.apache.commons.codec.binary.Base64;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.conn.ssl.NoopHostnameVerifier
;
import
org.apache.http.conn.ssl.SSLConnectionSocketFactory
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.ssl.SSLContexts
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.net.ssl.SSLContext
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -78,56 +72,14 @@ public class ShunfengSignUtils {
...
@@ -78,56 +72,14 @@ public class ShunfengSignUtils {
headers
.
put
(
"Accept"
,
"application/json"
);
headers
.
put
(
"Accept"
,
"application/json"
);
Map
<
String
,
String
>
querys
=
new
HashMap
<>();
Map
<
String
,
String
>
querys
=
new
HashMap
<>();
try
{
try
{
// HttpResponse httpResponse = HttpClientUtils.doPost(URL, url, "", headers, querys, body);
// HttpEntity httpEntity = new HttpEntity(body, "utf-8");
// HttpEntity httpEntity = new HttpEntity(body, "utf-8");
HttpEntity
httpEntity
=
new
StringEntity
(
body
,
"utf-8"
);
HttpEntity
httpEntity
=
new
StringEntity
(
body
,
"utf-8"
);
String
post
=
HttpsUtils
.
post
(
URL
+
url
,
headers
,
querys
,
httpEntity
);
String
post
=
HttpsUtils
.
post
(
URL
+
url
,
headers
,
querys
,
httpEntity
);
return
post
;
return
post
;
// HttpResponse httpResponse = HttpsUtils.post(URL+url, headers, querys, httpEntity);
/*if (httpResponse.getStatusLine().getStatusCode() == 200) {
System.out.println("发送请求成功");
HttpEntity entity = httpResponse.getEntity();
// 发送响应且编码UTF8!!!
return EntityUtils.toString(entity, "utf-8");
}*/
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"发送请求失败"
);
System
.
out
.
println
(
"发送请求失败"
);
e
.
printStackTrace
();
e
.
printStackTrace
();
return
e
.
getMessage
();
return
e
.
getMessage
();
}
}
// return null;
}
/**
* 生成签名并请求
* @param hbody 请求body
* @return
*/
public
String
generateSignatureAndRequestNew2
(
Map
<
String
,
String
>
hbody
,
String
url
)
{
long
currentTimeMillis
=
System
.
currentTimeMillis
();
// 时间戳
String
timestamp
=
currentTimeMillis
+
""
;
hbody
.
put
(
"companyId"
,
APP_ID
);
String
body
=
JsonUtils
.
toJson
(
hbody
);
// 生成签名
String
sign
=
genSign
(
timestamp
,
body
);
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"sendAppId"
,
APP_ID
);
headers
.
put
(
"timestamp"
,
timestamp
);
headers
.
put
(
"sign"
,
sign
);
headers
.
put
(
"Content-Type"
,
"application/json;charset=utf-8"
);
headers
.
put
(
"Accept"
,
"application/json"
);
try
{
String
sss
=
HttpUtils
.
sendSSLPost
(
URL
+
url
,
body
);
System
.
out
.
println
(
"发送请求成功"
);
System
.
out
.
println
(
sss
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"发送请求失败"
);
e
.
printStackTrace
();
return
e
.
getMessage
();
}
return
null
;
}
}
/**
/**
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/pom.xml
View file @
afe680b6
...
@@ -30,6 +30,11 @@
...
@@ -30,6 +30,11 @@
<artifactId>
wechatpay-apache-httpclient
</artifactId>
<artifactId>
wechatpay-apache-httpclient
</artifactId>
<version>
0.2.2
</version>
<version>
0.2.2
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.alipay.sdk
</groupId>
<artifactId>
alipay-sdk-java
</artifactId>
<version>
4.15.6.ALL
</version>
</dependency>
</dependencies>
</dependencies>
...
...
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/controller/RefundController.java
View file @
afe680b6
package
com
.
liquidnet
.
service
.
dragon
.
controller
;
package
com
.
liquidnet
.
service
.
dragon
.
controller
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.service.IDragonOrderRefundsService
;
import
com.liquidnet.service.dragon.service.IDragonOrderRefundsService
;
import
com.liquidnet.service.dragon.utils.PayUtils
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiResponse
;
import
io.swagger.annotations.ApiResponse
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.ByteArrayOutputStream
;
@RestController
@RestController
@RequestMapping
(
"refund"
)
@RequestMapping
(
"refund"
)
public
class
RefundController
{
public
class
RefundController
{
...
@@ -26,10 +17,18 @@ public class RefundController {
...
@@ -26,10 +17,18 @@ public class RefundController {
IDragonOrderRefundsService
orderRefundsService
;
IDragonOrderRefundsService
orderRefundsService
;
@PostMapping
(
"preTest"
)
@PostMapping
(
"preTest"
)
@ApiOperation
(
"
发送测试退款redis
"
)
@ApiOperation
(
"
微信退款
"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
public
ResponseDto
<
String
>
checkCanOrder
()
{
public
ResponseDto
<
String
>
checkCanOrder
()
{
orderRefundsService
.
sendRedisQueue
();
orderRefundsService
.
sendRedisQueue
();
return
ResponseDto
.
success
();
return
ResponseDto
.
success
();
}
}
@PostMapping
(
"refundAliPay"
)
@ApiOperation
(
"支付宝退款"
)
@ApiResponse
(
code
=
200
,
message
=
"接口返回对象参数"
)
public
ResponseDto
<
String
>
refundAliPay
()
{
// orderRefundsService.aliPayRefund();
return
ResponseDto
.
success
();
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/service/impl/DragonOrderRefundsServiceImpl.java
View file @
afe680b6
package
com
.
liquidnet
.
service
.
dragon
.
service
.
impl
;
package
com
.
liquidnet
.
service
.
dragon
.
service
.
impl
;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.DefaultAlipayClient
;
import
com.alipay.api.request.AlipayTradeRefundRequest
;
import
com.alipay.api.response.AlipayTradeRefundResponse
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
import
com.liquidnet.service.base.ResponseDto
;
import
com.liquidnet.service.dragon.service.IDragonOrderRefundsService
;
import
com.liquidnet.service.dragon.service.IDragonOrderRefundsService
;
import
com.liquidnet.service.dragon.utils.PayUtils
;
import
com.liquidnet.service.dragon.utils.PayAlipayUtils
;
import
com.liquidnet.service.dragon.utils.PayWepayUtils
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.entity.StringEntity
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.connection.stream.MapRecord
;
import
org.springframework.data.redis.connection.stream.StreamRecords
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.
util.HashMap
;
import
java.
math.BigDecimal
;
@Service
@Service
public
class
DragonOrderRefundsServiceImpl
implements
IDragonOrderRefundsService
{
public
class
DragonOrderRefundsServiceImpl
implements
IDragonOrderRefundsService
{
...
@@ -36,7 +38,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
...
@@ -36,7 +38,7 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
// }
// }
try
{
try
{
Pay
Utils
payUtils
=
new
P
ayUtils
();
Pay
WepayUtils
payWepayUtils
=
new
PayWep
ayUtils
();
HttpPost
httpPost
=
new
HttpPost
(
"https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi"
);
HttpPost
httpPost
=
new
HttpPost
(
"https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi"
);
httpPost
.
addHeader
(
"Accept"
,
"application/json"
);
httpPost
.
addHeader
(
"Accept"
,
"application/json"
);
httpPost
.
addHeader
(
"Content-type"
,
"application/json; charset=utf-8"
);
httpPost
.
addHeader
(
"Content-type"
,
"application/json; charset=utf-8"
);
...
@@ -53,18 +55,46 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
...
@@ -53,18 +55,46 @@ public class DragonOrderRefundsServiceImpl implements IDragonOrderRefundsService
rootNode
.
putObject
(
"amount"
)
rootNode
.
putObject
(
"amount"
)
.
put
(
"total"
,
1
);
.
put
(
"total"
,
1
);
rootNode
.
putObject
(
"payer"
)
rootNode
.
putObject
(
"payer"
)
.
put
(
"openid"
,
"oUp
F8uMuAJO_M2pxb1Q9zNjWeS6o
"
);
.
put
(
"openid"
,
"oUp
kkuHUgiyTYE4ZU8Y5Sga-znWQ
"
);
objectMapper
.
writeValue
(
bos
,
rootNode
);
objectMapper
.
writeValue
(
bos
,
rootNode
);
httpPost
.
setEntity
(
new
StringEntity
(
bos
.
toString
(
"UTF-8"
),
"UTF-8"
));
httpPost
.
setEntity
(
new
StringEntity
(
bos
.
toString
(
"UTF-8"
),
"UTF-8"
));
CloseableHttpResponse
response
=
payUtils
.
getHttpClient
().
execute
(
httpPost
);
CloseableHttpResponse
response
=
pay
Wepay
Utils
.
getHttpClient
().
execute
(
httpPost
);
String
bodyAsString
=
EntityUtils
.
toString
(
response
.
getEntity
());
String
bodyAsString
=
EntityUtils
.
toString
(
response
.
getEntity
());
System
.
out
.
println
(
bodyAsString
);
System
.
out
.
println
(
bodyAsString
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
@Override
public
void
dragonRefund
(
String
trade_no
,
String
out_trade_no
,
String
reason
,
String
returnUrl
,
BigDecimal
price
)
{
}
@Override
public
void
weyPayRefund
()
{
}
@Override
public
void
aliPayRefund
(
String
trade_no
,
String
out_trade_no
,
String
reason
,
String
returnUrl
,
BigDecimal
price
)
{
PayAlipayUtils
payAlipayUtils
=
new
PayAlipayUtils
();
try
{
AlipayTradeRefundRequest
request
=
new
AlipayTradeRefundRequest
();
//创建API对应的request类
request
.
setBizContent
(
"{"
+
"\"out_trade_no\":\"20210708171331569350143233340P\","
+
"\"trade_no\":\"2021070822001417381433077659\","
+
"\"out_request_no\":\"20210708145709112413077422058T\","
+
"\"refund_amount\":\"0.01\"}"
);
//设置业务参数
AlipayTradeRefundResponse
response
=
PayAlipayUtils
.
getHttpClient
().
execute
(
request
);
//通过alipayClient调用API,获得对应的response类
System
.
out
.
print
(
response
.
getBody
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/utils/PayAlipayUtils.java
0 → 100644
View file @
afe680b6
package
com
.
liquidnet
.
service
.
dragon
.
utils
;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.DefaultAlipayClient
;
import
com.alipay.api.request.AlipayTradeRefundRequest
;
import
com.alipay.api.response.AlipayTradeRefundResponse
;
import
com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder
;
import
com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier
;
import
com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner
;
import
com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials
;
import
com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator
;
import
com.wechat.pay.contrib.apache.httpclient.util.PemUtil
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.util.EntityUtils
;
import
java.io.FileInputStream
;
import
java.net.URL
;
import
java.security.PrivateKey
;
public
class
PayAlipayUtils
{
private
static
AlipayClient
httpClient
;
private
static
PayAlipayUtils
instance
=
new
PayAlipayUtils
();
private
String
appId
=
"2019082866535131"
;
private
String
merchant_pub_key
=
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmePaETscydypY3rV4mXa8MtcQIL5zjP1KxdusNkHpePeU61hAZxKn0Z8pDB1wNaTK72wgEWaORXeRp4YTbf4usHlW562Pe5wdiSutb3iT6EMJ5eBD4HLI9wWDgYBtwfHwS5JJFhf0eptP4R1XluLiMhmMynLwJvHepgkVrS3mN+jmoPRmKFhZHGIYDoWypBMbUKiFHWiToHK1n0NYHHIi4WgK2wt4Wj7nexQGD69W7ofRCirYmz35c/cNFUA1lqzOEKu2z7PpjA6jQV2GJolnJ4xXPJ8Dpgp4g/dgsGqRydlmFqZD71i/pDDpF0RfRKHL+WhWVhI1hqe6jLtvJE+zQIDAQAB"
;
private
String
merchant_private_key
=
"MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCArhnBTpcAww8wSYBTwGp6oBvenzCCYFrugERgxJDZ7YnBZ3ZdiAaHjJ9PI0WymkpDr27FSg9czVbiH7G91zPq+8s9onrZi/l6cBZ2VjrwQ9BQPN2a8zHy8D6BfoKEV+PIicGz6hNPA7lgf04NgsXeWjeXnYD/IBTLZmnCxB2sPYo/0EN32mlSG9snO63HlPkoqn8ycw71a1cBrlQ+Y22fFnJAk/vrGoou8E0UHfL5zVE/up+ToOYW/eOKMFL/DSceCy32t9Za0RmpV3i2E9s8gBDewzT10Yf4+4mPUiTR6AhcLjqafAy2IaKPK57WZ6cGF9cGs9yq8bSTRpeNC4alAgMBAAECggEAH0Ms+qvPP94j6IVS6gYLWHNhkfp23JXwQZVkB2Z6EpgFKbmrJhoQDAp8Acv9+OBHPp52ePP/O3qfqxwsIIUSFfrKa9T3p7a8C6UDsAhPFWRETdobtLN05SK87NUBfImly2i8aKtruXycIveKzPmCfPzKGMmpN1Jh+vCMrUbcNqX8OUcxmhGvJwnQuBW4QEiepzl89Nl91iSwFmxaZoqLaB9lYUKke/z7FDHTpTWpZvtvxlZ0gvMVNLVp9NBNazolQ8eEjBG2PsQGD2cLUbM33mLTz+/VQjzZR3KXu5kQR9MloURILDsdxE1AyA4AkIXd4eMszEjA4Dv6CQK/jjrsgQKBgQDIiCt1OGmV2sqDBSn4nZNH7BzY3Hdnf+qsYUi+TXKhnQaT8XPKWZpKE/AcqsIKnANmO4sX0NL7ACBe7Rl1RcU9Mq5XuHhnkveFBVRRIHindzUfEN0WgdLy23qmJ2N+1i4FigelY0E5T2lojVb7wycAgAc6vflwE+eYf8W3968q0QKBgQCkRgsVCWWNMSLZeB0V9LV3Om2/UPWY/ovadTxAQtxg0Z75V6Wdu8u0hrYaPSeUK2ryaoE6HKgp7U8NiJGzgm2wpj7D2ysrPmhX5+CjiWkDMCuvWytVT7hLqhhLp7frZT39u8VhyfC8lE0xA67gAPsGSl1sBoZPwvvsmNAQ/h6rlQKBgQCtCtw9be2m88M3JnieYhOax8Po2u5qsLZoBBcKqLhXf7ISbhPWNFXwwJ29jxicoR5J1O3lIj09fVFxuLX0Pb3DXn2VksjLz8Wp0vx8eUHEeRis8xdleaf4C68du/WemOHjw8VvUWQSOVWjc/vwiumYA+K5LQAXWAXM0c1jP+e3UQKBgEWY/1z8TDATn0Yvo3MH6FIJSTIDJOqa/bmibdJ0AVZruUS+o4Y+aEGlyUU4n6og8wCdqv5p4b1Rs2pyb/hzy/FJndHw60s495A2x2/B6eHV6Mw0fhl42wYDnKOA/WUX0bnMcgXKPtpGoqWff9mb0L6LhyUbZpAodf95hr2MTIY5AoGBAIyPtYP6jRyR980h/Ud1MS0fBxymjQrR+kg3GWjnw0ZJJ8yFEXxDqLV8uLyXQKc89HGbI0cClWgZBTjfIPJ5U4Gl19Xlwx1SFrdgg5mGUqnMARTg7w1TG5QLSqNhZo2jgBM5FCJRbDUCO/MzLcFhTeGNva9yP7E7gW5/Dott9D7d"
;
private
String
sign_type
=
"RSA2"
;
private
String
charset
=
"utf-8"
;
private
String
gatewayUrl
=
"https://openapi.alipay.com/gateway.do"
;
public
PayAlipayUtils
()
{
httpClient
=
new
DefaultAlipayClient
(
gatewayUrl
,
appId
,
merchant_private_key
,
"json"
,
charset
,
merchant_pub_key
,
sign_type
);
//获得初始化的AlipayClient
}
private
static
PayAlipayUtils
getInstance
()
{
return
instance
;
}
public
static
AlipayClient
getHttpClient
()
{
return
httpClient
;
}
}
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/utils/PayUtils.java
→
liquidnet-bus-service/liquidnet-service-dragon/liquidnet-service-dragon-impl/src/main/java/com/liquidnet/service/dragon/utils/Pay
Wepay
Utils.java
View file @
afe680b6
...
@@ -6,27 +6,30 @@ import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
...
@@ -6,27 +6,30 @@ import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner;
import
com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials
;
import
com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials
;
import
com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator
;
import
com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator
;
import
com.wechat.pay.contrib.apache.httpclient.util.PemUtil
;
import
com.wechat.pay.contrib.apache.httpclient.util.PemUtil
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.client.utils.URIBuilder
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.http.util.EntityUtils
;
import
java.io.FileInputStream
;
import
java.net.URL
;
import
java.security.PrivateKey
;
import
java.security.PrivateKey
;
import
java.util.Objects
;
public
class
PayUtils
{
public
class
PayWepayUtils
{
private
CloseableHttpClient
httpClient
;
// private static PayUtils instance = new PayUtils();
private
String
merchantId
=
"1551961491"
;
private
String
merchantId
=
"1551961491"
;
private
String
merchantSerialNumber
=
"6D25ECC819EAE0BCEA7DB18F143F0752431D9295"
;
private
String
merchantSerialNumber
=
"6D25ECC819EAE0BCEA7DB18F143F0752431D9295"
;
// private static PayUtils instance = new PayUtils();
private
String
appId
=
"wx3498304dda39c5a1"
;
private
CloseableHttpClient
httpClient
;
private
String
openId
=
"wx3498304dda39c5a1"
;
public
PayUtils
()
{
public
PayWepayUtils
()
{
System
.
out
.
println
(
"1"
);
try
{
try
{
URL
path
=
PayWepayUtils
.
class
.
getClassLoader
().
getResource
(
"payCert/wepay/wepay_apiclient_key.pem"
);
PrivateKey
merchantPrivateKey
=
PemUtil
.
loadPrivateKey
(
PrivateKey
merchantPrivateKey
=
PemUtil
.
loadPrivateKey
(
Objects
.
requireNonNull
(
PayUtils
.
class
.
getClassLoader
().
getResourceAsStream
(
"wepay_apiclient_key.pem"
))
new
FileInputStream
(
path
.
getPath
(
))
);
);
CloseableHttpClient
httpClientTemp
=
WechatPayHttpClientBuilder
.
create
()
CloseableHttpClient
httpClientTemp
=
WechatPayHttpClientBuilder
.
create
()
...
...
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/utils/OrderUtils.java
View file @
afe680b6
...
@@ -43,7 +43,7 @@ public class OrderUtils {
...
@@ -43,7 +43,7 @@ public class OrderUtils {
}
else
{
}
else
{
integers
=
roadShowOrderLimit
(
userId
,
idCard
,
performanceId
,
ticketId
,
performanceBuyCount
,
ticketBuyCount
,
isTrueName
);
integers
=
roadShowOrderLimit
(
userId
,
idCard
,
performanceId
,
ticketId
,
performanceBuyCount
,
ticketBuyCount
,
isTrueName
);
}
}
return
judgeMemberType
(
performanceLimitCount
,
performanceMemberLimitCount
,
ticketLimitCount
,
ticketMemberLimitCount
,
memberType
,
integers
[
0
],
integers
[
1
]);
return
judgeMemberType
(
performanceLimitCount
,
performanceMemberLimitCount
,
ticketLimitCount
,
ticketMemberLimitCount
,
memberType
,
integers
[
0
],
integers
[
1
]
,
isTrueName
);
}
}
public
Integer
[]
roadShowOrderLimit
(
public
Integer
[]
roadShowOrderLimit
(
...
@@ -85,20 +85,20 @@ public class OrderUtils {
...
@@ -85,20 +85,20 @@ public class OrderUtils {
return
new
Integer
[]{
performanceBuyCount
,
ticketBuyCount
};
return
new
Integer
[]{
performanceBuyCount
,
ticketBuyCount
};
}
}
public
String
judgeMemberType
(
int
performanceLimitCount
,
int
performanceMemberLimitCount
,
int
ticketLimitCount
,
int
ticketMemberLimitCount
,
int
memberType
,
int
performanceBuyCount
,
int
ticketBuyCount
)
{
public
String
judgeMemberType
(
int
performanceLimitCount
,
int
performanceMemberLimitCount
,
int
ticketLimitCount
,
int
ticketMemberLimitCount
,
int
memberType
,
int
performanceBuyCount
,
int
ticketBuyCount
,
int
isTrueName
)
{
if
(
memberType
==
1
||
memberType
==
2
)
{
if
(
memberType
==
1
||
memberType
==
2
)
{
if
(
performanceBuyCount
>
performanceMemberLimitCount
&&
performanceMemberLimitCount
!=
0
)
{
if
(
performanceBuyCount
>
performanceMemberLimitCount
&&
performanceMemberLimitCount
!=
0
)
{
return
"该演出只能购买"
+
performanceMemberLimitCount
+
"张
"
;
//超过演出维度购买量
return
(
1
==
isTrueName
?
"实名制"
:
"本场"
)
+
"演出限购"
+
performanceMemberLimitCount
+
"张,已超出
"
;
//超过演出维度购买量
}
}
if
(
ticketBuyCount
>
ticketMemberLimitCount
&&
ticketMemberLimitCount
!=
0
)
{
if
(
ticketBuyCount
>
ticketMemberLimitCount
&&
ticketMemberLimitCount
!=
0
)
{
return
"该票种只能购买"
+
ticketMemberLimitCount
+
"张
"
;
//超过票维度购买量
return
(
1
==
isTrueName
?
"实名制"
:
"该"
)
+
"票种限购"
+
ticketMemberLimitCount
+
"张,已超出
"
;
//超过票维度购买量
}
}
}
else
{
//非会员区间
}
else
{
//非会员区间
if
(
performanceBuyCount
>
performanceLimitCount
&&
performanceLimitCount
!=
0
)
{
if
(
performanceBuyCount
>
performanceLimitCount
&&
performanceLimitCount
!=
0
)
{
return
"该演出只能购买"
+
performanceLimitCount
+
"张
"
;
//超过演出维度购买量
return
(
1
==
isTrueName
?
"实名制"
:
"本场"
)
+
"演出限购"
+
performanceLimitCount
+
"张,已超出
"
;
//超过演出维度购买量
}
}
if
(
ticketBuyCount
>
ticketLimitCount
&&
ticketLimitCount
!=
0
)
{
if
(
ticketBuyCount
>
ticketLimitCount
&&
ticketLimitCount
!=
0
)
{
return
"该票种只能购买"
+
ticketLimitCount
+
"张
"
;
//超过票维度购买量
return
(
1
==
isTrueName
?
"实名制"
:
"该"
)
+
"票种限购"
+
ticketLimitCount
+
"张,已超出
"
;
//超过票维度购买量
}
}
}
}
return
""
;
return
""
;
...
...
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