Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
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
youjj
cloud-platform
Commits
881adaf8
Commit
881adaf8
authored
Nov 14, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
预授权问题
parent
24329497
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
18 deletions
+39
-18
OrderPayBiz.java
...ain/java/com/xxfc/platform/universal/biz/OrderPayBiz.java
+39
-18
No files found.
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/biz/OrderPayBiz.java
View file @
881adaf8
...
@@ -315,7 +315,6 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -315,7 +315,6 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
//这里和普通的接口调用不同,使用的是sdkExecute
//这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeAppPayResponse
response
=
alipayClient
.
sdkExecute
(
request
);
AlipayTradeAppPayResponse
response
=
alipayClient
.
sdkExecute
(
request
);
log
.
info
(
response
.
getBody
());
//就是orderString 可以直接给客户端请求,无需再做处理。
log
.
info
(
response
.
getBody
());
//就是orderString 可以直接给客户端请求,无需再做处理。
return
response
.
getBody
();
return
response
.
getBody
();
}
catch
(
AlipayApiException
e
)
{
}
catch
(
AlipayApiException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -337,12 +336,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -337,12 +336,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
"\"amount\": \""
+
realAmount
.
toString
()
+
"\" }"
);
"\"amount\": \""
+
realAmount
.
toString
()
+
"\" }"
);
request
.
setNotifyUrl
(
notifyUrl
);
//异步通知地址,必填,该接口只通过该参数进行异步通知
request
.
setNotifyUrl
(
notifyUrl
);
//异步通知地址,必填,该接口只通过该参数进行异步通知
AlipayFundAuthOrderAppFreezeResponse
response
=
alipayClient
.
sdkExecute
(
request
);
//注意这里是sdkExecute,可以获取签名参数
AlipayFundAuthOrderAppFreezeResponse
response
=
alipayClient
.
sdkExecute
(
request
);
//注意这里是sdkExecute,可以获取签名参数
log
.
info
(
"response: {}"
+
response
.
getBody
());
//签名后的参数,直接入参到
if
(
response
.
isSuccess
())
{
if
(
response
.
isSuccess
())
{
log
.
info
(
"调用成功"
);
log
.
info
(
"预授权冻结调用成功"
);
log
.
info
(
"response: {}"
+
response
.
getBody
());
//签名后的参数,直接入参到
return
response
.
getBody
();
return
response
.
getBody
();
}
else
{
}
else
{
log
.
info
(
"调用失败"
);
log
.
info
(
"
预授权冻结
调用失败"
);
return
null
;
return
null
;
}
}
}
}
...
@@ -359,6 +358,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -359,6 +358,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
request
.
setGrantType
(
"authorization_code"
);
request
.
setGrantType
(
"authorization_code"
);
request
.
setCode
(
code
);
request
.
setCode
(
code
);
AlipaySystemOauthTokenResponse
response
=
alipayClient
.
execute
(
request
);
AlipaySystemOauthTokenResponse
response
=
alipayClient
.
execute
(
request
);
log
.
info
(
"获取用户token调用成功,获取用户信息 {}"
,
response
.
getBody
());
if
(
response
.
isSuccess
()){
if
(
response
.
isSuccess
()){
log
.
info
(
"获取用户token调用成功,获取用户信息 {}"
,
response
.
getBody
());
log
.
info
(
"获取用户token调用成功,获取用户信息 {}"
,
response
.
getBody
());
if
(
response
.
getAccessToken
()
!=
null
)
{
if
(
response
.
getAccessToken
()
!=
null
)
{
...
@@ -414,10 +414,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -414,10 +414,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
"\"is_mobile\":\"true\""
+
"\"is_mobile\":\"true\""
+
" }"
);
" }"
);
AlipayUserInfoAuthResponse
response
=
alipayClient
.
execute
(
request
);
AlipayUserInfoAuthResponse
response
=
alipayClient
.
execute
(
request
);
log
.
info
(
"解冻预授权response: {}"
+
response
.
getBody
());
log
.
info
(
response
.
toString
());
if
(
response
.
isSuccess
()){
if
(
response
.
isSuccess
()){
System
.
out
.
println
(
"
调用成功"
);
log
.
info
(
"用户授权
调用成功"
);
}
else
{
}
else
{
System
.
out
.
println
(
"
调用失败"
);
log
.
info
(
"用户授权
调用失败"
);
}
}
return
response
.
getBody
();
return
response
.
getBody
();
}
}
...
@@ -439,13 +441,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -439,13 +441,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
request
.
setBizModel
(
model
);
request
.
setBizModel
(
model
);
request
.
setNotifyUrl
(
notifyUrl
);
//异步通知地址,必填,该接口只通过该参数进行异步通知
request
.
setNotifyUrl
(
notifyUrl
);
//异步通知地址,必填,该接口只通过该参数进行异步通知
AlipayFundAuthOrderUnfreezeResponse
response
=
alipayClient
.
execute
(
request
);
AlipayFundAuthOrderUnfreezeResponse
response
=
alipayClient
.
execute
(
request
);
log
.
info
(
"response: {}"
+
response
.
getBody
());
log
.
info
(
"
解冻预授权
response: {}"
+
response
.
getBody
());
if
(
response
.
isSuccess
())
{
if
(
response
.
isSuccess
())
{
log
.
info
(
"调用成功"
);
log
.
info
(
"解冻预授权调用成功"
);
log
.
info
(
"response: {}"
+
response
.
getBody
());
//签名后的参数,直接入参到
return
true
;
return
true
;
}
else
{
}
else
{
log
.
info
(
"调用失败"
);
log
.
info
(
"
解冻预授权
调用失败"
);
return
false
;
return
false
;
}
}
}
}
...
@@ -465,13 +466,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -465,13 +466,12 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
request
.
setNotifyUrl
(
notifyUrl
);
//异步通知地址,必填,该接口只通过该参数进行异步通知
request
.
setNotifyUrl
(
notifyUrl
);
//异步通知地址,必填,该接口只通过该参数进行异步通知
AlipayFundAuthOperationCancelResponse
response
=
alipayClient
.
execute
(
request
);
AlipayFundAuthOperationCancelResponse
response
=
alipayClient
.
execute
(
request
);
log
.
info
(
"response: {}"
+
response
.
getBody
());
log
.
info
(
"
取消预授权
response: {}"
+
response
.
getBody
());
if
(
response
.
isSuccess
())
{
if
(
response
.
isSuccess
())
{
log
.
info
(
"调用成功"
);
log
.
info
(
"取消预授权调用成功"
);
log
.
info
(
"response: {}"
+
response
.
getBody
());
//签名后的参数,直接入参到
return
response
.
getBody
();
return
response
.
getBody
();
}
else
{
}
else
{
log
.
info
(
"调用失败"
);
log
.
info
(
"
取消预授权
调用失败"
);
return
null
;
return
null
;
}
}
}
}
...
@@ -497,11 +497,11 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -497,11 +497,11 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
request
.
setNotifyUrl
(
notifyUrl
);
//异步通知地址,必填,该接口只通过该参数进行异步通知
request
.
setNotifyUrl
(
notifyUrl
);
//异步通知地址,必填,该接口只通过该参数进行异步通知
AlipayTradePayResponse
response
=
alipayClient
.
execute
(
request
);
AlipayTradePayResponse
response
=
alipayClient
.
execute
(
request
);
log
.
info
(
"预授权转支付response: {}"
+
response
.
getBody
());
if
(
response
.
isSuccess
())
{
if
(
response
.
isSuccess
())
{
log
.
info
(
"response: {}"
+
response
.
getBody
());
return
true
;
return
true
;
}
else
{
}
else
{
log
.
info
(
"调用失败"
);
log
.
info
(
"
预授权转支付
调用失败"
);
return
false
;
return
false
;
}
}
}
}
...
@@ -531,6 +531,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -531,6 +531,7 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
try
{
try
{
log
.
info
(
"支付宝退款中:outTradeNo = {}, tradNo = {}, refundAmount = {}, refundReason = {}"
,
outTradeNo
,
tradNo
,
refundAmount
,
refundReason
);
log
.
info
(
"支付宝退款中:outTradeNo = {}, tradNo = {}, refundAmount = {}, refundReason = {}"
,
outTradeNo
,
tradNo
,
refundAmount
,
refundReason
);
AlipayTradeRefundResponse
response
=
alipayClient
.
execute
(
request
);
AlipayTradeRefundResponse
response
=
alipayClient
.
execute
(
request
);
log
.
info
(
"APP支付退款response: {}"
+
response
.
getBody
());
if
(
response
.
isSuccess
())
{
if
(
response
.
isSuccess
())
{
return
true
;
return
true
;
}
else
{
}
else
{
...
@@ -544,6 +545,24 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -544,6 +545,24 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
return
false
;
return
false
;
}
}
/**
* 查询预授权订单
* @param tradNo
* @throws AlipayApiException
*/
public
void
fundAuthQuery
(
String
tradNo
)
throws
AlipayApiException
{
AlipayClient
alipayClient
=
getAlipayClient
();
AlipayFundAuthOperationDetailQueryRequest
request
=
new
AlipayFundAuthOperationDetailQueryRequest
();
AlipayFundAuthOperationDetailQueryModel
model
=
new
AlipayFundAuthOperationDetailQueryModel
();
//model.setAuthNo("2017120110002001390206804295"); // 支付宝资金授权订单号,在授权冻结成功时返回参数中获得
model
.
setOutOrderNo
(
tradNo
);
//商户的授权资金订单号,与支付宝的授权资金订单号不能同时为空
//model.setOperationId("20171201317348823902"); //支付宝的授权资金操作流水号,冻结成功同步返回
model
.
setOutRequestNo
(
tradNo
);
//商户的授权资金操作流水号,与支付宝的授权资金操作流水号不能同时为空,该值为冻结或解冻是的outRequestNo
request
.
setBizModel
(
model
);
AlipayFundAuthOperationDetailQueryResponse
response
=
alipayClient
.
execute
(
request
);
log
.
info
(
"response: {}"
+
response
.
getBody
());
}
public
static
void
main
(
String
[]
args
)
throws
AlipayApiException
{
public
static
void
main
(
String
[]
args
)
throws
AlipayApiException
{
OrderPayBiz
orderPayBiz
=
new
OrderPayBiz
();
OrderPayBiz
orderPayBiz
=
new
OrderPayBiz
();
OrderPayVo
orderPayVo
=
new
OrderPayVo
();
OrderPayVo
orderPayVo
=
new
OrderPayVo
();
...
@@ -553,9 +572,11 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
...
@@ -553,9 +572,11 @@ public class OrderPayBiz extends BaseBiz<OrderPayMapper, OrderPay> {
orderPayVo
.
setAmount
(
3
);
orderPayVo
.
setAmount
(
3
);
orderPayVo
.
setBody
(
"扣除租车订单费用"
);
orderPayVo
.
setBody
(
"扣除租车订单费用"
);
orderPayVo
.
setSubject
(
"租车订单交易费用"
);
orderPayVo
.
setSubject
(
"租车订单交易费用"
);
//orderPayBiz.fundAuthOrderUnFreeze(orderPayVo, "
");
orderPayBiz
.
fundAuthOrderUnFreeze
(
"2019111410002001530505959461"
,
"2019111410002001530505959461"
,
7
,
"退还押金
"
);
//orderPayBiz.alipayOrderRefund("20191024153859000003","2019102422001421530513773694", 2, "xxxx", "");
//orderPayBiz.alipayOrderRefund("20191024153859000003","2019102422001421530513773694", 2, "xxxx", "");
//orderPayBiz.tradePay(
orderPayVo, "
");
//orderPayBiz.tradePay(
"20191108195202000020", "2019110810002001710518149012", 120000,"退还押金", "退还押金
");
//orderPayBiz.fundAuthCancel(orderPayVo, "");
//orderPayBiz.fundAuthCancel(orderPayVo, "");
//orderPayBiz.tradePay("20191114182254000019", "2019111410002001530505959461", 1,"扣除违约金", "扣除违约金");
}
}
}
}
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