Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
asset-distribution
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
data-spider
asset-distribution
Commits
e14a908d
Commit
e14a908d
authored
Sep 10, 2021
by
shihuajun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资金路由第2版提交代码
parent
3aa8f453
Changes
24
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
399 additions
and
51 deletions
+399
-51
InitAreaCode.java
...antgroup/asset/distribution/config/code/InitAreaCode.java
+2
-2
CommonConstants.java
...antgroup/asset/distribution/constant/CommonConstants.java
+18
-0
CommonStants.java
.../quantgroup/asset/distribution/constant/CommonStants.java
+0
-7
IFeatureService.java
...p/asset/distribution/service/feature/IFeatureService.java
+4
-0
IdCardInfo.java
...oup/asset/distribution/service/feature/bo/IdCardInfo.java
+43
-0
FeatureServiceImpl.java
...distribution/service/feature/impl/FeatureServiceImpl.java
+20
-3
FundProductEntity.java
...et/distribution/service/jpa/entity/FundProductEntity.java
+14
-3
IFundProductRepository.java
...bution/service/jpa/repository/IFundProductRepository.java
+1
-1
CoreFilter.java
...tgroup/asset/distribution/service/newrule/CoreFilter.java
+18
-16
RuleHandleFactory.java
...asset/distribution/service/newrule/RuleHandleFactory.java
+17
-0
AbstractProductRuleVerifyImpl.java
...service/newrule/common/AbstractProductRuleVerifyImpl.java
+1
-1
AreaVerifyImpl.java
...t/distribution/service/newrule/common/AreaVerifyImpl.java
+3
-3
IdCardVerifyImpl.java
...distribution/service/newrule/common/IdCardVerifyImpl.java
+63
-0
RuleConstant.java
...asset/distribution/service/newrule/pojo/RuleConstant.java
+2
-0
CooperationEnum.java
...tribution/service/newrule/pojo/enums/CooperationEnum.java
+17
-1
IdCardExpireEnum.java
...ribution/service/newrule/pojo/enums/IdCardExpireEnum.java
+32
-0
SpecialRuleEnum.java
...tribution/service/newrule/pojo/enums/SpecialRuleEnum.java
+8
-6
FundCallBackParam.java
...ibution/service/newrule/pojo/funds/FundCallBackParam.java
+44
-0
RuleParam.java
...et/distribution/service/newrule/pojo/funds/RuleParam.java
+15
-0
ContactsNameSameVerifyImpl.java
...vice/newrule/specialrules/ContactsNameSameVerifyImpl.java
+1
-0
ContactsTelErrorVerifyImpl.java
...vice/newrule/specialrules/ContactsTelErrorVerifyImpl.java
+6
-6
ContactsTelSameVerifyImpl.java
...rvice/newrule/specialrules/ContactsTelSameVerifyImpl.java
+2
-1
AuditResponce.java
...set/distribution/service/newrule/third/AuditResponce.java
+1
-1
DateUtil.java
...java/com/quantgroup/asset/distribution/util/DateUtil.java
+67
-0
No files found.
src/main/java/com/quantgroup/asset/distribution/config/code/InitAreaCode.java
View file @
e14a908d
...
...
@@ -16,7 +16,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.concurrent.ConcurrentHashMap
;
@Component
//
@Component
@Data
public
class
InitAreaCode
{
...
...
@@ -24,7 +24,7 @@ public class InitAreaCode {
public
ConcurrentHashMap
<
String
,
AreaCode
>
concurrentHashMap
=
new
ConcurrentHashMap
<
String
,
AreaCode
>();
public
ConcurrentHashMap
<
String
,
AreaCode
>
concurrentNameHashMap
=
new
ConcurrentHashMap
<
String
,
AreaCode
>();
@PostConstruct
//
@PostConstruct
public
void
init
()
throws
Exception
{
logger
.
info
(
"初始化区域码"
);
InputStream
in
=
this
.
getClass
().
getResourceAsStream
(
"phone/gbt.txt"
);
...
...
src/main/java/com/quantgroup/asset/distribution/constant/CommonConstants.java
0 → 100644
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
constant
;
/**
* Created by renfeng on 2019/7/22.
*/
public
class
CommonConstants
{
/**
* 特殊字符start
*/
public
static
final
String
COMMA
=
","
;
public
static
final
String
HORIZONTAL_LINE
=
"-"
;
public
static
final
String
WAVE_LINE
=
"~"
;
public
static
final
char
NEW_LINE
=
'\n'
;
public
static
final
String
COLON
=
":"
;
public
static
final
String
PERCENT
=
"%"
;
public
static
final
char
FIELD_DELIMITER
=
','
;
// 特殊字符end
}
src/main/java/com/quantgroup/asset/distribution/constant/CommonStants.java
deleted
100644 → 0
View file @
3aa8f453
package
com
.
quantgroup
.
asset
.
distribution
.
constant
;
/**
* Created by renfeng on 2019/7/22.
*/
public
class
CommonStants
{
}
src/main/java/com/quantgroup/asset/distribution/service/feature/IFeatureService.java
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
feature
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.service.feature.bo.IdCardInfo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
...
...
@@ -21,4 +23,6 @@ public interface IFeatureService {
* @return
*/
Map
<
String
,
Object
>
getFeatureData
(
Set
<
String
>
keys
,
AssetForm
assetForm
,
int
type
);
IdCardInfo
getIdCardInfo
(
String
uuid
);
}
src/main/java/com/quantgroup/asset/distribution/service/feature/bo/IdCardInfo.java
0 → 100644
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
feature
.
bo
;
import
lombok.Data
;
/**
* @author shihuajun
* @date 2021/9/7 12:57
* @ describing
*/
@Data
public
class
IdCardInfo
{
private
String
name
;
private
String
gender
;
//性别 男/女
private
String
nation
;
//民族
private
String
birthday
;
//出生日期 格式 :1990.02.14
private
String
citizen_id
;
//身份证号
private
String
address
;
private
String
agency
;
//签发机关
private
String
valid_date_begin
;
//有效日期之起始日期 格式:20131022
private
String
valid_date_end
;
//有效日期之结束日期 格式:20231022
private
String
side
;
//正面-front 反面-back
private
String
img_base64
;
private
String
error_message
;
//身份证识别错误提示
private
String
bizId
;
//腾讯识别订单号
private
Boolean
success
;
private
String
responseCode
;
private
String
compareType
;
//OCR类型 h5或sdk
}
src/main/java/com/quantgroup/asset/distribution/service/feature/impl/FeatureServiceImpl.java
View file @
e14a908d
...
...
@@ -7,7 +7,9 @@ import com.quantgroup.asset.distribution.exception.QGExceptionType;
import
com.quantgroup.asset.distribution.exception.QGPreconditions
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.service.feature.IFeatureService
;
import
com.quantgroup.asset.distribution.service.feature.bo.IdCardInfo
;
import
com.quantgroup.asset.distribution.service.httpclient.IHttpService
;
import
com.quantgroup.asset.distribution.util.JacksonUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.MapUtils
;
...
...
@@ -16,9 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
/**
...
...
@@ -56,4 +56,21 @@ public class FeatureServiceImpl implements IFeatureService {
log
.
info
(
"决策特征属性获取完成, uuid : {}, assetNo : {}, bizChannel : {}, bizNo : {}, bizType : {}, type : {}, data : {}, 耗时 : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getAssetNo
(),
assetForm
.
getBizChannel
(),
assetForm
.
getBizNo
(),
assetForm
.
getBizType
(),
type
,
JSON
.
toJSONString
(
data
),
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
return
data
;
}
@Override
public
IdCardInfo
getIdCardInfo
(
String
uuid
)
{
if
(
StringUtils
.
isBlank
(
uuid
)){
throw
new
RuntimeException
(
"获取身份证信息参数为空"
);
}
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"uuid"
,
uuid
);
// todo 此处需要更改
String
responce
=
httpService
.
get
(
ruleEngineURL
,
map
);
List
<
IdCardInfo
>
idCardInfoList
=
JacksonUtil
.
deserializeList
(
responce
,
IdCardInfo
.
class
);
Optional
<
IdCardInfo
>
cardInfo
=
idCardInfoList
.
stream
().
filter
(
d
->
d
.
getSide
().
equals
(
"back"
)).
findFirst
();
if
(!
cardInfo
.
isPresent
()){
throw
new
RuntimeException
(
"调用第三方服务返回有问题"
);
}
return
cardInfo
.
get
();
}
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/entity/FundProductEntity.java
View file @
e14a908d
...
...
@@ -6,7 +6,7 @@ import java.util.Objects;
/**
* @author shihuajun
* @date 2021/9/
2 16:20
* @date 2021/9/
7 15:57
* @ describing
*/
@Entity
...
...
@@ -22,6 +22,7 @@ public class FundProductEntity {
private
String
systermType
;
private
String
basicRule
;
private
int
areaTerm
;
private
int
cardLimit
;
private
String
areaRule
;
private
String
ruleList
;
private
Byte
enable
;
...
...
@@ -128,6 +129,16 @@ public class FundProductEntity {
this
.
areaTerm
=
areaTerm
;
}
@Basic
@Column
(
name
=
"card_limit"
,
nullable
=
false
)
public
int
getCardLimit
()
{
return
cardLimit
;
}
public
void
setCardLimit
(
int
cardLimit
)
{
this
.
cardLimit
=
cardLimit
;
}
@Basic
@Column
(
name
=
"area_rule"
,
nullable
=
false
,
length
=
500
)
public
String
getAreaRule
()
{
...
...
@@ -183,11 +194,11 @@ public class FundProductEntity {
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
FundProductEntity
that
=
(
FundProductEntity
)
o
;
return
id
==
that
.
id
&&
fundId
==
that
.
fundId
&&
fundProId
==
that
.
fundProId
&&
areaTerm
==
that
.
areaTerm
&&
Objects
.
equals
(
fundName
,
that
.
fundName
)
&&
Objects
.
equals
(
fundType
,
that
.
fundType
)
&&
Objects
.
equals
(
orgType
,
that
.
orgType
)
&&
Objects
.
equals
(
businessType
,
that
.
businessType
)
&&
Objects
.
equals
(
systermType
,
that
.
systermType
)
&&
Objects
.
equals
(
basicRule
,
that
.
basicRule
)
&&
Objects
.
equals
(
areaRule
,
that
.
areaRule
)
&&
Objects
.
equals
(
ruleList
,
that
.
ruleList
)
&&
Objects
.
equals
(
enable
,
that
.
enable
)
&&
Objects
.
equals
(
createdAt
,
that
.
createdAt
)
&&
Objects
.
equals
(
updatedAt
,
that
.
updatedAt
);
return
id
==
that
.
id
&&
fundId
==
that
.
fundId
&&
fundProId
==
that
.
fundProId
&&
areaTerm
==
that
.
areaTerm
&&
cardLimit
==
that
.
cardLimit
&&
Objects
.
equals
(
fundName
,
that
.
fundName
)
&&
Objects
.
equals
(
fundType
,
that
.
fundType
)
&&
Objects
.
equals
(
orgType
,
that
.
orgType
)
&&
Objects
.
equals
(
businessType
,
that
.
businessType
)
&&
Objects
.
equals
(
systermType
,
that
.
systermType
)
&&
Objects
.
equals
(
basicRule
,
that
.
basicRule
)
&&
Objects
.
equals
(
areaRule
,
that
.
areaRule
)
&&
Objects
.
equals
(
ruleList
,
that
.
ruleList
)
&&
Objects
.
equals
(
enable
,
that
.
enable
)
&&
Objects
.
equals
(
createdAt
,
that
.
createdAt
)
&&
Objects
.
equals
(
updatedAt
,
that
.
updatedAt
);
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
id
,
fundId
,
fundProId
,
fundName
,
fundType
,
orgType
,
businessType
,
systermType
,
basicRule
,
areaTerm
,
areaRule
,
ruleList
,
enable
,
createdAt
,
updatedAt
);
return
Objects
.
hash
(
id
,
fundId
,
fundProId
,
fundName
,
fundType
,
orgType
,
businessType
,
systermType
,
basicRule
,
areaTerm
,
cardLimit
,
areaRule
,
ruleList
,
enable
,
createdAt
,
updatedAt
);
}
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/repository/IFundProductRepository.java
View file @
e14a908d
...
...
@@ -5,5 +5,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
public
interface
IFundProductRepository
extends
JpaRepository
<
FundProductEntity
,
Long
>{
FundProductEntity
getByIdEquals
(
Long
id
);
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/CoreFilter.java
View file @
e14a908d
...
...
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.google.common.collect.Maps
;
import
com.googlecode.aviator.AviatorEvaluator
;
import
com.googlecode.aviator.Expression
;
import
com.quantgroup.asset.distribution.constant.CommonConstants
;
import
com.quantgroup.asset.distribution.exception.QGException
;
import
com.quantgroup.asset.distribution.exception.QGExceptionType
;
import
com.quantgroup.asset.distribution.service.alarm.IAlarmService
;
...
...
@@ -20,6 +21,7 @@ import com.quantgroup.asset.distribution.service.newrule.pojo.RoutingRecordVO;
import
com.quantgroup.asset.distribution.service.newrule.pojo.RuleConstant
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.AreaEnum
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.CooperationEnum
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.IdCardExpireEnum
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.funds.*
;
import
com.quantgroup.asset.distribution.service.newrule.service.IProductRuleService
;
import
com.quantgroup.asset.distribution.service.newrule.third.AuditResponce
;
...
...
@@ -31,6 +33,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
shaded.com.google.common.collect.Lists
;
...
...
@@ -70,6 +73,7 @@ public class CoreFilter {
@Resource
private
IRoutingRecordRepository
routingRecordRepository
;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
coreHandle
(
AuditResponce
auditResponce
){
List
<
ChannelRuleEntity
>
channelRuleEntityList
=
channelRuleRepository
.
getByChannelId
(
Long
.
parseLong
(
auditResponce
.
getBizChannel
()));
if
(
CollectionUtils
.
isEmpty
(
channelRuleEntityList
)){
...
...
@@ -79,7 +83,7 @@ public class CoreFilter {
List
<
FinanceProduct
>
financeProducts
=
new
ArrayList
<>();
List
<
RoutingRecordVO
>
routingRecordList
=
new
ArrayList
<>();
for
(
ChannelRuleEntity
channelRuleEntity
:
channelRuleEntityList
)
{
FundProductEntity
fundProduct
=
fundProductRepository
.
get
One
(
channelRuleEntity
.
getFundProductId
());
FundProductEntity
fundProduct
=
fundProductRepository
.
get
ByIdEquals
(
channelRuleEntity
.
getFundProductId
());
if
(
fundProduct
==
null
){
log
.
error
(
"这种情况不可能出现,需要看下原因 {}"
,
JSON
.
toJSONString
(
channelRuleEntity
));
continue
;
...
...
@@ -126,7 +130,7 @@ public class CoreFilter {
FundInfo
fundInfo
=
new
FundInfo
();
fundInfo
.
setFundId
(
fundProduct
.
getFundId
());
fundInfo
.
setFundProductId
(
fundProduct
.
getFundProId
()
+
""
);
fundInfo
.
setCooperation
(
CooperationEnum
.
ASSISTANCE
);
fundInfo
.
setCooperation
(
CooperationEnum
.
parse
(
fundProduct
.
getOrgType
())
);
Terms
term
=
new
Terms
();
term
.
setTerm
(
Integer
.
parseInt
(
auditResponce
.
getTerm
()));
term
.
setFundInfos
(
Lists
.
newArrayList
(
fundInfo
));
...
...
@@ -161,12 +165,12 @@ public class CoreFilter {
if
(
channelId
!=
Long
.
parseLong
(
auditResponce
.
getBizChannel
())){
return
Boolean
.
FALSE
;
}
if
(
StringUtils
.
isNotBlank
(
auditResponce
.
getCreditLevel
())
||
!
channelRuleEntity
.
getUserLevel
().
contains
(
auditResponce
.
getCreditLevel
()))
{
if
(
StringUtils
.
isNotBlank
(
auditResponce
.
getCreditLevel
())
||
(
StringUtils
.
isNotBlank
(
auditResponce
.
getCreditLevel
())
&&
!
channelRuleEntity
.
getUserLevel
().
contains
(
auditResponce
.
getCreditLevel
())))
{
return
Boolean
.
FALSE
;
}
if
(
StringUtils
.
isNotBlank
(
auditResponce
.
getUserTag
())
||
!
channelRuleEntity
.
getUserTag
().
contains
(
auditResponce
.
getUserTag
(
))){
if
(
StringUtils
.
isNotBlank
(
auditResponce
.
getUserTag
())
||
(
StringUtils
.
isNotBlank
(
auditResponce
.
getUserTag
())
&&
!
channelRuleEntity
.
getUserTag
().
contains
(
auditResponce
.
getUserTag
()
))){
return
Boolean
.
FALSE
;
}
String
basicRule
=
fundProduct
.
getBasicRule
();
...
...
@@ -192,27 +196,25 @@ public class CoreFilter {
if
(
currentRuleVal
.
equals
(
RuleConstant
.
NOT_PERMIT_TELS
)){
env
.
put
(
currentRuleVal
,
StringUtils
.
substring
(
associationBean
.
getPhoneNo
(),
0
,
3
));
}
// todo 身份证
}
Boolean
execute
=
(
Boolean
)
compiledExp
.
execute
(
env
);
log
.
info
(
"基础校验结果 {}"
,
execute
);
if
(
execute
){
execute
=
areaVerify
(
fundProduct
,
associationBean
);
execute
=
commonVerify
(
fundProduct
,
associationBean
,
auditResponce
);
}
log
.
info
(
"
区域
校验结果 {}"
,
execute
);
log
.
info
(
"
公共
校验结果 {}"
,
execute
);
return
execute
;
}
private
Boolean
areaVerify
(
FundProductEntity
fundProduct
,
UserAssociationBean
associationBean
){
if
(
fundProduct
.
getAreaTerm
()
!=
AreaEnum
.
NO_DEMAND
.
getCode
()){
ProductRuleEntity
productRuleEntity
=
productRuleService
.
getProductRuleEntityById
(
fundProduct
.
getId
());
IRuleVerifyService
ruleVerifyService
=
ruleHandleFactory
.
getRuleVerifyServiceMap
(
productRuleEntity
.
getRuleEngine
());
private
Boolean
commonVerify
(
FundProductEntity
fundProduct
,
UserAssociationBean
associationBean
,
AuditResponce
auditResponce
){
for
(
IRuleVerifyService
ruleService
:
RuleHandleFactory
.
COMMON_VERIFY
)
{
RuleParam
ruleParam
=
new
RuleParam
();
ruleParam
.
setUserInfo
(
associationBean
);
ruleParam
.
setAreaNum
(
AreaEnum
.
parse
(
fundProduct
.
getAreaTerm
()));
ruleParam
.
setArea
(
fundProduct
.
getAreaRule
());
if
(!
ruleVerifyService
.
pass
(
ruleParam
)){
ruleParam
.
setUuid
(
auditResponce
.
getUuid
());
ruleParam
.
setCardExpireEnum
(
IdCardExpireEnum
.
parse
(
fundProduct
.
getCardLimit
()));
if
(!
ruleService
.
pass
(
ruleParam
)){
log
.
info
(
"当前用户区域校验不通过 {}"
,
JSON
.
toJSONString
(
associationBean
));
return
Boolean
.
FALSE
;
}
...
...
@@ -225,7 +227,7 @@ public class CoreFilter {
if
(
StringUtils
.
isBlank
(
ruleList
)){
return
Boolean
.
TRUE
;
}
String
[]
rules
=
ruleList
.
split
(
","
);
String
[]
rules
=
ruleList
.
split
(
CommonConstants
.
COMMA
);
for
(
String
id
:
rules
)
{
ProductRuleEntity
productRuleEntity
=
productRuleService
.
getProductRuleEntityById
(
Long
.
parseLong
(
id
));
IRuleVerifyService
ruleVerifyService
=
ruleHandleFactory
.
getRuleVerifyServiceMap
(
productRuleEntity
.
getRuleEngine
());
...
...
src/main/java/com/quantgroup/asset/distribution/service/newrule/RuleHandleFactory.java
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -11,11 +15,14 @@ import java.util.Map;
* @date 2021/8/27 10:58
* @ describing
*/
@Slf4j
@Component
public
class
RuleHandleFactory
{
@Resource
private
Map
<
String
,
IRuleVerifyService
>
ruleVerifyServiceMap
;
public
final
static
List
<
IRuleVerifyService
>
COMMON_VERIFY
=
Lists
.
newArrayList
();
public
IRuleVerifyService
getRuleVerifyServiceMap
(
String
className
)
{
if
(
StringUtils
.
isBlank
(
className
)){
throw
new
RuntimeException
(
"获取IRuleVerifyService入参有问题"
);
...
...
@@ -26,4 +33,14 @@ public class RuleHandleFactory {
throw
new
RuntimeException
(
"获取IRuleVerifyService入参有问题,没有对应的实现类"
);
}
}
@PostConstruct
public
void
init
(){
for
(
IRuleVerifyService
ruleVerifyService
:
ruleVerifyServiceMap
.
values
())
{
if
(
ruleVerifyService
.
getClass
().
getName
().
contains
(
"common"
)){
COMMON_VERIFY
.
add
(
ruleVerifyService
);
}
}
}
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/
specialrules
/AbstractProductRuleVerifyImpl.java
→
src/main/java/com/quantgroup/asset/distribution/service/newrule/
common
/AbstractProductRuleVerifyImpl.java
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
.
specialrules
;
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
.
common
;
import
com.quantgroup.asset.distribution.service.jpa.entity.ProductRuleEntity
;
import
com.quantgroup.asset.distribution.service.newrule.IRuleVerifyService
;
...
...
src/main/java/com/quantgroup/asset/distribution/service/newrule/
specialrules
/AreaVerifyImpl.java
→
src/main/java/com/quantgroup/asset/distribution/service/newrule/
common
/AreaVerifyImpl.java
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
.
specialrules
;
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
.
common
;
import
cn.quantgroup.motan.bean.UserAssociationBean
;
import
com.quantgroup.asset.distribution.model.entity.user.SDKUserInfo
;
...
...
@@ -28,8 +28,8 @@ import java.util.concurrent.atomic.AtomicInteger;
* @ describing
*/
@Slf4j
@Component
public
class
AreaVerifyImpl
extends
AbstractProductRuleVerifyImpl
{
@Component
(
"commonAreaVerifyImpl"
)
public
class
AreaVerifyImpl
extends
AbstractProductRuleVerifyImpl
{
private
static
final
String
PROVINCE
=
"省"
;
private
static
final
String
TEL_ALERM_TEXT
=
"用户的手机号是 %s"
;
...
...
src/main/java/com/quantgroup/asset/distribution/service/newrule/common/IdCardVerifyImpl.java
0 → 100644
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
.
common
;
import
com.quantgroup.asset.distribution.constant.CommonConstants
;
import
com.quantgroup.asset.distribution.service.feature.IFeatureService
;
import
com.quantgroup.asset.distribution.service.feature.bo.IdCardInfo
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.IdCardExpireEnum
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.SpecialRuleEnum
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.funds.RuleParam
;
import
com.quantgroup.asset.distribution.util.DateUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Date
;
/**
* @author shihuajun
* @date 2021/9/6 20:04
* @ describing
*/
@Slf4j
@Component
(
"commonIdCardVerifyImpl"
)
public
class
IdCardVerifyImpl
extends
AbstractProductRuleVerifyImpl
{
private
static
final
Integer
YEAR
=
365
;
@Resource
private
IFeatureService
featureService
;
@Override
public
boolean
pass
(
RuleParam
param
)
{
IdCardInfo
idCardInfo
=
featureService
.
getIdCardInfo
(
param
.
getUuid
());
String
validDateEnd
=
idCardInfo
.
getValid_date_end
();
if
(
StringUtils
.
isBlank
(
validDateEnd
)){
throw
new
RuntimeException
(
"从第三方服务获取的身份证valid_date_end结束日期有问题"
);
}
if
(
IdCardExpireEnum
.
CURRENT
.
equals
(
param
.
getCardExpireEnum
())){
return
DateUtil
.
between
(
idCardInfo
.
getValid_date_begin
(),
validDateEnd
);
}
else
if
(
IdCardExpireEnum
.
EXPIRE_BIG_ONE
.
equals
(
param
.
getCardExpireEnum
())){
return
calcTermValidity
(
validDateEnd
)
>=
1
;
}
else
if
(
IdCardExpireEnum
.
EXPIRE_BIG_LOAN
.
equals
(
param
.
getCardExpireEnum
())){
String
dateEnd
=
validDateEnd
.
substring
(
0
,
4
)
+
CommonConstants
.
HORIZONTAL_LINE
+
validDateEnd
.
substring
(
4
,
6
)
+
CommonConstants
.
HORIZONTAL_LINE
+
validDateEnd
.
substring
(
6
,
8
);
int
monthDiff
=
DateUtil
.
getMonthDiff
(
DateUtil
.
getDay
(),
dateEnd
);
return
monthDiff
>
Integer
.
parseInt
(
param
.
getAuditResponce
().
getTerm
());
}
return
false
;
}
@Override
public
SpecialRuleEnum
specialRuleName
()
{
return
SpecialRuleEnum
.
ID_CARD_VERIFY
;
}
private
int
calcTermValidity
(
String
data
){
Date
date
=
new
Date
(
Integer
.
parseInt
(
data
.
substring
(
0
,
4
))
-
1900
,
Integer
.
parseInt
(
data
.
substring
(
4
,
6
))
-
1
,
Integer
.
parseInt
(
data
.
substring
(
6
,
8
)));
int
days
=
DateUtil
.
getDays
(
date
);
return
days
/
YEAR
;
}
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/pojo/RuleConstant.java
View file @
e14a908d
...
...
@@ -13,4 +13,6 @@ public class RuleConstant {
public
final
static
String
AGE
=
"age"
;
public
final
static
String
NOT_PERMIT_TELS
=
"tel"
;
public
final
static
String
IDCARD_EXPIRE
=
"idcard_expire"
;
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/pojo/enums/CooperationEnum.java
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
.
pojo
.
enums
;
import
lombok.Getter
;
import
org.apache.commons.lang3.StringUtils
;
/**
* @author shihuajun
* @date 2021/8/27 14:33
* @ describing
*/
@Getter
public
enum
CooperationEnum
{
/**
* 助贷
...
...
@@ -13,5 +17,17 @@ public enum CooperationEnum {
/**
* 导流
*/
ASSISTANCE
ASSISTANCE
;
public
static
CooperationEnum
parse
(
String
name
){
if
(
StringUtils
.
isBlank
(
name
)){
throw
new
RuntimeException
(
"解析CooperationEnum入参为空"
);
}
for
(
CooperationEnum
cooperation
:
CooperationEnum
.
values
())
{
if
(
name
.
equals
(
cooperation
.
name
())){
return
cooperation
;
}
}
throw
new
RuntimeException
(
"解析CooperationEnum出问题了"
);
}
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/pojo/enums/IdCardExpireEnum.java
0 → 100644
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
.
pojo
.
enums
;
import
lombok.Getter
;
/**
* @author shihuajun
* @date 2021/9/7 14:23
* @ describing
*/
@Getter
public
enum
IdCardExpireEnum
{
CURRENT
(
0
,
"范围当前有效"
),
EXPIRE_BIG_ONE
(
1
,
"有效期大于1年"
),
EXPIRE_BIG_LOAN
(
2
,
"有效期大于借款期限"
);
private
final
Integer
code
;
private
final
String
desc
;
IdCardExpireEnum
(
Integer
code
,
String
desc
){
this
.
code
=
code
;
this
.
desc
=
desc
;
}
public
static
IdCardExpireEnum
parse
(
int
code
){
for
(
IdCardExpireEnum
ae
:
IdCardExpireEnum
.
values
())
{
if
(
code
==
ae
.
getCode
()){
return
ae
;
}
}
throw
new
RuntimeException
(
"解析IdCardExpireEnum出问题了,没有对应的枚举类型"
);
}
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/pojo/enums/SpecialRuleEnum.java
View file @
e14a908d
...
...
@@ -9,15 +9,17 @@ import lombok.Getter;
*/
@Getter
public
enum
SpecialRuleEnum
{
CONTACT_NAME_SAME_VERIFY
(
"联系人姓名相同"
),
CONTACT_TEL_SAME_VERIFY
(
"联系人手机号相同"
),
AREA_VERIFY
(
"各种区域的组合校验"
),
CONTACT_TEL_ERROR_VERIFY
(
"联系人手机号不正确"
);
CONTACT_NAME_SAME_VERIFY
(
"联系人姓名相同"
,
""
),
CONTACT_TEL_SAME_VERIFY
(
"联系人手机号相同"
,
""
),
AREA_VERIFY
(
"各种区域的组合校验"
,
""
),
ID_CARD_VERIFY
(
"身份证有效期的校验"
,
""
),
CONTACT_TEL_ERROR_VERIFY
(
"联系人手机号不正确"
,
""
);
private
String
desc
;
private
String
ruleEngine
;
SpecialRuleEnum
(
String
desc
){
SpecialRuleEnum
(
String
desc
,
String
ruleEngine
){
this
.
ruleEngine
=
ruleEngine
;
this
.
desc
=
desc
;
}
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/pojo/funds/FundCallBackParam.java
0 → 100644
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
.
pojo
.
funds
;
import
com.google.common.collect.Lists
;
import
com.quantgroup.asset.distribution.util.JacksonUtil
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @author shihuajun
* @date 2021/9/7 16:54
* @ describing
*/
@Data
public
class
FundCallBackParam
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
4913944253732857699L
;
private
String
bizNo
;
private
List
<
BaseParam
>
result
;
public
static
void
main
(
String
[]
args
)
{
/*BaseParam baseParam = new BaseParam();
baseParam.setFundId(11L);
baseParam.setDistributeStatus(21323 + "");
FundCallBackParam backParam = new FundCallBackParam();
backParam.setBizNo("fwef");
backParam.setResult(Lists.newArrayList(baseParam));
System.out.println(JacksonUtil.serialize(backParam));*/
List
<
String
>
list
=
Lists
.
newArrayList
(
"level1"
,
"level2"
,
"level3"
);
System
.
out
.
println
(
list
);
}
/**
* @author shihuajun
* @date 2021/9/7 19:06
* @ describing
*/
@Data
public
static
class
BaseParam
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1358066235935716831L
;
private
Long
fundId
;
private
String
distributeStatus
;
}
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/pojo/funds/RuleParam.java
View file @
e14a908d
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
newrule
.
pojo
.
funds
;
import
cn.quantgroup.motan.bean.UserAssociationBean
;
import
com.alibaba.fastjson.JSON
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.AreaEnum
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.IdCardExpireEnum
;
import
com.quantgroup.asset.distribution.service.newrule.third.AuditResponce
;
import
lombok.Data
;
...
...
@@ -15,6 +18,9 @@ public class RuleParam {
private
UserAssociationBean
userInfo
;
private
AreaEnum
areaNum
;
private
String
area
;
private
String
uuid
;
private
IdCardExpireEnum
cardExpireEnum
;
private
AuditResponce
auditResponce
;
/**
* @author shihuajun
...
...
@@ -30,4 +36,13 @@ public class RuleParam {
// 籍贯
private
String
nativeList
;
}
public
static
void
main
(
String
[]
args
)
{
AreaRuleConcrete
concrete
=
new
AreaRuleConcrete
();
concrete
.
setNativeList
(
"[110119,100000]"
);
concrete
.
setTelAreaNameList
(
"[100000]"
);
concrete
.
setResidenceList
(
"[100000]"
);
System
.
out
.
println
(
JSON
.
toJSONString
(
concrete
));
}
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/specialrules/ContactsNameSameVerifyImpl.java
View file @
e14a908d
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.motan.retbean.XContactInfo;
import
com.alibaba.fastjson.JSON
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.SpecialRuleEnum
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.funds.RuleParam
;
import
com.quantgroup.asset.distribution.service.newrule.common.AbstractProductRuleVerifyImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
src/main/java/com/quantgroup/asset/distribution/service/newrule/specialrules/ContactsTelErrorVerifyImpl.java
View file @
e14a908d
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.motan.retbean.XContactInfo;
import
com.alibaba.fastjson.JSON
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.SpecialRuleEnum
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.funds.RuleParam
;
import
com.quantgroup.asset.distribution.service.newrule.common.AbstractProductRuleVerifyImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -19,7 +20,9 @@ import java.util.List;
*/
@Slf4j
@Component
public
class
ContactsTelErrorVerifyImpl
extends
AbstractProductRuleVerifyImpl
{
public
class
ContactsTelErrorVerifyImpl
extends
AbstractProductRuleVerifyImpl
{
private
static
final
int
TEL_LENGTH
=
11
;
@Override
public
boolean
pass
(
RuleParam
param
)
{
if
(
param
==
null
){
...
...
@@ -53,15 +56,12 @@ public class ContactsTelErrorVerifyImpl extends AbstractProductRuleVerifyImpl{
}
private
boolean
telVerify
(
String
tel
){
if
(
tel
.
length
()
!=
11
){
if
(
tel
.
length
()
!=
TEL_LENGTH
){
return
false
;
}
if
(!
tel
.
startsWith
(
"1"
)){
return
false
;
}
if
(
tel
.
startsWith
(
"170"
)
||
tel
.
startsWith
(
"171"
)){
return
false
;
}
return
true
;
return
!
tel
.
startsWith
(
"170"
)
&&
!
tel
.
startsWith
(
"171"
);
}
}
src/main/java/com/quantgroup/asset/distribution/service/newrule/specialrules/ContactsTelSameVerifyImpl.java
View file @
e14a908d
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.motan.retbean.XContactInfo;
import
com.alibaba.fastjson.JSON
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.enums.SpecialRuleEnum
;
import
com.quantgroup.asset.distribution.service.newrule.pojo.funds.RuleParam
;
import
com.quantgroup.asset.distribution.service.newrule.common.AbstractProductRuleVerifyImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -19,7 +20,7 @@ import java.util.List;
*/
@Slf4j
@Component
public
class
ContactsTelSameVerifyImpl
extends
AbstractProductRuleVerifyImpl
{
public
class
ContactsTelSameVerifyImpl
extends
AbstractProductRuleVerifyImpl
{
@Override
public
boolean
pass
(
RuleParam
param
)
{
if
(
param
==
null
){
...
...
src/main/java/com/quantgroup/asset/distribution/service/newrule/third/AuditResponce.java
View file @
e14a908d
...
...
@@ -97,7 +97,7 @@ public class AuditResponce {
* 6-vcc贷中交易反欺诈审核
* ...
*/
@NotNull
@NotNull
(
message
=
"method不能为空"
)
private
Integer
method
;
private
String
isWhiteBlackListHit
;
...
...
src/main/java/com/quantgroup/asset/distribution/util/DateUtil.java
View file @
e14a908d
...
...
@@ -6,8 +6,13 @@ import org.joda.time.format.DateTimeFormat;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.ZonedDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.time.temporal.ChronoUnit
;
import
java.time.temporal.Temporal
;
import
java.util.Date
;
/**
...
...
@@ -90,4 +95,66 @@ public class DateUtil {
public
static
DateTime
toDateTime
(
String
dateTime
,
DateTimeUtilFormat
dateTimeUtilFormat
)
{
return
DateTimeFormat
.
forPattern
(
dateTimeUtilFormat
.
format
).
parseLocalDate
(
dateTime
).
toDateTimeAtStartOfDay
();
}
public
static
Date
localDateTimeToDate
(
LocalDateTime
localDateTime
)
{
ZoneId
zoneId
=
ZoneId
.
systemDefault
();
ZonedDateTime
zdt
=
localDateTime
.
atZone
(
zoneId
);
return
Date
.
from
(
zdt
.
toInstant
());
}
public
static
int
getDays
(
Date
time
)
{
long
days
=
ChronoUnit
.
DAYS
.
between
(
new
Date
().
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
(),
time
.
toInstant
().
atZone
(
ZoneId
.
systemDefault
()).
toLocalDate
());
return
(
int
)
days
;
}
public
static
boolean
between
(
String
startData
,
String
endData
){
LocalDate
start
=
LocalDate
.
of
(
Integer
.
parseInt
(
startData
.
substring
(
0
,
4
))
,
Integer
.
parseInt
(
startData
.
substring
(
4
,
6
)),
Integer
.
parseInt
(
startData
.
substring
(
6
,
8
)));
LocalDate
end
=
LocalDate
.
of
(
Integer
.
parseInt
(
endData
.
substring
(
0
,
4
))
,
Integer
.
parseInt
(
endData
.
substring
(
4
,
6
)),
Integer
.
parseInt
(
endData
.
substring
(
6
,
8
)));
return
LocalDate
.
now
().
isBefore
(
end
)
&&
LocalDate
.
now
().
isAfter
(
start
);
}
/**
* 获取两个日期相差的月数
*/
public
static
int
getMonthDiff
(
String
d1
,
String
d2
)
{
/*Calendar c1 = Calendar.getInstance();
Calendar c2 = Calendar.getInstance();
c1.setTime(d1);
c2.setTime(d2);
int year1 = c1.get(Calendar.YEAR);
int year2 = c2.get(Calendar.YEAR);
int month1 = c1.get(Calendar.MONTH);
int month2 = c2.get(Calendar.MONTH);
int day1 = c1.get(Calendar.DAY_OF_MONTH);
int day2 = c2.get(Calendar.DAY_OF_MONTH);
// 获取年的差值
int yearInterval = year1 - year2;
// 如果 d1的 月-日 小于 d2的 月-日 那么 yearInterval-- 这样就得到了相差的年数
if (month1 < month2 || month1 == month2 && day1 < day2) {
yearInterval--;
}
// 获取月数差值
int monthInterval = (month1 + 12) - month2;
if (day1 < day2) {
monthInterval--;
}
monthInterval %= 12;
return yearInterval * 12 + monthInterval;*/
String
text1
=
"2020-08-02"
;
Temporal
temporal1
=
LocalDate
.
parse
(
d1
);
String
text2
=
"2020-09-03"
;
Temporal
temporal2
=
LocalDate
.
parse
(
d2
);
// 方法返回为相差月份
return
(
int
)
ChronoUnit
.
MONTHS
.
between
(
temporal1
,
temporal2
);
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
between
(
"20210722"
,
"20310722"
));
}
}
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