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
提交
9091e460
提交
9091e460
编写于
3月 24, 2020
作者:
Chongwen.jiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调用风控接口修改完成
上级
73a19199
流水线
#23396
已失败 于阶段
in 0 second
变更
5
流水线
1
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
84 行增加
和
52 行删除
+84
-52
pom.xml
server/pom.xml
+1
-1
Constants.java
...ica/cloud/account/account/server/constants/Constants.java
+6
-0
AutoCodeController.java
...account/account/server/controller/AutoCodeController.java
+10
-5
AuthCodeService.java
...cloud/account/account/server/service/AuthCodeService.java
+3
-3
AuthCodeServiceImpl.java
...ount/account/server/service/impl/AuthCodeServiceImpl.java
+64
-43
未找到文件。
server/pom.xml
浏览文件 @
9091e460
...
...
@@ -167,7 +167,7 @@
<dependency>
<groupId>
com.pica.cloud.riskcontrol
</groupId>
<artifactId>
pica-cloud-riskcontrol-client
</artifactId>
<version>
1.0.
2
</version>
<version>
1.0.
3.1
</version>
</dependency>
<!-- apple identifyToken校验 -->
...
...
server/src/main/java/com/pica/cloud/account/account/server/constants/Constants.java
浏览文件 @
9091e460
...
...
@@ -66,4 +66,10 @@ public class Constants {
/** 注册逻辑幂等处理缓存key */
public
static
final
String
REPEAT_REGISTER_PREFIX
=
"repeat-register—"
;
/** h5拼图缓存key */
public
static
final
String
JIGSAW_CODE_KEY
=
"jigsaw-code-{mobile}"
;
/** h5拼图缓存时长*/
public
static
final
int
JIGSAW_CODE_EXPIRE_SECONDS
=
60
*
10
;
}
server/src/main/java/com/pica/cloud/account/account/server/controller/AutoCodeController.java
浏览文件 @
9091e460
...
...
@@ -107,12 +107,13 @@ public class AutoCodeController extends AccountBaseController {
// 验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机
// 4重置密码 5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
request
.
setSourceType
(
super
.
getSourceType
());
AccountUtils
.
checkMobilePhone
(
request
.
getMobile
());
if
(
request
.
getBizType
()
!=
null
&&
request
.
getBizType
().
equals
(
1
))
{
logger
.
info
(
"app-rcValidate-start"
);
// 调用风控接口
authCodeService
.
rcValidate
(
req
,
request
,
super
.
getDeviceInfo
());
authCodeService
.
rcValidate
(
req
,
request
,
super
.
getDeviceInfo
()
,
super
.
getSourceType
()
);
// 发送短信验证码
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
return
PicaResponse
.
toResponse
();
...
...
@@ -138,16 +139,19 @@ public class AutoCodeController extends AccountBaseController {
// 验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机
// 4重置密码 5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
request
.
setSourceType
(
super
.
getSourceType
());
AccountUtils
.
checkMobilePhone
(
request
.
getMobile
());
// 拼图验证
authCodeService
.
validateJigsawCode
(
request
.
getMobile
(),
request
.
getCapCode
(),
request
.
getxPos
()
);
Boolean
recordData
=
authCodeService
.
validateJigsawCode
(
req
,
request
);
// 发送短信验证码
processSysCode
(
request
.
getMobile
(),
request
.
getFlag
());
// TODO 记录风控数据(记录是h5端)
authCodeService
.
recordRcData
(
req
,
request
,
super
.
getDeviceInfo
(
"device_ip"
));
if
(
recordData
)
{
// 记录风控数据(记录是h5端)
authCodeService
.
recordRcData
(
req
,
request
,
super
.
getDeviceInfo
(
"device_ip"
));
}
return
PicaResponse
.
toResponse
();
}
...
...
@@ -165,6 +169,7 @@ public class AutoCodeController extends AccountBaseController {
public
PicaResponse
<
String
>
getAuthCodeWithCaptcha
(
@RequestBody
EncryptEntity
entity
,
HttpServletRequest
req
)
throws
Exception
{
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
request
.
setSourceType
(
super
.
getSourceType
());
String
mobilePhone
=
request
.
getMobile
();
String
flag
=
request
.
getFlag
()
+
""
;
String
captchaToken
=
request
.
getCaptchaToken
();
...
...
@@ -198,7 +203,7 @@ public class AutoCodeController extends AccountBaseController {
public
PicaResponse
getJigsawCode
(
@RequestBody
EncryptEntity
entity
,
HttpServletRequest
req
)
throws
Exception
{
BaseRequest
request
=
CryptoUtil
.
decrypt
(
entity
,
BaseRequest
.
class
);
return
PicaResponse
.
toResponse
(
authCodeService
.
validateJigsawCode
(
request
.
getMobile
()));
return
PicaResponse
.
toResponse
(
authCodeService
.
getJigsawCode
(
req
,
super
.
getSourceType
(),
request
.
getMobile
()));
}
@ApiOperation
(
"微信获取验证码"
)
...
...
server/src/main/java/com/pica/cloud/account/account/server/service/AuthCodeService.java
浏览文件 @
9091e460
...
...
@@ -16,13 +16,13 @@ import javax.servlet.http.HttpServletRequest;
*/
public
interface
AuthCodeService
{
void
rcValidate
(
HttpServletRequest
request
,
BaseRequest
baseRequest
,
String
deviceInfoStr
);
Boolean
rcValidate
(
HttpServletRequest
request
,
BaseRequest
baseRequest
,
String
deviceInfoStr
,
Integer
sourceType
);
void
recordRcData
(
HttpServletRequest
req
,
BaseRequest
baseRequest
,
String
deviceIp
);
void
validateJigsawCode
(
String
mobile
,
String
capCode
,
int
xPos
);
Boolean
validateJigsawCode
(
HttpServletRequest
request
,
BaseRequest
req
);
JigsawCodeModel
validateJigsawCode
(
String
mobile
);
JigsawCodeModel
getJigsawCode
(
HttpServletRequest
request
,
Integer
sourceType
,
String
mobile
);
}
server/src/main/java/com/pica/cloud/account/account/server/service/impl/AuthCodeServiceImpl.java
浏览文件 @
9091e460
...
...
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.pica.cloud.account.account.server.constants.Constants
;
import
com.pica.cloud.account.account.server.enums.AccountExceptionEnum
;
import
com.pica.cloud.account.account.server.enums.RcRepTypeEnum
;
import
com.pica.cloud.account.account.server.enums.SourceTypeEnum
;
import
com.pica.cloud.account.account.server.req.BaseRequest
;
import
com.pica.cloud.account.account.server.model.JigsawCodeModel
;
import
com.pica.cloud.account.account.server.service.AuthCodeService
;
...
...
@@ -69,7 +70,8 @@ public class AuthCodeServiceImpl implements AuthCodeService {
* @Return com.pica.cloud.account.account.server.resp.UnifiedVerificationResp
*/
@Override
public
void
rcValidate
(
HttpServletRequest
request
,
BaseRequest
baseRequest
,
String
deviceInfoStr
)
{
public
Boolean
rcValidate
(
HttpServletRequest
request
,
BaseRequest
baseRequest
,
String
deviceInfoStr
,
Integer
sourceType
)
{
Boolean
need
=
true
;
// 调用风控接口
PicaResponse
picaResponse
=
null
;
try
{
...
...
@@ -81,6 +83,7 @@ public class AuthCodeServiceImpl implements AuthCodeService {
rcReq
.
setIp
(
publicIp
);
rcReq
.
setDeviceIp
(
deviceInfo
.
getDevice_ip
());
rcReq
.
setDeviceId
(
deviceToken
);
rcReq
.
setSourceType
(
sourceType
);
logger
.
info
(
"rc-checkcodeRisk-req:{}"
,
JSON
.
toJSONString
(
rcReq
));
picaResponse
=
rcClient
.
checkcodeRisk
(
rcReq
);
logger
.
info
(
"rc-checkcodeRisk-resp:{}"
,
JSON
.
toJSONString
(
picaResponse
));
...
...
@@ -104,8 +107,12 @@ public class AuthCodeServiceImpl implements AuthCodeService {
throw
new
PicaWarnException
(
AccountExceptionEnum
.
PICA_RC_SEND_FAIL
.
getCode
(),
AccountExceptionEnum
.
PICA_RC_SEND_FAIL
.
getMessage
());
}
else
if
(
processCode
.
equals
(
RcRepTypeEnum
.
RC_TRIGGER
.
getCode
()))
{
throw
new
PicaWarnException
(
AccountExceptionEnum
.
PICA_RC_TRIGGER
.
getCode
(),
AccountExceptionEnum
.
PICA_RC_TRIGGER
.
getMessage
());
if
(
SourceTypeEnum
.
H5
.
getCode
().
equals
(
sourceType
))
{
// h5端需要触发拼图验证,后台去获取拼图数据返给前端
}
else
{
throw
new
PicaWarnException
(
AccountExceptionEnum
.
PICA_RC_TRIGGER
.
getCode
(),
AccountExceptionEnum
.
PICA_RC_TRIGGER
.
getMessage
());
}
}
else
if
(
processCode
.
equals
(
RcRepTypeEnum
.
RC_BLACKLIST
.
getCode
()))
{
throw
new
PicaWarnException
(
AccountExceptionEnum
.
PICA_RC_BLACKLIST
.
getCode
(),
AccountExceptionEnum
.
PICA_RC_BLACKLIST
.
getMessage
());
...
...
@@ -124,15 +131,18 @@ public class AuthCodeServiceImpl implements AuthCodeService {
}
}
else
{
// 刚好60秒缓存时间过去了,也允许发送短信验证码
need
=
false
;
}
}
else
{
// processCode equals "1" (允许发送短信验证码)
need
=
false
;
}
}
}
}
}
return
need
;
}
/**
...
...
@@ -150,6 +160,7 @@ public class AuthCodeServiceImpl implements AuthCodeService {
rec
.
setIp
(
IPUtil
.
getIpAdrress
(
request
));
rec
.
setDeviceIp
(
deviceIp
);
rec
.
setDeviceId
(
baseRequest
.
getDevice_token
());
rec
.
setSourceType
(
baseRequest
.
getSourceType
());
try
{
threadPoolTaskExecutor
.
execute
(()
->
{
logger
.
info
(
"recordRcData-execute-{}"
,
JSON
.
toJSONString
(
rec
));
...
...
@@ -170,17 +181,39 @@ public class AuthCodeServiceImpl implements AuthCodeService {
* @Return void
*/
@Override
public
void
validateJigsawCode
(
String
mobile
,
String
capCode
,
int
xPos
)
{
// 调用风控服务,是否需要触发拼图验证
Boolean
need
=
this
.
judgeNeedJigsaw
(
mobile
);
Boolean
paramValid
=
StringUtils
.
isNotEmpty
(
capCode
)
&&
xPos
>
0
;
if
(!
need
&&
!
paramValid
)
{
return
;
public
Boolean
validateJigsawCode
(
HttpServletRequest
request
,
BaseRequest
paramReq
)
{
Boolean
recordData
=
false
;
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
();
if
(!
paramValid
)
{
throw
new
PicaWarnException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
PicaResultCode
.
PARAM_IS_INVALID
.
message
());
BaseRequest
rcReq
=
new
BaseRequest
();
rcReq
.
setMobile
(
paramReq
.
getMobile
());
Boolean
need
=
this
.
rcValidate
(
request
,
rcReq
,
"{}"
,
paramReq
.
getSourceType
());
if
(!
need
)
{
recordData
=
true
;
return
recordData
;
}
String
key
=
Constants
.
JIGSAW_CODE_KEY
.
replace
(
"{mobile}"
,
paramReq
.
getMobile
());
if
(
StringUtils
.
isEmpty
(
capCode
)
||
xPos
<=
0
)
{
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
());
}
}
PicaResponse
resp
=
null
;
try
{
SliderImageRequest
req
=
new
SliderImageRequest
();
...
...
@@ -190,16 +223,16 @@ 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
());
/*
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
());
/*
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
))
{
...
...
@@ -215,6 +248,9 @@ public class AuthCodeServiceImpl implements AuthCodeService {
throw
new
PicaWarnException
(
AccountExceptionEnum
.
PICA_CAP_CODE_ERROR
.
getCode
(),
AccountExceptionEnum
.
PICA_CAP_CODE_ERROR
.
getMessage
());
}
// 拼图验证通过
cacheClient
.
set
(
key
,
100
,
Constants
.
JIGSAW_CODE_EXPIRE_SECONDS
);
return
recordData
;
}
/**
...
...
@@ -226,10 +262,16 @@ public class AuthCodeServiceImpl implements AuthCodeService {
* @Return com.pica.cloud.account.account.server.model.JigsawCodeModel
*/
@Override
public
JigsawCodeModel
validateJigsawCode
(
String
mobile
)
{
logger
.
info
(
"getJigsawCode-mobile:{}"
,
mobile
);
public
JigsawCodeModel
getJigsawCode
(
HttpServletRequest
request
,
Integer
sourceType
,
String
mobile
)
{
logger
.
info
(
"getJigsawCode-mobile:{}, sourceType:{}"
,
mobile
,
sourceType
);
if
(!
SourceTypeEnum
.
H5
.
getCode
().
equals
(
sourceType
))
{
logger
.
error
(
"getJigsawCode-h5 sourceType error"
);
throw
new
PicaWarnException
(
PicaResultCode
.
PARAM_IS_INVALID
.
code
(),
PicaResultCode
.
PARAM_IS_INVALID
.
message
());
}
// 调用风控服务,是否需要触发拼图验证
Boolean
need
=
this
.
judgeNeedJigsaw
(
mobile
);
BaseRequest
req
=
new
BaseRequest
();
req
.
setMobile
(
mobile
);
Boolean
need
=
this
.
rcValidate
(
request
,
req
,
"{}"
,
sourceType
);
// 调用proof服务获取拼图数据
JigsawCodeModel
data
=
new
JigsawCodeModel
();
...
...
@@ -240,14 +282,14 @@ public class AuthCodeServiceImpl implements AuthCodeService {
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
());
/*
throw new PicaWarnException(AccountExceptionEnum.PICA_CAP_GET_INVOKE_ERROR.getCode(),
AccountExceptionEnum.PICA_CAP_GET_INVOKE_ERROR.getMessage());
*/
}
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
());
/*
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
))
{
...
...
@@ -262,26 +304,5 @@ public class AuthCodeServiceImpl implements AuthCodeService {
return
data
;
}
/**
* @Description 调用风控服务,是否需要触发拼图验证
* @Author Chongwen.jiang
* @Date 2020/3/23 16:01
* @ModifyDate 2020/3/23 16:01
* @Params [mobile]
* @Return java.lang.Boolean true:需要触发拼图验证 false:不需要
*/
private
Boolean
judgeNeedJigsaw
(
String
mobile
)
{
Boolean
need
=
true
;
try
{
// TODO 调用风控服务,是否需要触发拼图验证
// rcClient.
}
catch
(
Exception
e
)
{
logger
.
error
(
"judgeNeedJigsaw-client invoke exception"
,
e
.
getMessage
());
throw
new
PicaWarnException
(
PicaResultCode
.
INTERFACE_INVOKE_ERROR
.
code
(),
PicaResultCode
.
INTERFACE_INVOKE_ERROR
.
message
());
}
return
need
;
}
}
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录