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
29d4f5ce
Commit
29d4f5ce
authored
Mar 02, 2026
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新单跟进同步预约信息4
parent
8c4ee699
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
155 additions
and
8 deletions
+155
-8
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionExpectedServiceImpl.java
+155
-8
No files found.
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionExpectedServiceImpl.java
View file @
29d4f5ce
...
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
...
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.yd.base.feign.client.exchangerate.ApiExchangeRateFeignClient
;
import
com.yd.base.feign.client.exchangerate.ApiExchangeRateFeignClient
;
import
com.yd.common.constant.CommonConstant
;
import
com.yd.common.constant.CommonConstant
;
import
com.yd.common.constant.RedisConstants
;
import
com.yd.common.constant.RedisConstants
;
...
@@ -41,6 +43,7 @@ import org.springframework.stereotype.Service;
...
@@ -41,6 +43,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.math.RoundingMode
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
...
@@ -77,6 +80,9 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
...
@@ -77,6 +80,9 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
@Resource
@Resource
private
ApiExchangeRateFeignClient
apiExchangeRateFeignClient
;
private
ApiExchangeRateFeignClient
apiExchangeRateFeignClient
;
// 用于对象转换的ObjectMapper
private
static
final
ObjectMapper
objectMapper
=
new
ObjectMapper
();
@Override
@Override
public
Page
<
CommissionExpectedVO
>
getCommissionExpectedVOPage
(
Page
<
CommissionExpected
>
commissionExpectedPage
)
{
public
Page
<
CommissionExpectedVO
>
getCommissionExpectedVOPage
(
Page
<
CommissionExpected
>
commissionExpectedPage
)
{
...
@@ -481,6 +487,10 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
...
@@ -481,6 +487,10 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
if
(
paymentPremium
==
null
)
{
if
(
paymentPremium
==
null
)
{
throw
new
BusinessException
(
"保费不能为空"
);
throw
new
BusinessException
(
"保费不能为空"
);
}
}
Integer
policyHolderAge
=
policy
.
getPolicyHolderAge
();
if
(
policyHolderAge
==
null
)
{
throw
new
BusinessException
(
"保單持有人年齡不能为空"
);
}
Date
effectiveDate
=
policy
.
getEffectiveDate
();
Date
effectiveDate
=
policy
.
getEffectiveDate
();
if
(
effectiveDate
==
null
)
{
if
(
effectiveDate
==
null
)
{
throw
new
BusinessException
(
"保单生效日期不能为空"
);
throw
new
BusinessException
(
"保单生效日期不能为空"
);
...
@@ -501,22 +511,25 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
...
@@ -501,22 +511,25 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
List
<
CommissionExpected
>
commissionExpectedList
=
new
ArrayList
<>();
List
<
CommissionExpected
>
commissionExpectedList
=
new
ArrayList
<>();
if
(
CollUtil
.
isNotEmpty
(
expectedSpeciesList
))
{
if
(
CollUtil
.
isNotEmpty
(
expectedSpeciesList
))
{
//
根据供款年期匹配规格
//
匹配规格并获取不匹配的条件
List
<
ApiExpectedSpeciesListResponse
>
collect
=
expectedSpeciesList
.
stream
()
MatchResult
matchResult
=
matchExpectedSpecies
(
.
filter
(
i
->
paymentTerm
.
equals
(
i
.
getPaymentTerm
()))
expectedSpeciesList
,
paymentTerm
,
reconciliationCompanyBizId
,
.
collect
(
Collectors
.
toList
()
);
policyHolderAge
,
paymentPremium
);
if
(
ObjectUtils
.
isEmpty
(
collect
))
{
if
(
matchResult
.
getMatchedList
().
isEmpty
())
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"未查询到对应供款年期的佣金规格"
);
String
errorMsg
=
matchResult
.
getUnmatchedConditions
().
isEmpty
()
?
"未查询到对应供款年期的佣金规格"
:
"未查询到对应供款年期的佣金规格,不匹配条件:"
+
String
.
join
(
"、"
,
matchResult
.
getUnmatchedConditions
());
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
errorMsg
);
}
}
// 计算佣金总期数 list 中 endPeriod最大值
// 计算佣金总期数 list 中 endPeriod最大值
Integer
maxEndPeriod
=
collect
.
stream
()
Integer
maxEndPeriod
=
matchResult
.
getMatchedList
()
.
stream
()
.
map
(
item
->
Convert
.
toInt
(
item
.
getEndPeriod
()))
.
map
(
item
->
Convert
.
toInt
(
item
.
getEndPeriod
()))
.
max
(
Integer:
:
compareTo
)
.
max
(
Integer:
:
compareTo
)
.
orElse
(
0
);
.
orElse
(
0
);
for
(
ApiExpectedSpeciesListResponse
item
:
collect
)
{
for
(
ApiExpectedSpeciesListResponse
item
:
matchResult
.
getMatchedList
()
)
{
CommissionExpected
commissionExpected
=
new
CommissionExpected
();
CommissionExpected
commissionExpected
=
new
CommissionExpected
();
commissionExpected
.
setCommissionExpectedBizId
(
RandomStringGenerator
.
generateBizId16
(
"commission_expected"
));
commissionExpected
.
setCommissionExpectedBizId
(
RandomStringGenerator
.
generateBizId16
(
"commission_expected"
));
commissionExpected
.
setReceivableNo
(
receivableService
.
generateReceivableNo
(
"R"
,
reconciliationCompanyCode
,
reconciliationCompany
));
commissionExpected
.
setReceivableNo
(
receivableService
.
generateReceivableNo
(
"R"
,
reconciliationCompanyCode
,
reconciliationCompany
));
...
@@ -565,6 +578,140 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
...
@@ -565,6 +578,140 @@ public class CommissionExpectedServiceImpl extends ServiceImpl<CommissionExpecte
}
}
}
}
/**
* 匹配规格结果内部类
*/
private
static
class
MatchResult
{
private
List
<
ApiExpectedSpeciesListResponse
>
matchedList
;
private
List
<
String
>
unmatchedConditions
;
public
MatchResult
(
List
<
ApiExpectedSpeciesListResponse
>
matchedList
,
List
<
String
>
unmatchedConditions
)
{
this
.
matchedList
=
matchedList
;
this
.
unmatchedConditions
=
unmatchedConditions
;
}
public
List
<
ApiExpectedSpeciesListResponse
>
getMatchedList
()
{
return
matchedList
;
}
public
List
<
String
>
getUnmatchedConditions
()
{
return
unmatchedConditions
;
}
}
/**
* 匹配预计规格并返回不匹配的条件
*
* @param expectedSpeciesList 预计规格列表
* @param paymentTerm 供款年期
* @param reconciliationCompanyId 对账公司ID
* @param policyHolderAge 保单持有人年龄
* @param paymentPremium 年缴保费
* @return 匹配结果
*/
private
MatchResult
matchExpectedSpecies
(
List
<
ApiExpectedSpeciesListResponse
>
expectedSpeciesList
,
String
paymentTerm
,
String
reconciliationCompanyId
,
Integer
policyHolderAge
,
BigDecimal
paymentPremium
)
{
List
<
String
>
unmatchedConditions
=
new
ArrayList
<>();
List
<
ApiExpectedSpeciesListResponse
>
currentList
=
expectedSpeciesList
;
// 检查供款年期
currentList
=
filterAndCheck
(
currentList
,
i
->
paymentTerm
.
equals
(
i
.
getPaymentTerm
()),
unmatchedConditions
,
"供款年期["
+
paymentTerm
+
"]"
);
if
(
unmatchedConditions
.
size
()
>
0
)
{
return
new
MatchResult
(
Collections
.
emptyList
(),
unmatchedConditions
);
}
// 检查对账公司
currentList
=
filterAndCheck
(
currentList
,
i
->
reconciliationCompanyId
.
equals
(
i
.
getReconciliationCompany
()),
unmatchedConditions
,
"对账公司["
+
reconciliationCompanyId
+
"]"
);
if
(
unmatchedConditions
.
size
()
>
0
)
{
return
new
MatchResult
(
Collections
.
emptyList
(),
unmatchedConditions
);
}
// 检查年龄
currentList
=
filterAndCheck
(
currentList
,
i
->
containsValue
(
i
.
getSpeciesJson
(),
"AGE"
,
Convert
.
toStr
(
policyHolderAge
)),
unmatchedConditions
,
"年龄["
+
policyHolderAge
+
"]"
);
if
(
unmatchedConditions
.
size
()
>
0
)
{
return
new
MatchResult
(
Collections
.
emptyList
(),
unmatchedConditions
);
}
// 检查保费
currentList
=
filterAndCheck
(
currentList
,
i
->
containsValue
(
i
.
getSpeciesJson
(),
"PREMIUM"
,
Convert
.
toStr
(
paymentPremium
)),
unmatchedConditions
,
"保费["
+
paymentPremium
+
"]"
);
return
new
MatchResult
(
currentList
,
unmatchedConditions
);
}
/**
* 过滤列表并检查是否为空
*
* @param list 待过滤的列表
* @param predicate 过滤条件
* @param unmatchedConditions 不匹配条件列表
* @param conditionDesc 条件描述
* @return 过滤后的列表
*/
private
List
<
ApiExpectedSpeciesListResponse
>
filterAndCheck
(
List
<
ApiExpectedSpeciesListResponse
>
list
,
java
.
util
.
function
.
Predicate
<
ApiExpectedSpeciesListResponse
>
predicate
,
List
<
String
>
unmatchedConditions
,
String
conditionDesc
)
{
List
<
ApiExpectedSpeciesListResponse
>
filtered
=
list
.
stream
()
.
filter
(
predicate
)
.
collect
(
Collectors
.
toList
());
if
(
filtered
.
isEmpty
())
{
unmatchedConditions
.
add
(
conditionDesc
);
}
return
filtered
;
}
private
static
boolean
containsValue
(
String
json
,
String
targetKey
,
String
targetValue
)
{
if
(
json
==
null
||
json
.
trim
().
isEmpty
())
return
false
;
try
{
List
<
Map
<
String
,
Object
>>
params
=
objectMapper
.
readValue
(
json
,
new
TypeReference
<
List
<
Map
<
String
,
Object
>>>()
{});
// AGE 和 PREMIUM 使用最小值匹配(targetValue >= value)
if
(
targetKey
.
equals
(
"AGE"
)
||
targetKey
.
equals
(
"PREMIUM"
))
{
return
params
.
stream
().
anyMatch
(
p
->
{
Object
value
=
p
.
get
(
"value"
);
if
(
value
==
null
)
{
return
false
;
}
// 转换为 BigDecimal
BigDecimal
threshold
;
if
(
value
instanceof
BigDecimal
)
{
threshold
=
(
BigDecimal
)
value
;
}
else
if
(
value
instanceof
Number
)
{
threshold
=
BigDecimal
.
valueOf
(((
Number
)
value
).
doubleValue
());
}
else
if
(
value
instanceof
String
)
{
try
{
threshold
=
new
BigDecimal
((
String
)
value
);
}
catch
(
NumberFormatException
e
)
{
return
false
;
}
}
else
{
return
false
;
}
// 判断是否大于等于最小值
return
new
BigDecimal
(
targetValue
).
compareTo
(
threshold
)
>=
0
;
});
}
// 其他字段使用等于匹配
else
{
return
params
.
stream
().
anyMatch
(
p
->
targetValue
.
equals
(
p
.
get
(
"value"
)));
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
@Override
@Override
public
List
<
ApiExpectedSpeciesListResponse
>
queryExpectedSpeciesByFeign
(
String
productLaunchBizId
)
{
public
List
<
ApiExpectedSpeciesListResponse
>
queryExpectedSpeciesByFeign
(
String
productLaunchBizId
)
{
ApiExpectedSpeciesListRequest
apiExpectedSpeciesListRequest
=
new
ApiExpectedSpeciesListRequest
();
ApiExpectedSpeciesListRequest
apiExpectedSpeciesListRequest
=
new
ApiExpectedSpeciesListRequest
();
...
...
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