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
9dfb4bb1
Commit
9dfb4bb1
authored
Oct 21, 2019
by
liwenbin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资方模块
parent
4429b314
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
1067 additions
and
5 deletions
+1067
-5
HandleException.java
...asset/distribution/config/annotation/HandleException.java
+14
-0
HandleExceptionAspect.java
...distribution/config/annotation/HandleExceptionAspect.java
+55
-0
FundModuleConstants.java
...roup/asset/distribution/constant/FundModuleConstants.java
+15
-0
FundModuleController.java
...p/asset/distribution/controller/FundModuleController.java
+88
-0
AssetResponse.java
...roup/asset/distribution/enums/response/AssetResponse.java
+2
-1
FundModuleResponse.java
...asset/distribution/enums/response/FundModuleResponse.java
+39
-0
QGExceptionType.java
...ntgroup/asset/distribution/exception/QGExceptionType.java
+6
-1
ChannelFundConfig.java
...set/distribution/model/entity/fund/ChannelFundConfig.java
+43
-0
FundInfo.java
...tgroup/asset/distribution/model/entity/fund/FundInfo.java
+31
-0
AssetForm.java
...m/quantgroup/asset/distribution/model/form/AssetForm.java
+2
-0
GlobalResponse.java
...oup/asset/distribution/model/response/GlobalResponse.java
+9
-1
AssetAttributeServiceImpl.java
...ibution/service/asset/impl/AssetAttributeServiceImpl.java
+29
-1
AssetServiceImpl.java
...set/distribution/service/asset/impl/AssetServiceImpl.java
+105
-1
IFundModuleChannelFundConfigService.java
.../service/funding/IFundModuleChannelFundConfigService.java
+22
-0
IFundModuleLimitTypeService.java
...ribution/service/funding/IFundModuleLimitTypeService.java
+21
-0
IFundModuleService.java
...sset/distribution/service/funding/IFundModuleService.java
+39
-0
FundModuleChannelFundConfigServiceImpl.java
.../funding/impl/FundModuleChannelFundConfigServiceImpl.java
+109
-0
FundModuleLimitTypeServiceImpl.java
.../service/funding/impl/FundModuleLimitTypeServiceImpl.java
+31
-0
FundModuleServiceImpl.java
...tribution/service/funding/impl/FundModuleServiceImpl.java
+100
-0
FundModuleChannelFundConfig.java
...ution/service/jpa/entity/FundModuleChannelFundConfig.java
+69
-0
FundModuleLimitTypeConfig.java
...ibution/service/jpa/entity/FundModuleLimitTypeConfig.java
+62
-0
IFundModuleChannelFundConfigRepository.java
...pa/repository/IFundModuleChannelFundConfigRepository.java
+28
-0
IFundModuleLimitTypeConfigRepository.java
.../jpa/repository/IFundModuleLimitTypeConfigRepository.java
+21
-0
ChannelFundConfigUtil.java
.../distribution/util/fund/module/ChannelFundConfigUtil.java
+74
-0
FundModuleTest.java
...om/quantgroup/asset/distribution/fund/FundModuleTest.java
+30
-0
NotifyTest.java
.../com/quantgroup/asset/distribution/notify/NotifyTest.java
+23
-0
No files found.
src/main/java/com/quantgroup/asset/distribution/config/annotation/HandleException.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
config
.
annotation
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.ElementType
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
@Documented
@Target
(
ElementType
.
METHOD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
HandleException
{
}
src/main/java/com/quantgroup/asset/distribution/config/annotation/HandleExceptionAspect.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
config
.
annotation
;
import
org.aspectj.lang.ProceedingJoinPoint
;
import
org.aspectj.lang.annotation.Around
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
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.alarm.IAlarmService
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 异常捕获处理AOP
* @author liwenbin
*
*/
@Aspect
@Component
@Slf4j
public
class
HandleExceptionAspect
{
@Autowired
private
IAlarmService
alarmService
;
@Pointcut
(
"@annotation(com.quantgroup.asset.distribution.config.annotation.HandleException)"
)
private
void
fundModulePointCut
()
{
}
@Around
(
"fundModulePointCut()"
)
public
GlobalResponse
handleException
(
ProceedingJoinPoint
point
)
{
try
{
return
(
GlobalResponse
)
point
.
proceed
();
}
catch
(
QGException
qe
)
{
log
.
error
(
"资方模块接口出现错误, class : {}, method : {}, 错误信息捕获 : {}"
,
point
.
getTarget
().
getClass
().
getSimpleName
(),
point
.
getSignature
().
getName
(),
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
);
alarmService
.
dingtalkAlarm
(
"Warn"
,
"资方模块接口出现错误"
,
"class : "
+
point
.
getTarget
().
getClass
().
getSimpleName
()
+
" , method : "
+
point
.
getSignature
().
getName
()
+
" , 错误信息 : "
+
qe
.
qgExceptionType
.
code
+
"->"
+
qe
.
detail
);
return
GlobalResponse
.
create
(
qe
);
}
catch
(
Exception
e
)
{
log
.
error
(
"资方模块接口出现异常, class : {}, method : {}"
,
point
.
getTarget
().
getClass
().
getSimpleName
(),
point
.
getSignature
().
getName
(),
e
);
alarmService
.
dingtalkAlarm
(
"Error"
,
"资方模块接口出现异常"
,
"class : "
+
point
.
getTarget
().
getClass
().
getSimpleName
()
+
" , method : "
+
point
.
getSignature
().
getName
()
+
" , 出现未知异常, 请查看!"
);
return
GlobalResponse
.
error
(
QGExceptionType
.
COMMON_SERVER_ERROR
);
}
catch
(
Throwable
e
)
{
log
.
error
(
"资方模块接口出现异常, class : {}, method : {}"
,
point
.
getTarget
().
getClass
().
getSimpleName
(),
point
.
getSignature
().
getName
(),
e
);
alarmService
.
dingtalkAlarm
(
"Error"
,
"资方模块接口出现异常"
,
"class : "
+
point
.
getTarget
().
getClass
().
getSimpleName
()
+
" , method : "
+
point
.
getSignature
().
getName
()
+
" , 出现未知异常, 请查看!"
);
return
GlobalResponse
.
error
(
QGExceptionType
.
COMMON_SERVER_ERROR
);
}
}
}
src/main/java/com/quantgroup/asset/distribution/constant/FundModuleConstants.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
constant
;
/**
* 资方模块常量类
* @author liwenbin
*
*/
public
class
FundModuleConstants
{
// 渠道资方操作, 新增
public
static
final
int
CHANNEL_FUNDS_OPERAOTR_TYPE_ADD
=
1
;
// 渠道资方操作, 修改
public
static
final
int
CHANNEL_FUNDS_OPERATOR_TYPE_UPDATE
=
2
;
}
src/main/java/com/quantgroup/asset/distribution/controller/FundModuleController.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
controller
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.base.Stopwatch
;
import
com.quantgroup.asset.distribution.constant.FundModuleConstants
;
import
com.quantgroup.asset.distribution.enums.response.FundModuleResponse
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleService
;
import
com.quantgroup.asset.distribution.util.fund.module.ChannelFundConfigUtil
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 资方模块Controller
* @author liwenbin
*
*/
@RestController
@Slf4j
@RequestMapping
(
"/fund"
)
public
class
FundModuleController
{
@Autowired
private
IFundModuleService
fundModuleService
;
@RequestMapping
(
"/get_all_funds"
)
public
GlobalResponse
getAllFunds
()
{
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
GlobalResponse
response
=
fundModuleService
.
getAllFundsInfo
();
log
.
info
(
"资方模块接口, 获取所有资方信息完成, 耗时 : {}, response : {}"
,
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
),
JSON
.
toJSONString
(
response
));
return
response
;
}
@RequestMapping
(
"/get_all_limit_type"
)
public
GlobalResponse
getAllLimitInfo
()
{
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
GlobalResponse
response
=
fundModuleService
.
getAllLimitType
();
log
.
info
(
"资方模块接口, 获取所有条件限制类型完成, 耗时 : {}, response : {}"
,
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
),
response
);
return
response
;
}
@RequestMapping
(
"save_channel_funds_config"
)
public
GlobalResponse
saveChannelFundsConfig
(
Integer
type
,
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
)
{
log
.
info
(
"资方模块接口, 新增或修改资方配置开始, type : {}, id : {}, bizChannel : {}, funds : {}, remarks : {}"
,
type
,
id
,
bizChannel
,
funds
,
remarks
);
// 参数校验
if
(
type
==
null
)
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
TYPE_IS_EMPTY
);
}
if
(
type
!=
FundModuleConstants
.
CHANNEL_FUNDS_OPERAOTR_TYPE_ADD
&&
type
!=
FundModuleConstants
.
CHANNEL_FUNDS_OPERATOR_TYPE_UPDATE
)
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
UNKNOW_TYPE
);
}
if
(
type
==
2
&&
id
==
null
)
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
ID_IS_EMPTY
);
}
if
(
StringUtils
.
isEmpty
(
bizChannel
))
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
BIZ_CHANNEL_IS_EMPTY
);
}
if
(
StringUtils
.
isEmpty
(
funds
))
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
FUNDS_INFO_IS_EMPTY
);
}
if
(!
ChannelFundConfigUtil
.
checkFunds
(
funds
))
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
FUNDS_INFO_ERROR
);
}
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
GlobalResponse
response
=
fundModuleService
.
saveChannelFundConfig
(
type
,
id
,
bizChannel
,
funds
,
remarks
);
log
.
info
(
"资方模块接口, 新增或修改资方配置结束, type : {}, id : {}, bizChannel : {}, funds : {}, remarks : {}, 耗时 : {}, reponse : {}"
,
type
,
id
,
bizChannel
,
funds
,
remarks
,
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
),
response
);
return
response
;
}
@RequestMapping
(
"/get_channel_fund_configs"
)
public
GlobalResponse
getChannelFundConfigs
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
)
{
log
.
info
(
"资方模块接口, 查询渠道资方配置信息开始, bizChannel : {}, fundId : {}, pageNum : {}, pageSize : {}"
,
bizChannel
,
fundId
,
pageNum
,
pageSize
);
if
(
pageNum
==
null
||
pageSize
==
null
)
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
PAGEING_CONDITIONS_IS_EMPTY
);
}
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
GlobalResponse
response
=
fundModuleService
.
getChannelFundConfigs
(
bizChannel
,
fundId
,
pageNum
,
pageSize
);
log
.
info
(
"资方模块接口, 查询渠道资方配置信息结束, bizChannel : {}, fundId : {}, pageNum : {}, pageSize : {}, 耗时 : {}, response : {}"
,
bizChannel
,
fundId
,
pageNum
,
pageSize
,
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
),
response
);
return
response
;
}
}
src/main/java/com/quantgroup/asset/distribution/enums/response/AssetResponse.java
View file @
9dfb4bb1
...
...
@@ -14,7 +14,8 @@ public enum AssetResponse implements GlobalResponseEnum{
AUDIT_RESULT_OR_DEAD_LINE_IS_EMPTY
(
1002
,
"auditResult或deadLine为空"
),
AMOUNT_OR_FINANCE_PRODUCTS_IS_EMPTY
(
1003
,
"auditResult为true时, 金融产品集或amount为空"
),
FINANCE_PRODUCTS_IS_ERROR1
(
1004
,
"金融产品集不符合(0 <= max - min <= 1)规则"
),
FINANCE_PRODUCTS_IS_ERROR2
(
1005
,
"金融产品及不符合(amount >= floor)规则"
);
FINANCE_PRODUCTS_IS_ERROR2
(
1005
,
"金融产品及不符合(amount >= floor)规则"
),
AMOUNT_OR_TERM_IS_EMPTY
(
1006
,
"auditResult为true时,amount或term为空"
);
@Getter
private
int
code
;
...
...
src/main/java/com/quantgroup/asset/distribution/enums/response/FundModuleResponse.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
enums
.
response
;
import
lombok.Getter
;
/**
* 资方模块返回结果
* @author liwenbin
*
*/
public
enum
FundModuleResponse
implements
GlobalResponseEnum
{
SUCCESS
(
0
,
"success"
),
TYPE_IS_EMPTY
(
4001
,
"type不能为空"
),
UNKNOW_TYPE
(
4002
,
"未知的type类型"
),
ID_IS_EMPTY
(
4003
,
"id不能为空"
),
BIZ_CHANNEL_IS_EMPTY
(
4004
,
"渠道号不能为空"
),
FUNDS_INFO_IS_EMPTY
(
4005
,
"渠道资方信息不能为空"
),
FUNDS_INFO_ERROR
(
4006
,
"渠道资方信息有误,请检查"
),
CHANNEL_FUND_CONFIG_IS_EXIST
(
4007
,
"渠道资方配置已存在, 添加失败!"
),
CHANNEL_FUND_CONFIG_NOT_EXIST
(
4008
,
"渠道资方配置修改失败, id不存在!"
),
PAGEING_CONDITIONS_IS_EMPTY
(
4009
,
"分页条件不能为空"
),
HAS_NO_DATA
(
4010
,
"未找到数据"
);
@Getter
private
int
code
;
@Getter
private
String
businessCode
;
@Getter
private
String
msg
;
@Getter
private
Object
body
;
FundModuleResponse
(
int
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
businessCode
=
null
;
this
.
msg
=
msg
;
this
.
body
=
null
;
}
}
src/main/java/com/quantgroup/asset/distribution/exception/QGExceptionType.java
View file @
9dfb4bb1
...
...
@@ -35,7 +35,12 @@ public enum QGExceptionType {
NOTIFY_FUND_SERVER_ERROR
(
2041
,
"通知资金系统失败, uuid : %s, bizNo : %s, assetNo : %s"
),
NOT_FOUND_FUND_SERVER_RESULT_BIZNO
(
2042
,
"未找到资金结果通知订单, bizNo : %s, status : %s"
),
NOTIFY_BUSINESS_FLOW_ERROR
(
2042
,
"通知业务流系统订单终态失败, bizNo : %s, status : %s"
);
NOTIFY_BUSINESS_FLOW_ERROR
(
2042
,
"通知业务流系统订单终态失败, bizNo : %s, status : %s"
),
// 资方模块错误信息
GET_ALL_FUNDS_INFO_ERROR
(
3001
,
"拉取所有资方信息失败, res : %s"
),
NO_FUND_INFO_BEEN_HIT
(
3002
,
"未命中任何资方, bizChannel : %s, amount : %s, term : %s"
),
FUND_PRIORITY_IS_ERROR
(
3003
,
"资方优先级不符合要求, bizChannel : %s, amount : %s, term : %s"
);
...
...
src/main/java/com/quantgroup/asset/distribution/model/entity/fund/ChannelFundConfig.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
model
.
entity
.
fund
;
import
java.io.Serializable
;
import
java.util.List
;
import
lombok.Data
;
@Data
public
class
ChannelFundConfig
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
private
Integer
fundId
;
private
Integer
fundProductId
;
private
String
fundName
;
private
String
attentions
;
private
List
<
Limit
>
limits
;
private
String
rate
;
private
Integer
feeType
;
private
Integer
rateType
;
private
Integer
priority
;
@Data
public
class
Limit
{
private
String
key
;
private
String
limit
;
private
Integer
type
;
}
}
src/main/java/com/quantgroup/asset/distribution/model/entity/fund/FundInfo.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
model
.
entity
.
fund
;
import
java.io.Serializable
;
import
lombok.Data
;
/**
* 资方信息
* @author liwenbin
*
*/
@Data
public
class
FundInfo
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
// 资方Id
private
Long
fundId
;
// 资方名称
private
String
fundName
;
// 简称
private
String
strategyName
;
// 注意事项
private
String
remarks
;
}
src/main/java/com/quantgroup/asset/distribution/model/form/AssetForm.java
View file @
9dfb4bb1
...
...
@@ -33,6 +33,8 @@ public class AssetForm implements Serializable{
private
String
amount
;
private
String
term
;
private
String
deadLine
;
private
String
exData
;
...
...
src/main/java/com/quantgroup/asset/distribution/model/response/GlobalResponse.java
View file @
9dfb4bb1
...
...
@@ -66,6 +66,10 @@ public class GlobalResponse {
return
new
GlobalResponse
(
responseEnum
.
getCode
(),
responseEnum
.
getBusinessCode
(),
responseEnum
.
getMsg
(),
object
);
}
public
static
GlobalResponse
create
(
QGException
ex
)
{
return
new
GlobalResponse
(
ex
.
qgExceptionType
.
code
,
StringUtils
.
isNotBlank
(
ex
.
detail
)
?
ex
.
detail
:
ex
.
qgExceptionType
.
text
,
null
);
}
public
static
GlobalResponse
error
(
String
msg
)
{
return
new
GlobalResponse
(
1
,
msg
,
null
);
}
...
...
@@ -74,6 +78,10 @@ public class GlobalResponse {
return
new
GlobalResponse
(
code
,
null
,
data
);
}
public
static
GlobalResponse
error
(
QGExceptionType
qgExceptionType
)
{
return
new
GlobalResponse
(
qgExceptionType
.
code
,
qgExceptionType
.
text
,
null
);
}
public
GlobalResponse
(
Object
code
,
String
msg
)
{
if
(
code
instanceof
String
&&
StringUtils
.
isNumeric
(((
String
)
code
)))
{
this
.
code
=
Integer
.
parseInt
(((
String
)
code
));
...
...
src/main/java/com/quantgroup/asset/distribution/service/asset/impl/AssetAttributeServiceImpl.java
View file @
9dfb4bb1
...
...
@@ -62,15 +62,24 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
// 决策特征Key
Set
<
String
>
decKeys
=
new
HashSet
<>();
Set
<
String
>
propertyKeys
=
new
HashSet
<>();
decKeys
.
add
(
AssetAttributeConstants
.
USER_LOAN_TYPE
);
if
(
assetAttributeExtendConfigList
!=
null
&&
assetAttributeExtendConfigList
.
size
()
>
0
)
{
for
(
AssetAttributeExtendConfig
config
:
assetAttributeExtendConfigList
)
{
if
(
config
.
getAssetAttributeType
()
==
1
)
{
decKeys
.
add
(
config
.
getAssetAttributeCode
());
}
if
(
config
.
getAssetAttributeType
()
==
1
)
{
decKeys
.
add
(
config
.
getAssetAttributeCode
());
}
else
if
(
config
.
getAssetAttributeType
()
==
2
)
{
// 自有属性,amount和term
propertyKeys
.
add
(
config
.
getAssetAttributeCode
());
}
}
}
// 请求决策特征
Map
<
String
,
Object
>
decAttributeValue
=
getDecAttributeValue
(
decKeys
,
assetForm
);
data
.
putAll
(
decAttributeValue
);
// 自有属性
Map
<
String
,
Object
>
propertyValue
=
getPropertyAttributeValue
(
propertyKeys
,
assetForm
);
data
.
putAll
(
propertyValue
);
log
.
info
(
"用户所有资产扩展属性获取完成, uuid : {}, assetNo : {}, bizNo : {}, bizType : {}, 耗时 : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getAssetNo
(),
assetForm
.
getBizNo
(),
assetForm
.
getBizType
(),
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
));
return
data
;
}
...
...
@@ -98,6 +107,25 @@ public class AssetAttributeServiceImpl implements IAssetAttributeService {
return
data
;
}
/**
* 获取自有属性值
* @param propertyKeys
* @param assetForm
* @return
*/
public
Map
<
String
,
Object
>
getPropertyAttributeValue
(
Set
<
String
>
propertyKeys
,
AssetForm
assetForm
)
{
if
(
CollectionUtils
.
isEmpty
(
propertyKeys
))
{
return
MapUtils
.
EMPTY_MAP
;
}
JSONObject
json
=
JSON
.
parseObject
(
JSON
.
toJSONString
(
assetForm
));
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
for
(
String
propertyKey
:
propertyKeys
)
{
String
value
=
json
.
getString
(
propertyKey
);
if
(
StringUtils
.
isNotEmpty
(
value
))
{
data
.
put
(
propertyKey
,
value
);
}
}
return
data
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Override
public
void
saveAssetAttrubite
(
Asset
asset
,
List
<
AssetAttributeExtendConfig
>
assetAttributeExtendConfigList
,
...
...
src/main/java/com/quantgroup/asset/distribution/service/asset/impl/AssetServiceImpl.java
View file @
9dfb4bb1
...
...
@@ -2,10 +2,12 @@ package com.quantgroup.asset.distribution.service.asset.impl;
import
java.lang.reflect.Field
;
import
java.math.BigDecimal
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Async
;
...
...
@@ -16,10 +18,11 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.base.Stopwatch
;
import
com.quantgroup.asset.distribution.config.annotation.Attribute
;
import
com.quantgroup.asset.distribution.constant.DistributeLogoConstants
;
import
com.quantgroup.asset.distribution.enums.response.AssetResponse
;
import
com.quantgroup.asset.distribution.exception.QGException
;
import
com.quantgroup.asset.distribution.exception.QGExceptionType
;
import
com.quantgroup.asset.distribution.exception.QGPreconditions
;
import
com.quantgroup.asset.distribution.model.entity.fund.ChannelFundConfig
;
import
com.quantgroup.asset.distribution.model.form.AssetForm
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.alarm.IAlarmService
;
...
...
@@ -28,8 +31,11 @@ import com.quantgroup.asset.distribution.service.asset.IAssetAttributeService;
import
com.quantgroup.asset.distribution.service.asset.IAssetService
;
import
com.quantgroup.asset.distribution.service.distribute.IAssetDistributeService
;
import
com.quantgroup.asset.distribution.service.distribute.IDistributeFailLogService
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.Asset
;
import
com.quantgroup.asset.distribution.service.jpa.entity.AssetAttributeExtendConfig
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig
;
import
com.quantgroup.asset.distribution.service.rule.IRuleService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -52,6 +58,10 @@ public class AssetServiceImpl implements IAssetService{
private
IAlarmService
alarmService
;
@Autowired
private
IDistributeFailLogService
distributeFailLogService
;
@Autowired
private
IFundModuleChannelFundConfigService
fundModuleCHannelFundConfigService
;
@Autowired
private
IRuleService
ruleService
;
@Async
...
...
@@ -59,6 +69,9 @@ public class AssetServiceImpl implements IAssetService{
public
void
assetsIn
(
AssetForm
assetForm
)
{
try
{
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
// 如果使用资方模块则去命中资方,创建金融产品集
hitFundIfUseFundModule
(
assetForm
);
// 转换为资产Object
Asset
asset
=
assetForm
.
transToAsset
();
// 获取所有资产扩展属性配置
List
<
AssetAttributeExtendConfig
>
assetAttributeExtendConfigList
=
assetAttributeExtendConfigService
.
getAllExtendConfig
();
...
...
@@ -101,6 +114,28 @@ public class AssetServiceImpl implements IAssetService{
log
.
info
(
"资产入库auditResult或deadLine为空, uuid : {}, bizNo : {}"
,
assetForm
.
getUuid
(),
assetForm
.
getBizNo
());
return
GlobalResponse
.
create
(
AssetResponse
.
AUDIT_RESULT_OR_DEAD_LINE_IS_EMPTY
);
}
// auditResult为true时, 校验是使用资方模块还是老金融产品集
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
()))
{
if
(
StringUtils
.
isNotEmpty
(
assetForm
.
getFinanceProducts
()))
{
return
checkOldAssetForm
(
assetForm
);
}
else
{
return
checkNewAssetForm
(
assetForm
);
}
}
else
{
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
}
}
public
GlobalResponse
checkNewAssetForm
(
AssetForm
assetForm
)
{
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
()))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getAmount
())
||
StringUtils
.
isEmpty
(
assetForm
.
getTerm
()))
{
return
GlobalResponse
.
create
(
AssetResponse
.
AMOUNT_OR_TERM_IS_EMPTY
);
}
}
return
GlobalResponse
.
create
(
AssetResponse
.
SUCCESS
);
}
public
GlobalResponse
checkOldAssetForm
(
AssetForm
assetForm
)
{
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
()))
{
if
(
StringUtils
.
isEmpty
(
assetForm
.
getFinanceProducts
())
||
StringUtils
.
isEmpty
(
assetForm
.
getAmount
()))
{
// auditResult为true,金融产品集和amount不能为空
...
...
@@ -173,4 +208,73 @@ public class AssetServiceImpl implements IAssetService{
}
return
sb
.
toString
();
}
/**
* 如果使用资方模块,需要去命中资方
* @param assetForm
*/
public
void
hitFundIfUseFundModule
(
AssetForm
assetForm
)
{
if
(
"false"
.
equals
(
assetForm
.
getAuditResult
()))
{
return
;
}
if
(
"true"
.
equals
(
assetForm
.
getAuditResult
())
&&
StringUtils
.
isNotEmpty
(
assetForm
.
getFinanceProducts
()))
{
return
;
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
data
.
put
(
"amount"
,
assetForm
.
getAmount
());
data
.
put
(
"term"
,
assetForm
.
getTerm
());
// 创建金融产品集,并初始化金额期数
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
);
termJSON
.
put
(
"term"
,
assetForm
.
getTerm
());
JSONArray
fundArray
=
new
JSONArray
();
termJSON
.
put
(
"fundInfo"
,
fundArray
);
FundModuleChannelFundConfig
config
=
fundModuleCHannelFundConfigService
.
findByBizChannel
(
assetForm
.
getBizChannel
());
List
<
ChannelFundConfig
>
fundConfigList
=
JSONArray
.
parseArray
(
config
.
getFunds
(),
ChannelFundConfig
.
class
);
A
:
for
(
ChannelFundConfig
channelFundConfig
:
fundConfigList
)
{
List
<
ChannelFundConfig
.
Limit
>
limits
=
channelFundConfig
.
getLimits
();
if
(
CollectionUtils
.
isNotEmpty
(
limits
))
{
for
(
ChannelFundConfig
.
Limit
limit
:
limits
)
{
String
expression
=
limit
.
getLimit
();
if
(!
ruleService
.
valid
(
expression
,
data
))
{
continue
A
;
}
}
}
// 创建并增加资方配置
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
);
}
// 如果fundArray为空,未命中任何一个资方
QGPreconditions
.
checkArgument
(
fundArray
.
size
()
!=
0
,
QGExceptionType
.
NO_FUND_INFO_BEEN_HIT
,
assetForm
.
getBizChannel
(),
assetForm
.
getAmount
(),
assetForm
.
getTerm
());
// 看命中优先级是否符合要求
boolean
[]
bucket
=
new
boolean
[
fundArray
.
size
()];
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
;
}
// 装填金融产品集并返回
assetForm
.
setFinanceProducts
(
JSON
.
toJSONString
(
financeProductArray
));
}
}
src/main/java/com/quantgroup/asset/distribution/service/funding/IFundModuleChannelFundConfigService.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
;
import
java.util.Map
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig
;
/**
* 渠道资金配置Service
* @author liwenbin
*
*/
public
interface
IFundModuleChannelFundConfigService
{
public
Map
<
String
,
Object
>
getChannelFundConfigsByChannelOrFundId
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
);
public
GlobalResponse
addChannelFundConfig
(
String
bizChannel
,
String
funds
,
String
remarks
);
public
GlobalResponse
updateChannelFundConfig
(
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
);
public
FundModuleChannelFundConfig
findByBizChannel
(
String
bizChannel
);
}
src/main/java/com/quantgroup/asset/distribution/service/funding/IFundModuleLimitTypeService.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
;
import
java.util.List
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleLimitTypeConfig
;
/**
* 资方模块条件类型Service
* @author liwenbin
*
*/
public
interface
IFundModuleLimitTypeService
{
/**
* 获取所有条件类型, name和code
* @return
*/
public
List
<
FundModuleLimitTypeConfig
>
getAllLimitType
();
public
void
clearCache
();
}
src/main/java/com/quantgroup/asset/distribution/service/funding/IFundModuleService.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
/**
* 资方模块Service
* @author liwenbin
*
*/
public
interface
IFundModuleService
{
/**
* 获取所有资方信息
* @return
*/
public
GlobalResponse
getAllFundsInfo
();
/**
* 获取资方配置所有条件类型, 以及对应的code
* @return
*/
public
GlobalResponse
getAllLimitType
();
/**
* 保存或更改渠道资方配置
* @return
*/
public
GlobalResponse
saveChannelFundConfig
(
Integer
type
,
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
);
/**
* 获取渠道资方配置信息
* @param bizChannel
* @param fundId
* @param pageNum
* @param pageSize
* @return
*/
public
GlobalResponse
getChannelFundConfigs
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
);
}
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/FundModuleChannelFundConfigServiceImpl.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
.
impl
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
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
com.quantgroup.asset.distribution.enums.response.FundModuleResponse
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig
;
import
com.quantgroup.asset.distribution.service.jpa.repository.IFundModuleChannelFundConfigRepository
;
import
com.quantgroup.asset.distribution.util.fund.module.ChannelFundConfigUtil
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@Service
public
class
FundModuleChannelFundConfigServiceImpl
implements
IFundModuleChannelFundConfigService
{
@Autowired
private
IFundModuleChannelFundConfigRepository
fundModuleChannelFundConfigRepository
;
/**
* 分页使用
*/
@Override
public
Map
<
String
,
Object
>
getChannelFundConfigsByChannelOrFundId
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
)
{
// 分页条件
Pageable
pageable
=
new
PageRequest
(
pageNum
<
0
?
0
:
pageNum
,
pageSize
);
Specification
<
FundModuleChannelFundConfig
>
specification
=
new
Specification
<
FundModuleChannelFundConfig
>()
{
@Override
public
Predicate
toPredicate
(
Root
<
FundModuleChannelFundConfig
>
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
<
FundModuleChannelFundConfig
>
channelFundConfigs
=
fundModuleChannelFundConfigRepository
.
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
;
}
@Override
public
GlobalResponse
addChannelFundConfig
(
String
bizChannel
,
String
funds
,
String
remarks
)
{
// 新增配置, 根据渠道查询如果库里已存在,返回异常;测试一下渠道号存在2条配置去find正常否
FundModuleChannelFundConfig
fundModuleChannelFundConfig
=
fundModuleChannelFundConfigRepository
.
findByBizChannelAndEnableIsTrue
(
bizChannel
);
if
(
fundModuleChannelFundConfig
!=
null
)
{
log
.
info
(
"资方模块, 渠道 : {}资方配置已存在, 添加失败!"
,
bizChannel
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
CHANNEL_FUND_CONFIG_IS_EXIST
);
}
fundModuleChannelFundConfig
=
new
FundModuleChannelFundConfig
();
fundModuleChannelFundConfig
.
setBizChannel
(
bizChannel
);
fundModuleChannelFundConfig
.
setFunds
(
funds
);
fundModuleChannelFundConfig
.
setRemarks
(
remarks
);
fundModuleChannelFundConfig
.
setFundIds
(
ChannelFundConfigUtil
.
getAllFundIds
(
funds
));
fundModuleChannelFundConfig
.
setEnable
(
true
);
fundModuleChannelFundConfigRepository
.
save
(
fundModuleChannelFundConfig
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
SUCCESS
);
}
@Override
public
GlobalResponse
updateChannelFundConfig
(
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
)
{
// 更改配置, 根据id查询如果库里不存在,返回异常
FundModuleChannelFundConfig
fundModuleChannelFundConfig
=
fundModuleChannelFundConfigRepository
.
findByIdAndEnableIsTrue
(
id
);
if
(
fundModuleChannelFundConfig
==
null
)
{
log
.
info
(
"资方模块, 渠道 : {}, 配置id : {}, 资方配置不存在, 修改失败!"
,
bizChannel
,
id
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
CHANNEL_FUND_CONFIG_NOT_EXIST
);
}
fundModuleChannelFundConfig
.
setBizChannel
(
bizChannel
);
fundModuleChannelFundConfig
.
setFunds
(
funds
);
fundModuleChannelFundConfig
.
setRemarks
(
remarks
);
fundModuleChannelFundConfig
.
setFundIds
(
ChannelFundConfigUtil
.
getAllFundIds
(
funds
));
fundModuleChannelFundConfig
.
setEnable
(
true
);
fundModuleChannelFundConfigRepository
.
save
(
fundModuleChannelFundConfig
);
return
GlobalResponse
.
create
(
FundModuleResponse
.
SUCCESS
);
}
@Override
public
FundModuleChannelFundConfig
findByBizChannel
(
String
bizChannel
)
{
return
fundModuleChannelFundConfigRepository
.
findByBizChannelAndEnableIsTrue
(
bizChannel
);
}
}
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/FundModuleLimitTypeServiceImpl.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
.
impl
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleLimitTypeService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleLimitTypeConfig
;
import
com.quantgroup.asset.distribution.service.jpa.repository.IFundModuleLimitTypeConfigRepository
;
@Service
public
class
FundModuleLimitTypeServiceImpl
implements
IFundModuleLimitTypeService
{
@Autowired
private
IFundModuleLimitTypeConfigRepository
fundModuleLimitTypeConfigRepository
;
@Cacheable
(
value
=
"cacheManager"
,
key
=
"'ASSET_DISTRIBUTION:FUND_MODULE:ALL_LIMIT_TYPE:CC8C'"
)
@Override
public
List
<
FundModuleLimitTypeConfig
>
getAllLimitType
()
{
List
<
FundModuleLimitTypeConfig
>
configList
=
fundModuleLimitTypeConfigRepository
.
findByEnableIsTrue
();
return
configList
;
}
@CacheEvict
(
value
=
"cacheManager"
,
key
=
"'ASSET_DISTRIBUTION:FUND_MODULE:ALL_LIMIT_TYPE:CC8C'"
)
@Override
public
void
clearCache
()
{
}
}
src/main/java/com/quantgroup/asset/distribution/service/funding/impl/FundModuleServiceImpl.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
funding
.
impl
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.base.Stopwatch
;
import
com.quantgroup.asset.distribution.config.annotation.HandleException
;
import
com.quantgroup.asset.distribution.constant.FundModuleConstants
;
import
com.quantgroup.asset.distribution.enums.response.FundModuleResponse
;
import
com.quantgroup.asset.distribution.exception.QGExceptionType
;
import
com.quantgroup.asset.distribution.exception.QGPreconditions
;
import
com.quantgroup.asset.distribution.model.entity.fund.FundInfo
;
import
com.quantgroup.asset.distribution.model.response.GlobalResponse
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigService
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleLimitTypeService
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleService
;
import
com.quantgroup.asset.distribution.service.httpclient.IHttpService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleLimitTypeConfig
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 资方模块Service
* @author liwenbin
*
*/
@Service
@Slf4j
public
class
FundModuleServiceImpl
implements
IFundModuleService
{
@Autowired
private
IHttpService
httpService
;
@Autowired
private
IFundModuleLimitTypeService
fundModuleLimitTypeService
;
@Autowired
private
IFundModuleChannelFundConfigService
fundModuleChannelFundConfigService
;
@Value
(
"${clotho.url}"
)
private
String
clothoURL
;
@HandleException
@Override
public
GlobalResponse
getAllFundsInfo
()
{
Stopwatch
stopwatch
=
Stopwatch
.
createStarted
();
String
text
=
httpService
.
get
(
clothoURL
+
"/ex/funding/corp/all"
);
log
.
info
(
"拉取xyqb所有资方信息完成, 耗时 : {}, 结果 : {}"
,
stopwatch
.
stop
().
elapsed
(
TimeUnit
.
MILLISECONDS
),
text
);
QGPreconditions
.
checkArgument
(
StringUtils
.
isNotEmpty
(
text
),
QGExceptionType
.
GET_ALL_FUNDS_INFO_ERROR
,
text
);
JSONObject
data
=
JSONObject
.
parseObject
(
text
);
QGPreconditions
.
checkArgument
(
data
!=
null
&&
"0000"
.
equals
(
data
.
getString
(
"code"
)),
QGExceptionType
.
GET_ALL_FUNDS_INFO_ERROR
,
text
);
// 将xyqb返回的结果转化成返回结果
List
<
FundInfo
>
fundInfoList
=
new
ArrayList
<>();
JSONArray
fundsArray
=
data
.
getJSONArray
(
"data"
);
for
(
int
i
=
0
,
len
=
fundsArray
.
size
();
i
<
len
;
++
i
)
{
FundInfo
fundInfo
=
new
FundInfo
();
JSONObject
fundInfoJSON
=
fundsArray
.
getJSONObject
(
i
);
fundInfo
.
setFundId
(
fundInfoJSON
.
getLong
(
"id"
));
fundInfo
.
setFundName
(
fundInfoJSON
.
getString
(
"name"
));
fundInfo
.
setStrategyName
(
fundInfoJSON
.
getString
(
"strategyName"
));
fundInfoList
.
add
(
fundInfo
);
}
return
GlobalResponse
.
create
(
FundModuleResponse
.
SUCCESS
,
fundInfoList
);
}
@HandleException
@Override
public
GlobalResponse
getAllLimitType
()
{
List
<
FundModuleLimitTypeConfig
>
configList
=
fundModuleLimitTypeService
.
getAllLimitType
();
return
GlobalResponse
.
create
(
FundModuleResponse
.
SUCCESS
,
configList
);
}
@HandleException
@Override
public
GlobalResponse
saveChannelFundConfig
(
Integer
type
,
Long
id
,
String
bizChannel
,
String
funds
,
String
remarks
)
{
if
(
type
==
FundModuleConstants
.
CHANNEL_FUNDS_OPERAOTR_TYPE_ADD
)
{
return
fundModuleChannelFundConfigService
.
addChannelFundConfig
(
bizChannel
,
funds
,
remarks
);
}
else
if
(
type
==
FundModuleConstants
.
CHANNEL_FUNDS_OPERATOR_TYPE_UPDATE
)
{
return
fundModuleChannelFundConfigService
.
updateChannelFundConfig
(
id
,
bizChannel
,
funds
,
remarks
);
}
else
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
SUCCESS
);
}
}
@HandleException
@Override
public
GlobalResponse
getChannelFundConfigs
(
String
bizChannel
,
Long
fundId
,
Integer
pageNum
,
Integer
pageSize
)
{
Map
<
String
,
Object
>
result
=
fundModuleChannelFundConfigService
.
getChannelFundConfigsByChannelOrFundId
(
bizChannel
,
fundId
,
pageNum
,
pageSize
);
if
(
result
.
size
()
==
0
)
{
return
GlobalResponse
.
create
(
FundModuleResponse
.
HAS_NO_DATA
);
}
return
GlobalResponse
.
success
(
result
);
}
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/entity/FundModuleChannelFundConfig.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
entity
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.PrePersist
;
import
javax.persistence.PreUpdate
;
import
javax.persistence.Table
;
import
lombok.Data
;
/**
* 资方模块渠道资方配置
* @author liwenbin
*
*/
@Table
(
name
=
"fund_module_channel_fund_config"
)
@Entity
@Data
public
class
FundModuleChannelFundConfig
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
=
"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
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
entity
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.GenerationType
;
import
javax.persistence.Id
;
import
javax.persistence.PrePersist
;
import
javax.persistence.PreUpdate
;
import
javax.persistence.Table
;
import
lombok.Data
;
/**
* 资方模块条件类型配置表
* @author liwenbin
*
*/
@Table
(
name
=
"fund_module_limit_type_config"
)
@Entity
@Data
public
class
FundModuleLimitTypeConfig
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
@Id
@Column
(
name
=
"id"
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
@Column
(
name
=
"name"
)
private
String
name
;
@Column
(
name
=
"code"
)
private
String
code
;
@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/repository/IFundModuleChannelFundConfigRepository.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
repository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig
;
/**
* 渠道资方配置表Repository
* @author liwenbin
*
*/
public
interface
IFundModuleChannelFundConfigRepository
extends
JpaRepository
<
FundModuleChannelFundConfig
,
Long
>,
JpaSpecificationExecutor
<
FundModuleChannelFundConfig
>{
/**
* 根据渠道号查询渠道资方配置
* @param bizChannel
* @return
*/
public
FundModuleChannelFundConfig
findByBizChannelAndEnableIsTrue
(
String
bizChannel
);
/**
* 根据id查询渠道资方配置
* @param id
* @return
*/
public
FundModuleChannelFundConfig
findByIdAndEnableIsTrue
(
Long
id
);
}
src/main/java/com/quantgroup/asset/distribution/service/jpa/repository/IFundModuleLimitTypeConfigRepository.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
service
.
jpa
.
repository
;
import
java.util.List
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleLimitTypeConfig
;
/**
* 资方模块条件类型配置表Repository
* @author liwenbin
*
*/
public
interface
IFundModuleLimitTypeConfigRepository
extends
JpaRepository
<
FundModuleLimitTypeConfig
,
Long
>{
/**
* 获取所有可用条件类型
* @return
*/
public
List
<
FundModuleLimitTypeConfig
>
findByEnableIsTrue
();
}
src/main/java/com/quantgroup/asset/distribution/util/fund/module/ChannelFundConfigUtil.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
util
.
fund
.
module
;
import
java.util.HashSet
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
org.apache.commons.lang3.StringUtils
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
/**
* 渠道资方配置信息工具类
* @author liwenbin
*
*/
@Slf4j
public
class
ChannelFundConfigUtil
{
/**
* 检测渠道配置funds信息是否正常
* @return
*/
public
static
boolean
checkFunds
(
String
channelFundConfigInfo
)
{
try
{
if
(
StringUtils
.
isEmpty
(
channelFundConfigInfo
))
{
return
false
;
}
JSONArray
array
=
JSONArray
.
parseArray
(
channelFundConfigInfo
);
for
(
int
i
=
0
,
len
=
array
.
size
();
i
<
len
;
i
++)
{
JSONObject
data
=
array
.
getJSONObject
(
i
);
if
(
data
.
getLong
(
"fundId"
)
==
null
)
{
return
false
;
}
if
(
StringUtils
.
isEmpty
(
"fundName"
))
{
return
false
;
}
if
(
StringUtils
.
isEmpty
(
"rate"
))
{
return
false
;
}
if
(
StringUtils
.
isEmpty
(
"feeType"
))
{
return
false
;
}
if
(
StringUtils
.
isEmpty
(
"rateType"
))
{
return
false
;
}
if
(
StringUtils
.
isEmpty
(
"priority"
))
{
return
false
;
}
}
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
"检查渠道资方配置信息出现异常!"
,
e
);
return
false
;
}
}
/**
* 根据资方配置信息获取所有资方
* @param funds
* @return
*/
public
static
String
getAllFundIds
(
String
funds
)
{
Set
<
String
>
fundIdSet
=
new
LinkedHashSet
<>();
JSONArray
array
=
JSONArray
.
parseArray
(
funds
);
for
(
int
i
=
0
,
len
=
array
.
size
();
i
<
len
;
i
++)
{
JSONObject
data
=
array
.
getJSONObject
(
i
);
fundIdSet
.
add
(
data
.
getString
(
"fundId"
));
}
return
StringUtils
.
join
(
fundIdSet
,
","
);
}
}
src/test/java/com/quantgroup/asset/distribution/fund/FundModuleTest.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
fund
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
com.quantgroup.asset.distribution.AssetDistributionBootstrap
;
import
com.quantgroup.asset.distribution.service.funding.IFundModuleChannelFundConfigService
;
import
com.quantgroup.asset.distribution.service.jpa.entity.FundModuleChannelFundConfig
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
AssetDistributionBootstrap
.
class
)
public
class
FundModuleTest
{
@Autowired
private
IFundModuleChannelFundConfigService
channelFundConfigService
;
@Test
public
void
testFindBy
()
{
// FundModuleChannelFundConfig config = channelFundConfigService.findByBizChannel("1");
// System.out.println(config);
System
.
out
.
println
(
channelFundConfigService
.
getChannelFundConfigsByChannelOrFundId
(
"1"
,
null
,
0
,
20
));
System
.
out
.
println
(
channelFundConfigService
.
getChannelFundConfigsByChannelOrFundId
(
"1"
,
140L
,
0
,
20
));
// System.out.println(channelFundConfigService.getChannelFundConfigsByChannelOrFundId("1", null, 0, 20));
// System.out.println(channelFundConfigService.getChannelFundConfigsByChannelOrFundId("1", null, 0, 20));
}
}
src/test/java/com/quantgroup/asset/distribution/notify/NotifyTest.java
0 → 100644
View file @
9dfb4bb1
package
com
.
quantgroup
.
asset
.
distribution
.
notify
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
com.quantgroup.asset.distribution.AssetDistributionBootstrap
;
import
com.quantgroup.asset.distribution.service.notify.INotifyService
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
classes
=
AssetDistributionBootstrap
.
class
)
public
class
NotifyTest
{
@Autowired
private
INotifyService
notifyService
;
@Test
public
void
testBusinessFlow
()
{
notifyService
.
notifyBusinessFlow
(
"SP527400898415178843596841"
,
0
);
}
}
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