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
dc467329
Commit
dc467329
authored
Jul 22, 2019
by
data-爬虫-任锋
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
助贷资金路由模块开发
parent
8954fa72
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
11 deletions
+88
-11
RedisKeyConstants.java
...tgroup/asset/distribution/constant/RedisKeyConstants.java
+12
-1
RedisFlushController.java
...p/asset/distribution/controller/RedisFlushController.java
+2
-2
AidFundRouteServiceImpl.java
...ibution/service/funding/impl/AidFundRouteServiceImpl.java
+47
-7
AidLoanFundConfigServiceImpl.java
...on/service/funding/impl/AidLoanFundConfigServiceImpl.java
+7
-1
DateUtil.java
...java/com/quantgroup/asset/distribution/util/DateUtil.java
+20
-0
No files found.
src/main/java/com/quantgroup/asset/distribution/constant/RedisKeyConstants.java
View file @
dc467329
...
...
@@ -9,5 +9,16 @@ public class RedisKeyConstants {
/**
* 助贷资金池所有key的hmset key
*/
public
final
static
String
AID_LOAN_POOLKEYS_HMSET_KEY
=
"AID.LOAN.POOLKEYS.HMSET.KEY.8UJ2WS"
;
public
final
static
String
AID_LOAN_POOLKEYS_HMSET_KEY
=
"AID.LOAN.POOLKEYS.HMSET.KEY.8UJ2WS_"
;
/**
* 助贷资金次数限制缓存key
*/
public
final
static
String
AID_LOAN_COUNT_LIMIT_KEY
=
"AID.LOAN.COUNT.LIMIT.KEY.23RFRY45_"
;
/**
* 助贷资金总金额限制缓存key
*/
public
final
static
String
AID_LOAN_ALL_AMOUNT_LIMIT_KEY
=
"AID.LOAN.ALL.AMOUNT.LIMIT.KEY.9QDBFD_"
;
}
src/main/java/com/quantgroup/asset/distribution/controller/RedisFlushController.java
View file @
dc467329
...
...
@@ -32,7 +32,7 @@ public class RedisFlushController {
*/
@RequestMapping
(
"/aid_loan_fund_pool_flush"
)
public
GlobalResponse
aidLoanFundPoolFlush
(
String
key
){
if
(
authKey
.
equals
(
key
))
{}
if
(
authKey
.
equals
(
key
))
redisService
.
del
(
RedisKeyConstants
.
AID_LOAN_POOLKEYS_HMSET_KEY
);
return
GlobalResponse
.
success
();
}
...
...
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/AidFundRouteServiceImpl.java
View file @
dc467329
...
...
@@ -3,9 +3,24 @@ package com.quantgroup.asset.distribution.service.funding.impl;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.funding.IAidFundRouteService
;
import
com.quantgroup.asset.distribution.service.funding.IAidLoanFundConfigService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.AidLoanFundConfig
;
import
com.quantgroup.asset.distribution.service.redis.IRedisService
;
import
com.quantgroup.asset.distribution.util.DateUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
static
com
.
quantgroup
.
asset
.
distribution
.
constant
.
RedisKeyConstants
.
AID_LOAN_ALL_AMOUNT_LIMIT_KEY
;
import
static
com
.
quantgroup
.
asset
.
distribution
.
constant
.
RedisKeyConstants
.
AID_LOAN_COUNT_LIMIT_KEY
;
/**
* Created by renfeng on 2019/7/19.
*/
...
...
@@ -13,6 +28,13 @@ import org.springframework.stereotype.Service;
@Slf4j
public
class
AidFundRouteServiceImpl
implements
IAidFundRouteService
{
@Autowired
private
IAidLoanFundConfigService
iAidLoanFundConfigService
;
@Autowired
private
IRedisService
<
String
>
redisService
;
/**
* 助贷资金路由
*
...
...
@@ -22,13 +44,31 @@ public class AidFundRouteServiceImpl implements IAidFundRouteService {
@Override
public
GlobalResponse
aidFundRoute
(
AssetForm
assetForm
)
{
//
//第一步 查询所有助贷资金
List
<
AidLoanFundConfig
>
aidLoanFundConfigList
=
iAidLoanFundConfigService
.
findAll
();
return
GlobalResponse
.
success
();
//第二步 开关筛选
if
(
CollectionUtils
.
isNotEmpty
(
aidLoanFundConfigList
))
aidLoanFundConfigList
=
aidLoanFundConfigList
.
parallelStream
().
filter
(
aidLoanFundConfig
->
aidLoanFundConfig
.
getFundSwitchState
()==
1
).
collect
(
Collectors
.
toList
());
//第三步 限制次数筛选
if
(
CollectionUtils
.
isNotEmpty
(
aidLoanFundConfigList
)){
// AID_LOAN_COUNT_LIMIT_KEY + DateUtil.getDay() //TODO 放redis
aidLoanFundConfigList
=
aidLoanFundConfigList
.
parallelStream
()
.
filter
(
aidLoanFundConfig
->
aidLoanFundConfig
.
getFundCountLimit
()
>=
redisService
.
setIncr
(
AID_LOAN_COUNT_LIMIT_KEY
+
DateUtil
.
getDay
(),
0
,
3
,
TimeUnit
.
DAYS
))
.
collect
(
Collectors
.
toList
());
}
//第四步 限制总额度筛选
if
(
CollectionUtils
.
isNotEmpty
(
aidLoanFundConfigList
)){
// 获取已放款总金额 AID_LOAN_ALL_AMOUNT_LIMIT_KEY + DateUtil.getDay() //TODO 放redis
String
allAmount
=
redisService
.
getString
(
AID_LOAN_ALL_AMOUNT_LIMIT_KEY
+
DateUtil
.
getDay
());
aidLoanFundConfigList
=
aidLoanFundConfigList
.
parallelStream
()
.
filter
(
aidLoanFundConfig
->
new
BigDecimal
(
aidLoanFundConfig
.
getFundAllAmountLimit
()).
compareTo
(
new
BigDecimal
(
StringUtils
.
isEmpty
(
allAmount
)?
"0"
:
allAmount
))>
0
)
.
collect
(
Collectors
.
toList
());
}
//第五步 开始路由
if
(
CollectionUtils
.
isNotEmpty
(
aidLoanFundConfigList
)){
//TODO 未接到助贷资金 暂时不能进行开发
}
return
GlobalResponse
.
error
(
"未匹配到助贷资金"
);
}
}
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/AidLoanFundConfigServiceImpl.java
View file @
dc467329
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
.
impl
;
import
com.google.common.collect.Lists
;
import
com.quantgroup.asset.distribution.service.funding.IAidLoanFundConfigService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.AidLoanFundConfig
;
import
com.quantgroup.asset.distribution.service.jpa.repository.IAidLoanFundConfigRepository
;
...
...
@@ -11,11 +12,13 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
static
com
.
quantgroup
.
asset
.
distribution
.
constant
.
FundingConstants
.
AID_LOAN_FUND_CONFIG_POOL
;
import
static
com
.
quantgroup
.
asset
.
distribution
.
constant
.
RedisKeyConstants
.
AID_LOAN_POOLKEYS_HMSET_KEY
;
import
static
java
.
util
.
Collections
.
addAll
;
/**
* Created by renfeng on 2019/7/22.
...
...
@@ -49,9 +52,12 @@ public class AidLoanFundConfigServiceImpl implements IAidLoanFundConfigService {
redisService
.
hmset
(
AID_LOAN_POOLKEYS_HMSET_KEY
,
key
,
key
,
7
,
TimeUnit
.
DAYS
);
}
}
return
AID_LOAN_FUND_CONFIG_POOL
.
getAidLoanFundConfigList
();
//一定要拷贝
return
new
ArrayList
<>(
AID_LOAN_FUND_CONFIG_POOL
.
getAidLoanFundConfigList
()!=
null
?
AID_LOAN_FUND_CONFIG_POOL
.
getAidLoanFundConfigList
():
new
ArrayList
<>());
}
/**
* 根据id查询助贷资金
*
...
...
src/main/java/com/quantgroup/asset/distribution/util/DateUtil.java
0 → 100644
View file @
dc467329
package
com
.
quantgroup
.
asset
.
distribution
.
util
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
/**
* Created by renfeng on 2019/7/22.
*/
public
class
DateUtil
{
/**
* 获取当前日期(天)
* @return
*/
public
static
String
getDay
(){
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
return
df
.
format
(
new
Date
());
}
}
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