Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
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
fangxinjiang
yifu-mvp
Commits
20e0e23b
Commit
20e0e23b
authored
Mar 03, 2023
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVP1.5.2 校验服务新增银行卡 三要素校验 姓名 身份证 银行卡号 一致性校验接口
parent
a58022e4
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
275 additions
and
6 deletions
+275
-6
ChecksUtil.java
...n/java/com/yifu/cloud/plus/v1/check/utils/ChecksUtil.java
+72
-2
CheckBankNoThreeVo.java
...a/com/yifu/cloud/plus/v1/check/vo/CheckBankNoThreeVo.java
+37
-0
TCheckBankNoController.java
...loud/plus/v1/check/controller/TCheckBankNoController.java
+30
-0
TCheckBankNoService.java
...yifu/cloud/plus/v1/check/service/TCheckBankNoService.java
+5
-0
TCheckBankNoServiceImpl.java
...d/plus/v1/check/service/impl/TCheckBankNoServiceImpl.java
+131
-4
No files found.
yifu-check/yifu-check-api/src/main/java/com/yifu/cloud/plus/v1/check/utils/ChecksUtil.java
View file @
20e0e23b
...
...
@@ -31,7 +31,8 @@ public class ChecksUtil {
private
static
final
String
API_URL
=
"https://api.253.com/open/idcard/id-card-auth"
;
private
static
final
String
API_URL_MOBILE
=
"https://api.253.com/open/unn/batch-ucheck"
;
private
static
final
String
API_URL_BANK_NO
=
"https://api.253.com/open/bankcard/card-auth"
;
private
static
final
String
API_URL_BANK_NO_TWO
=
"https://api.253.com/open/bankcard/card-two-auth"
;
private
static
final
String
API_URL_BANK_NO_TWO
=
"https://api.253.com/open/bankcard/card-two-auth"
;
private
static
final
String
API_URL_BANK_NO_THREE
=
"https://api.253.com/open/bankcard/card-three-auth"
;
private
static
JsonParser
jsonParser
=
new
JsonParser
();
public
static
void
checkIdCard
(
TCheckIdCard
checkIdCard
,
boolean
canCheck
)
{
...
...
@@ -96,7 +97,28 @@ public class ChecksUtil {
return
R
.
ok
(
checkBankNo
);
}
}
/**
* @Author fxj
* @Description 银行卡四要素标准版 校验
* @Date 17:50 2022/6/20
* @param name 姓名 是 [string]
* @param cardNo 银行卡号,限单个 是 [string]
**/
public
static
R
<
TCheckBankNo
>
checkBankNoThree
(
String
name
,
String
cardNo
,
String
idNum
,
boolean
canCheck
)
{
if
(
canCheck
)
{
// 1.调用银行卡信息校验api
return
checkBankNoThreeMethod
(
name
,
cardNo
,
idNum
);
}
else
{
TCheckBankNo
checkBankNo
=
new
TCheckBankNo
();
checkBankNo
.
setBankNo
(
cardNo
);
checkBankNo
.
setName
(
name
);
checkBankNo
.
setMessage
(
ChecksConstants
.
CHECK_CONFIG_ACCESS
);
checkBankNo
.
setResult
(
"01"
);
checkBankNo
.
setType
(
CommonConstants
.
ONE_STRING
);
checkBankNo
.
setRemark
(
ChecksConstants
.
CHECK_CONFIG_ACCESS
);
return
R
.
ok
(
checkBankNo
);
}
}
private
static
R
<
TCheckBankNo
>
checkBankNoTwoMethod
(
String
name
,
String
cardNo
)
{
final
JsonObject
jsonObject
=
ChecksUtil
.
invokeBankNoTwoAuth
(
name
,
cardNo
);
TCheckBankNo
checkBankNo
=
new
TCheckBankNo
();
...
...
@@ -131,6 +153,40 @@ public class ChecksUtil {
return
R
.
ok
(
checkBankNo
);
}
private
static
R
<
TCheckBankNo
>
checkBankNoThreeMethod
(
String
name
,
String
cardNo
,
String
idNum
)
{
final
JsonObject
jsonObject
=
ChecksUtil
.
invokeBankNoThreeAuth
(
name
,
cardNo
,
idNum
);
TCheckBankNo
checkBankNo
=
new
TCheckBankNo
();
// 2.处理返回结果
if
(
jsonObject
!=
null
)
{
//响应code码。200000:成功,其他失败
String
code
=
jsonObject
.
get
(
ChecksConstants
.
CODE
).
getAsString
();
if
(
ChecksConstants
.
CODE_200000
.
equals
(
code
)
&&
jsonObject
.
get
(
ChecksConstants
.
DATA
)
!=
null
)
{
// 调用身份信息校验成功
// 解析结果数据,进行业务处理
// 校验状态码 200000:成功,其他失败
JsonObject
resJson
=
jsonObject
.
get
(
ChecksConstants
.
DATA
).
getAsJsonObject
();
String
message
=
jsonObject
.
get
(
ChecksConstants
.
MESSAGE
).
getAsString
();
if
(
Common
.
isNotNull
(
resJson
)){
checkBankNo
.
setBankNo
(
cardNo
);
checkBankNo
.
setBankName
(
getJsonElementValue
(
resJson
.
getAsJsonObject
().
get
(
"bankName"
)));
checkBankNo
.
setCardCategory
(
getJsonElementValue
(
resJson
.
getAsJsonObject
().
get
(
"cardCategory"
)));
checkBankNo
.
setCardType
(
getJsonElementValue
(
resJson
.
getAsJsonObject
().
get
(
"cardType"
)));
checkBankNo
.
setResult
(
getJsonElementValue
(
resJson
.
getAsJsonObject
().
get
(
ChecksConstants
.
RESULT
)));
checkBankNo
.
setMessage
(
message
);
checkBankNo
.
setRemark
(
getJsonElementValue
(
resJson
.
getAsJsonObject
().
get
(
ChecksConstants
.
REMARK
)));
checkBankNo
.
setType
(
CommonConstants
.
ONE_STRING
);
checkBankNo
.
setName
(
name
);
}
}
else
{
// 记录错误日志,正式项目中请换成log打印
return
R
.
failed
(
"银行卡号校验失败:"
+
jsonObject
.
get
(
ChecksConstants
.
MESSAGE
).
getAsString
());
}
}
else
{
return
R
.
failed
(
ChecksConstants
.
NO_DATA_RESULT
);
}
return
R
.
ok
(
checkBankNo
);
}
private
static
String
getJsonElementValue
(
JsonElement
temp
){
return
Common
.
isNotNull
(
temp
)?
temp
.
getAsString
():
CommonConstants
.
EMPTY_STRING
;
}
...
...
@@ -273,4 +329,18 @@ public class ChecksUtil {
}
return
null
;
}
private
static
JsonObject
invokeBankNoThreeAuth
(
String
name
,
String
cardNo
,
String
idNum
)
{
Map
<
String
,
String
>
params
=
new
HashMap
<>();
params
.
put
(
ChecksConstants
.
APP_ID
,
APP_ID
);
params
.
put
(
ChecksConstants
.
APP_KEY
,
APP_KEY_IDCARD
);
params
.
put
(
ChecksConstants
.
NAME
,
name
);
params
.
put
(
ChecksConstants
.
CARD_NO
,
cardNo
);
params
.
put
(
ChecksConstants
.
ID_NUM
,
idNum
);
String
result
=
HttpUtils
.
post
(
API_URL_BANK_NO_THREE
,
params
);
// 解析json,并返回结果
if
(
Common
.
isNotNull
(
result
)){
return
jsonParser
.
parse
(
result
).
getAsJsonObject
();
}
return
null
;
}
}
yifu-check/yifu-check-api/src/main/java/com/yifu/cloud/plus/v1/check/vo/CheckBankNoThreeVo.java
0 → 100644
View file @
20e0e23b
package
com
.
yifu
.
cloud
.
plus
.
v1
.
check
.
vo
;
import
com.alibaba.excel.annotation.ExcelProperty
;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.RowIndex
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @Author fxj
* @Date 2023/3/3
* @Description
* @Version 1.0
*/
@Data
public
class
CheckBankNoThreeVo
extends
RowIndex
implements
Serializable
{
/**
* 银行卡号
*/
@Schema
(
description
=
"银行卡号"
)
@ExcelProperty
(
value
=
"银行卡号"
)
private
String
bankNo
;
/**
* 姓名
*/
@Schema
(
description
=
"姓名"
)
@ExcelProperty
(
value
=
"姓名"
)
private
String
name
;
/**
* 身份证
*/
@Schema
(
description
=
"身份证"
)
@ExcelProperty
(
value
=
"身份证"
)
private
String
idNum
;
}
yifu-check/yifu-check-biz/src/main/java/com/yifu/cloud/plus/v1/check/controller/TCheckBankNoController.java
View file @
20e0e23b
...
...
@@ -23,14 +23,17 @@ import com.yifu.cloud.plus.v1.check.entity.TCheckBankNo;
import
com.yifu.cloud.plus.v1.check.service.TCheckBankNoService
;
import
com.yifu.cloud.plus.v1.check.vo.CheckBankNoVo
;
import
com.yifu.cloud.plus.v1.check.vo.CheckBatchVo
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
import
com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner
;
import
io.swagger.v3.oas.annotations.Operation
;
import
io.swagger.v3.oas.annotations.tags.Tag
;
import
lombok.RequiredArgsConstructor
;
import
lombok.SneakyThrows
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
...
...
@@ -152,4 +155,31 @@ public class TCheckBankNoController {
return
tCheckBankNoService
.
checkBankNo
(
name
,
bankNo
);
}
/**
* 银行卡号校验
* @param checkBankNo 姓名 是 [string] 身份证号码,限单个 是 [string] 银行卡号,限单个 是 [string]银行预留手机号,仅支持国内11位号码
*/
@Operation
(
description
=
"银行卡号校验"
)
@SysLog
(
"银行卡号校验"
)
@Inner
@PostMapping
(
"/inner/checkBankNoThree"
)
public
CheckBankNoVo
checkBankNoThreeInner
(
@RequestBody
TCheckBankNo
checkBankNo
)
{
return
tCheckBankNoService
.
checkBankNoThree
(
checkBankNo
.
getName
(),
checkBankNo
.
getBankNo
(),
checkBankNo
.
getIdNum
());
}
/**
* 批量新增员工工作信息
*
* @param file
* @return
* @Author fxj
* @Date 2019-08-16
**/
@SneakyThrows
@Operation
(
description
=
"批量新增员工工作信息 hasPermission('archives_tempworkrecording_importListAdd')"
)
@SysLog
(
"批量新增员工工作信息"
)
@PostMapping
(
"/importListAdd"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(
@RequestBody
MultipartFile
file
)
{
return
tCheckBankNoService
.
importDiy
(
file
.
getInputStream
());
}
}
yifu-check/yifu-check-biz/src/main/java/com/yifu/cloud/plus/v1/check/service/TCheckBankNoService.java
View file @
20e0e23b
...
...
@@ -21,8 +21,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.yifu.cloud.plus.v1.check.entity.TCheckBankNo
;
import
com.yifu.cloud.plus.v1.check.vo.CheckBankNoVo
;
import
com.yifu.cloud.plus.v1.check.vo.CheckBatchVo
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
java.io.InputStream
;
import
java.util.List
;
/**
...
...
@@ -41,6 +43,8 @@ public interface TCheckBankNoService extends IService<TCheckBankNo> {
**/
R
<
TCheckBankNo
>
checkBankNo
(
String
name
,
String
cardNo
);
CheckBankNoVo
checkBankNoThree
(
String
name
,
String
cardNo
,
String
idNum
);
CheckBankNoVo
checkBankNoTwo
(
String
name
,
String
cardNo
);
/**
...
...
@@ -52,4 +56,5 @@ public interface TCheckBankNoService extends IService<TCheckBankNo> {
**/
CheckBatchVo
checkBankNoBatch
(
List
<
TCheckBankNo
>
list
);
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
);
}
yifu-check/yifu-check-biz/src/main/java/com/yifu/cloud/plus/v1/check/service/impl/TCheckBankNoServiceImpl.java
View file @
20e0e23b
...
...
@@ -16,6 +16,11 @@
*/
package
com
.
yifu
.
cloud
.
plus
.
v1
.
check
.
service
.
impl
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.read.listener.ReadListener
;
import
com.alibaba.excel.read.metadata.holder.ReadRowHolder
;
import
com.alibaba.excel.util.ListUtils
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.yifu.cloud.plus.v1.check.entity.TCheckBankNo
;
...
...
@@ -23,20 +28,24 @@ import com.yifu.cloud.plus.v1.check.mapper.TCheckBankNoMapper;
import
com.yifu.cloud.plus.v1.check.service.TCanCheckService
;
import
com.yifu.cloud.plus.v1.check.service.TCheckBankNoService
;
import
com.yifu.cloud.plus.v1.check.utils.ChecksUtil
;
import
com.yifu.cloud.plus.v1.check.vo.CheckBankNoThreeVo
;
import
com.yifu.cloud.plus.v1.check.vo.CheckBankNoVo
;
import
com.yifu.cloud.plus.v1.check.vo.CheckBatchVo
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording
;
import
com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo
;
import
com.yifu.cloud.plus.v1.yifu.archives.vo.EmpWorkRecordExcelVO
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.stereotype.Service
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 银行卡卡号 校验
...
...
@@ -71,7 +80,30 @@ public class TCheckBankNoServiceImpl extends ServiceImpl<TCheckBankNoMapper, TCh
return
resR
;
}
}
@Override
public
CheckBankNoVo
checkBankNoThree
(
String
name
,
String
cardNo
,
String
idNum
)
{
CheckBankNoVo
vo
=
new
CheckBankNoVo
();
if
(
Common
.
isEmpty
(
name
)
||
Common
.
isEmpty
(
cardNo
)){
vo
.
setRes
(
R
.
failed
(
MsgUtils
.
getMessage
(
ErrorCodes
.
CHECKS_BANK_NO_REQUEST_PARAM_ERROR
)));
return
vo
;
}
synchronized
(
this
){
TCheckBankNo
checkBankNo
=
baseMapper
.
selectOne
(
Wrappers
.<
TCheckBankNo
>
query
().
lambda
()
.
eq
(
TCheckBankNo:
:
getBankNo
,
cardNo
)
.
eq
(
TCheckBankNo:
:
getName
,
name
)
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
checkBankNo
)){
vo
.
setRes
(
R
.
ok
(
checkBankNo
));
return
vo
;
}
R
<
TCheckBankNo
>
resR
=
ChecksUtil
.
checkBankNoThree
(
name
,
cardNo
,
idNum
,
canCheckService
.
getCanCheck
());
if
(
Common
.
isNotNull
(
resR
)
&&
Common
.
isNotNull
(
resR
.
getData
())){
baseMapper
.
insert
(
resR
.
getData
());
}
vo
.
setRes
(
resR
);
return
vo
;
}
}
@Override
public
CheckBankNoVo
checkBankNoTwo
(
String
name
,
String
cardNo
)
{
CheckBankNoVo
vo
=
new
CheckBankNoVo
();
...
...
@@ -160,4 +192,99 @@ public class TCheckBankNoServiceImpl extends ServiceImpl<TCheckBankNoMapper, TCh
return
vo
;
}
@Override
public
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
CheckBankNoThreeVo
>
util1
=
new
ExcelUtil
<>(
CheckBankNoThreeVo
.
class
);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
CheckBankNoThreeVo
.
class
,
new
ReadListener
<
CheckBankNoThreeVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
CheckBankNoThreeVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
CheckBankNoThreeVo
data
,
AnalysisContext
context
)
{
ReadRowHolder
readRowHolder
=
context
.
readRowHolder
();
Integer
rowIndex
=
readRowHolder
.
getRowIndex
();
data
.
setRowIndex
(
rowIndex
+
1
);
cachedDataList
.
add
(
data
);
if
(
cachedDataList
.
size
()
>=
BATCH_COUNT
)
{
saveData
();
// 存储完成清理 list
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
saveData
();
}
/**
* 加上存储数据库
*/
private
void
saveData
()
{
importRecord
(
cachedDataList
,
errorMessageList
);
}
}).
sheet
().
doRead
();
}
catch
(
Exception
e
){
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
return
R
.
failed
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
);
}
return
R
.
ok
(
errorMessageList
);
}
private
void
importRecord
(
List
<
CheckBankNoThreeVo
>
cachedDataList
,
List
<
ErrorMessage
>
errorMessageList
)
{
if
(
Common
.
isNotNull
(
cachedDataList
)){
CheckBankNoVo
vo
;
TCheckBankNo
checkBankNo
;
List
<
CheckBankNoVo
>
res
=
new
ArrayList
<>();
for
(
CheckBankNoThreeVo
threeVo:
cachedDataList
){
vo
=
new
CheckBankNoVo
();
if
(
Common
.
isEmpty
(
threeVo
.
getName
())
||
Common
.
isEmpty
(
threeVo
.
getBankNo
())||
Common
.
isEmpty
(
threeVo
.
getIdNum
())){
vo
.
setRes
(
R
.
failed
(
MsgUtils
.
getMessage
(
ErrorCodes
.
CHECKS_BANK_NO_REQUEST_PARAM_ERROR
)));
res
.
add
(
vo
);
}
synchronized
(
this
){
checkBankNo
=
baseMapper
.
selectOne
(
Wrappers
.<
TCheckBankNo
>
query
().
lambda
()
.
eq
(
TCheckBankNo:
:
getBankNo
,
threeVo
.
getBankNo
())
.
eq
(
TCheckBankNo:
:
getName
,
threeVo
.
getName
())
.
eq
(
TCheckBankNo:
:
getIdNum
,
threeVo
.
getIdNum
())
.
last
(
CommonConstants
.
LAST_ONE_SQL
));
if
(
Common
.
isNotNull
(
checkBankNo
)){
vo
.
setRes
(
R
.
ok
(
checkBankNo
));
res
.
add
(
vo
);
}
R
<
TCheckBankNo
>
resR
=
ChecksUtil
.
checkBankNoThree
(
threeVo
.
getName
(),
threeVo
.
getBankNo
(),
threeVo
.
getIdNum
(),
canCheckService
.
getCanCheck
());
if
(
Common
.
isNotNull
(
resR
)
&&
Common
.
isNotNull
(
resR
.
getData
())){
baseMapper
.
insert
(
resR
.
getData
());
}
vo
.
setRes
(
resR
);
res
.
add
(
vo
);
if
(
resR
.
getCode
()==
200
){
log
.
error
(
threeVo
.
getBankNo
()+
"|"
+
threeVo
.
getIdNum
()+
"|"
+
threeVo
.
getName
()+
"|"
+
resR
.
getData
().
getResult
()+
"|"
+
resR
.
getData
().
getRemark
());
}
else
{
log
.
error
(
threeVo
.
getBankNo
()+
"|"
+
threeVo
.
getIdNum
()+
"|"
+
threeVo
.
getName
()+
"|"
+
resR
.
getMsg
());
}
}
}
}
}
}
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