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
af188164
Commit
af188164
authored
Jul 10, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev' into prod
parents
8faa5287
49a2a946
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
168 additions
and
103 deletions
+168
-103
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
+4
-2
yd-csf-service/src/main/java/com/yd/csf/service/model/Policy.java
+5
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/FortuneService.java
+1
-1
yd-csf-service/src/main/java/com/yd/csf/service/service/IExpectedFortuneService.java
+3
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
+62
-29
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/ExpectedFortuneServiceImpl.java
+29
-2
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
+56
-68
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/PolicyFollowServiceImpl.java
+6
-0
yd-csf-service/src/main/resources/mappers/PolicyMapper.xml
+2
-1
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
View file @
af188164
...
...
@@ -522,7 +522,7 @@ public class ApiFortuneController {
// 查询统计数据
List
<
Fortune
>
fortuneList
=
fortuneService
.
list
(
queryWrapper
);
FortuneStatisticsVO
statisticsVO
=
fortuneService
.
getFortuneStatistics
(
fortuneList
.
stream
().
map
(
Fortune:
:
getId
).
collect
(
Collectors
.
toList
())
);
FortuneStatisticsVO
statisticsVO
=
fortuneService
.
getFortuneStatistics
(
fortuneList
);
// 组装返回结果
FortunePageResponse
response
=
new
FortunePageResponse
();
...
...
@@ -540,7 +540,9 @@ public class ApiFortuneController {
if
(
CollectionUtils
.
isEmpty
(
statisticsRequest
.
getFortuneIdList
()))
{
return
Result
.
fail
(
ErrorCode
.
PARAMS_ERROR
.
getCode
(),
"fortuneId列表不能为空"
);
}
return
Result
.
success
(
fortuneService
.
getFortuneStatistics
(
statisticsRequest
.
getFortuneIdList
()));
List
<
Fortune
>
fortuneList
=
fortuneService
.
listByIds
(
statisticsRequest
.
getFortuneIdList
());
// 计算统计数据
return
Result
.
success
(
fortuneService
.
getFortuneStatistics
(
fortuneList
));
}
/**
...
...
yd-csf-service/src/main/java/com/yd/csf/service/model/Policy.java
View file @
af188164
...
...
@@ -120,6 +120,11 @@ public class Policy implements Serializable {
private
BigDecimal
totalPaymentPremium
;
/**
* 总保费(HKD)
*/
private
BigDecimal
totalPaymentPremiumHkd
;
/**
* 保单状态
*/
private
String
status
;
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/FortuneService.java
View file @
af188164
...
...
@@ -37,7 +37,7 @@ public interface FortuneService extends IService<Fortune> {
Fortune
queryOne
(
String
fortuneBizId
);
FortuneStatisticsVO
getFortuneStatistics
(
List
<
Long
>
fortuneId
List
);
FortuneStatisticsVO
getFortuneStatistics
(
List
<
Fortune
>
fortune
List
);
Boolean
addFortuneBatch
(
List
<
FortuneAddRequest
>
fortuneAddRequestList
);
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/IExpectedFortuneService.java
View file @
af188164
...
...
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import
com.yd.csf.service.vo.ExpectedFortuneStatisticsVO
;
import
com.yd.csf.service.vo.PayableReportVO
;
import
java.math.BigDecimal
;
import
java.util.List
;
/**
...
...
@@ -87,4 +88,6 @@ public interface IExpectedFortuneService extends IService<ExpectedFortune> {
* @return 全部列表数据
*/
List
<
ApiExpectedFortunePageResponse
>
queryListAll
(
QueryWrapper
<
ExpectedFortune
>
queryWrapper
);
BigDecimal
queryExchangeRateByFeign
(
String
sourceCurrency
,
String
targetCurrency
);
}
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
View file @
af188164
...
...
@@ -620,6 +620,18 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"未找到对应的来佣记录,请先创建来佣记录"
);
}
// 获取所有检核年月
Set
<
String
>
reconciliationYearMonthSet
=
commissions
.
stream
()
.
map
(
Commission:
:
getReconciliationYearMonth
)
.
collect
(
Collectors
.
toSet
());
// 校验检核年月是否一致
if
(
reconciliationYearMonthSet
.
size
()
!=
1
)
{
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"请选择相同的检核年月"
);
}
// 本次检核年月
String
reconciliationYearMonth
=
reconciliationYearMonthSet
.
iterator
().
next
();
for
(
Commission
commission
:
commissions
)
{
if
(
"U"
.
equals
(
commission
.
getCommissionBizType
()))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"非关联保单应收单,不能点击生成可出账记录"
);
...
...
@@ -638,11 +650,16 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
List
<
ExpectedFortune
>
expectedFortuneList
=
iExpectedFortuneService
.
lambdaQuery
()
.
in
(
ExpectedFortune:
:
getPolicyNo
,
policyNoSet
)
.
list
();
// 1.2 根据期数筛选符合的预计发佣记录
Set
<
Integer
>
commissionPeriodSet
=
commissions
.
stream
().
map
(
Commission:
:
getCommissionPeriod
).
collect
(
Collectors
.
toSet
());
// 1.2 构建保单号+佣金期数的快速查找集合
Set
<
String
>
commissionKeySet
=
commissions
.
stream
()
.
map
(
c
->
c
.
getPolicyNo
()
+
"_"
+
c
.
getCommissionPeriod
())
.
collect
(
Collectors
.
toSet
());
// 1.3 根据保单号+佣金期数筛选符合的预计发佣记录
List
<
ExpectedFortune
>
filteredExpectedFortuneList1
=
new
ArrayList
<>();
for
(
ExpectedFortune
expectedFortune
:
expectedFortuneList
)
{
if
(
commission
PeriodSet
.
contains
(
expectedFortune
.
getFortunePeriod
()))
{
if
(
commission
KeySet
.
contains
(
expectedFortune
.
getPolicyNo
()
+
"_"
+
expectedFortune
.
getFortunePeriod
()))
{
filteredExpectedFortuneList1
.
add
(
expectedFortune
);
}
}
...
...
@@ -650,38 +667,53 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"未找到保单对应的预计发佣记录,请先创建预计发佣记录"
);
}
// 2. 根据本次
发佣期数,删除未出账的
记录
// 2. 根据本次
涉及的预计发佣记录,查询相关的 fortune
记录
List
<
Fortune
>
fortuneList
=
fortuneService
.
lambdaQuery
()
.
in
(
Fortune:
:
getStatus
,
FortuneStatusEnum
.
CAN_SEND
.
getItemValue
(),
FortuneStatusEnum
.
WAIT
.
getItemValue
())
.
in
(
Fortune:
:
getExpectedFortuneBizId
,
filteredExpectedFortuneList1
.
stream
().
map
(
ExpectedFortune:
:
getExpectedFortuneBizId
).
collect
(
Collectors
.
toList
()))
.
list
();
// 2.1 对 fortune 记录进行分类,已出账、已分期、手动加的记录不能删除,其他记录删除后根据预计发佣记录重新生成
List
<
Fortune
>
deleteList
=
new
ArrayList
<>();
List
<
Fortune
>
keepList
=
new
ArrayList
<>();
for
(
Fortune
fortune
:
fortuneList
)
{
if
(
FortuneStatusEnum
.
SENT
.
getItemValue
().
equals
(
fortune
.
getStatus
())
||
!
"系统生成"
.
equals
(
fortune
.
getReconciliationOperator
())
||
1
==
fortune
.
getIsPart
())
{
keepList
.
add
(
fortune
);
}
else
{
deleteList
.
add
(
fortune
);
}
}
// 2.1 物理删除
if
(
CollectionUtils
.
isNotEmpty
(
fortun
eList
))
{
fortuneService
.
removeByIdsPhysical
(
fortun
eList
.
stream
().
map
(
Fortune:
:
getId
).
collect
(
Collectors
.
toList
()));
if
(
CollectionUtils
.
isNotEmpty
(
delet
eList
))
{
fortuneService
.
removeByIdsPhysical
(
delet
eList
.
stream
().
map
(
Fortune:
:
getId
).
collect
(
Collectors
.
toList
()));
}
// 2.2 筛选出未出账的记录
// 2.2 keepList 的记录,不重新生成
Set
<
String
>
keepExpectedFortuneBizIdSet
=
keepList
.
stream
().
map
(
Fortune:
:
getExpectedFortuneBizId
).
collect
(
Collectors
.
toSet
());
// 2.3 筛选出需要重新生成的记录
List
<
ExpectedFortune
>
filteredExpectedFortuneList2
=
new
ArrayList
<>();
for
(
ExpectedFortune
expectedFortune
:
filteredExpectedFortuneList1
)
{
// 如果
有已出账
记录,跳过
if
(
FortuneStatusEnum
.
SENT
.
getItemValue
().
equals
(
expectedFortune
.
getStatus
()))
{
// 如果
是 keep
记录,跳过
if
(
keepExpectedFortuneBizIdSet
.
contains
(
expectedFortune
.
getExpectedFortuneBizId
()))
{
continue
;
}
filteredExpectedFortuneList2
.
add
(
expectedFortune
);
}
// 2.
3
校验预计发佣记录是否有出账币种、默认结算汇率
// 2.
4
校验预计发佣记录是否有出账币种、默认结算汇率
for
(
ExpectedFortune
expectedFortune
:
filteredExpectedFortuneList2
)
{
if
(
StringUtils
.
isBlank
(
expectedFortune
.
getRuleCurrency
()))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"预计发佣记录"
+
expectedFortune
.
getExpectedFortuneBizId
()
+
"未配置保单币种"
);
}
}
// 2.
4
根据保单号、期数查询入账检核汇率
Map
<
String
,
BigDecimal
>
exchangeRateMap
=
this
.
queryCommissionExchangeRateMap
(
policyNoSet
,
commissionPeriodSet
);
// 2.
5
根据保单号、期数查询入账检核汇率
Map
<
String
,
BigDecimal
>
exchangeRateMap
=
this
.
queryCommissionExchangeRateMap
(
commissions
);
// 3. 构建实际的初始发佣记录(使用入账检核汇率)
List
<
Fortune
>
newFortuneList
=
buildNewFortunes
(
filteredExpectedFortuneList2
,
commissions
,
exchangeRateMap
);
List
<
Fortune
>
newFortuneList
=
buildNewFortunes
(
filteredExpectedFortuneList2
,
commissions
,
exchangeRateMap
,
reconciliationYearMonth
);
// 4. 保存发佣记录
saveNewFortunes
(
newFortuneList
);
...
...
@@ -689,18 +721,15 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
return
true
;
}
private
Map
<
String
,
BigDecimal
>
queryCommissionExchangeRateMap
(
Set
<
String
>
policyNoSet
,
Set
<
Integer
>
commissionPeriodSet
)
{
if
(
CollectionUtils
.
isEmpty
(
policyNoSet
)
||
CollectionUtils
.
isEmpty
(
commissionPeriodSet
))
{
private
Map
<
String
,
BigDecimal
>
queryCommissionExchangeRateMap
(
List
<
Commission
>
commissions
)
{
if
(
CollectionUtils
.
isEmpty
(
commissions
))
{
return
new
HashMap
<>();
}
// 1. 查询所有符合条件的记录,按入账日期降序排序
List
<
Commission
>
commissionExchangeRateList
=
this
.
lambdaQuery
()
.
in
(
Commission:
:
getPolicyNo
,
policyNoSet
)
.
in
(
Commission:
:
getCommissionPeriod
,
commissionPeriodSet
)
.
select
(
Commission:
:
getPolicyNo
,
Commission:
:
getCommissionPeriod
,
Commission:
:
getExchangeRate
,
Commission:
:
getCommissionDate
)
.
orderByDesc
(
Commission:
:
getId
)
.
list
();
// 1. 按入账日期降序排序
List
<
Commission
>
commissionExchangeRateList
=
commissions
.
stream
()
.
sorted
(
Comparator
.
comparing
(
Commission:
:
getCommissionDate
).
reversed
())
.
collect
(
Collectors
.
toList
());
// 2. 按 policyNo + commissionPeriod 分组,取每组的第一条(最新的)
Map
<
String
,
BigDecimal
>
exchangeRateMap
=
commissionExchangeRateList
.
stream
()
...
...
@@ -715,11 +744,9 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
// 3. 确保所有 policyNo + commissionPeriod 组合都在 Map 中,没有记录的设为 null
Map
<
String
,
BigDecimal
>
result
=
new
HashMap
<>();
for
(
String
policyNo
:
policyNoSet
)
{
for
(
Integer
commissionPeriod
:
commissionPeriodSet
)
{
String
key
=
buildPolicyPeriodKey
(
policyNo
,
commissionPeriod
);
result
.
put
(
key
,
exchangeRateMap
.
getOrDefault
(
key
,
null
));
}
for
(
Commission
commission
:
commissions
)
{
String
key
=
buildPolicyPeriodKey
(
commission
.
getPolicyNo
(),
commission
.
getCommissionPeriod
());
result
.
put
(
key
,
exchangeRateMap
.
getOrDefault
(
key
,
null
));
}
return
result
;
...
...
@@ -744,7 +771,8 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
*/
private
List
<
Fortune
>
buildNewFortunes
(
List
<
ExpectedFortune
>
expectedFortuneList
,
List
<
Commission
>
commissionList
,
Map
<
String
,
BigDecimal
>
exchangeRateMap
)
{
Map
<
String
,
BigDecimal
>
exchangeRateMap
,
String
reconciliationYearMonth
)
{
if
(
CollectionUtils
.
isEmpty
(
expectedFortuneList
))
{
return
new
ArrayList
<>();
}
...
...
@@ -778,6 +806,7 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
fortune
.
setFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_FORTUNE
.
getCode
()));
fortune
.
setId
(
null
);
fortune
.
setFortuneBizType
(
"R"
);
fortune
.
setReconciliationYearMonth
(
reconciliationYearMonth
);
// 优先使用入账检核汇率,如果没有则使用默认汇率
String
key
=
buildPolicyPeriodKey
(
expectedFortune
.
getPolicyNo
(),
expectedFortune
.
getFortunePeriod
());
...
...
@@ -1104,6 +1133,10 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
if
(
StringUtils
.
isBlank
(
request
.
getCommissionType
()))
{
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"入账项目类型不能为空"
);
}
// 检核年月不能为空
if
(
StringUtils
.
isBlank
(
request
.
getReconciliationYearMonth
()))
{
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"检核年月不能为空"
);
}
// commissionType 只能是数字
if
(!
StringUtils
.
isNumeric
(
request
.
getCommissionType
()))
{
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"入账项目类型只能是字典值"
);
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/ExpectedFortuneServiceImpl.java
View file @
af188164
...
...
@@ -5,10 +5,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yd.base.feign.client.exchangerate.ApiExchangeRateFeignClient
;
import
com.yd.common.enums.ResultCode
;
import
com.yd.common.exception.BusinessException
;
import
com.yd.common.result.Result
;
import
com.yd.csf.feign.request.expectedfortune.ApiExpectedFortunePageRequest
;
import
com.yd.csf.feign.response.expectedfortune.ApiExpectedFortunePageResponse
;
import
com.yd.csf.service.dto.UserGradeDto
;
import
com.yd.csf.service.enums.CurrencyEnum
;
import
com.yd.csf.service.enums.FortuneTypeEnum
;
import
com.yd.csf.service.model.ExpectedFortune
;
import
com.yd.csf.service.dao.ExpectedFortuneMapper
;
...
...
@@ -24,7 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.
time.LocalDate
;
import
java.
math.BigDecimal
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -53,6 +56,9 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
@Autowired
private
IAgentAccumulatedFycService
iAgentAccumulatedFycService
;
@Resource
private
ApiExchangeRateFeignClient
apiExchangeRateFeignClient
;
@Override
public
IPage
<
ApiExpectedFortunePageResponse
>
page
(
Page
<
ApiExpectedFortunePageResponse
>
page
,
ApiExpectedFortunePageRequest
request
)
{
...
...
@@ -388,4 +394,25 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
return
records
;
}
/**
* 查询币对的默认汇率
*
* @param sourceCurrency 源币种
* @param targetCurrency 目标币种
* @return 汇率
*/
@Override
public
BigDecimal
queryExchangeRateByFeign
(
String
sourceCurrency
,
String
targetCurrency
)
{
if
(
sourceCurrency
.
equalsIgnoreCase
(
targetCurrency
))
{
return
BigDecimal
.
ONE
;
}
// 调用Feign客户端查询汇率
Result
<
BigDecimal
>
result
=
apiExchangeRateFeignClient
.
getExchangeRate
(
sourceCurrency
,
targetCurrency
,
""
);
if
(
result
!=
null
&&
result
.
getData
()
!=
null
)
{
return
result
.
getData
();
}
else
{
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"查询币对的默认汇率失败, 币种:"
+
sourceCurrency
+
" -> "
+
targetCurrency
);
}
}
}
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
View file @
af188164
...
...
@@ -698,73 +698,66 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
}
@Override
public
FortuneStatisticsVO
getFortuneStatistics
(
List
<
Long
>
fortuneIdList
)
{
if
(
CollectionUtils
.
isEmpty
(
fortuneIdList
))
{
FortuneStatisticsVO
fortuneStatisticsVO
=
new
FortuneStatisticsVO
();
fortuneStatisticsVO
.
setTotalInAmount
(
BigDecimal
.
ZERO
);
fortuneStatisticsVO
.
setTotalPolicyCount
(
0L
);
fortuneStatisticsVO
.
setTotalPremium
(
BigDecimal
.
ZERO
);
fortuneStatisticsVO
.
setPendingOutAmount
(
BigDecimal
.
ZERO
);
fortuneStatisticsVO
.
setAvailableOutAmount
(
BigDecimal
.
ZERO
);
public
FortuneStatisticsVO
getFortuneStatistics
(
List
<
Fortune
>
fortuneList
)
{
// 初始化默认值
FortuneStatisticsVO
fortuneStatisticsVO
=
new
FortuneStatisticsVO
();
fortuneStatisticsVO
.
setTotalInAmount
(
BigDecimal
.
ZERO
);
fortuneStatisticsVO
.
setTotalPolicyCount
(
0L
);
fortuneStatisticsVO
.
setTotalPremium
(
BigDecimal
.
ZERO
);
fortuneStatisticsVO
.
setPendingOutAmount
(
BigDecimal
.
ZERO
);
fortuneStatisticsVO
.
setAvailableOutAmount
(
BigDecimal
.
ZERO
);
if
(
CollectionUtils
.
isEmpty
(
fortuneList
))
{
return
fortuneStatisticsVO
;
}
// 自定义查询
List
<
FortuneStatisticsVO
>
fortuneStatisticsList
=
this
.
baseMapper
.
getFortuneStatistics
(
fortuneIdList
);
// 查询结果
FortuneStatisticsVO
fortuneStatistics
;
if
(
CollectionUtils
.
isNotEmpty
(
fortuneStatisticsList
)
&&
fortuneStatisticsList
.
size
()
>
1
)
{
// 合并查询结果
FortuneStatisticsVO
noPolicyNoData
=
fortuneStatisticsList
.
get
(
0
);
FortuneStatisticsVO
policyNoData
=
fortuneStatisticsList
.
get
(
1
);
// 合并查询结果
fortuneStatistics
=
new
FortuneStatisticsVO
();
fortuneStatistics
.
setTotalInAmount
(
policyNoData
.
getTotalInAmount
());
fortuneStatistics
.
setTotalPolicyCount
(
policyNoData
.
getTotalPolicyCount
());
fortuneStatistics
.
setTotalPremium
(
policyNoData
.
getTotalPremium
());
fortuneStatistics
.
setPendingOutAmount
(
noPolicyNoData
.
getPendingOutAmount
().
add
(
policyNoData
.
getPendingOutAmount
()));
fortuneStatistics
.
setAvailableOutAmount
(
noPolicyNoData
.
getAvailableOutAmount
().
add
(
policyNoData
.
getAvailableOutAmount
()));
}
else
{
fortuneStatistics
=
fortuneStatisticsList
.
get
(
0
);
}
if
(
fortuneStatistics
.
getAvailableOutAmount
()
==
null
)
{
fortuneStatistics
.
setAvailableOutAmount
(
BigDecimal
.
ZERO
);
}
// 计算总保费、入账金额
if
(
CollectionUtils
.
isNotEmpty
(
fortuneIdList
))
{
List
<
Fortune
>
fortuneList
=
this
.
listByIds
(
fortuneIdList
);
// 计算总保单数
Set
<
String
>
policyNoSet
=
fortuneList
.
stream
().
map
(
Fortune:
:
getPolicyNo
).
collect
(
Collectors
.
toSet
());
fortuneStatisticsVO
.
setTotalPolicyCount
((
long
)
policyNoSet
.
size
());
Map
<
String
,
BigDecimal
>
exchangeRateMap
=
new
HashMap
<>();
for
(
Fortune
fortune
:
fortuneList
)
{
exchangeRateMap
.
put
(
fortune
.
getPolicyNo
(),
fortune
.
getExchangeRate
());
// 计算待出账、可出账金额
BigDecimal
pendingOutAmount
=
BigDecimal
.
ZERO
;
BigDecimal
availableOutAmount
=
BigDecimal
.
ZERO
;
for
(
Fortune
fortune
:
fortuneList
)
{
if
(
FortuneStatusEnum
.
WAIT
.
getItemValue
().
equals
(
fortune
.
getStatus
())
||
FortuneStatusEnum
.
CAN_SEND
.
getItemValue
().
equals
(
fortune
.
getStatus
()))
{
pendingOutAmount
=
pendingOutAmount
.
add
(
fortune
.
getCurrentPaymentHkdAmount
());
}
else
if
(
FortuneStatusEnum
.
CHECKED
.
getItemValue
().
equals
(
fortune
.
getStatus
()))
{
availableOutAmount
=
availableOutAmount
.
add
(
fortune
.
getCurrentPaymentHkdAmount
());
}
}
fortuneStatisticsVO
.
setPendingOutAmount
(
pendingOutAmount
);
fortuneStatisticsVO
.
setAvailableOutAmount
(
availableOutAmount
);
Set
<
String
>
policyNoSet
=
fortuneList
.
stream
().
map
(
Fortune:
:
getPolicyNo
).
collect
(
Collectors
.
toSet
());
// 查询总保费
List
<
Policy
>
policyList
=
policyService
.
lambdaQuery
().
in
(
Policy:
:
getPolicyNo
,
policyNoSet
).
list
();
BigDecimal
totalPremium
=
BigDecimal
.
ZERO
;
if
(
CollectionUtils
.
isNotEmpty
(
policyList
))
{
for
(
Policy
policy
:
policyList
)
{
BigDecimal
exchangeRate
=
exchangeRateMap
.
getOrDefault
(
policy
.
getPolicyNo
(),
BigDecimal
.
ONE
);
totalPremium
=
totalPremium
.
add
(
policy
.
getTotalPaymentPremium
().
multiply
(
exchangeRate
));
}
fortuneStatistics
.
setTotalPremium
(
totalPremium
);
// 计算总保费
List
<
Policy
>
policyList
=
policyService
.
lambdaQuery
().
in
(
Policy:
:
getPolicyNo
,
policyNoSet
).
list
();
BigDecimal
totalPremium
=
BigDecimal
.
ZERO
;
if
(
CollectionUtils
.
isNotEmpty
(
policyList
))
{
for
(
Policy
policy
:
policyList
)
{
totalPremium
=
totalPremium
.
add
(
policy
.
getTotalPaymentPremiumHkd
());
}
// 查询总入账金额
List
<
Commission
>
commissions
=
commissionService
.
lambdaQuery
()
.
in
(
Commission:
:
getPolicyNo
,
policyNoSet
)
.
select
(
Commission:
:
getHkdAmount
)
.
list
();
BigDecimal
totalInAmount
=
BigDecimal
.
ZERO
;
if
(
CollectionUtils
.
isNotEmpty
(
commissions
))
{
for
(
Commission
commission
:
commissions
)
{
totalInAmount
=
totalInAmount
.
add
(
commission
.
getHkdAmount
());
}
fortuneStatistics
.
setTotalInAmount
(
totalInAmount
);
}
fortuneStatisticsVO
.
setTotalPremium
(
totalPremium
);
// 根据保单号+佣金期数计算总入账金额
List
<
Commission
>
commissions
=
commissionService
.
lambdaQuery
()
.
in
(
Commission:
:
getPolicyNo
,
policyNoSet
)
.
select
(
Commission:
:
getHkdAmount
)
.
list
();
// 根据 fortuneList 的保单号+佣金期数,筛选对应的入账记录
Set
<
String
>
policyNoPeriodSet
=
new
HashSet
<>();
for
(
Fortune
fortune
:
fortuneList
)
{
policyNoPeriodSet
.
add
(
fortune
.
getPolicyNo
()+
"_"
+
fortune
.
getFortunePeriod
());
}
// 计算总入账金额
BigDecimal
totalInAmount
=
BigDecimal
.
ZERO
;
for
(
Commission
commission
:
commissions
)
{
if
(
policyNoPeriodSet
.
contains
(
commission
.
getPolicyNo
()
+
"_"
+
commission
.
getCommissionPeriod
()))
{
totalInAmount
=
totalInAmount
.
add
(
commission
.
getHkdAmount
());
}
}
fortuneStatisticsVO
.
setTotalInAmount
(
totalInAmount
);
return
fortuneStatistics
;
return
fortuneStatistics
VO
;
}
@Override
...
...
@@ -794,7 +787,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
.
list
()
.
stream
()
.
collect
(
Collectors
.
toMap
(
i
->
i
.
getPolicyNo
()
+
"_"
+
i
.
getFortunePeriod
()
+
"_"
+
i
.
getFortuneType
(),
i
->
i
.
getPolicyNo
()
+
"_"
+
i
.
getFortunePeriod
()
+
"_"
+
i
.
getFortuneType
()
+
"_"
+
i
.
getBrokerBizId
()
,
Function
.
identity
(),
(
oldValue
,
newValue
)
->
newValue
)
);
...
...
@@ -804,7 +797,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
if
(
CollectionUtils
.
isNotEmpty
(
commissionList
))
{
commissionByPolicyPeriod
=
commissionList
.
stream
()
.
collect
(
Collectors
.
toMap
(
commission
->
commission
Service
.
buildPolicyPeriodKey
(
commission
.
getPolicyNo
(),
commission
.
getCommissionPeriod
()
),
commission
->
commission
.
getPolicyNo
()
+
"_"
+
commission
.
getCommissionPeriod
(
),
Function
.
identity
(),
(
oldValue
,
newValue
)
->
newValue
// 遇到重复时使用新值
));
...
...
@@ -817,7 +810,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
String
realName
=
currentLoginUser
.
getRealName
();
List
<
Fortune
>
fortuneList
=
new
ArrayList
<>();
List
<
ExpectedFortune
>
expectedFortuneUpdateList
=
new
ArrayList
<>();
for
(
FortuneAddRequest
fortuneAddRequest
:
fortuneAddRequestList
)
{
// 校验参数
valiAddFortune
(
fortuneAddRequest
);
...
...
@@ -830,13 +823,12 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
String
fortuneName
=
queryByDict
(
fortuneAddRequest
.
getFortuneType
());
fortune
.
setFortuneName
(
fortuneName
);
if
(
"R"
.
equals
(
fortuneAddRequest
.
getFortuneBizType
()))
{
Policy
policy
=
policyMap
.
get
(
fortuneAddRequest
.
getPolicyNo
());
if
(
policy
==
null
)
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
fortuneAddRequest
.
getPolicyNo
()
+
" 保单号不存在"
);
}
ExpectedFortune
expectedFortune
=
expectedFortuneMap
.
get
(
fortuneAddRequest
.
getPolicyNo
()
+
"_"
+
fortuneAddRequest
.
getFortunePeriod
()
+
"_"
+
fortuneAddRequest
.
getFortuneType
());
ExpectedFortune
expectedFortune
=
expectedFortuneMap
.
get
(
fortuneAddRequest
.
getPolicyNo
()
+
"_"
+
fortuneAddRequest
.
getFortunePeriod
()
+
"_"
+
fortuneAddRequest
.
getFortuneType
()
+
"_"
+
fortuneAddRequest
.
getBrokerBizId
()
);
if
(
expectedFortune
==
null
)
{
// 同步新增预计出账
expectedFortune
=
createExpectedFortune
(
fortuneAddRequest
,
policy
,
fortuneName
);
...
...
@@ -864,7 +856,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
fortune
.
setPayoutDate
(
expectedFortune
.
getPayoutDate
());
// 关联来佣业务ID
String
key
=
commissionService
.
buildPolicyPeriodKey
(
expectedFortune
.
getPolicyNo
(),
expectedFortune
.
getFortunePeriod
()
);
String
key
=
fortune
.
getPolicyNo
()
+
"_"
+
fortune
.
getFortunePeriod
(
);
Commission
matchedCommission
=
commissionByPolicyPeriod
.
get
(
key
);
if
(
matchedCommission
!=
null
)
{
fortune
.
setCommissionBizId
(
matchedCommission
.
getCommissionBizId
());
...
...
@@ -896,10 +888,6 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
}
this
.
saveBatch
(
fortuneList
);
if
(
CollectionUtils
.
isNotEmpty
(
expectedFortuneUpdateList
))
{
expectedFortuneService
.
updateBatchById
(
expectedFortuneUpdateList
);
}
return
true
;
}
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/PolicyFollowServiceImpl.java
View file @
af188164
...
...
@@ -698,6 +698,7 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
policy
.
setCurrency
(
policyFollow
.
getPolicyCurrency
());
policy
.
setPaymentTerm
(
policyFollow
.
getIssueNumber
());
policy
.
setTotalPaymentPremium
(
calculateTotalPaymentPremium
(
policy
));
policy
.
setTotalPaymentPremiumHkd
(
calculateTotalPaymentPremiumHkd
(
policy
.
getCurrency
(),
policy
.
getTotalPaymentPremium
()));
policy
.
setUnderwritingDate
(
changePolicyFollowStatusRequest
.
getUnderwritingDate
());
policy
.
setEffectiveDate
(
changePolicyFollowStatusRequest
.
getEffectiveDate
());
//冷静期结束日期
...
...
@@ -733,6 +734,11 @@ public class PolicyFollowServiceImpl extends ServiceImpl<PolicyFollowMapper, Pol
return
true
;
}
private
BigDecimal
calculateTotalPaymentPremiumHkd
(
String
currency
,
BigDecimal
totalPaymentPremium
)
{
BigDecimal
originalToHkdRate
=
expectedFortuneService
.
queryExchangeRateByFeign
(
currency
,
"HKD"
);
return
totalPaymentPremium
.
multiply
(
originalToHkdRate
).
setScale
(
4
,
RoundingMode
.
HALF_UP
);
}
private
void
policyFollowChangeStatusValidPolicyFollow
(
PolicyFollow
policyFollow
)
{
if
(
ObjectUtils
.
isEmpty
(
policyFollow
.
getReconciliationCompanyBizId
()))
{
throw
new
BusinessException
(
"新单跟进-基础数据,reconciliationCompanyBizId 不能为空"
);
...
...
yd-csf-service/src/main/resources/mappers/PolicyMapper.xml
View file @
af188164
...
...
@@ -25,6 +25,7 @@
<result
property=
"paymentFrequency"
column=
"payment_frequency"
/>
<result
property=
"paymentPremium"
column=
"payment_premium"
/>
<result
property=
"totalPaymentPremium"
column=
"total_payment_premium"
/>
<result
property=
"totalPaymentPremiumHkd"
column=
"total_payment_premium_hkd"
/>
<result
property=
"status"
column=
"status"
/>
<result
property=
"currency"
column=
"currency"
/>
<result
property=
"initialPremium"
column=
"initial_premium"
/>
...
...
@@ -58,7 +59,7 @@
<sql
id=
"Base_Column_List"
>
id,policy_biz_id,policy_no,user_biz_id,product_launch_biz_id,product_code,
product_name,product_cate,insurance_company,insurance_company_biz_id,region,
policy_holder,policy_holder_age,insured,guarantee_period,sum_insured,payment_term,payment_frequency,payment_premium,total_payment_premium,
policy_holder,policy_holder_age,insured,guarantee_period,sum_insured,payment_term,payment_frequency,payment_premium,total_payment_premium,
total_payment_premium_hkd,
status,currency,initial_premium,sign_date,issue_date,
effective_date,cooling_off_end_date,cooling_off_days,renewal_date,is_prepaid,deductibles,prepaid_term,
initial_payment_method,renewal_payment_method,dividend_distribution_method,is_backtrack,is_join,
...
...
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