Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzpay
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzpay
提交
f9aff901
提交
f9aff901
编写于
8月 31, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支付接口调整
上级
8cf85d8e
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
41 行增加
和
24 行删除
+41
-24
PayCoreService.java
...va/cn/ibizlab/core/extensions/service/PayCoreService.java
+37
-21
PayCoreResource.java
.../java/cn/ibizlab/api/rest/extensions/PayCoreResource.java
+4
-3
未找到文件。
ibzpay-core/src/main/java/cn/ibizlab/core/extensions/service/PayCoreService.java
浏览文件 @
f9aff901
...
...
@@ -6,6 +6,7 @@ import cn.ibizlab.core.pay.domain.PayOpenAccess;
import
cn.ibizlab.core.pay.domain.PayTrade
;
import
cn.ibizlab.core.pay.service.IPayOpenAccessService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.DefaultAlipayClient
;
import
com.alipay.api.request.*
;
...
...
@@ -68,17 +69,18 @@ public class PayCoreService {
* @param trade
* @return
*/
public
boolean
preCreate
(
PayTrade
trade
){
public
JSONObject
preCreate
(
PayTrade
trade
){
JSONObject
rs
=
new
JSONObject
();
PayOpenAccess
openAccess
=
getOpenAccess
(
trade
);
switch
(
openAccess
.
getOpenType
()){
case
"aliyun"
:
aliPayPreCreate
(
openAccess
,
trade
);
// qrcode=
aliPayPreCreate(openAccess,trade);
break
;
case
"wechat"
:
wechatPreCreate
(
openAccess
,
trade
);
rs
=
wechatPreCreate
(
openAccess
,
trade
);
break
;
}
return
true
;
return
rs
;
}
/**
...
...
@@ -86,17 +88,18 @@ public class PayCoreService {
* @param trade
* @return
*/
public
boolean
query
(
PayTrade
trade
){
public
JSONObject
query
(
PayTrade
trade
){
JSONObject
rs
=
new
JSONObject
();
PayOpenAccess
openAccess
=
getOpenAccess
(
trade
);
switch
(
openAccess
.
getOpenType
()){
case
"aliyun"
:
aliPayQuery
(
openAccess
,
trade
);
//
aliPayQuery(openAccess,trade);
break
;
case
"wechat"
:
wechatPayQuery
(
openAccess
,
trade
);
rs
=
wechatPayQuery
(
openAccess
,
trade
);
break
;
}
return
true
;
return
rs
;
}
/**
...
...
@@ -104,17 +107,18 @@ public class PayCoreService {
* @param trade
* @return
*/
public
boolean
cancel
(
PayTrade
trade
){
public
JSONObject
cancel
(
PayTrade
trade
){
JSONObject
rs
=
new
JSONObject
();
PayOpenAccess
openAccess
=
getOpenAccess
(
trade
);
switch
(
openAccess
.
getOpenType
()){
case
"aliyun"
:
aliPayCancel
(
openAccess
,
trade
);
//
aliPayCancel(openAccess,trade);
break
;
case
"wechat"
:
wechatPayCancel
(
openAccess
,
trade
);
rs
=
wechatPayCancel
(
openAccess
,
trade
);
break
;
}
return
true
;
return
rs
;
}
/**
...
...
@@ -184,7 +188,8 @@ public class PayCoreService {
* @param trade
*/
@SneakyThrows
private
void
wechatPreCreate
(
PayOpenAccess
openAccess
,
PayTrade
trade
)
{
private
JSONObject
wechatPreCreate
(
PayOpenAccess
openAccess
,
PayTrade
trade
)
{
JSONObject
rs
=
new
JSONObject
();
WechatPayConfig
config
=
getWechatPayConfig
(
openAccess
);
WXPay
wxpay
=
new
WXPay
(
config
);
Map
<
String
,
String
>
data
=
new
HashMap
<
String
,
String
>();
...
...
@@ -197,8 +202,11 @@ public class PayCoreService {
data
.
put
(
"notify_url"
,
openAccess
.
getRedirectUri
());
data
.
put
(
"trade_type"
,
"NATIVE"
);
// 此处指定为扫码支付
// data.put("product_id", "12");
Map
<
String
,
String
>
resp
=
wxpay
.
unifiedOrder
(
data
);
System
.
out
.
println
(
resp
);
Map
resp
=
wxpay
.
unifiedOrder
(
data
);
if
(
resp
!=
null
){
rs
=
new
JSONObject
(
resp
);
}
return
rs
;
}
/**
...
...
@@ -206,13 +214,17 @@ public class PayCoreService {
* @param trade
*/
@SneakyThrows
private
void
wechatPayQuery
(
PayOpenAccess
openAccess
,
PayTrade
trade
)
{
private
JSONObject
wechatPayQuery
(
PayOpenAccess
openAccess
,
PayTrade
trade
)
{
JSONObject
rs
=
new
JSONObject
();
WechatPayConfig
config
=
getWechatPayConfig
(
openAccess
);
WXPay
wxpay
=
new
WXPay
(
config
);
Map
<
String
,
String
>
data
=
new
HashMap
<
String
,
String
>();
data
.
put
(
"out_trade_no"
,
trade
.
getOutTradeNo
());
Map
<
String
,
String
>
resp
=
wxpay
.
orderQuery
(
data
);
System
.
out
.
println
(
resp
);
Map
resp
=
wxpay
.
orderQuery
(
data
);
if
(
resp
!=
null
){
rs
=
new
JSONObject
(
resp
);
}
return
rs
;
}
/**
...
...
@@ -220,13 +232,17 @@ public class PayCoreService {
* @param trade
*/
@SneakyThrows
private
void
wechatPayCancel
(
PayOpenAccess
openAccess
,
PayTrade
trade
)
{
private
JSONObject
wechatPayCancel
(
PayOpenAccess
openAccess
,
PayTrade
trade
)
{
JSONObject
rs
=
new
JSONObject
();
WechatPayConfig
config
=
getWechatPayConfig
(
openAccess
);
WXPay
wxpay
=
new
WXPay
(
config
);
Map
<
String
,
String
>
data
=
new
HashMap
<
String
,
String
>();
data
.
put
(
"out_trade_no"
,
trade
.
getOutTradeNo
());
Map
<
String
,
String
>
resp
=
wxpay
.
closeOrder
(
data
);
System
.
out
.
println
(
resp
);
Map
resp
=
wxpay
.
closeOrder
(
data
);
if
(
resp
!=
null
){
rs
=
new
JSONObject
(
resp
);
}
return
rs
;
}
/**
...
...
ibzpay-provider/ibzpay-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/PayCoreResource.java
浏览文件 @
f9aff901
...
...
@@ -3,6 +3,7 @@ package cn.ibizlab.api.rest.extensions;
import
cn.ibizlab.api.dto.PayTradeDTO
;
import
cn.ibizlab.api.mapping.PayTradeMapping
;
import
cn.ibizlab.core.extensions.service.PayCoreService
;
import
com.alibaba.fastjson.JSONObject
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
...
...
@@ -27,19 +28,19 @@ public class PayCoreResource {
@ApiOperation
(
value
=
"预下单获取二维码"
,
tags
=
{
"获取二维码"
},
notes
=
"预下单获取二维码"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/trade/precreate"
)
public
ResponseEntity
<
Boolean
>
preCreate
(
@Validated
@RequestBody
PayTradeDTO
dto
){
public
ResponseEntity
<
JSONObject
>
preCreate
(
@Validated
@RequestBody
PayTradeDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
payCoreService
.
preCreate
(
payTradeMapping
.
toDomain
(
dto
)));
}
@ApiOperation
(
value
=
"查询订单"
,
tags
=
{
"查询订单"
},
notes
=
"查询订单"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/trade/query"
)
public
ResponseEntity
<
Boolean
>
query
(
@Validated
@RequestBody
PayTradeDTO
dto
){
public
ResponseEntity
<
JSONObject
>
query
(
@Validated
@RequestBody
PayTradeDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
payCoreService
.
query
(
payTradeMapping
.
toDomain
(
dto
)));
}
@ApiOperation
(
value
=
"取消订单"
,
tags
=
{
"取消订单"
},
notes
=
"取消订单"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/trade/cancel"
)
public
ResponseEntity
<
Boolean
>
cancel
(
@Validated
@RequestBody
PayTradeDTO
dto
){
public
ResponseEntity
<
JSONObject
>
cancel
(
@Validated
@RequestBody
PayTradeDTO
dto
){
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
payCoreService
.
cancel
(
payTradeMapping
.
toDomain
(
dto
)));
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录