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
8514774c
Commit
8514774c
authored
Aug 05, 2019
by
hanfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改实名认证
parent
a9e5d34e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
91 deletions
+8
-91
CertificationController.java
...latform/universal/controller/CertificationController.java
+2
-16
CertificationService.java
...xxfc/platform/universal/service/CertificationService.java
+6
-75
No files found.
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/controller/CertificationController.java
View file @
8514774c
...
...
@@ -57,33 +57,23 @@ public class CertificationController {
*/
@PostMapping
(
"/app/certificate"
)
public
ObjectRestResponse
certificate
(
@RequestBody
IdInformation
idInformation
,
HttpServletRequest
request
)
{
if
(
idInformation
==
null
)
{
ObjectRestResponse
.
create
DefaultFail
(
);
ObjectRestResponse
.
create
FailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"无法识别,请重新上传"
);
}
String
token
=
request
.
getHeader
(
"Authorization"
);
log
.
info
(
"------token======"
+
token
);
if
(
StringUtils
.
isEmpty
(
token
))
{
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
RSTOKEN_NULL_CODE
,
"无法识别,请重新上传"
);
}
//获得用户信息
ObjectRestResponse
<
AppUserDTO
>
appUserDTOObjectRestResponse
=
userFeign
.
userDetailByToken
(
token
);
log
.
info
(
"----用户信息========="
+
appUserDTOObjectRestResponse
.
getData
());
if
(
appUserDTOObjectRestResponse
==
null
||
appUserDTOObjectRestResponse
.
getData
()==
null
||
appUserDTOObjectRestResponse
.
getData
().
getId
()==
0
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
GET_APPUSER_FAILED_CODE
,
"无法识别,请重新上传"
);
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
GET_APPUSER_FAILED_CODE
,
"无法识别,请重新上传"
);
}
AppUserDTO
appUserDTO
=
appUserDTOObjectRestResponse
.
getData
();
idInformation
.
setUserLonginId
(
appUserDTO
.
getUserid
());
//获取用户认证信息
ObjectRestResponse
orr
=
null
;
try
{
...
...
@@ -91,12 +81,9 @@ public class CertificationController {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
orr
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
GET_AUTH_INFO_FAILED_CODE
,
"无法识别,请重新上传"
);
}
Integer
type
=
idInformation
.
getCertificateType
();
log
.
info
(
"----type========="
+
type
);
try
{
...
...
@@ -116,7 +103,6 @@ public class CertificationController {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
"无法识别,请重新上传"
);
}
...
...
xx-universal/xx-universal-server/src/main/java/com/xxfc/platform/universal/service/CertificationService.java
View file @
8514774c
...
...
@@ -147,60 +147,41 @@ public class CertificationService {
//携带返回参数的map
HashedMap
hashMap
=
new
HashedMap
();
// 认证状态:true是认证过
//判断是否bean是否为null
if
(
idInformation
==
null
)
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"无法识别,请重新上传"
);
}
//判断是否有填写身份证号
if
(
StringUtils
.
isBlank
(
idInformation
.
getIdNumber
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"未填写证件号"
);
}
if
(!
Validation
.
isIdCard
(
idInformation
.
getIdNumber
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
WRONG_FORMAT_OF_ID_CARD
,
"填写的证件格式错误"
);
}
//判断是有否填写名字
if
(
StringUtils
.
isBlank
(
idInformation
.
getName
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"未填写姓名"
);
}
//判断是否有正面照片
if
(
StringUtils
.
isBlank
(
idInformation
.
getFrontUrl
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"请上传正面照"
);
}
//判断是否有背面照片
if
(
StringUtils
.
isBlank
(
idInformation
.
getBackUrl
()))
{
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"请上传背面照"
);
}
//2.解析
//正面进行解析
String
front
=
imageParse
(
idInformation
.
getFrontUrl
(),
frontParameter
);
//解析证件背面
String
back
=
imageParse
(
idInformation
.
getBackUrl
(),
backParameter
);
log
.
info
(
"----解析front========="
+
front
);
log
.
info
(
"----解析back========="
+
back
);
if
(
StringUtils
.
isBlank
(
front
)
||
StringUtils
.
isBlank
(
back
))
{
return
ObjectRestResponse
.
create
DefaultFail
(
);
return
ObjectRestResponse
.
create
FailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"无法识别,请重新上传"
);
}
Map
frontMap
=
(
Map
)
JSONObject
.
parse
(
front
);
//反面进行解析
Map
backMap
=
(
Map
)
JSONObject
.
parse
(
back
);
...
...
@@ -209,33 +190,21 @@ public class CertificationService {
||
!(
frontMap
.
get
(
imageRet
).
equals
(
imageResultCode
))
||
MapUtil
.
isEmpty
(
backMap
)
||
!(
backMap
.
get
(
imageRet
).
equals
(
imageResultCode
))
)
{
return
ObjectRestResponse
.
createDefaultFail
();
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"无法识别,请重新上传"
);
}
Map
frontData
=
(
Map
)
frontMap
.
get
(
dataNam
);
Map
backData
=
(
Map
)
backMap
.
get
(
dataNam
);
if
(
MapUtil
.
isEmpty
(
backData
)
||
MapUtil
.
isEmpty
(
frontData
))
{
return
ObjectRestResponse
.
createDefaultFail
();
return
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"无法识别,请重新上传"
);
}
//解析通过,进行匹配
String
name
=
(
String
)
frontData
.
get
(
iName
);
String
number
=
(
String
)
frontData
.
get
(
numberName
);
if
(
idInformation
.
getName
().
equals
(
name
))
{
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
"姓名不一致"
);
}
if
(
idInformation
.
getIdNumber
().
equals
(
number
))
{
ObjectRestResponse
.
createFailedResult
(
ResultCode
.
FAILED_CODE
,
"证件号不一致"
);
}
...
...
@@ -243,33 +212,23 @@ public class CertificationService {
//map携带身份证和姓名进行认证
Map
<
String
,
String
>
authMap
=
new
HashMap
<>();
authMap
.
put
(
idCardName
,
(
String
)
frontData
.
get
(
numberName
));
authMap
.
put
(
cName
,
(
String
)
frontData
.
get
(
cName
));
//3.调用接口进行认证
String
result
=
certificate
(
authMap
);
log
.
info
(
"----认证结果result========="
+
result
);
//认证返回的参数是否为空
if
(!
StringUtils
.
isBlank
(
result
))
{
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
JSONObject
.
parse
(
result
);
log
.
info
(
"----certifRet========="
+
certifRet
);
if
(
MapUtil
.
isNotEmpty
(
map
)
||
certifResultCode
.
equals
(
map
.
get
(
certifRet
)))
{
//认证成功后存入保存到数据库
//获得身份证正面记录的身份证号和真实姓名
//设置姓名
idInformation
.
setName
((
String
)
frontData
.
get
(
iName
));
//设置身份证号
idInformation
.
setIdNumber
((
String
)
frontData
.
get
(
numberName
));
//获得到期时间
String
endDate
=
(
String
)
backData
.
get
(
expirationDateName
);
log
.
info
(
"----获得到期时间endDate========="
+
endDate
);
if
(
StringUtils
.
isBlank
(
endDate
))
{
return
ObjectRestResponse
.
succ
();
...
...
@@ -281,16 +240,14 @@ public class CertificationService {
c
.
setTime
(
date
);
c
.
add
(
Calendar
.
YEAR
,
100
);
expirationDate
=
c
.
getTime
();
}
else
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
formatter
.
setLenient
(
false
);
try
{
expirationDate
=
formatter
.
parse
(
endDate
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
return
ObjectRestResponse
.
create
DefaultFail
(
);
return
ObjectRestResponse
.
create
FailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"无法识别,请重新上传"
);
}
}
idInformation
.
setExpirationDate
(
expirationDate
);
...
...
@@ -300,7 +257,6 @@ public class CertificationService {
if
(
objRR
.
getRel
())
{
return
ObjectRestResponse
.
succ
(
objRR
.
getData
());
}
}
}
...
...
@@ -313,34 +269,22 @@ public class CertificationService {
//认证
public
String
certificate
(
Map
<
String
,
String
>
querys
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
"Authorization"
,
"APPCODE "
+
cAppcode
);
//
//
try
{
log
.
info
(
"----querys========="
+
querys
);
HttpResponse
response
=
CertifHttpUtils
.
doGet
(
cHost
,
cPath
,
cMethod
,
headers
,
querys
);
StatusLine
statusLine
=
response
.
getStatusLine
();
int
statusCode
=
statusLine
.
getStatusCode
();
/**
* 状态码: 200 正常;400 URL无效;401 appCode错误; 403 次数用完; 500 API网管错误
*/
//获取response的body
if
(
statusCode
==
200
)
{
return
EntityUtils
.
toString
(
response
.
getEntity
());
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
...
...
@@ -348,27 +292,16 @@ public class CertificationService {
//身份证照片解析
public
String
imageParse
(
String
imageUrl
,
String
type
)
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
headers
.
put
(
"Authorization"
,
"APPCODE "
+
iAppcode
);
Map
<
String
,
String
>
querys
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
bodys
=
new
HashMap
<
String
,
String
>();
bodys
.
put
(
picName
,
imageUrl
);
//默认正面front,背面请传back
bodys
.
put
(
typeName
,
type
);
try
{
HttpResponse
response
=
CertifHttpUtils
.
doPost
(
iHost
,
iPath
,
iMethod
,
headers
,
querys
,
bodys
);
StatusLine
statusLine
=
response
.
getStatusLine
();
...
...
@@ -383,9 +316,7 @@ public class CertificationService {
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
...
...
@@ -422,7 +353,7 @@ public class CertificationService {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
TransactionAspectSupport
.
currentTransactionStatus
();
return
ObjectRestResponse
.
create
DefaultFail
(
);
return
ObjectRestResponse
.
create
FailedResult
(
ResultCode
.
INCOMPLETE_DATA
,
"无法识别,请重新上传"
);
}
...
...
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