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
279cd9c5
Commit
279cd9c5
authored
Feb 28, 2020
by
liwenbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
390d74a0
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
570 additions
and
62 deletions
+570
-62
FundModuleController.java
...p/asset/distribution/controller/FundModuleController.java
+89
-39
FundModuleResponse.java
...asset/distribution/enums/response/FundModuleResponse.java
+1
-1
IApprovalLogService.java
...et/distribution/service/approval/IApprovalLogService.java
+3
-3
ApprovalLogServiceImpl.java
...ibution/service/approval/impl/ApprovalLogServiceImpl.java
+11
-5
IFundModuleChannelFundConfigNewService.java
...rvice/funding/IFundModuleChannelFundConfigNewService.java
+29
-0
IFundModuleService.java
...sset/distribution/service/funding/IFundModuleService.java
+32
-0
FundModuleChannelFundConfigNewServiceImpl.java
...nding/impl/FundModuleChannelFundConfigNewServiceImpl.java
+198
-0
FundModuleChannelFundConfigServiceImpl.java
.../funding/impl/FundModuleChannelFundConfigServiceImpl.java
+43
-7
FundModuleServiceImpl.java
...tribution/service/funding/impl/FundModuleServiceImpl.java
+37
-2
FundModuleChannelFundConfigNew.java
...on/service/jpa/entity/FundModuleChannelFundConfigNew.java
+61
-0
FundModuleLimitTypeConfig.java
...ibution/service/jpa/entity/FundModuleLimitTypeConfig.java
+3
-0
IApprovalLogRepository.java
...bution/service/jpa/repository/IApprovalLogRepository.java
+5
-2
IFundModuleChannelFundConfigNewRepository.java
...repository/IFundModuleChannelFundConfigNewRepository.java
+38
-0
ChannelFundConfigUtil.java
.../distribution/util/fund/module/ChannelFundConfigUtil.java
+20
-3
No files found.
src/main/java/com/quantgroup/asset/distribution/controller/FundModuleController.java
View file @
279cd9c5
This diff is collapsed.
Click to expand it.
src/main/java/com/quantgroup/asset/distribution/enums/response/FundModuleResponse.java
View file @
279cd9c5
...
...
@@ -24,7 +24,7 @@ public enum FundModuleResponse implements GlobalResponseEnum{
USER_IS_EMPTY
(
4012
,
"用户信息为空"
),
AUDIT_STATUS_IS_EMPTY
(
4013
,
"审批状态为空!"
),
UKNOW_AUDIT_STATUS
(
4014
,
"未知的审批状态"
),
CHANNEL_FUND_CONFIG_IS_AUDITING
(
4015
,
"该渠道资方配置正在审核中,不允许
修改
!"
);
CHANNEL_FUND_CONFIG_IS_AUDITING
(
4015
,
"该渠道资方配置正在审核中,不允许
进行操作
!"
);
@Getter
private
int
code
;
...
...
src/main/java/com/quantgroup/asset/distribution/service/approval/IApprovalLogService.java
View file @
279cd9c5
...
...
@@ -57,9 +57,9 @@ public interface IApprovalLogService {
public
ApprovalLog
findById
(
Long
id
);
/**
* 查询
该条
配置是否正在审批
* @param
channelFundConfigId
* 查询
渠道
配置是否正在审批
* @param
bizChannel
* @return
*/
public
Boolean
isAuditing
(
Long
channelFundConfigId
);
public
Boolean
isAuditing
(
String
bizChannel
);
}
src/main/java/com/quantgroup/asset/distribution/service/approval/impl/ApprovalLogServiceImpl.java
View file @
279cd9c5
...
...
@@ -12,6 +12,8 @@ import javax.persistence.criteria.Order;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigNewService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
...
...
@@ -38,6 +40,8 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
private
IApprovalLogRepository
approvalLogRepository
;
@Autowired
private
IFundModuleChannelFundConfigService
fundModuleChannelFundConfigService
;
@Autowired
private
IFundModuleChannelFundConfigNewService
fundModuleChannelFundConfigNewService
;
@Override
public
void
createApprovalLog
(
AuditTypeEnum
auditType
,
AuditTargetEnum
auditTarget
,
String
targetName
,
...
...
@@ -111,9 +115,10 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
public
void
audit
(
ApprovalLog
approvalLog
,
Integer
auditStatus
)
{
if
(
auditStatus
==
AuditStatusEnum
.
PASS
.
getCode
())
{
// 先更改审核记录, 这里返回的是新配置
FundModuleChannelFundConfig
config
=
fundModuleChannelFundConfigService
.
auditPassConfig
(
approvalLog
.
getPreConfigId
(),
approvalLog
.
getAuditConfigId
());
// FundModuleChannelFundConfig config = fundModuleChannelFundConfigService.auditPassConfig(approvalLog.getPreConfigId(), approvalLog.getAuditConfigId());
FundModuleChannelFundConfigNew
config
=
fundModuleChannelFundConfigNewService
.
auditPassConfig
(
approvalLog
.
getPreConfigId
(),
approvalLog
.
getAuditConfigId
());
// 根据新配置清楚渠道缓存
fundModuleChannelFundConfigService
.
clearChannelFundConfigCache
(
config
.
getBizChannel
());
fundModuleChannelFundConfig
New
Service
.
clearChannelFundConfigCache
(
config
.
getBizChannel
());
}
updateApprovalLogAuditStatus
(
approvalLog
,
auditStatus
);
}
...
...
@@ -126,7 +131,7 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
/**
* 更改审批记录状态和审批时间
* @param approvalLog
* @param s
* @param
auditStatu
s
*/
private
void
updateApprovalLogAuditStatus
(
ApprovalLog
approvalLog
,
Integer
auditStatus
)
{
approvalLog
.
setAuditTime
(
DateUtil
.
getCurDateTime
());
...
...
@@ -135,7 +140,8 @@ public class ApprovalLogServiceImpl implements IApprovalLogService{
}
@Override
public
Boolean
isAuditing
(
Long
channelFundConfigId
)
{
return
approvalLogRepository
.
findByPreConfigIdAndAuditStatus
(
channelFundConfigId
,
AuditStatusEnum
.
WAIT
.
getCode
())
!=
null
;
public
Boolean
isAuditing
(
String
bizChannel
)
{
return
approvalLogRepository
.
findByAuditTypeAndAuditTargetAndTargetNameAndAuditStatusAndEnableIsTrue
(
AuditTypeEnum
.
ONLINE
.
getCode
(),
AuditTargetEnum
.
FUND_CONFIG
.
getCode
(),
bizChannel
,
AuditStatusEnum
.
WAIT
.
getCode
())
!=
null
;
}
}
src/main/java/com/quantgroup/asset/distribution/service/funding/IFundModuleChannelFundConfigNewService.java
0 → 100644
View file @
279cd9c5
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew
;
import
java.util.Map
;
/**
* @author : Hyuk
* @description : IFundModuleChannelFundConfigNewService
* @date : 2020/2/26 5:31 下午
*/
public
interface
IFundModuleChannelFundConfigNewService
{
public
Map
<
String
,
Object
>
getChannelFundConfigsByChannelOrFundId
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
);
public
GlobalResponse
addChannelFundConfig
(
String
bizChannel
,
String
funds
,
String
remarks
,
String
proposer
,
String
auditor
);
public
GlobalResponse
updateChannelFundConfig
(
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
,
String
proposer
,
String
auditor
);
public
FundModuleChannelFundConfigNew
findByBizChannel
(
String
bizChannel
);
public
FundModuleChannelFundConfigNew
findById
(
Long
id
);
public
FundModuleChannelFundConfigNew
auditPassConfig
(
Long
preId
,
Long
auditId
);
public
void
clearChannelFundConfigCache
(
String
bizChannel
);
}
src/main/java/com/quantgroup/asset/distribution/service/funding/IFundModuleService.java
View file @
279cd9c5
...
...
@@ -27,6 +27,20 @@ public interface IFundModuleService {
*/
public
GlobalResponse
saveChannelFundConfig
(
Integer
type
,
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
,
String
auditor
,
String
proposer
);
/**
* 保存或更改渠道资方配置(新)
* @param type
* @param id
* @param bizChannel
* @param funds
* @param remarks
* @param auditor
* @param proposer
* @return
*/
public
GlobalResponse
saveChannelFundConfigNew
(
Integer
type
,
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
,
String
auditor
,
String
proposer
);
/**
* 获取渠道资方配置信息
...
...
@@ -37,6 +51,17 @@ public interface IFundModuleService {
* @return
*/
public
GlobalResponse
getChannelFundConfigs
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
);
/**
* 获取渠道资方配置信息(新)
* @param bizChannel
* @param fundId
* @param pageNum
* @param pageSize
* @return
*/
public
GlobalResponse
getChannelFundConfigsNew
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
);
/**
* 获取审批列表
...
...
@@ -59,6 +84,13 @@ public interface IFundModuleService {
* @return
*/
public
GlobalResponse
findChannelFundConfigById
(
Long
configId
);
/**
* 根据id获取资方配置(新)
* @param configId
* @return
*/
public
GlobalResponse
findChannelFundConfigNewById
(
Long
configId
);
/**
* 审批接口
...
...
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/FundModuleChannelFundConfigNewServiceImpl.java
0 → 100644
View file @
279cd9c5
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
.
impl
;
import
com.quantgroup.asset.distribution.enums.funding.AuditTargetEnum
;
import
com.quantgroup.asset.distribution.enums.funding.AuditTypeEnum
;
import
com.quantgroup.asset.distribution.enums.response.FundModuleResponse
;
import
com.quantgroup.asset.distribution.exception.QGException
;
import
com.quantgroup.asset.distribution.exception.QGExceptionType
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.approval.IApprovalLogService
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigNewService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew
;
import
com.quantgroup.asset.distribution.service.jpa.repository.IFundModuleChannelFundConfigNewRepository
;
import
com.quantgroup.asset.distribution.util.fund.module.ChannelFundConfigUtil
;
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.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.*
;
/**
* @author : Hyuk
* @description : FundModuleChannelFundConfigNewServiceImpl
* @date : 2020/2/26 5:38 下午
*/
@Slf4j
@Service
public
class
FundModuleChannelFundConfigNewServiceImpl
implements
IFundModuleChannelFundConfigNewService
{
@Autowired
private
IFundModuleChannelFundConfigNewRepository
fundModuleChannelFundConfigNewRepository
;
@Autowired
private
IApprovalLogService
approvalLogService
;
@Override
public
Map
<
String
,
Object
>
getChannelFundConfigsByChannelOrFundId
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
)
{
// 分页条件
Pageable
pageable
=
new
PageRequest
(
pageNum
<
0
?
0
:
pageNum
,
pageSize
);
Specification
<
FundModuleChannelFundConfigNew
>
specification
=
new
Specification
<
FundModuleChannelFundConfigNew
>()
{
@Override
public
Predicate
toPredicate
(
Root
<
FundModuleChannelFundConfigNew
>
root
,
CriteriaQuery
<?>
query
,
CriteriaBuilder
cb
)
{
List
<
Predicate
>
predicates
=
new
ArrayList
<>();
predicates
.
add
(
cb
.
equal
(
root
.
get
(
"enable"
),
true
));
if
(
StringUtils
.
isNotEmpty
(
bizChannel
)){
predicates
.
add
(
cb
.
equal
(
root
.
get
(
"bizChannel"
),
bizChannel
));
}
if
(
fundId
!=
null
){
predicates
.
add
(
cb
.
like
(
root
.
get
(
"fundIds"
),
"%"
+
fundId
+
"%"
));
}
query
.
where
(
predicates
.
toArray
(
new
Predicate
[
predicates
.
size
()]));
return
query
.
getRestriction
();
}
};
Page
<
FundModuleChannelFundConfigNew
>
channelFundConfigs
=
fundModuleChannelFundConfigNewRepository
.
findAll
(
specification
,
pageable
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"total"
,
channelFundConfigs
.
getTotalElements
());
result
.
put
(
"pages"
,
channelFundConfigs
.
getTotalPages
());
result
.
put
(
"pageSize"
,
channelFundConfigs
.
getSize
());
result
.
put
(
"pageNum"
,
channelFundConfigs
.
getNumber
());
result
.
put
(
"list"
,
channelFundConfigs
.
getContent
());
return
result
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
GlobalResponse
addChannelFundConfig
(
String
bizChannel
,
String
funds
,
String
remarks
,
String
proposer
,
String
auditor
)
{
// 新增配置, 根据渠道查询如果库里已存在,返回异常;
FundModuleChannelFundConfigNew
fundModuleChannelFundConfigNew
=
findByBizChannel
(
bizChannel
);
if
(
fundModuleChannelFundConfigNew
!=
null
)
{
log
.
info
(
"资方模块, 渠道 : {}资方配置已存在, 添加失败!"
,
bizChannel
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
CHANNEL_FUND_CONFIG_IS_EXIST
);
}
// 渠道资方配置是否正在审核
if
(
approvalLogService
.
isAuditing
(
bizChannel
))
{
log
.
info
(
"资方模块, 渠道 : {} 资方配置正在审批中, 不允许修改"
,
bizChannel
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
CHANNEL_FUND_CONFIG_IS_AUDITING
);
}
FundModuleChannelFundConfigNew
newConfig
=
createdNewChannelFundConfigNew
(
bizChannel
,
funds
,
remarks
);
createdChannelFundConfigApprovalLog
(
bizChannel
,
proposer
,
auditor
,
null
,
newConfig
.
getId
());
return
GlobalResponse
.
create
(
FundModuleResponse
.
SUCCESS
);
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
GlobalResponse
updateChannelFundConfig
(
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
,
String
proposer
,
String
auditor
)
{
// 更改配置, 根据id查询如果库里不存在,返回异常
FundModuleChannelFundConfigNew
configNew
=
fundModuleChannelFundConfigNewRepository
.
findByIdAndEnableIsTrue
(
id
);
if
(
configNew
==
null
)
{
log
.
info
(
"资方模块, 渠道 : {}, 配置id : {}, 资方配置不存在, 修改失败!"
,
bizChannel
,
id
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
CHANNEL_FUND_CONFIG_NOT_EXIST
);
}
// 如果该条配置在审批,不允许更改
boolean
isAuditing
=
approvalLogService
.
isAuditing
(
bizChannel
);
if
(
isAuditing
)
{
log
.
info
(
"资方模块, 渠道 : {}, 配置id : {}, 正在审批中, 不允许修改"
,
bizChannel
,
id
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
CHANNEL_FUND_CONFIG_IS_AUDITING
);
}
FundModuleChannelFundConfigNew
newConfig
=
createdNewChannelFundConfigNew
(
bizChannel
,
funds
,
remarks
);
createdChannelFundConfigApprovalLog
(
bizChannel
,
proposer
,
auditor
,
id
,
newConfig
.
getId
());
return
GlobalResponse
.
create
(
FundModuleResponse
.
SUCCESS
);
}
@Cacheable
(
value
=
"cacheManager"
,
key
=
"'ASSET_DISTRIBUTION:FUND_MODULE:CHANNEL_FUND_CONFIG:CK9A_'+#bizChannel"
)
@Override
public
FundModuleChannelFundConfigNew
findByBizChannel
(
String
bizChannel
)
{
List
<
FundModuleChannelFundConfigNew
>
configList
=
fundModuleChannelFundConfigNewRepository
.
findByBizChannelAndEnableIsTrue
(
bizChannel
);
if
(
CollectionUtils
.
isEmpty
(
configList
))
{
return
null
;
}
// 避免脏读
if
(
configList
.
size
()
>
2
)
{
throw
new
QGException
(
QGExceptionType
.
CHANNEL_FUND_CONFIG_GREATER_THAN_TOW
,
bizChannel
);
}
Collections
.
sort
(
configList
,
(
c1
,
c2
)
->
{
// 别直接把相减把long类型转成int,可能越界
if
(
c2
.
getId
()
>
c1
.
getId
())
{
return
1
;
}
else
if
(
c2
.
getId
()
<
c1
.
getId
())
{
return
-
1
;
}
else
{
return
0
;
}
});
return
configList
.
get
(
0
);
}
@Override
public
FundModuleChannelFundConfigNew
findById
(
Long
id
)
{
return
fundModuleChannelFundConfigNewRepository
.
findById
(
id
);
}
@Override
public
FundModuleChannelFundConfigNew
auditPassConfig
(
Long
preId
,
Long
auditId
)
{
FundModuleChannelFundConfigNew
config
=
updateEnable
(
auditId
,
true
);
if
(
preId
!=
null
)
{
updateEnable
(
preId
,
false
);
}
return
config
;
}
@CacheEvict
(
value
=
"cacheManager"
,
key
=
"'ASSET_DISTRIBUTION:FUND_MODULE:CHANNEL_FUND_CONFIG:CK9A_'+#bizChannel"
)
@Override
public
void
clearChannelFundConfigCache
(
String
bizChannel
)
{
log
.
info
(
"渠道资方配置缓存清除, bizChannel : {}"
,
bizChannel
);
}
/**
* 更改配置enable状态
* @param id
* @param enable
*/
private
FundModuleChannelFundConfigNew
updateEnable
(
Long
id
,
Boolean
enable
)
{
FundModuleChannelFundConfigNew
config
=
fundModuleChannelFundConfigNewRepository
.
findById
(
id
);
config
.
setEnable
(
enable
);
return
fundModuleChannelFundConfigNewRepository
.
save
(
config
);
}
/**
* 创建一条新配置记录
* @param bizChannel
* @param funds
* @param remarks
* @return
*/
private
FundModuleChannelFundConfigNew
createdNewChannelFundConfigNew
(
String
bizChannel
,
String
funds
,
String
remarks
)
{
FundModuleChannelFundConfigNew
config
=
new
FundModuleChannelFundConfigNew
();
config
.
setBizChannel
(
bizChannel
);
config
.
setFunds
(
funds
);
config
.
setRemarks
(
remarks
);
config
.
setFundIds
(
ChannelFundConfigUtil
.
getAllFundIds
(
funds
));
config
.
setFundLimitTranslate
(
ChannelFundConfigUtil
.
getFundLimitTranslate
(
funds
));
config
.
setEnable
(
false
);
return
fundModuleChannelFundConfigNewRepository
.
save
(
config
);
}
/**
* 创建渠道资方配置审批记录
* @param bizChannel
* @param proposer
* @param auditor
* @param preConfigId
* @param auditConfigId
*/
private
void
createdChannelFundConfigApprovalLog
(
String
bizChannel
,
String
proposer
,
String
auditor
,
Long
preConfigId
,
Long
auditConfigId
)
{
approvalLogService
.
createApprovalLog
(
AuditTypeEnum
.
ONLINE
,
AuditTargetEnum
.
FUND_CONFIG
,
bizChannel
,
proposer
,
auditor
,
preConfigId
,
auditConfigId
);
}
}
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/FundModuleChannelFundConfigServiceImpl.java
View file @
279cd9c5
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
.
impl
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.quantgroup.asset.distribution.model.entity.fund.ChannelFundConfig
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -88,7 +88,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
log
.
info
(
"资方模块, 渠道 : {}资方配置已存在, 添加失败!"
,
bizChannel
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
CHANNEL_FUND_CONFIG_IS_EXIST
);
}
FundModuleChannelFundConfig
newConfig
=
fundModuleChannelFundConfig
=
createdNewChannelFundConfig
(
bizChannel
,
funds
,
remarks
);
FundModuleChannelFundConfig
newConfig
=
createdNewChannelFundConfig
(
bizChannel
,
funds
,
remarks
);
createdChannelFundConfigApprovalLog
(
bizChannel
,
proposer
,
auditor
,
null
,
newConfig
.
getId
());
return
GlobalResponse
.
create
(
FundModuleResponse
.
SUCCESS
);
}
...
...
@@ -103,7 +103,7 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
return
GlobalResponse
.
create
(
FundModuleResponse
.
CHANNEL_FUND_CONFIG_NOT_EXIST
);
}
// 如果该条配置在审批,不允许更改
boolean
isAuditing
=
approvalLogService
.
isAuditing
(
id
);
boolean
isAuditing
=
approvalLogService
.
isAuditing
(
bizChannel
);
if
(
isAuditing
)
{
log
.
info
(
"资方模块, 渠道 : {}, 配置id : {}, 正在审批中, 不允许修改"
,
bizChannel
,
id
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
CHANNEL_FUND_CONFIG_IS_AUDITING
);
...
...
@@ -196,4 +196,40 @@ public class FundModuleChannelFundConfigServiceImpl implements IFundModuleChanne
public
void
clearChannelFundConfigCache
(
String
bizChannel
)
{
log
.
info
(
"渠道资方配置缓存清除, bizChannel : {}"
,
bizChannel
);
}
/**
* 渠道资方配置按条件类型分组
* @param fundModuleChannelFundConfig
* @return
*/
private
FundModuleChannelFundConfig
groupByLimit
(
FundModuleChannelFundConfig
fundModuleChannelFundConfig
)
{
List
<
ChannelFundConfig
>
fundConfigList
=
JSONArray
.
parseArray
(
fundModuleChannelFundConfig
.
getFunds
(),
ChannelFundConfig
.
class
);
// 条件类型分组, key:条件类型
Map
<
String
,
List
<
ChannelFundConfig
>>
channelFundConfigMap
=
new
LinkedHashMap
<>();
for
(
ChannelFundConfig
channelFundConfig
:
fundConfigList
)
{
List
<
ChannelFundConfig
.
Limit
>
limits
=
channelFundConfig
.
getLimits
();
// 先把每个资方下的条件排序,保证多个条件下的条件顺序相同
Collections
.
sort
(
limits
,
Comparator
.
comparingInt
(
l
->
l
.
getLimit
().
hashCode
()));
StringBuilder
key
=
new
StringBuilder
();
limits
.
forEach
(
limit
->
key
.
append
(
limit
.
getLimit
()));
if
(
channelFundConfigMap
.
get
(
key
.
toString
())
==
null
)
{
channelFundConfigMap
.
put
(
key
.
toString
(),
new
ArrayList
<>());
}
channelFundConfigMap
.
get
(
key
.
toString
()).
add
(
channelFundConfig
);
}
// 分完组后,开始对组内优先级进行排序
channelFundConfigMap
.
entrySet
().
stream
().
forEach
(
entry
->
{
Collections
.
sort
(
entry
.
getValue
(),
Comparator
.
comparingInt
(
config
->
config
.
getPriority
()));
});
// 重新组装
List
<
ChannelFundConfig
>
sortedList
=
new
ArrayList
<>();
channelFundConfigMap
.
entrySet
().
forEach
(
e
->
{
sortedList
.
addAll
(
e
.
getValue
());
});
fundModuleChannelFundConfig
.
setFunds
(
JSON
.
toJSONString
(
sortedList
));
return
fundModuleChannelFundConfig
;
}
}
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/FundModuleServiceImpl.java
View file @
279cd9c5
...
...
@@ -5,6 +5,8 @@ import java.util.List;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigNewService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -48,6 +50,8 @@ public class FundModuleServiceImpl implements IFundModuleService{
@Autowired
private
IFundModuleChannelFundConfigService
fundModuleChannelFundConfigService
;
@Autowired
private
IFundModuleChannelFundConfigNewService
fundModuleChannelFundConfigNewService
;
@Autowired
private
IApprovalLogService
approvalLogService
;
@Value
(
"${clotho.url}"
)
private
String
clothoURL
;
...
...
@@ -91,7 +95,18 @@ public class FundModuleServiceImpl implements IFundModuleService{
}
else
if
(
type
==
FundModuleConstants
.
CHANNEL_FUNDS_OPERATOR_TYPE_UPDATE
)
{
return
fundModuleChannelFundConfigService
.
updateChannelFundConfig
(
id
,
bizChannel
,
funds
,
remarks
,
proposer
,
auditor
);
}
return
GlobalResponse
.
create
(
FundModuleResponse
.
SUCCESS
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
UNKNOW_TYPE
);
}
@HandleException
@Override
public
GlobalResponse
saveChannelFundConfigNew
(
Integer
type
,
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
,
String
auditor
,
String
proposer
)
{
if
(
type
==
FundModuleConstants
.
CHANNEL_FUNDS_OPERAOTR_TYPE_ADD
)
{
return
fundModuleChannelFundConfigNewService
.
addChannelFundConfig
(
bizChannel
,
funds
,
remarks
,
proposer
,
auditor
);
}
else
if
(
type
==
FundModuleConstants
.
CHANNEL_FUNDS_OPERATOR_TYPE_UPDATE
)
{
return
fundModuleChannelFundConfigNewService
.
updateChannelFundConfig
(
id
,
bizChannel
,
funds
,
remarks
,
proposer
,
auditor
);
}
return
GlobalResponse
.
create
(
FundModuleResponse
.
UNKNOW_TYPE
);
}
@HandleException
...
...
@@ -104,6 +119,16 @@ public class FundModuleServiceImpl implements IFundModuleService{
return
GlobalResponse
.
success
(
result
);
}
@HandleException
@Override
public
GlobalResponse
getChannelFundConfigsNew
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
)
{
Map
<
String
,
Object
>
result
=
fundModuleChannelFundConfigNewService
.
getChannelFundConfigsByChannelOrFundId
(
bizChannel
,
fundId
,
pageNum
,
pageSize
);
if
(
result
==
null
||
result
.
size
()
==
0
)
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
HAS_NO_DATA
);
}
return
GlobalResponse
.
success
(
result
);
}
@HandleException
@Override
public
GlobalResponse
getAuditInfos
(
String
targetName
,
Integer
auditStatus
,
Integer
auditType
,
Integer
auditTarget
,
...
...
@@ -124,7 +149,17 @@ public class FundModuleServiceImpl implements IFundModuleService{
}
return
GlobalResponse
.
success
(
config
);
}
@HandleException
@Override
public
GlobalResponse
findChannelFundConfigNewById
(
Long
configId
)
{
FundModuleChannelFundConfigNew
config
=
fundModuleChannelFundConfigNewService
.
findById
(
configId
);
if
(
config
==
null
)
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
HAS_NO_DATA
);
}
return
GlobalResponse
.
success
(
config
);
}
@HandleException
@Override
public
GlobalResponse
audit
(
Long
id
,
Integer
auditStatus
)
{
...
...
src/main/java/com/quantgroup/asset/distribution/service/jpa/entity/FundModuleChannelFundConfigNew.java
0 → 100644
View file @
279cd9c5
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
entity
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
/**
* @author : Hyuk
* @description : FundModuleChannelFundConfigNew
* @date : 2020/2/26 5:40 下午
*/
@Data
@Table
(
name
=
"fund_module_channel_fund_config_new"
)
@Entity
public
class
FundModuleChannelFundConfigNew
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
@Column
(
name
=
"id"
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
@Column
(
name
=
"biz_channel"
)
private
String
bizChannel
;
@Column
(
name
=
"funds"
)
private
String
funds
;
@Column
(
name
=
"remarks"
)
private
String
remarks
;
@Column
(
name
=
"fund_ids"
)
private
String
fundIds
;
@Column
(
name
=
"fund_limit_translate"
)
private
String
fundLimitTranslate
;
@Column
(
name
=
"enable"
)
private
Boolean
enable
;
@Column
(
name
=
"created_at"
)
private
Timestamp
createdAt
;
@Column
(
name
=
"updated_at"
)
private
Timestamp
updatedAt
;
@PrePersist
public
void
prePersist
()
{
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
createdAt
=
timestamp
;
updatedAt
=
timestamp
;
}
@PreUpdate
public
void
preUpdate
()
{
updatedAt
=
new
Timestamp
(
System
.
currentTimeMillis
());
}
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/entity/FundModuleLimitTypeConfig.java
View file @
279cd9c5
...
...
@@ -38,6 +38,9 @@ public class FundModuleLimitTypeConfig implements Serializable{
@Column
(
name
=
"code"
)
private
String
code
;
@Column
(
name
=
"type"
)
private
String
type
;
@Column
(
name
=
"enable"
)
private
Boolean
enable
;
...
...
src/main/java/com/quantgroup/asset/distribution/service/jpa/repository/IApprovalLogRepository.java
View file @
279cd9c5
...
...
@@ -8,6 +8,9 @@ import com.quantgroup.asset.distribution.service.jpa.entity.ApprovalLog;
public
interface
IApprovalLogRepository
extends
JpaRepository
<
ApprovalLog
,
Long
>,
JpaSpecificationExecutor
<
ApprovalLog
>{
public
ApprovalLog
findByIdAndEnableIsTrue
(
Long
id
);
public
ApprovalLog
findByPreConfigIdAndAuditStatus
(
Long
preConfigId
,
Integer
auditStatus
);
public
ApprovalLog
findByAuditTypeAndAuditTargetAndTargetNameAndAuditStatusAndEnableIsTrue
(
Integer
auditType
,
Integer
auditTarget
,
String
targetName
,
Integer
auditStatus
);
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/repository/IFundModuleChannelFundConfigNewRepository.java
0 → 100644
View file @
279cd9c5
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
repository
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfigNew
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
java.util.List
;
/**
* @author : Hyuk
* @description : IFundModuleChannelFundConfigNewRepository
* @date : 2020/2/26 5:53 下午
*/
public
interface
IFundModuleChannelFundConfigNewRepository
extends
JpaRepository
<
FundModuleChannelFundConfigNew
,
Long
>,
JpaSpecificationExecutor
<
FundModuleChannelFundConfigNew
>
{
/**
* 根据渠道号查询渠道资方配置
* @param bizChannel
* @return
*/
public
List
<
FundModuleChannelFundConfigNew
>
findByBizChannelAndEnableIsTrue
(
String
bizChannel
);
/**
* 根据配置id查询资方配置
* @param id
* @return
*/
public
FundModuleChannelFundConfigNew
findByIdAndEnableIsTrue
(
Long
id
);
/**
* 根据id查询资方配置, 主要是审核部分用, 这时候配置还没应用到线上, enable还是false
* @param id
* @return
*/
public
FundModuleChannelFundConfigNew
findById
(
Long
id
);
}
src/main/java/com/quantgroup/asset/distribution/util/fund/module/ChannelFundConfigUtil.java
View file @
279cd9c5
package
com
.
quantgroup
.
asset
.
distribution
.
util
.
fund
.
module
;
import
java.util.HashSet
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
java.util.*
;
import
com.alibaba.fastjson.JSON
;
import
org.apache.commons.lang3.StringUtils
;
import
com.alibaba.fastjson.JSONArray
;
...
...
@@ -71,4 +70,22 @@ public class ChannelFundConfigUtil {
}
return
StringUtils
.
join
(
fundIdSet
,
","
);
}
/**
* 根据资方配置获取资方对应条件
* @param funds
* @return
*/
public
static
String
getFundLimitTranslate
(
String
funds
)
{
Map
<
String
,
String
>
map
=
new
LinkedHashMap
<>();
JSONArray
array
=
JSONArray
.
parseArray
(
funds
);
for
(
int
i
=
0
,
len
=
array
.
size
();
i
<
len
;
i
++)
{
JSONObject
data
=
array
.
getJSONObject
(
i
);
String
fundId
=
data
.
getString
(
"fundId"
);
JSONObject
limitObj
=
data
.
getJSONObject
(
"limits"
);
String
limitTranslate
=
limitObj
.
getString
(
"limitTranslate"
);
map
.
put
(
fundId
,
limitTranslate
);
}
return
JSON
.
toJSONString
(
map
);
}
}
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