Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Jeepay
Commits
bdf7fdb7
Commit
bdf7fdb7
authored
Jun 09, 2021
by
dingzhiwei
Browse files
优化支付回调处理
parent
8409f2e4
Changes
7
Hide whitespace changes
Inline
Side-by-side
docs/sql/init.sql
View file @
bdf7fdb7
...
...
@@ -512,7 +512,7 @@ insert into t_sys_role values ('ROLE_OP', '普通操作员', 'MGR', '0', '2021-0
-- insert into t_sys_role_ent_rela select '801', ent_id from t_sys_entitlement;
-- 超管用户: jeepay / jeepay123
insert
into
t_sys_user
values
(
801
,
'jeepay'
,
'超管'
,
'13000000001'
,
'1'
,
'https://
edu-system
.oss-cn-beijing.aliyuncs.com/
1/img/z/avatar_1.jp
g'
,
'D0001'
,
1
,
1
,
'MGR'
,
'0'
,
'2020-06-13'
,
'2020-06-13'
);
insert
into
t_sys_user
values
(
801
,
'jeepay'
,
'超管'
,
'13000000001'
,
'1'
,
'https://
jeequan
.oss-cn-beijing.aliyuncs.com/
jeepay/img/defava_m.pn
g'
,
'D0001'
,
1
,
1
,
'MGR'
,
'0'
,
'2020-06-13'
,
'2020-06-13'
);
insert
into
t_sys_user_auth
values
(
801
,
'801'
,
'1'
,
'jeepay'
,
'$2a$10$WKuPJKE1XhX15ibqDM745eOCaZZVUiRitUjEyX6zVNd9k.cQXfzGa'
,
'testkey'
,
'MGR'
);
-- insert into t_sys_user_role_rela values (801, 801);
...
...
jeepay-core/src/main/java/com/jeequan/jeepay/core/utils/StringKit.java
View file @
bdf7fdb7
...
...
@@ -15,6 +15,10 @@
*/
package
com.jeequan.jeepay.core.utils
;
import
cn.hutool.core.net.url.UrlBuilder
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.Map
;
import
java.util.UUID
;
/*
...
...
@@ -33,4 +37,32 @@ public class StringKit {
public
static
String
getUUID
(
int
endAt
){
return
getUUID
().
substring
(
0
,
endAt
);
}
/** 拼接url参数 **/
public
static
String
appendUrlQuery
(
String
url
,
Map
<
String
,
Object
>
map
){
if
(
StringUtils
.
isEmpty
(
url
)
||
map
==
null
||
map
.
isEmpty
()){
return
url
;
}
UrlBuilder
result
=
UrlBuilder
.
create
().
of
(
url
);
map
.
forEach
((
k
,
v
)
->
{
if
(
k
!=
null
&&
v
!=
null
){
result
.
addQuery
(
k
,
v
.
toString
());
}
});
return
result
.
toURI
().
toString
();
}
/** 是否 http 或 https连接 **/
public
static
boolean
isAvailableUrl
(
String
url
){
if
(
StringUtils
.
isEmpty
(
url
)){
return
false
;
}
return
url
.
startsWith
(
"http://"
)
||
url
.
startsWith
(
"https://"
);
}
}
jeepay-manager/src/main/resources/application.yml
View file @
bdf7fdb7
...
...
@@ -71,5 +71,5 @@ isys:
# 文件系统配置项(系统内oss, 并非云oss)
oss-file
:
root-path
:
E:/home/jeepay/files
#存储根路径 ( 无需以‘/’结尾 )
public-path
:
${isys.oss-file.root-path}/pubic
#公共读取块 ( 一般配合root-path参数进行设置,需以‘/’ 开头, 无需以‘/’结尾 )
public-path
:
${isys.oss-file.root-path}/pub
l
ic
#公共读取块 ( 一般配合root-path参数进行设置,需以‘/’ 开头, 无需以‘/’结尾 )
private-path
:
${isys.oss-file.root-path}/private
#私有化本地访问,不允许url方式公共读取 ( 一般配合root-path参数进行设置,需以‘/’ 开头, 无需以‘/’结尾 )
jeepay-merchant/src/main/resources/application.yml
View file @
bdf7fdb7
...
...
@@ -71,6 +71,6 @@ isys:
# 文件系统配置项(系统内oss, 并非云oss)
oss-file
:
root-path
:
E:/home/jeepay/files
#存储根路径 ( 无需以‘/’结尾 )
public-path
:
${isys.oss-file.root-path}/pubic
#公共读取块 ( 一般配合root-path参数进行设置,需以‘/’ 开头, 无需以‘/’结尾 )
public-path
:
${isys.oss-file.root-path}/pub
l
ic
#公共读取块 ( 一般配合root-path参数进行设置,需以‘/’ 开头, 无需以‘/’结尾 )
private-path
:
${isys.oss-file.root-path}/private
#私有化本地访问,不允许url方式公共读取 ( 一般配合root-path参数进行设置,需以‘/’ 开头, 无需以‘/’结尾 )
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/ctrl/payorder/AbstractPayOrderController.java
View file @
bdf7fdb7
...
...
@@ -24,6 +24,7 @@ import com.jeequan.jeepay.core.exception.BizException;
import
com.jeequan.jeepay.core.model.ApiRes
;
import
com.jeequan.jeepay.core.utils.SeqKit
;
import
com.jeequan.jeepay.core.utils.SpringBeansUtil
;
import
com.jeequan.jeepay.core.utils.StringKit
;
import
com.jeequan.jeepay.pay.channel.IPaymentService
;
import
com.jeequan.jeepay.pay.ctrl.ApiController
;
import
com.jeequan.jeepay.pay.exception.ChannelException
;
...
...
@@ -107,6 +108,13 @@ public abstract class AbstractPayOrderController extends ApiController {
throw
new
BizException
(
"商户订单["
+
bizRQ
.
getMchOrderNo
()+
"]已存在"
);
}
if
(
StringUtils
.
isNotEmpty
(
bizRQ
.
getNotifyUrl
())
&&
!
StringKit
.
isAvailableUrl
(
bizRQ
.
getNotifyUrl
())){
throw
new
BizException
(
"异步通知地址协议仅支持http:// 或 https:// !"
);
}
if
(
StringUtils
.
isNotEmpty
(
bizRQ
.
getReturnUrl
())
&&
!
StringKit
.
isAvailableUrl
(
bizRQ
.
getReturnUrl
())){
throw
new
BizException
(
"同步通知地址协议仅支持http:// 或 https:// !"
);
}
//获取支付参数 (缓存数据) 和 商户信息
MchConfigContext
mchConfigContext
=
configContextService
.
getMchConfigContext
(
mchNo
);
if
(
mchConfigContext
==
null
){
...
...
jeepay-payment/src/main/java/com/jeequan/jeepay/pay/service/PayMchNotifyService.java
View file @
bdf7fdb7
...
...
@@ -20,6 +20,7 @@ import com.jeequan.jeepay.core.entity.MchInfo;
import
com.jeequan.jeepay.core.entity.MchNotifyRecord
;
import
com.jeequan.jeepay.core.entity.PayOrder
;
import
com.jeequan.jeepay.core.utils.JeepayKit
;
import
com.jeequan.jeepay.core.utils.StringKit
;
import
com.jeequan.jeepay.pay.mq.queue.MqQueue4PayOrderMchNotify
;
import
com.jeequan.jeepay.pay.rqrs.QueryPayOrderRS
;
import
com.jeequan.jeepay.service.impl.MchInfoService
;
...
...
@@ -29,9 +30,6 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLEncoder
;
/*
* 商户通知 service
*
...
...
@@ -101,15 +99,11 @@ public class PayMchNotifyService {
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
queryPayOrderRS
);
jsonObject
.
put
(
"reqTime"
,
System
.
currentTimeMillis
());
//添加请求时间
// 先对原文签名
String
reqSign
=
JeepayKit
.
getSign
(
jsonObject
,
mchKey
);
jsonObject
.
put
(
"sign"
,
reqSign
);
// 签名
// 生成参数串
String
param
=
JeepayKit
.
genUrlParams
(
jsonObject
);
// 报文签名
jsonObject
.
put
(
"sign"
,
JeepayKit
.
getSign
(
jsonObject
,
mchKey
));
//
响应结果
return
payOrder
.
getNotifyUrl
()
+
"?"
+
param
;
//
生成通知
return
StringKit
.
appendUrlQuery
(
payOrder
.
getNotifyUrl
()
,
jsonObject
)
;
}
...
...
@@ -126,17 +120,12 @@ public class PayMchNotifyService {
JSONObject
jsonObject
=
(
JSONObject
)
JSONObject
.
toJSON
(
queryPayOrderRS
);
jsonObject
.
put
(
"reqTime"
,
System
.
currentTimeMillis
());
//添加请求时间
jsonObject
.
keySet
().
stream
().
forEach
(
key
->
jsonObject
.
put
(
key
,
(
jsonObject
.
getString
(
key
)
==
null
?
null
:
URLEncoder
.
encode
(
jsonObject
.
getString
(
key
)))
));
// 先对原文签名
String
reqSign
=
JeepayKit
.
getSign
(
jsonObject
,
mchKey
);
// 报文签名
jsonObject
.
put
(
"sign"
,
JeepayKit
.
getSign
(
jsonObject
,
mchKey
));
// 签名
jsonObject
.
put
(
"sign"
,
reqSign
);
// 签名
// 生成参数串
String
param
=
JeepayKit
.
genUrlParams
(
jsonObject
);
// 生成跳转地址
return
StringKit
.
appendUrlQuery
(
payOrder
.
getReturnUrl
(),
jsonObject
);
//响应结果
return
payOrder
.
getReturnUrl
()
+
"?"
+
param
;
}
}
jeepay-service/src/main/java/com/jeequan/jeepay/service/impl/SysUserService.java
View file @
bdf7fdb7
...
...
@@ -76,9 +76,9 @@ public class SysUserService extends ServiceImpl<SysUserMapper, SysUser> {
//女 默认头像
if
(
sysUser
.
getSex
()
!=
null
&&
CS
.
SEX_FEMALE
==
sysUser
.
getSex
()){
sysUser
.
setAvatarUrl
(
"/img
s
/defava_f.png"
);
sysUser
.
setAvatarUrl
(
"
https://jeequan.oss-cn-beijing.aliyuncs.com/jeepay
/img/defava_f.png"
);
}
else
{
sysUser
.
setAvatarUrl
(
"/img
s
/defava_m.png"
);
sysUser
.
setAvatarUrl
(
"
https://jeequan.oss-cn-beijing.aliyuncs.com/jeepay
/img/defava_m.png"
);
}
//1. 插入用户主表
...
...
Write
Preview
Supports
Markdown
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