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
b194b275
Commit
b194b275
authored
Apr 28, 2020
by
liwenbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
fce613a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
203 deletions
+12
-203
AssetServiceImpl.java
...set/distribution/service/asset/impl/AssetServiceImpl.java
+12
-203
No files found.
src/main/java/com/quantgroup/asset/distribution/service/asset/impl/AssetServiceImpl.java
View file @
b194b275
...
@@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit;
...
@@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit;
@Slf4j
@Slf4j
@Service
@Service
public
class
AssetServiceImpl
implements
IAssetService
{
public
class
AssetServiceImpl
implements
IAssetService
{
@Autowired
@Autowired
private
IAssetAttributeExtendConfigService
assetAttributeExtendConfigService
;
private
IAssetAttributeExtendConfigService
assetAttributeExtendConfigService
;
@Autowired
@Autowired
...
@@ -50,7 +50,7 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -50,7 +50,7 @@ public class AssetServiceImpl implements IAssetService{
@Autowired
@Autowired
private
IDistributeFailLogService
distributeFailLogService
;
private
IDistributeFailLogService
distributeFailLogService
;
@Async
@Async
@Override
@Override
public
void
assetsIn
(
AssetForm
assetForm
)
{
public
void
assetsIn
(
AssetForm
assetForm
)
{
...
@@ -68,11 +68,11 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -68,11 +68,11 @@ public class AssetServiceImpl implements IAssetService{
data
=
addAssetAttributeToData
(
asset
,
data
);
data
=
addAssetAttributeToData
(
asset
,
data
);
// 资产分发
// 资产分发
assetDistributeService
.
distribute
(
assetForm
,
asset
,
data
);
assetDistributeService
.
distribute
(
assetForm
,
asset
,
data
);
log
.
info
(
"资产分发完成, uuid : {}, bizNo : {}, assetNo : {}, bizChannel : {}, 耗时 : {}"
,
assetForm
.
getUuid
(),
log
.
info
(
"资产分发完成, uuid : {}, bizNo : {}, assetNo : {}, bizChannel : {}, 耗时 : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
(),
assetForm
.
getBizChannel
(),
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
(),
assetForm
.
getBizChannel
(),
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
}
catch
(
QGException
qe
)
{
}
catch
(
QGException
qe
)
{
log
.
error
(
"资产入库分发出现错误 : {}, uuid : {}, bizChannel : {}, bizType : {}, bizNo : {}, assetNo : {} "
,
log
.
error
(
"资产入库分发出现错误 : {}, uuid : {}, bizChannel : {}, bizType : {}, bizNo : {}, assetNo : {} "
,
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
,
assetForm
.
getUuid
(),
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
,
assetForm
.
getUuid
(),
assetForm
.
getBizChannel
(),
assetForm
.
getBizType
(),
assetForm
.
getBizChannel
(),
assetForm
.
getBizType
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
());
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
());
distributeFailLogService
.
saveDistributeFailLog
(
assetForm
,
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
);
distributeFailLogService
.
saveDistributeFailLog
(
assetForm
,
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
);
...
@@ -81,7 +81,7 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -81,7 +81,7 @@ public class AssetServiceImpl implements IAssetService{
+
" , assetNo : "
+
assetForm
.
getAssetNo
()
+
" , uuid : "
+
assetForm
.
getUuid
()
+
" , assetNo : "
+
assetForm
.
getAssetNo
()
+
" , uuid : "
+
assetForm
.
getUuid
()
+
" , 错误信息 : "
+
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
);
+
" , 错误信息 : "
+
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
);
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
log
.
error
(
"资产入库分发出现异常, uuid : {}, bizChannel : {}, bizType : {}, bizNo : {}, assetNo : {} "
,
assetForm
.
getUuid
(),
log
.
error
(
"资产入库分发出现异常, uuid : {}, bizChannel : {}, bizType : {}, bizNo : {}, assetNo : {} "
,
assetForm
.
getUuid
(),
assetForm
.
getBizChannel
(),
assetForm
.
getBizType
(),
assetForm
.
getBizChannel
(),
assetForm
.
getBizType
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
(),
ex
);
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
(),
ex
);
distributeFailLogService
.
saveDistributeFailLog
(
assetForm
,
"未知异常."
);
distributeFailLogService
.
saveDistributeFailLog
(
assetForm
,
"未知异常."
);
...
@@ -91,13 +91,13 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -91,13 +91,13 @@ public class AssetServiceImpl implements IAssetService{
+
" , 错误信息 : 未知错误."
);
+
" , 错误信息 : 未知错误."
);
}
}
}
}
@Override
@Override
public
GlobalResponse
checkAssetForm
(
AssetForm
assetForm
)
{
public
GlobalResponse
checkAssetForm
(
AssetForm
assetForm
)
{
// auditResult和deadLine必填
// auditResult和deadLine必填
if
(
StringUtils
.
isEmpty
(
assetForm
.
getAuditResult
())
||
StringUtils
.
isEmpty
(
assetForm
.
getDeadLine
()))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getAuditResult
())
||
StringUtils
.
isEmpty
(
assetForm
.
getDeadLine
()))
{
log
.
info
(
"资产入库auditResult或deadLine为空, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
log
.
info
(
"资产入库auditResult或deadLine为空, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
GlobalResponse
.
create
(
AssetResponse
.
AUDIT_RESULT_OR_DEAD_LINE_IS_EMPTY
);
return
GlobalResponse
.
create
(
AssetResponse
.
AUDIT_RESULT_OR_DEAD_LINE_IS_EMPTY
);
}
}
// auditResult为true时, 校验是使用资方模块还是老金融产品集
// auditResult为true时, 校验是使用资方模块还是老金融产品集
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
()))
{
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
()))
{
...
@@ -110,7 +110,7 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -110,7 +110,7 @@ public class AssetServiceImpl implements IAssetService{
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
}
}
}
}
public
GlobalResponse
checkNewAssetForm
(
AssetForm
assetForm
)
{
public
GlobalResponse
checkNewAssetForm
(
AssetForm
assetForm
)
{
//"8"-vcc 不校验期数
//"8"-vcc 不校验期数
if
(
StringUtils
.
isEmpty
(
assetForm
.
getAmount
())
||
(
StringUtils
.
isEmpty
(
assetForm
.
getTerm
())
&&
!
"8"
.
equals
(
assetForm
.
getBizType
())))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getAmount
())
||
(
StringUtils
.
isEmpty
(
assetForm
.
getTerm
())
&&
!
"8"
.
equals
(
assetForm
.
getBizType
())))
{
...
@@ -118,7 +118,7 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -118,7 +118,7 @@ public class AssetServiceImpl implements IAssetService{
}
}
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
}
}
public
GlobalResponse
checkOldAssetForm
(
AssetForm
assetForm
)
{
public
GlobalResponse
checkOldAssetForm
(
AssetForm
assetForm
)
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getFinanceProducts
())
||
StringUtils
.
isEmpty
(
assetForm
.
getAmount
()))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getFinanceProducts
())
||
StringUtils
.
isEmpty
(
assetForm
.
getAmount
()))
{
// auditResult为true,金融产品集和amount不能为空
// auditResult为true,金融产品集和amount不能为空
...
@@ -149,7 +149,7 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -149,7 +149,7 @@ public class AssetServiceImpl implements IAssetService{
}
}
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
}
}
/**
/**
* 将资产属性值放入data
* 将资产属性值放入data
* @param asset
* @param asset
...
@@ -172,7 +172,7 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -172,7 +172,7 @@ public class AssetServiceImpl implements IAssetService{
}
}
return
data
;
return
data
;
}
}
/**
/**
* 将驼峰字符转转换为下划线字符串
* 将驼峰字符转转换为下划线字符串
* @param name
* @param name
...
@@ -190,195 +190,4 @@ public class AssetServiceImpl implements IAssetService{
...
@@ -190,195 +190,4 @@ public class AssetServiceImpl implements IAssetService{
}
}
return
sb
.
toString
();
return
sb
.
toString
();
}
}
/**
* 如果使用资方模块,需要去命中资方
* @param assetForm
*/
public
String
hitFundIfUseFundModule
(
AssetForm
assetForm
,
Map
<
String
,
Object
>
data
,
ExecuteType
executeType
)
{
// 如果auditResult为true, amount或term有一个为空, 那就不管是否是测试,都不能使用资方模块了
// 同时兼容量子魔方白名单,白名单的没有期数直接返回
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
())
&&
(
StringUtils
.
isEmpty
(
assetForm
.
getAmount
())
||
StringUtils
.
isEmpty
(
assetForm
.
getTerm
())))
{
return
null
;
}
FundModuleChannelFundConfigNew
config
=
fundModuleChannelFundConfigNewService
.
findByBizChannel
(
assetForm
.
getBizChannel
());
// 未找到资方渠道配置直接通知
if
(
config
==
null
)
{
return
null
;
}
QGPreconditions
.
checkArgument
(
config
!=
null
,
QGExceptionType
.
NOT_FOUNT_CHANNEL_FUNDS_INFO
,
assetForm
.
getBizChannel
());
JSONArray
fundArray
=
new
JSONArray
();
// 资方去重, 可能存在多条件同一个资方
Set
<
String
>
fundSet
=
new
HashSet
<>();
List
<
ChannelFundConfigNew
>
fundConfigList
=
JSONArray
.
parseArray
(
config
.
getFunds
(),
ChannelFundConfigNew
.
class
);
A
:
for
(
ChannelFundConfigNew
channelFundConfig
:
fundConfigList
)
{
IRuleVO
ruleVO
=
ruleService
.
getIRuleVo
(
channelFundConfig
.
getLimits
());
if
(
ruleVO
==
null
)
{
throw
new
QGException
(
QGExceptionType
.
CRATE_RULE_VO_ERROR
);
}
// 如果参数为空,直接不满足
Set
<
String
>
params
=
ruleVO
.
getParamNames
();
for
(
String
key
:
params
)
{
if
(!
data
.
containsKey
(
key
))
{
continue
A
;
}
}
if
(!
ruleVO
.
valid
(
data
))
{
continue
A
;
}
// 是否配了审核条件
boolean
hasAuditResultLimit
=
params
.
contains
(
"audit_result"
);
if
(!
hasAuditResultLimit
)
{
// 如果没配,自动过一层auditResult@true的条件
if
(!
ruleService
.
valid
(
"audit_result==true"
,
data
))
{
continue
A
;
}
}
String
key
=
channelFundConfig
.
getFundId
()
+
"_"
+
channelFundConfig
.
getFundProductId
()
+
"_"
+
channelFundConfig
.
getPriority
();
if
(!
fundSet
.
contains
(
key
))
{
// 创建并增加资方配置
JSONObject
fundInfoJSON
=
new
JSONObject
();
fundInfoJSON
.
put
(
"fundId"
,
channelFundConfig
.
getFundId
());
fundInfoJSON
.
put
(
"fundProductId"
,
channelFundConfig
.
getFundProductId
());
fundInfoJSON
.
put
(
"priority"
,
channelFundConfig
.
getPriority
());
fundInfoJSON
.
put
(
"feeType"
,
channelFundConfig
.
getFeeType
());
fundInfoJSON
.
put
(
"rateType"
,
channelFundConfig
.
getRateType
());
fundInfoJSON
.
put
(
"rate"
,
channelFundConfig
.
getRate
());
fundArray
.
add
(
fundInfoJSON
);
log
.
info
(
"资方模块用户命中资方条件, uuid : {}, assetNo : {}, bizNo : {}, bizChannel : {}, fundId : {}, fundProductId : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getAssetNo
(),
assetForm
.
getBizNo
(),
assetForm
.
getBizChannel
(),
channelFundConfig
.
getFundId
(),
channelFundConfig
.
getFundProductId
());
fundSet
.
add
(
key
);
}
}
// 如果审核拒绝,也没命中任何资方, 直接返回
if
(
"false"
.
equals
(
assetForm
.
getAuditResult
())
&&
fundArray
.
size
()
==
0
)
{
return
null
;
}
QGPreconditions
.
checkArgument
(
fundArray
.
size
()
!=
0
,
QGExceptionType
.
NO_FUND_INFO_BEEN_HIT
,
assetForm
.
getBizChannel
(),
assetForm
.
getAmount
(),
assetForm
.
getTerm
());
// 看命中优先级是否符合要求
boolean
[]
bucket
=
new
boolean
[
fundArray
.
size
()
+
1
];
for
(
int
i
=
0
,
len
=
fundArray
.
size
();
i
<
len
;
i
++)
{
int
priority
=
fundArray
.
getJSONObject
(
i
).
getIntValue
(
"priority"
);
if
(!(
priority
>
0
&&
priority
<=
len
))
{
throw
new
QGException
(
QGExceptionType
.
FUND_PRIORITY_IS_ERROR
,
assetForm
.
getBizChannel
(),
assetForm
.
getAmount
(),
assetForm
.
getTerm
());
}
if
(
bucket
[
priority
])
{
// 多个相同的优先级
throw
new
QGException
(
QGExceptionType
.
FUND_PRIORITY_IS_ERROR
,
assetForm
.
getBizChannel
(),
assetForm
.
getAmount
(),
assetForm
.
getTerm
());
}
bucket
[
priority
]
=
true
;
}
String
hitFinanceProduct
=
createFinancePro
(
assetForm
,
fundArray
);
log
.
info
(
"资方模块组成金融产品集完成, uuid : {}, assetNo : {}, bizNo : {}, bizChannel : {}, financeProduct : {}, executeType : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getAssetNo
(),
assetForm
.
getBizNo
(),
assetForm
.
getBizChannel
(),
hitFinanceProduct
,
executeType
.
name
());
return
hitFinanceProduct
;
}
/**
* 资方模块命中后结果处理
* @param assetForm
* @param hitFinanceProduct
* @return
*/
private
AssetForm
checkFundResult
(
AssetForm
assetForm
,
String
hitFinanceProduct
)
{
if
(
hitFinanceProduct
==
null
)
{
if
(
"false"
.
equals
(
assetForm
.
getAuditResult
()))
{
// 把传过来的额度和期数处理为null
assetForm
.
setAmount
(
null
);
assetForm
.
setTerm
(
null
);
}
return
assetForm
;
}
// 金融产品集替换
String
oldFinanceProduct
=
assetForm
.
getFinanceProducts
();
assetForm
.
setFinanceProducts
(
hitFinanceProduct
);
// 审核结果替换
String
oldAuditResult
=
assetForm
.
getAuditResult
();
if
(
"false"
.
equals
(
oldAuditResult
))
{
assetForm
.
setAuditResult
(
"true"
);
}
// 保存日志
financeProductHitLogService
.
saveLog
(
assetForm
,
oldFinanceProduct
,
hitFinanceProduct
,
oldAuditResult
,
assetForm
.
getAuditResult
(),
ExecuteType
.
ONLINE
);
log
.
info
(
"资方命中后,审核最终结果, assetForm : {}"
,
JSON
.
toJSONString
(
assetForm
));
return
assetForm
;
}
/**
* 组建金融产品集
* @param assetForm
* @param fundArray
* @return
*/
private
String
createFinancePro
(
AssetForm
assetForm
,
JSONArray
fundArray
)
{
// 首先判断是否有额度期数
QGPreconditions
.
checkArgument
(
StringUtils
.
isNotEmpty
(
assetForm
.
getAmount
())
&&
StringUtils
.
isNotEmpty
(
assetForm
.
getTerm
()),
QGExceptionType
.
HIT_FUND_BUT_AMOUNT_OR_TERM_IS_EMPTY
);
JSONArray
financeProductArray
=
new
JSONArray
();
JSONObject
amountJSON
=
new
JSONObject
();
financeProductArray
.
add
(
amountJSON
);
amountJSON
.
put
(
"min"
,
assetForm
.
getAmount
());
amountJSON
.
put
(
"max"
,
assetForm
.
getAmount
());
JSONArray
termArray
=
new
JSONArray
();
amountJSON
.
put
(
"terms"
,
termArray
);
JSONObject
termJSON
=
new
JSONObject
();
termArray
.
add
(
termJSON
);
try
{
// 不能是string,否则资方那边会报错
termJSON
.
put
(
"term"
,
Integer
.
parseInt
(
assetForm
.
getTerm
()));
}
catch
(
Exception
e
)
{
termJSON
.
put
(
"term"
,
Double
.
parseDouble
(
assetForm
.
getTerm
()));
}
termJSON
.
put
(
"fundInfo"
,
fundArray
);
return
JSON
.
toJSONString
(
financeProductArray
);
}
/**
* 资方配置空跑
* @param assetForm
* @param data
*/
private
void
doTestExecute
(
AssetForm
assetForm
,
Map
<
String
,
Object
>
data
)
{
executorPool
.
execute
(()
->
{
try
{
assetForm
.
setBizChannel
(
"88888_"
+
assetForm
.
getBizChannel
());
String
hitFundPro
=
hitFundIfUseFundModule
(
assetForm
,
data
,
ExecuteType
.
TEST
);
if
(
hitFundPro
!=
null
)
{
// 如果命中了记录一下,并且如果审核状态为false改为true
String
oldFundPro
=
assetForm
.
getFinanceProducts
();
String
oldAuditResult
=
assetForm
.
getAuditResult
();
assetForm
.
setFinanceProducts
(
hitFundPro
);
assetForm
.
setAuditResult
(
"true"
);
financeProductHitLogService
.
saveLog
(
assetForm
,
oldFundPro
,
hitFundPro
,
oldAuditResult
,
assetForm
.
getAuditResult
(),
ExecuteType
.
TEST
);
}
else
{
// 如果没命中,且审核结果未false
if
(
"false"
.
equals
(
assetForm
.
getAuditResult
()))
{
// 把传过来的额度和期数处理为null
assetForm
.
setAmount
(
null
);
assetForm
.
setTerm
(
null
);
}
}
log
.
info
(
"空跑审核最终结果, assetForm : {}"
,
JSON
.
toJSONString
(
assetForm
));
}
catch
(
QGException
qe
)
{
log
.
error
(
"资方配置执行空跑出现错误 : {}, uuid : {}, bizChannel : {}, bizType : {}, bizNo : {}, assetNo : {} "
,
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
,
assetForm
.
getUuid
(),
assetForm
.
getBizChannel
(),
assetForm
.
getBizType
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
());
alarmService
.
dingtalkAlarm
(
"Warn"
,
"资方配置执行空跑出现错误"
,
"bizChannel : "
+
assetForm
.
getBizChannel
()
+
" , bizType : "
+
assetForm
.
getBizType
()
+
" , bizNo : "
+
assetForm
.
getBizNo
()
+
" , assetNo : "
+
assetForm
.
getAssetNo
()
+
" , uuid : "
+
assetForm
.
getUuid
()
+
" , 错误信息 : "
+
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"资方配置执行空跑出现异常, uuid : {}, bizChannel : {}, bizType : {}, bizNo : {}, assetNo : {} "
,
assetForm
.
getUuid
(),
assetForm
.
getBizChannel
(),
assetForm
.
getBizType
(),
assetForm
.
getBizNo
(),
assetForm
.
getAssetNo
(),
ex
);
alarmService
.
dingtalkAlarm
(
"Warn"
,
"资方配置执行空跑出现异常"
,
"bizChannel : "
+
assetForm
.
getBizChannel
()
+
" , bizType : "
+
assetForm
.
getBizType
()
+
" , bizNo : "
+
assetForm
.
getBizNo
()
+
" , assetNo : "
+
assetForm
.
getAssetNo
()
+
" , uuid : "
+
assetForm
.
getUuid
()
+
" , 错误信息 : 未知错误."
);
}
});
}
}
}
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