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
8868d149
Commit
8868d149
authored
Jul 10, 2026
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
出账检核页面统计数据错误
parent
de226113
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
101 additions
and
64 deletions
+101
-64
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/ExpectedFortuneServiceImpl.java
+29
-2
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
+51
-58
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 @
8868d149
...
...
@@ -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 @
8868d149
...
...
@@ -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 @
8868d149
...
...
@@ -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 @
8868d149
...
...
@@ -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/ExpectedFortuneServiceImpl.java
View file @
8868d149
...
...
@@ -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 @
8868d149
...
...
@@ -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
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/PolicyFollowServiceImpl.java
View file @
8868d149
...
...
@@ -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 @
8868d149
...
...
@@ -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