Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-cloud-account
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
com.pica.cloud.account
pica-cloud-account
提交
71e38152
提交
71e38152
编写于
3月 25, 2020
作者:
Chongwen.jiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
获取拼图添加打印日志...
上级
bc8d22c5
流水线
#23426
已失败 于阶段
in 2 second
变更
4
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
27 行增加
和
63 行删除
+27
-63
Constants.java
...ica/cloud/account/account/server/constants/Constants.java
+1
-1
AutoCodeController.java
...account/account/server/controller/AutoCodeController.java
+3
-11
AuthCodeService.java
...cloud/account/account/server/service/AuthCodeService.java
+1
-1
AuthCodeServiceImpl.java
...ount/account/server/service/impl/AuthCodeServiceImpl.java
+22
-50
未找到文件。
server/src/main/java/com/pica/cloud/account/account/server/constants/Constants.java
浏览文件 @
71e38152
...
...
@@ -70,6 +70,6 @@ public class Constants {
public
static
final
String
JIGSAW_CODE_KEY
=
"jigsaw-code-{mobile}"
;
/** h5拼图缓存时长*/
public
static
final
int
JIGSAW_CODE_EXPIRE_SECONDS
=
60
*
10
;
public
static
final
int
JIGSAW_CODE_EXPIRE_SECONDS
=
60
;
}
server/src/main/java/com/pica/cloud/account/account/server/controller/AutoCodeController.java
浏览文件 @
71e38152
...
...
@@ -136,21 +136,13 @@ public class AutoCodeController extends AccountBaseController {
AccountUtils
.
checkMobilePhone
(
request
.
getMobile
());
// 拼图验证
Boolean
recordData
=
authCodeService
.
validateJigsawCode
(
req
,
request
);
authCodeService
.
validateJigsawCode
(
req
,
request
);
long
start
=
System
.
currentTimeMillis
();
// 发送短信验证码
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
long
end1
=
System
.
currentTimeMillis
();
logger
.
info
(
"getH5AuthCode-发送短信验证码 used {} million seconds"
,
end1
-
start
);
if
(
recordData
)
{
// 记录风控数据(记录是h5端)
authCodeService
.
recordRcData
(
req
,
request
,
super
.
getDeviceInfo
(
"device_ip"
));
long
end2
=
System
.
currentTimeMillis
();
logger
.
info
(
"getH5AuthCode-recordRcData used {} million seconds"
,
end2
-
start
);
}
// 记录风控数据(记录是h5端)
authCodeService
.
recordRcData
(
req
,
request
,
super
.
getDeviceInfo
(
"device_ip"
));
return
PicaResponse
.
toResponse
();
}
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/AuthCodeService.java
浏览文件 @
71e38152
...
...
@@ -20,7 +20,7 @@ public interface AuthCodeService {
void
recordRcData
(
HttpServletRequest
req
,
BaseRequest
baseRequest
,
String
deviceIp
);
Boolean
validateJigsawCode
(
HttpServletRequest
request
,
BaseRequest
req
);
void
validateJigsawCode
(
HttpServletRequest
request
,
BaseRequest
req
);
JigsawCodeModel
getJigsawCode
(
HttpServletRequest
request
,
Integer
sourceType
,
String
mobile
);
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/impl/AuthCodeServiceImpl.java
浏览文件 @
71e38152
...
...
@@ -79,7 +79,7 @@ public class AuthCodeServiceImpl implements AuthCodeService {
String
publicIp
=
IPUtil
.
getIpAdrress
(
request
);
String
deviceToken
=
baseRequest
.
getDevice_token
();
CheckcodeRiskReq
rcReq
=
new
CheckcodeRiskReq
();
rcReq
.
setMobile
(
baseRequest
.
getMobile
());
rcReq
.
setMobile
(
baseRequest
.
getMobile
()
.
replace
(
" "
,
""
)
);
rcReq
.
setIp
(
publicIp
);
rcReq
.
setDeviceIp
(
deviceInfo
.
getDevice_ip
());
rcReq
.
setDeviceId
(
deviceToken
);
...
...
@@ -181,42 +181,32 @@ public class AuthCodeServiceImpl implements AuthCodeService {
* @Return void
*/
@Override
public
Boolean
validateJigsawCode
(
HttpServletRequest
request
,
BaseRequest
paramReq
)
{
long
start
=
System
.
currentTimeMillis
();
Boolean
recordData
=
false
;
public
void
validateJigsawCode
(
HttpServletRequest
request
,
BaseRequest
paramReq
)
{
if
(!
SourceTypeEnum
.
H5
.
getCode
().
equals
(
paramReq
.
getSourceType
()))
{
logger
.
error
(
"validateJigsawCode-h5 sourceType error"
);
throw
new
PicaWarnException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
PicaResultCode
.
PARAM_IS_INVALID
.
message
());
}
// 调用风控服务,是否需要触发拼图验证
String
capCode
=
paramReq
.
getCapCode
();
int
xPos
=
paramReq
.
getxPos
();
// 1、调用风控服务,是否需要触发拼图验证
BaseRequest
rcReq
=
new
BaseRequest
();
rcReq
.
setMobile
(
paramReq
.
getMobile
());
Boolean
need
=
this
.
rcValidate
(
request
,
rcReq
,
"{}"
,
paramReq
.
getSourceType
());
long
end1
=
System
.
currentTimeMillis
();
logger
.
info
(
"validateJigsawCode-rcValidate used {} million seconds"
,
end1
-
start
);
if
(!
need
)
{
recordData
=
true
;
return
recordData
;
// 不需要拼图验证,直接去发短信
return
;
}
String
key
=
Constants
.
JIGSAW_CODE_KEY
.
replace
(
"{mobile}"
,
paramReq
.
getMobile
());
String
capCode
=
paramReq
.
getCapCode
();
int
xPos
=
paramReq
.
getxPos
();
if
(
StringUtils
.
isEmpty
(
capCode
)
||
xPos
<=
0
)
{
String
key
=
Constants
.
JIGSAW_CODE_KEY
.
replace
(
"{mobile}"
,
paramReq
.
getMobile
());
Long
count
=
cacheClient
.
decr
(
key
);
logger
.
info
(
"validateJigsawCode-count:{}"
,
count
);
if
(
count
.
equals
(
99
))
{
// 上一次拼图验证通过时设置的值是100,这一次直接去发送短信验证码
cacheClient
.
del
(
key
);
recordData
=
true
;
return
recordData
;
}
else
{
logger
.
error
(
"validateJigsawCode-abnormal request, jigsaw code cache not correct"
);
throw
new
PicaWarnException
(
AccountExceptionEnum
.
PICA_CAP_CODE_ERROR
.
getCode
(),
AccountExceptionEnum
.
PICA_CAP_CODE_ERROR
.
getMessage
());
// 本应需要拼图验证,但是在调用获取拼图数据接口时报错了,也直接去发送短信
return
;
}
}
// 2、调用拼图验证接口
PicaResponse
resp
=
null
;
try
{
SliderImageRequest
req
=
new
SliderImageRequest
();
...
...
@@ -226,38 +216,27 @@ public class AuthCodeServiceImpl implements AuthCodeService {
logger
.
info
(
"validateJigsawCode-resp:{}"
,
JSON
.
toJSONString
(
resp
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"validateJigsawCode-sliderImageService.checkcapcode invoke exception"
,
e
.
getMessage
());
/*throw new PicaWarnException(AccountExceptionEnum.PICA_CAP_CODE_ERROR.getCode(),
AccountExceptionEnum.PICA_CAP_CODE_ERROR.getMessage());*/
}
String
code
=
"2"
;
if
(
Objects
.
nonNull
(
resp
))
{
if
(!
PicaResultCode
.
SUCCESS
.
code
().
equals
(
resp
.
getCode
()))
{
logger
.
info
(
"validateJigsawCode-code exception"
);
/*throw new PicaWarnException(AccountExceptionEnum.PICA_CAP_CODE_ERROR.getCode(),
AccountExceptionEnum.PICA_CAP_CODE_ERROR.getMessage());*/
}
JSONObject
respData
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
resp
.
getData
()),
JSONObject
.
class
);
if
(
Objects
.
nonNull
(
respData
))
{
Object
codeObj
=
respData
.
get
(
"code"
);
if
(
Objects
.
nonNull
(
codeObj
))
{
code
=
String
.
valueOf
(
codeObj
);
String
code
=
String
.
valueOf
(
codeObj
);
if
(
StringUtil
.
equals
(
code
,
"2"
)
||
StringUtil
.
equals
(
code
,
"3"
))
{
// 3超期 2验证失败 1成功
throw
new
PicaWarnException
(
AccountExceptionEnum
.
PICA_CAP_CODE_ERROR
.
getCode
(),
AccountExceptionEnum
.
PICA_CAP_CODE_ERROR
.
getMessage
());
}
}
}
}
if
(
StringUtil
.
equals
(
code
,
"2"
)
||
StringUtil
.
equals
(
code
,
"3"
))
{
// 3超期 2验证失败 1成功
throw
new
PicaWarnException
(
AccountExceptionEnum
.
PICA_CAP_CODE_ERROR
.
getCode
(),
AccountExceptionEnum
.
PICA_CAP_CODE_ERROR
.
getMessage
());
}
// 拼图验证通过
cacheClient
.
set
(
key
,
100
,
Constants
.
JIGSAW_CODE_EXPIRE_SECONDS
);
long
end2
=
System
.
currentTimeMillis
();
logger
.
info
(
"validateJigsawCode-total used {} million seconds"
,
end2
-
start
);
return
recordData
;
}
/**
...
...
@@ -270,7 +249,6 @@ public class AuthCodeServiceImpl implements AuthCodeService {
*/
@Override
public
JigsawCodeModel
getJigsawCode
(
HttpServletRequest
request
,
Integer
sourceType
,
String
mobile
)
{
long
start
=
System
.
currentTimeMillis
();
logger
.
info
(
"getJigsawCode-mobile:{}, sourceType:{}"
,
mobile
,
sourceType
);
if
(!
SourceTypeEnum
.
H5
.
getCode
().
equals
(
sourceType
))
{
logger
.
error
(
"getJigsawCode-h5 sourceType error"
);
...
...
@@ -280,8 +258,6 @@ public class AuthCodeServiceImpl implements AuthCodeService {
BaseRequest
req
=
new
BaseRequest
();
req
.
setMobile
(
mobile
);
Boolean
need
=
this
.
rcValidate
(
request
,
req
,
"{}"
,
sourceType
);
long
end1
=
System
.
currentTimeMillis
();
logger
.
info
(
"getJigsawCode-rcValidate used {} million seconds"
,
end1
-
start
);
// 调用proof服务获取拼图数据
JigsawCodeModel
data
=
new
JigsawCodeModel
();
...
...
@@ -289,22 +265,20 @@ public class AuthCodeServiceImpl implements AuthCodeService {
if
(
need
)
{
try
{
picResp
=
sliderImageService
.
getPic
();
long
end3
=
System
.
currentTimeMillis
();
logger
.
info
(
"getJigsawCode-getPic used {} million seconds"
,
end3
-
start
);
logger
.
info
(
"getJigsawCode-getPic-code:{}"
,
picResp
.
getCode
());
}
catch
(
Exception
e
)
{
logger
.
error
(
"getJigsawCode-sliderImageService.getPic invoke exception"
,
e
.
getMessage
());
/*throw new PicaWarnException(AccountExceptionEnum.PICA_CAP_GET_INVOKE_ERROR.getCode(),
AccountExceptionEnum.PICA_CAP_GET_INVOKE_ERROR.getMessage());*/
// 记录改手机号调用接口获取拼图时接口报错
String
key
=
Constants
.
JIGSAW_CODE_KEY
.
replace
(
"{mobile}"
,
mobile
);
cacheClient
.
set
(
key
,
100
,
Constants
.
JIGSAW_CODE_EXPIRE_SECONDS
);
}
if
(
Objects
.
nonNull
(
picResp
))
{
if
(!
PicaResultCode
.
SUCCESS
.
code
().
equals
(
picResp
.
getCode
()))
{
logger
.
info
(
"getJigsawCode-getPic-code exception"
);
/*throw new PicaWarnException(AccountExceptionEnum.PICA_CAP_GET_INVOKE_ERROR.getCode(),
AccountExceptionEnum.PICA_CAP_GET_INVOKE_ERROR.getMessage());*/
}
JSONObject
respData
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
picResp
.
getData
()),
JSONObject
.
class
);
if
(
Objects
.
nonNull
(
respData
))
{
logger
.
info
(
"getJigsawCode-capcode:{}"
,
respData
.
getString
(
"capcode"
));
data
.
setCapCode
(
respData
.
getString
(
"capcode"
));
data
.
setBackImage
(
respData
.
getString
(
"backImage"
));
data
.
setSlidingImage
(
respData
.
getString
(
"slidingImage"
));
...
...
@@ -312,8 +286,6 @@ public class AuthCodeServiceImpl implements AuthCodeService {
}
}
}
long
end2
=
System
.
currentTimeMillis
();
logger
.
info
(
"getJigsawCode-getPic-total used {} million seconds"
,
end2
-
start
);
return
data
;
}
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录