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
6fe34a9b
Commit
6fe34a9b
authored
May 13, 2026
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
出账检核-增加币种42
parent
dd60f236
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
71 deletions
+172
-71
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
+16
-35
yd-csf-service/src/main/java/com/yd/csf/service/enums/FortuneTypeEnum.java
+42
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/IExpectedFortuneService.java
+4
-5
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
+87
-12
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/ExpectedFortuneServiceImpl.java
+16
-14
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
+7
-5
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
View file @
6fe34a9b
...
...
@@ -33,6 +33,7 @@ import com.yd.csf.service.dto.QueryPolicyBrokerDto;
import
com.yd.csf.service.dto.UserGradeDto
;
import
com.yd.csf.service.enums.CurrencyEnum
;
import
com.yd.csf.service.enums.FortuneStatusEnum
;
import
com.yd.csf.service.enums.FortuneTypeEnum
;
import
com.yd.csf.service.helper.FeignResultHelper
;
import
com.yd.csf.service.model.*
;
import
com.yd.csf.service.service.*
;
...
...
@@ -685,7 +686,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
ExpectedFortune
updateObj
=
new
ExpectedFortune
();
updateObj
.
setId
(
expectedFortune
.
getId
());
updateObj
.
setPayableNo
(
this
.
createPayableNo
(
"R"
,
expectedFortune
.
getPayoutDate
(),
policyNo
,
expectedFortune
.
getFortunePerio
d
()));
updateObj
.
setPayableNo
(
iExpectedFortuneService
.
getPayableNo
(
expectedFortune
.
getFortuneType
(),
policyNo
,
expectedFortune
.
getI
d
()));
updateObj
.
setFortuneType
(
GetDictItemListByDictTypeResponse
.
getItemValue
(
dictTypeResponses
,
"csf_fortune_type"
,
expectedFortune
.
getFortuneName
()));
...
...
@@ -1055,9 +1056,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
expectedFortune
.
setExpectedFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_EXPECTED_FORTUNE
.
getCode
()));
// 预计发佣类型名称
expectedFortune
.
setFortuneName
(
queryByDict
(
expectedFortuneDto
.
getFortuneType
()));
// 应付款编号(序号递增)
expectedFortune
.
setPayableNo
(
this
.
createPayableNo
(
expectedFortune
.
getFortuneBizType
(),
expectedFortuneDto
.
getPayoutDate
(),
expectedFortuneDto
.
getPolicyNo
(),
expectedFortuneDto
.
getFortunePeriod
()));
// 已出帐金额、待出帐金额、已出帐比例、待出帐比例
expectedFortune
.
setPaidAmount
(
BigDecimal
.
ZERO
);
...
...
@@ -1069,6 +1067,20 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
fortuneList
.
add
(
expectedFortune
);
}
iExpectedFortuneService
.
saveOrUpdateBatch
(
fortuneList
);
// 更新应付款编号
List
<
ExpectedFortune
>
updateList
=
new
ArrayList
<>();
for
(
ExpectedFortune
expected
:
fortuneList
)
{
// 生成应付款编号
String
payableNo
=
iExpectedFortuneService
.
getPayableNo
(
expected
.
getFortuneType
(),
expected
.
getPolicyNo
(),
expected
.
getId
());
ExpectedFortune
updateExpected
=
new
ExpectedFortune
();
updateExpected
.
setId
(
expected
.
getId
());
updateExpected
.
setPayableNo
(
payableNo
);
updateList
.
add
(
updateExpected
);
}
iExpectedFortuneService
.
updateBatchById
(
updateList
);
return
true
;
}
...
...
@@ -1212,37 +1224,6 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
}
/**
* 创建应付款编号 应付单类型(R/U)+预计年月+保单号后4位(如不够用0补齐)+出账期数(3位)
*
* @param fortuneBizType 预计发佣业务类型
* @param payoutDate 预计出账日期
* @param policyNo 保单号
* @param fortunePeriod 预计出账期数
* @return
*/
public
String
createPayableNo
(
String
fortuneBizType
,
LocalDate
payoutDate
,
String
policyNo
,
int
fortunePeriod
)
{
// 1. 安全获取保单号后4位
String
last4Chars
=
""
;
if
(
policyNo
!=
null
&&
!
policyNo
.
isEmpty
())
{
int
startIdx
=
Math
.
max
(
0
,
policyNo
.
length
()
-
4
);
last4Chars
=
policyNo
.
substring
(
startIdx
);
}
// 2. 字符串左补0至4位
// %4s 表示最小宽度为4,不足部分默认用空格填充在左侧
// replace(' ', '0') 将填充的空格替换为0,实现左补0效果
String
formattedPolicySuffix
=
String
.
format
(
"%4s"
,
last4Chars
).
replace
(
' '
,
'0'
);
// 3. 组装最终字符串
return
String
.
format
(
"%s%04d%02d%s%03d"
,
fortuneBizType
,
payoutDate
.
getYear
(),
payoutDate
.
getMonthValue
(),
formattedPolicySuffix
,
fortunePeriod
);
}
/**
* 分页查询 - 预计发佣
*
* @param request
...
...
yd-csf-service/src/main/java/com/yd/csf/service/enums/FortuneTypeEnum.java
0 → 100644
View file @
6fe34a9b
package
com
.
yd
.
csf
.
service
.
enums
;
/**
* 项目类型码枚举
* XS("销售佣金", "1")
* M1("一级管理奖", "2")
* M2("二级管理奖", "3")
* TJ("终身推荐奖", "4")
* FD("辅导奖", "5")
* OT("其他加扣款", "6")
* PA("协议约定金额", "7")
*/
public
enum
FortuneTypeEnum
{
//项目类型枚举
XS
(
"XS"
,
"1"
),
M1
(
"M1"
,
"2"
),
M2
(
"M2"
,
"3"
),
TJ
(
"TJ"
,
"4"
),
FD
(
"FD"
,
"5"
),
OT
(
"OT"
,
"6"
),
PA
(
"PA"
,
"7"
),
;
//字典项标签(名称)
private
String
itemLabel
;
//字典项值
private
String
itemValue
;
//构造函数
FortuneTypeEnum
(
String
itemLabel
,
String
itemValue
)
{
this
.
itemLabel
=
itemLabel
;
this
.
itemValue
=
itemValue
;
}
public
String
getItemLabel
()
{
return
itemLabel
;
}
public
String
getItemValue
()
{
return
itemValue
;
}
}
yd-csf-service/src/main/java/com/yd/csf/service/service/IExpectedFortuneService.java
View file @
6fe34a9b
...
...
@@ -54,15 +54,14 @@ public interface IExpectedFortuneService extends IService<ExpectedFortune> {
Integer
getPayableNoCurrentSeq
();
/**
* 生成应付款编号
(序号递增) 格式:发佣类型-CSF+年份+序
号
* 生成应付款编号
格式:发佣类型-保单号后6位-流水
号
*
* @param fortuneBizType 应付款类型
* @param payoutDate 出账年月 yyyy-MM
* @param fortuneType 应付款类型
* @param policyNo 保单号
* @param
fortunePeriod 出账期数
* @param
expectedFortuneId 预计发佣ID
* @return 应付款编号
*/
String
getPayableNo
(
String
fortune
BizType
,
String
payoutDate
,
String
policyNo
,
Integer
fortunePerio
d
);
String
getPayableNo
(
String
fortune
Type
,
String
policyNo
,
long
expectedFortuneI
d
);
/**
* 查询预计发佣和实际发佣的分页列表(手动分页)
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
View file @
6fe34a9b
...
...
@@ -31,7 +31,6 @@ import com.yd.insurance.base.feign.client.insurancereconciliationcompany.ApiInsu
import
com.yd.insurance.base.feign.request.insurancereconciliationcompany.ApiInsuranceReconciliationCompanyPageRequest
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
...
...
@@ -673,8 +672,11 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
}
}
// 3. 构建实际的初始发佣记录
List
<
Fortune
>
newFortuneList
=
buildNewFortunes
(
filteredExpectedFortuneList2
,
commissions
);
// 2.4 根据保单号、期数查询入账检核汇率
Map
<
String
,
BigDecimal
>
exchangeRateMap
=
this
.
queryCommissionExchangeRateMap
(
policyNoSet
,
commissionPeriodSet
);
// 3. 构建实际的初始发佣记录(使用入账检核汇率)
List
<
Fortune
>
newFortuneList
=
buildNewFortunes
(
filteredExpectedFortuneList2
,
commissions
,
exchangeRateMap
);
// 4. 保存发佣记录
saveNewFortunes
(
newFortuneList
);
...
...
@@ -682,6 +684,42 @@ 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
))
{
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:
:
getCommissionDate
)
.
list
();
// 2. 按 policyNo + commissionPeriod 分组,取每组的第一条(最新的)
Map
<
String
,
BigDecimal
>
exchangeRateMap
=
commissionExchangeRateList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
commission
->
buildPolicyPeriodKey
(
commission
.
getPolicyNo
(),
commission
.
getCommissionPeriod
())
))
.
entrySet
().
stream
()
.
collect
(
Collectors
.
toMap
(
Map
.
Entry
::
getKey
,
entry
->
entry
.
getValue
().
get
(
0
).
getExchangeRate
()
));
// 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
));
}
}
return
result
;
}
/**
* 保存新的发佣记录
*/
...
...
@@ -700,7 +738,8 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
* 构建新的发佣记录
*/
private
List
<
Fortune
>
buildNewFortunes
(
List
<
ExpectedFortune
>
expectedFortuneList
,
List
<
Commission
>
commissionList
)
{
List
<
Commission
>
commissionList
,
Map
<
String
,
BigDecimal
>
exchangeRateMap
)
{
if
(
CollectionUtils
.
isEmpty
(
expectedFortuneList
))
{
return
new
ArrayList
<>();
}
...
...
@@ -713,24 +752,51 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
));
Date
now
=
new
Date
();
return
expectedFortuneList
.
stream
()
.
map
(
expectedFortune
->
{
// 创建新的发佣记录
List
<
Fortune
>
newFortuneList
=
new
ArrayList
<>();
// 更新预计发佣记录的港币金额
List
<
ExpectedFortune
>
updatedExpectedFortuneList
=
new
ArrayList
<>();
for
(
ExpectedFortune
expectedFortune
:
expectedFortuneList
)
{
Fortune
fortune
=
new
Fortune
();
BeanUtils
.
copyProperties
(
expectedFortune
,
fortune
);
fortune
.
setFortuneBizId
(
RandomStringGenerator
.
generateBizId16
(
CommonEnum
.
UID_TYPE_FORTUNE
.
getCode
()));
fortune
.
setId
(
null
);
fortune
.
setFortuneBizType
(
"R"
);
fortune
.
setExchangeRate
(
expectedFortune
.
getDefaultExchangeRate
());
// 优先使用入账检核汇率,如果没有则使用默认汇率
String
key
=
buildPolicyPeriodKey
(
expectedFortune
.
getPolicyNo
(),
expectedFortune
.
getFortunePeriod
());
BigDecimal
exchangeRate
=
exchangeRateMap
.
get
(
key
);
if
(
exchangeRate
!=
null
)
{
fortune
.
setExchangeRate
(
exchangeRate
);
fortune
.
setOriginalToHkdRate
(
exchangeRate
);
// 重新计算港币金额
BigDecimal
hkdAmount
=
fortune
.
getRuleAmount
().
multiply
(
exchangeRate
);
fortune
.
setHkdAmount
(
hkdAmount
);
fortune
.
setCurrentPaymentAmount
(
hkdAmount
);
fortune
.
setCurrentPaymentHkdAmount
(
hkdAmount
);
// 更新预计发佣记录的港币金额
ExpectedFortune
update
=
new
ExpectedFortune
();
update
.
setId
(
expectedFortune
.
getId
());
update
.
setDefaultExchangeRate
(
exchangeRate
);
update
.
setOriginalToHkdRate
(
exchangeRate
);
update
.
setHkdAmount
(
hkdAmount
);
update
.
setUnpaidAmount
(
hkdAmount
);
updatedExpectedFortuneList
.
add
(
update
);
}
else
{
fortune
.
setExchangeRate
(
expectedFortune
.
getDefaultExchangeRate
());
fortune
.
setCurrentPaymentAmount
(
expectedFortune
.
getOriginalAmount
());
fortune
.
setCurrentPaymentHkdAmount
(
expectedFortune
.
getHkdAmount
());
}
fortune
.
setExpectedFortuneBizId
(
expectedFortune
.
getExpectedFortuneBizId
());
fortune
.
setStatus
(
FortuneStatusEnum
.
CAN_SEND
.
getItemValue
());
fortune
.
setIsPart
(
0
);
// 关联来佣业务ID
String
key
=
buildPolicyPeriodKey
(
expectedFortune
.
getPolicyNo
(),
expectedFortune
.
getFortunePeriod
());
Commission
matchedCommission
=
commissionByPolicyPeriod
.
get
(
key
);
if
(
matchedCommission
!=
null
)
{
fortune
.
setCommissionBizId
(
matchedCommission
.
getCommissionBizId
());
...
...
@@ -743,9 +809,18 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
fortune
.
setCreateTime
(
now
);
fortune
.
setUpdateTime
(
now
);
return
fortune
;
})
.
collect
(
Collectors
.
toList
());
newFortuneList
.
add
(
fortune
);
}
// 更新预计发佣记录
if
(
CollectionUtils
.
isNotEmpty
(
updatedExpectedFortuneList
))
{
boolean
updateSuccess
=
iExpectedFortuneService
.
updateBatchById
(
updatedExpectedFortuneList
);
if
(!
updateSuccess
)
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"更新预计发佣记录港币金额失败"
);
}
}
return
newFortuneList
;
}
/**
...
...
@@ -768,7 +843,7 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
}
/**
* 构建保单号+期
次
的唯一键
* 构建保单号+期
数
的唯一键
*/
@Override
public
String
buildPolicyPeriodKey
(
String
policyNo
,
Object
period
)
{
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/ExpectedFortuneServiceImpl.java
View file @
6fe34a9b
...
...
@@ -9,6 +9,7 @@ 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
;
import
com.yd.csf.service.model.Policy
;
...
...
@@ -289,26 +290,27 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
}
@Override
public
String
getPayableNo
(
String
fortune
BizType
,
String
payoutDate
,
String
policyNo
,
Integer
fortunePerio
d
)
{
// 1. 安全获取保单号后
4
位
String
last
4
Chars
=
""
;
public
String
getPayableNo
(
String
fortune
Type
,
String
policyNo
,
long
expectedFortuneI
d
)
{
// 1. 安全获取保单号后
6
位
String
last
6
Chars
=
""
;
if
(
policyNo
!=
null
&&
!
policyNo
.
isEmpty
())
{
int
startIdx
=
Math
.
max
(
0
,
policyNo
.
length
()
-
4
);
last
4
Chars
=
policyNo
.
substring
(
startIdx
);
int
startIdx
=
Math
.
max
(
0
,
policyNo
.
length
()
-
6
);
last
6
Chars
=
policyNo
.
substring
(
startIdx
);
}
// 2. 字符串左补0至
4
位
// %
4s 表示最小宽度为4
,不足部分默认用空格填充在左侧
// 2. 字符串左补0至
6
位
// %
6s 表示最小宽度为6
,不足部分默认用空格填充在左侧
// replace(' ', '0') 将填充的空格替换为0,实现左补0效果
String
formattedPolicySuffix
=
String
.
format
(
"%
4s"
,
last4
Chars
).
replace
(
' '
,
'0'
);
String
formattedPolicySuffix
=
String
.
format
(
"%
6s"
,
last6
Chars
).
replace
(
' '
,
'0'
);
// 3. 组装最终字符串
return
String
.
format
(
"%s%04d%02d%s%03d"
,
fortuneBizType
,
Integer
.
parseInt
(
payoutDate
.
substring
(
0
,
4
)),
Integer
.
parseInt
(
payoutDate
.
substring
(
5
,
7
)),
// 3. 项目类型枚举转换为字符串
String
fortuneTypeCode
=
FortuneTypeEnum
.
valueOf
(
fortuneType
).
getItemLabel
();
// 4. 组装最终字符串
return
String
.
format
(
"%s-%s-%d"
,
fortuneTypeCode
,
formattedPolicySuffix
,
fortunePerio
d
);
expectedFortuneI
d
);
}
@Override
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
View file @
6fe34a9b
...
...
@@ -789,6 +789,12 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
expectedFortune
=
createExpectedFortune
(
fortuneAddRequest
,
policy
,
fortuneName
);
// 保存
expectedFortuneService
.
save
(
expectedFortune
);
// 更新应付款编号
String
payableNo
=
expectedFortuneService
.
getPayableNo
(
fortuneAddRequest
.
getFortuneType
(),
policy
.
getPolicyNo
(),
expectedFortune
.
getId
());
expectedFortuneService
.
lambdaUpdate
()
.
set
(
ExpectedFortune:
:
getPayableNo
,
payableNo
)
.
eq
(
ExpectedFortune:
:
getId
,
expectedFortune
.
getId
())
.
update
();
}
else
{
// 如果有预计出账记录,提示去应付款管理页面修改金额,而不是在出账页面新增
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
fortuneAddRequest
.
getFortuneName
()
+
" 已存在应付记录,请在应付款管理页面修改金额"
);
...
...
@@ -830,10 +836,6 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
}
private
ExpectedFortune
createExpectedFortune
(
FortuneAddRequest
fortuneAddRequest
,
Policy
policy
,
String
fortuneName
)
{
// 应付款编号(序号递增)
String
payableNo
=
expectedFortuneService
.
getPayableNo
(
fortuneAddRequest
.
getFortuneBizType
(),
fortuneAddRequest
.
getPayoutDate
(),
policy
.
getPolicyNo
(),
fortuneAddRequest
.
getFortunePeriod
());
// 创建 expectedFortune
ExpectedFortune
expectedFortune
=
new
ExpectedFortune
();
BeanUtil
.
copyProperties
(
fortuneAddRequest
,
expectedFortune
);
...
...
@@ -849,7 +851,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
// 预计发佣类型名称
expectedFortune
.
setFortuneName
(
fortuneName
);
// 应付款编号
expectedFortune
.
setPayableNo
(
payableNo
);
expectedFortune
.
setPayableNo
(
null
);
// 是否拆分
expectedFortune
.
setIsPart
(
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