Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-csf
Commits
8295b567
Commit
8295b567
authored
Jan 29, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/test' into test
parents
b7891caa
d75b431a
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
217 additions
and
21 deletions
+217
-21
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiAppointmentServiceImpl.java
+1
-1
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
+61
-2
yd-csf-service/src/main/java/com/yd/csf/service/model/Fortune.java
+1
-1
yd-csf-service/src/main/java/com/yd/csf/service/model/PolicyFollow.java
+1
-1
yd-csf-service/src/main/java/com/yd/csf/service/service/CommissionService.java
+2
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionExpectedServiceImpl.java
+1
-7
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
+2
-1
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneAccountServiceImpl.java
+1
-1
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
+147
-7
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiAppointmentServiceImpl.java
View file @
8295b567
...
...
@@ -717,7 +717,7 @@ public class ApiAppointmentServiceImpl implements ApiAppointmentService {
follow
.
setPolicyCurrency
(
apiProductPlanMainInfoDto
.
getPolicyCurrency
());
// 供款年期
if
(
StringUtils
.
isNotBlank
(
apiProductPlanMainInfoDto
.
getIssueNumber
()))
{
follow
.
setIssueNumber
(
Integer
.
parseInt
(
apiProductPlanMainInfoDto
.
getIssueNumber
()
));
follow
.
setIssueNumber
(
apiProductPlanMainInfoDto
.
getIssueNumber
(
));
}
// 保障期限
if
(
StringUtils
.
isNotBlank
(
apiProductPlanMainInfoDto
.
getGuaranteePeriod
()))
{
...
...
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
View file @
8295b567
package
com
.
yd
.
csf
.
api
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.alibaba.excel.ExcelWriter
;
import
com.alibaba.excel.write.metadata.WriteSheet
;
...
...
@@ -20,6 +21,7 @@ import com.yd.csf.api.dto.*;
import
com.yd.csf.api.service.ApiBasicLawCalculateService
;
import
com.yd.csf.api.service.ApiExpectedFortuneLogService
;
import
com.yd.csf.api.service.ApiExpectedFortuneService
;
import
com.yd.csf.feign.dto.appointmentfile.ItineraryDto
;
import
com.yd.csf.feign.request.expectedfortune.*
;
import
com.yd.csf.feign.response.expectedfortune.ApiExpectedFortunePageResponse
;
import
com.yd.csf.feign.response.expectedfortune.ApiGenerateExpectedFortuneResponse
;
...
...
@@ -29,6 +31,7 @@ import com.yd.csf.service.dto.QueryPolicyBrokerDto;
import
com.yd.csf.service.enums.FortuneStatusEnum
;
import
com.yd.csf.service.model.CommissionRuleBinding
;
import
com.yd.csf.service.model.ExpectedFortune
;
import
com.yd.csf.service.model.Policy
;
import
com.yd.csf.service.model.PolicyBroker
;
import
com.yd.csf.service.service.ICommissionRuleBindingService
;
import
com.yd.csf.service.service.IExpectedFortuneService
;
...
...
@@ -59,6 +62,7 @@ import java.math.RoundingMode;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@Slf4j
...
...
@@ -302,7 +306,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
}
}
}
//批量设置应付款编号
//批量设置应付款编号
、发佣类型
updatePayableNoBatch
(
policyNo
);
//执行成功完毕,也要销毁redis缓存
...
...
@@ -409,6 +413,9 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//查询当前保单号的所有预计发佣记录
List
<
ExpectedFortune
>
expectedFortuneList
=
iExpectedFortuneService
.
queryList
(
policyNo
);
//查询redis缓存的字典列表信息
List
<
GetDictItemListByDictTypeResponse
>
dictTypeResponses
=
redisUtil
.
getCacheObject
(
RedisConstants
.
DICT_LIST
);
//获取当前序号作为起点
int
currentSeq
=
0
;
if
(!
Objects
.
isNull
(
latest
))
{
...
...
@@ -416,8 +423,12 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
}
//批量更新应付款编号,每个item递增
ExpectedFortune
expectedFortune
;
for
(
int
i
=
0
;
i
<
expectedFortuneList
.
size
();
i
++)
{
expectedFortuneList
.
get
(
i
).
setPayableNo
(
this
.
createPayableNo
(
"R"
,
currentSeq
+
i
+
1
));
expectedFortune
=
expectedFortuneList
.
get
(
i
);
expectedFortune
.
setPayableNo
(
this
.
createPayableNo
(
"R"
,
currentSeq
+
i
+
1
));
expectedFortune
.
setFortuneType
(
GetDictItemListByDictTypeResponse
.
getItemValue
(
dictTypeResponses
,
"csf_fortune_type"
,
expectedFortune
.
getFortuneName
()));
}
iExpectedFortuneService
.
updateBatchById
(
expectedFortuneList
);
}
...
...
@@ -670,6 +681,18 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
}
validateAdd
(
fortuneAddRequestList
);
// 查询保单信息
Set
<
String
>
policyNoSet
=
fortuneAddRequestList
.
stream
()
.
map
(
ExpectedFortuneAddRequest:
:
getPolicyNo
)
.
filter
(
StringUtils:
:
isNotBlank
).
collect
(
Collectors
.
toSet
());
Map
<
String
,
Policy
>
policyMap
=
new
HashMap
<>();
if
(
CollUtil
.
isNotEmpty
(
policyNoSet
))
{
List
<
Policy
>
policyList
=
policyService
.
lambdaQuery
().
in
(
Policy:
:
getPolicyNo
,
policyNoSet
).
list
();
// 保单映射
policyMap
=
policyList
.
stream
().
collect
(
Collectors
.
toMap
(
Policy:
:
getPolicyNo
,
Function
.
identity
()));
}
// 查询最新一条有 payableNo 记录
ExpectedFortune
latest
=
iExpectedFortuneService
.
getOne
(
new
QueryWrapper
<
ExpectedFortune
>().
isNotNull
(
"payable_no"
).
orderByDesc
(
"id"
).
last
(
"LIMIT 1"
),
...
...
@@ -686,8 +709,23 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
ExpectedFortune
expectedFortune
=
new
ExpectedFortune
();
BeanUtil
.
copyProperties
(
expectedFortuneDto
,
expectedFortune
);
if
(
"R"
.
equals
(
expectedFortuneDto
.
getFortuneBizType
()))
{
Policy
policy
=
policyMap
.
get
(
expectedFortuneDto
.
getPolicyNo
());
if
(
ObjectUtils
.
isEmpty
(
policy
))
{
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"保单号为"
+
expectedFortuneDto
.
getPolicyNo
()
+
"的保单不存在"
);
}
// 设置关联字段
expectedFortune
.
setInsuranceCompanyBizId
(
policy
.
getInsuranceCompanyBizId
());
expectedFortune
.
setProductLaunchBizId
(
policy
.
getProductLaunchBizId
());
expectedFortune
.
setPremium
(
policy
.
getPaymentPremium
());
expectedFortune
.
setPolicyCurrency
(
policy
.
getCurrency
());
}
// 预计发佣业务id
expectedFortune
.
setExpectedFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_EXPECTED_FORTUNE
.
getCode
()));
// 预计发佣类型名称
expectedFortune
.
setFortuneName
(
queryByDict
(
expectedFortuneDto
.
getFortuneType
()));
// 应付款编号(序号递增)
expectedFortune
.
setPayableNo
(
this
.
createPayableNo
(
expectedFortune
.
getFortuneBizType
(),
++
currentSeq
));
// 默认结算汇率
...
...
@@ -696,6 +734,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
expectedFortune
.
setHkdAmount
(
expectedFortune
.
getAmount
().
multiply
(
expectedFortune
.
getDefaultExchangeRate
()));
// 已出帐金额、待出帐金额、已出帐比例、待出帐比例
expectedFortune
.
setPaidAmount
(
BigDecimal
.
ZERO
);
// 转介人比例默认100%
expectedFortune
.
setBrokerRatio
(
"100"
);
expectedFortune
.
setUnpaidAmount
(
expectedFortune
.
getAmount
());
expectedFortune
.
setPaidRatio
(
BigDecimal
.
ZERO
);
expectedFortune
.
setUnpaidRatio
(
BigDecimal
.
valueOf
(
100
));
...
...
@@ -705,6 +745,25 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
return
true
;
}
private
String
queryByDict
(
String
fortuneType
)
{
//查询redis缓存的字典列表信息
List
<
GetDictItemListByDictTypeResponse
>
dictTypeResponses
=
redisUtil
.
getCacheObject
(
RedisConstants
.
DICT_LIST
);
String
fortuneName
=
GetDictItemListByDictTypeResponse
.
getItemLabel
(
dictTypeResponses
,
"csf_fortune_type"
,
fortuneType
);
if
(
ObjectUtils
.
isNotEmpty
(
fortuneName
))
{
return
fortuneName
;
}
Result
<
List
<
GetDictItemListByDictTypeResponse
>>
result
=
apiSysDictFeignClient
.
getDictItemListByDictType
(
"csf_fortune_type"
);
if
(
ObjectUtils
.
isNotEmpty
(
result
.
getData
()))
{
for
(
GetDictItemListByDictTypeResponse
dictItem
:
result
.
getData
())
{
if
(
StringUtils
.
equalsIgnoreCase
(
dictItem
.
getItemValue
(),
fortuneType
))
{
return
dictItem
.
getItemLabel
();
}
}
}
return
null
;
}
private
BigDecimal
queryDefaultExchangeRate
(
String
currency
)
{
if
(
"HKD"
.
equalsIgnoreCase
(
currency
))
{
return
BigDecimal
.
valueOf
(
1
);
...
...
yd-csf-service/src/main/java/com/yd/csf/service/model/Fortune.java
View file @
8295b567
...
...
@@ -171,7 +171,7 @@ public class Fortune implements Serializable {
/**
* 实际出账日期
*/
private
Local
Date
actualPayoutDate
;
private
Date
actualPayoutDate
;
/**
* 检核人
...
...
yd-csf-service/src/main/java/com/yd/csf/service/model/PolicyFollow.java
View file @
8295b567
...
...
@@ -138,7 +138,7 @@ public class PolicyFollow implements Serializable {
/**
* 供款年期
*/
private
Integer
issueNumber
;
private
Object
issueNumber
;
/**
* 保障期限
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/CommissionService.java
View file @
8295b567
...
...
@@ -32,6 +32,8 @@ public interface CommissionService extends IService<Commission> {
Boolean
generateFortune
(
GenerateFortuneRequest
generateFortuneRequest
);
String
buildPolicyPeriodKey
(
String
policyNo
,
Object
period
);
Commission
getByCommissionBizId
(
String
commissionBizId
);
List
<
Commission
>
queryList
(
CommissionDto
dto
);
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionExpectedServiceImpl.java
View file @
8295b567
...
...
@@ -255,22 +255,16 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
}
validateAddCommissionExpected
(
addDtoList
);
// 查询保单信息
、保单产品信息
// 查询保单信息
Set
<
String
>
policyNoSet
=
addDtoList
.
stream
()
.
map
(
CommissionExpectedAddDto:
:
getPolicyNo
)
.
filter
(
StringUtils:
:
isNotBlank
).
collect
(
Collectors
.
toSet
());
Map
<
String
,
Policy
>
policyMap
=
new
HashMap
<>();
Map
<
String
,
PolicyProductInfo
>
policyProductInfoMap
=
new
HashMap
<>();
if
(
CollUtil
.
isNotEmpty
(
policyNoSet
))
{
List
<
Policy
>
policyList
=
policyService
.
lambdaQuery
().
in
(
Policy:
:
getPolicyNo
,
policyNoSet
).
list
();
// 保单映射
policyMap
=
policyList
.
stream
().
collect
(
Collectors
.
toMap
(
Policy:
:
getPolicyNo
,
Function
.
identity
()));
// 关联查询保单产品信息
Set
<
String
>
productLaunchBizIdSet
=
policyList
.
stream
()
.
map
(
Policy:
:
getProductLaunchBizId
)
.
collect
(
Collectors
.
toSet
());
// policyProductInfoMap = policyService.getPolicyProductInfoMap(productLaunchBizIdSet);
}
List
<
CommissionExpected
>
addList
=
new
ArrayList
<>();
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
View file @
8295b567
...
...
@@ -726,7 +726,8 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
/**
* 构建保单号+期次的唯一键
*/
private
String
buildPolicyPeriodKey
(
String
policyNo
,
Object
period
)
{
@Override
public
String
buildPolicyPeriodKey
(
String
policyNo
,
Object
period
)
{
return
(
policyNo
==
null
?
""
:
policyNo
)
+
"|"
+
(
period
==
null
?
""
:
period
.
toString
());
}
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneAccountServiceImpl.java
View file @
8295b567
...
...
@@ -284,7 +284,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
if
(
CollectionUtils
.
isNotEmpty
(
fortunes
))
{
fortunes
.
forEach
(
f
->
{
f
.
setStatus
(
FortuneStatusEnum
.
SENT
.
getItemValue
());
f
.
setActualPayoutDate
(
LocalDate
.
now
());
f
.
setActualPayoutDate
(
new
Date
());
f
.
setUpdaterId
(
loginUserId
.
toString
());
f
.
setUpdateTime
(
new
Date
());
});
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
View file @
8295b567
...
...
@@ -2,6 +2,7 @@ package com.yd.csf.service.service.impl;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollUtil
;
import
cn.hutool.core.util.NumberUtil
;
import
com.alibaba.excel.EasyExcel
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
...
...
@@ -11,11 +12,13 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.google.common.base.Joiner
;
import
com.yd.auth.core.dto.AuthUserDto
;
import
com.yd.auth.core.utils.SecurityUtil
;
import
com.yd.common.constant.RedisConstants
;
import
com.yd.common.enums.CommonEnum
;
import
com.yd.common.enums.ResultCode
;
import
com.yd.common.exception.BusinessException
;
import
com.yd.common.result.Result
;
import
com.yd.common.utils.RandomStringGenerator
;
import
com.yd.common.utils.RedisUtil
;
import
com.yd.csf.service.dto.*
;
import
com.yd.csf.service.enums.FortuneStatusEnum
;
import
com.yd.csf.service.model.*
;
...
...
@@ -24,12 +27,10 @@ import com.yd.csf.service.dao.FortuneMapper;
import
com.yd.csf.service.vo.FortuneVO
;
import
com.yd.user.feign.client.sysdict.ApiSysDictFeignClient
;
import
com.yd.user.feign.response.sysdict.GetDictItemListByDictTypeResponse
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -41,8 +42,8 @@ import java.math.BigDecimal;
import
java.math.RoundingMode
;
import
java.net.URLEncoder
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -64,9 +65,10 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
private
IExpectedFortuneService
expectedFortuneService
;
@Resource
private
PolicyService
policyService
;
@
Autowired
@
Resource
private
ApiSysDictFeignClient
apiSysDictFeignClient
;
@Resource
private
RedisUtil
redisUtil
;
@Override
public
Wrapper
<
Fortune
>
getQueryWrapper
(
FortuneQueryRequest
fortuneQueryRequest
)
{
...
...
@@ -505,19 +507,89 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
@Override
public
Boolean
addFortune
(
FortuneAddRequest
fortuneAddRequest
)
{
valiAddFortune
(
fortuneAddRequest
);
// 创建Fortune实体
Fortune
fortune
=
new
Fortune
();
BeanUtil
.
copyProperties
(
fortuneAddRequest
,
fortune
);
if
(
"R"
.
equals
(
fortuneAddRequest
.
getFortuneBizType
()))
{
if
(
ObjectUtils
.
isEmpty
(
fortuneAddRequest
.
getPolicyNo
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"关联保单应付款,保单号不能为空"
);
}
if
(
ObjectUtils
.
isEmpty
(
fortuneAddRequest
.
getFortunePeriod
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"关联保单应付款,佣金期数不能为空"
);
}
ExpectedFortune
expectedFortune
=
expectedFortuneService
.
lambdaQuery
()
.
eq
(
ExpectedFortune:
:
getPolicyNo
,
fortuneAddRequest
.
getPolicyNo
())
.
eq
(
ExpectedFortune:
:
getFortunePeriod
,
fortuneAddRequest
.
getFortunePeriod
())
.
eq
(
ExpectedFortune:
:
getFortuneType
,
fortuneAddRequest
.
getFortuneType
())
.
one
();
if
(
expectedFortune
==
null
)
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"未查询到当前项目对应的预计出账数据"
);
}
fortune
.
setExpectedFortuneBizId
(
expectedFortune
.
getExpectedFortuneBizId
());
fortune
.
setCommissionExpectedBizId
(
expectedFortune
.
getExpectedFortuneBizId
());
fortune
.
setPolicyCurrency
(
expectedFortune
.
getPolicyCurrency
());
fortune
.
setExchangeRate
(
expectedFortune
.
getDefaultExchangeRate
());
fortune
.
setHkdAmount
(
fortuneAddRequest
.
getAmount
().
multiply
(
expectedFortune
.
getDefaultExchangeRate
()));
fortune
.
setCurrentPaymentHkdAmount
(
fortune
.
getHkdAmount
());
fortune
.
setPayoutDate
(
expectedFortune
.
getPayoutDate
());
}
else
{
fortune
.
setExchangeRate
(
queryDefaultExchangeRate
(
fortuneAddRequest
.
getCurrency
()));
fortune
.
setHkdAmount
(
fortuneAddRequest
.
getAmount
().
multiply
(
fortune
.
getExchangeRate
()));
fortune
.
setCurrentPaymentHkdAmount
(
fortune
.
getHkdAmount
());
}
// 生成发佣业务ID
fortune
.
setFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_FORTUNE
.
getCode
()));
fortune
.
setCurrentPaymentAmount
(
fortuneAddRequest
.
getAmount
());
fortune
.
setFortuneName
(
queryByDict
(
fortuneAddRequest
.
getFortuneType
()));
fortune
.
setActualPayoutDate
(
fortuneAddRequest
.
getPayoutDate
());
fortune
.
setIsPart
(
0
);
fortune
.
setStatus
(
FortuneStatusEnum
.
WAIT
.
getItemValue
());
fortune
.
setStatus
(
FortuneStatusEnum
.
CAN_SEND
.
getItemValue
());
return
this
.
save
(
fortune
);
}
private
static
void
valiAddFortune
(
FortuneAddRequest
fortuneAddRequest
)
{
if
(
ObjectUtils
.
isEmpty
(
fortuneAddRequest
.
getFortuneBizType
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"出账类型不能为空"
);
}
if
(
ObjectUtils
.
isEmpty
(
fortuneAddRequest
.
getAmount
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"出账金额不能为空"
);
}
if
(
ObjectUtils
.
isEmpty
(
fortuneAddRequest
.
getCurrency
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"出账币种不能为空"
);
}
if
(
ObjectUtils
.
isEmpty
(
fortuneAddRequest
.
getFortuneType
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"出账项目不能为空"
);
}
if
(
ObjectUtils
.
isEmpty
(
fortuneAddRequest
.
getBrokerBizId
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"转介人不能为空"
);
}
if
(
"R"
.
equals
(
fortuneAddRequest
.
getFortuneBizType
()))
{
if
(
ObjectUtils
.
isEmpty
(
fortuneAddRequest
.
getPolicyNo
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"关联保单应付款,保单号不能为空"
);
}
if
(
ObjectUtils
.
isEmpty
(
fortuneAddRequest
.
getFortunePeriod
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"关联保单应付款,佣金期数不能为空"
);
}
}
}
private
String
queryByDict
(
String
fortuneType
)
{
//查询redis缓存的字典列表信息
List
<
GetDictItemListByDictTypeResponse
>
dictTypeResponses
=
redisUtil
.
getCacheObject
(
RedisConstants
.
DICT_LIST
);
String
fortuneName
=
GetDictItemListByDictTypeResponse
.
getItemLabel
(
dictTypeResponses
,
"csf_fortune_type"
,
fortuneType
);
if
(
ObjectUtils
.
isNotEmpty
(
fortuneName
))
{
return
fortuneName
;
}
Result
<
List
<
GetDictItemListByDictTypeResponse
>>
result
=
apiSysDictFeignClient
.
getDictItemListByDictType
(
"csf_fortune_type"
);
if
(
CollectionUtils
.
isNotEmpty
(
result
.
getData
()))
{
for
(
GetDictItemListByDictTypeResponse
dictItem
:
result
.
getData
())
{
...
...
@@ -583,13 +655,81 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
return
false
;
}
Set
<
String
>
policyNoSet
=
fortuneAddRequestList
.
stream
()
.
map
(
FortuneAddRequest:
:
getPolicyNo
)
.
filter
(
StringUtils:
:
isNotBlank
).
collect
(
Collectors
.
toSet
());
// 查询预计出账
Map
<
String
,
ExpectedFortune
>
expectedFortuneMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
policyNoSet
))
{
expectedFortuneMap
=
expectedFortuneService
.
lambdaQuery
()
.
in
(
ExpectedFortune:
:
getPolicyNo
,
policyNoSet
)
.
list
()
.
stream
()
.
collect
(
Collectors
.
toMap
(
i
->
i
.
getPolicyNo
()
+
"_"
+
i
.
getFortunePeriod
()
+
"_"
+
i
.
getFortuneType
(),
Function
.
identity
(),
(
oldValue
,
newValue
)
->
newValue
)
);
}
// 查询入账记录
List
<
Commission
>
commissionList
=
commissionService
.
lambdaQuery
().
in
(
Commission:
:
getPolicyNo
,
policyNoSet
)
.
list
();
Map
<
String
,
Commission
>
commissionByPolicyPeriod
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
commissionList
))
{
commissionByPolicyPeriod
=
commissionList
.
stream
()
.
collect
(
Collectors
.
toMap
(
commission
->
commissionService
.
buildPolicyPeriodKey
(
commission
.
getPolicyNo
(),
commission
.
getCommissionPeriod
()),
Function
.
identity
(),
(
oldValue
,
newValue
)
->
newValue
// 遇到重复时使用新值
));
}
List
<
Fortune
>
fortuneList
=
new
ArrayList
<>();
for
(
FortuneAddRequest
fortuneAddRequest
:
fortuneAddRequestList
)
{
// 校验参数
valiAddFortune
(
fortuneAddRequest
);
Fortune
fortune
=
new
Fortune
();
BeanUtil
.
copyProperties
(
fortuneAddRequest
,
fortune
);
if
(
"R"
.
equals
(
fortuneAddRequest
.
getFortuneBizType
()))
{
ExpectedFortune
expectedFortune
=
expectedFortuneMap
.
get
(
fortuneAddRequest
.
getPolicyNo
()
+
"_"
+
fortuneAddRequest
.
getFortunePeriod
()
+
"_"
+
fortuneAddRequest
.
getFortuneType
());
if
(
expectedFortune
==
null
)
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
fortuneAddRequest
.
getFortuneName
()
+
" 预计出账不存在"
);
}
fortune
.
setExpectedFortuneBizId
(
expectedFortune
.
getExpectedFortuneBizId
());
fortune
.
setPolicyCurrency
(
expectedFortune
.
getPolicyCurrency
());
fortune
.
setExchangeRate
(
expectedFortune
.
getDefaultExchangeRate
());
fortune
.
setHkdAmount
(
fortuneAddRequest
.
getAmount
().
multiply
(
expectedFortune
.
getDefaultExchangeRate
()));
fortune
.
setCurrentPaymentHkdAmount
(
fortune
.
getHkdAmount
());
fortune
.
setCurrentPaymentRatio
(
BigDecimal
.
valueOf
(
100
));
fortune
.
setPayoutDate
(
expectedFortune
.
getPayoutDate
());
// 关联来佣业务ID
String
key
=
commissionService
.
buildPolicyPeriodKey
(
expectedFortune
.
getPolicyNo
(),
expectedFortune
.
getFortunePeriod
());
Commission
matchedCommission
=
commissionByPolicyPeriod
.
get
(
key
);
if
(
matchedCommission
!=
null
)
{
fortune
.
setCommissionBizId
(
matchedCommission
.
getCommissionBizId
());
fortune
.
setCommissionExpectedBizId
(
matchedCommission
.
getCommissionExpectedBizId
());
}
else
{
fortune
.
setStatus
(
FortuneStatusEnum
.
MATCH_FAIL
.
getItemValue
());
fortune
.
setRemark
(
"未找到当前预计发佣对应的来佣"
);
}
}
else
{
fortune
.
setExchangeRate
(
queryDefaultExchangeRate
(
fortuneAddRequest
.
getCurrency
()));
fortune
.
setHkdAmount
(
fortuneAddRequest
.
getAmount
().
multiply
(
fortune
.
getExchangeRate
()));
fortune
.
setCurrentPaymentHkdAmount
(
fortune
.
getHkdAmount
());
}
// 生成发佣业务ID
fortune
.
setFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_FORTUNE
.
getCode
()));
fortune
.
setStatus
(
FortuneStatusEnum
.
WAIT
.
getItemValue
());
fortune
.
setCurrentPaymentAmount
(
fortuneAddRequest
.
getAmount
());
fortune
.
setFortuneName
(
queryByDict
(
fortuneAddRequest
.
getFortuneType
()));
fortune
.
setActualPayoutDate
(
fortuneAddRequest
.
getPayoutDate
());
fortune
.
setIsPart
(
0
);
fortune
.
setStatus
(
FortuneStatusEnum
.
CAN_SEND
.
getItemValue
());
fortuneList
.
add
(
fortune
);
}
return
this
.
saveBatch
(
fortuneList
);
...
...
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