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
0052b908
Commit
0052b908
authored
May 20, 2026
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
应付明细2
parent
944ef8fb
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
222 additions
and
283 deletions
+222
-283
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
+2
-2
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
+7
-3
yd-csf-feign/src/main/java/com/yd/csf/feign/response/expectedfortune/ApiExpectedFortunePageResponse.java
+71
-175
yd-csf-service/src/main/java/com/yd/csf/service/model/ExpectedFortune.java
+18
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
+4
-8
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/ExpectedFortuneServiceImpl.java
+0
-7
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneAccountServiceImpl.java
+96
-49
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
+24
-36
yd-csf-service/src/main/java/com/yd/csf/service/vo/ExpectedFortuneExportDTO.java
+0
-3
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
View file @
0052b908
...
...
@@ -429,13 +429,13 @@ public class ApiFortuneController {
}
/**
* 修改设置出账年月(实)
),设置完成后,更新到应付款管理明细中
* 修改设置出账年月(实)
*
* @param editActualPayoutDateRequest
* @return
*/
@PostMapping
(
"/edit/actual_payout_date"
)
@Operation
(
summary
=
"修改设置出账年月(实)
,设置完成后,更新到应付款管理明细中
"
)
@Operation
(
summary
=
"修改设置出账年月(实)"
)
public
Result
<
Boolean
>
editActualPayoutDate
(
@RequestBody
EditActualPayoutDateRequest
editActualPayoutDateRequest
)
{
if
(
editActualPayoutDateRequest
==
null
||
StringUtils
.
isBlank
(
editActualPayoutDateRequest
.
getFortuneBizId
()))
{
return
Result
.
fail
(
ErrorCode
.
PARAMS_ERROR
.
getCode
(),
"fortuneBizId 不能为空"
);
...
...
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
View file @
0052b908
...
...
@@ -496,15 +496,16 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//原币种
updateObj
.
setOriginalCurrency
(
policyCurrency
);
//原币种金额
updateObj
.
setOriginalAmount
(
expectedFortune
.
getRuleAmount
());
BigDecimal
ruleAmount
=
expectedFortune
.
getRuleAmount
();
updateObj
.
setOriginalAmount
(
ruleAmount
);
//原币种 -> 港币汇率
updateObj
.
setOriginalToHkdRate
(
originalToHkdRate
);
//保单币种
updateObj
.
setRuleCurrency
(
policyCurrency
);
//默认保单币种 -> 港币汇率
updateObj
.
setDefaultExchangeRate
(
originalToHkdRate
);
//
港币金额
(标准发佣金额 * 默认保单币种 -> 港币汇率)
BigDecimal
hkdAmount
=
expectedFortune
.
getRuleAmount
()
.
multiply
(
originalToHkdRate
);
//
应发港币金额(估)
(标准发佣金额 * 默认保单币种 -> 港币汇率)
BigDecimal
hkdAmount
=
ruleAmount
.
multiply
(
originalToHkdRate
);
updateObj
.
setHkdAmount
(
hkdAmount
);
//发放币种
updateObj
.
setPayoutCurrency
(
currency
);
...
...
@@ -513,6 +514,9 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
//港币 -> 发放币种汇率
updateObj
.
setHkdToPayoutRate
(
hkdToPayoutRate
);
//默认值
updateObj
.
setPaidRuleAmount
(
BigDecimal
.
ZERO
);
updateObj
.
setUnpaidRuleAmount
(
ruleAmount
);
updateObj
.
setUnpaidRuleAmountHkd
(
hkdAmount
);
updateObj
.
setPaidAmount
(
BigDecimal
.
ZERO
);
updateObj
.
setPaidRatio
(
BigDecimal
.
ZERO
);
updateObj
.
setUnpaidAmount
(
expectedFortune
.
getHkdAmount
());
...
...
yd-csf-feign/src/main/java/com/yd/csf/feign/response/expectedfortune/ApiExpectedFortunePageResponse.java
View file @
0052b908
...
...
@@ -35,246 +35,142 @@ public class ApiExpectedFortunePageResponse {
@Schema
(
description
=
"应付款类型 R-关联保单应付款 U-非关联保单应付款"
)
private
String
fortuneBizType
;
/**
* 应付款编号
*/
@Schema
(
description
=
"应付款编号(业务编号)"
)
@Schema
(
description
=
"业务编号"
)
private
String
payableNo
;
/**
* 保单号
*/
@Schema
(
description
=
"policy no"
)
private
String
policyNo
;
/**
* 期交保费
*/
@Schema
(
description
=
"期交保费"
)
private
BigDecimal
premium
;
/**
* 保险公司 ID
*/
@Schema
(
description
=
"保险公司 ID"
)
private
String
insuranceCompanyBizId
;
/**
* 保险公司
*/
@Schema
(
description
=
"保险公司"
)
private
String
insuranceCompany
;
/**
* 产品计划 ID
*/
@Schema
(
description
=
"产品计划 ID"
)
private
String
productLaunchBizId
;
/**
* 产品计划
*/
@Schema
(
description
=
"产品计划"
)
private
String
productName
;
/**
* 出账期数(1=第一年; 2=第二年; 3=第三年; 4=第四年; 5=第五年)
*/
@Schema
(
description
=
"出账期数"
)
private
Integer
fortunePeriod
;
/**
* 总期数
*/
@Schema
(
description
=
"总期数"
)
private
Integer
fortuneTotalPeriod
;
/**
* 转介人
*/
@Schema
(
description
=
"转介人"
)
private
String
broker
;
/**
* 转介人业务ID
*/
@Schema
(
description
=
"转介人业务ID"
)
private
String
brokerBizId
;
/**
* 转介人等级名称
*/
@Schema
(
description
=
"转介人等级名称"
)
@Schema
(
description
=
"职级"
)
private
String
brokerGradeName
;
/**
* 团队名称
*/
@Schema
(
description
=
"团队名称"
)
private
String
team
;
/**
* 所属团队业务ID
*/
@Schema
(
description
=
"所属团队业务ID"
)
private
String
teamBizId
;
/**
* 出账项目
*/
@Schema
(
description
=
"出账项目"
)
private
String
fortuneName
;
/**
* 出账项目类型
*/
@Schema
(
description
=
"出账项目类型 字典值: csf_fortune_type"
)
private
String
fortuneType
;
/**
* 持有比例
*/
@Schema
(
description
=
"持有比例"
)
private
String
brokerRatio
;
@Schema
(
description
=
"出账状态 0=待出账 1=可出帐,待检核 2=完成出账 3=部分出账 4=保留 5=已失效 6=可出账, 已检核 7=未找到当前预计出账对应的来佣 字典值: csf_expected_fortune_status"
)
private
String
status
;
@Schema
(
description
=
"出账期数"
)
private
Integer
fortunePeriod
;
// ========== 保单币种及金额(基本法币种) ==========
/**
* 保单币种金额(保单币种金额 = 标准发佣金额 * 转介人介绍费占比)
*/
@Schema
(
description
=
"保单币种金额(保单币种金额 = 标准发佣金额 * 转介人介绍费占比)"
)
private
BigDecimal
ruleAmount
;
@Schema
(
description
=
"总期数"
)
private
Integer
fortuneTotalPeriod
;
/**
* 保单币种
*/
@Schema
(
description
=
"保单币种"
)
private
String
ruleCurrency
;
@Schema
(
description
=
"出账年月(估)"
)
@JsonFormat
(
pattern
=
"yyyy-MM"
,
timezone
=
"GMT+8"
)
private
LocalDate
payoutDate
;
/**
* 预计出账-默认保单币种汇率(保单币种 -> 港币汇率)
*/
@Schema
(
description
=
"预计出账-默认保单币种汇率(保单币种 -> 港币汇率)"
)
@Schema
(
description
=
"出账年月(实)"
)
@JsonFormat
(
pattern
=
"yyyy-MM"
,
timezone
=
"GMT+8"
)
private
LocalDate
actualPayoutDate
;
@Schema
(
description
=
"入账检核汇率"
)
private
BigDecimal
exchangeRate
;
@Schema
(
description
=
"保单币种->HKD汇率"
)
private
BigDecimal
defaultExchangeRate
;
/**
* 预计出账-HKD应出账金额
*/
@Schema
(
description
=
"预计出账-HKD应出账金额"
)
private
BigDecimal
hkdAmount
;
@Schema
(
description
=
"HKD->发放币种汇率"
)
private
BigDecimal
hkdToPayoutRate
;
@Schema
(
description
=
"保单币种"
)
private
String
ruleCurrency
;
// ========== 原币种及金额 ==========
@Schema
(
description
=
"原币种"
)
private
String
originalCurrency
;
@Schema
(
description
=
"发放币种"
)
private
String
payoutCurrency
;
@Schema
(
description
=
"原币种金额"
)
private
BigDecimal
originalAmount
;
@Schema
(
description
=
"
原币→港币汇率
"
)
private
BigDecimal
originalToHkdRate
;
@Schema
(
description
=
"
应发港币金额(估)
"
)
private
BigDecimal
hkdAmount
;
@Schema
(
description
=
"应发保单记账金额"
)
private
BigDecimal
ruleAmount
;
// ========== 发放币种及金额 ==========
@Schema
(
description
=
"发放币种"
)
private
String
payoutCurrency
;
@Schema
(
description
=
"发放币种金额"
)
private
BigDecimal
payoutAmount
;
@Schema
(
description
=
"港币→发放币汇率"
)
private
BigDecimal
hkdToPayoutRate
;
@Schema
(
description
=
"本次发放保单记账金额"
)
private
BigDecimal
currentPaymentRuleAmount
;
@Schema
(
description
=
"本次发放金额"
)
private
BigDecimal
currentPayoutAmount
;
/**
* 实际出账-本次出账金额(HKD)
*/
@Schema
(
description
=
"实际出账-本次出账金额(HKD)"
)
@Schema
(
description
=
"本次发放折合港币金额"
)
private
BigDecimal
currentPaymentHkdAmount
;
/**
* 实际出账-本期结算汇率
*/
@Schema
(
description
=
"实际出账-本期结算汇率"
)
private
BigDecimal
exchangeRate
;
@Schema
(
description
=
"本次发放比例"
)
private
BigDecimal
currentPaymentRatio
;
/**
* 出账币种名称
*/
@Schema
(
description
=
"出账币种名称"
)
private
String
currencyName
;
@Schema
(
description
=
"累积已发放保单记账金额"
)
private
BigDecimal
paidRuleAmount
;
/**
* 出账状态
*/
@Schema
(
description
=
"出账状态 0=待出账 1=可出帐,待检核 2=完成出账 3=部分出账 4=保留 5=已失效 6=可出账, 已检核 7=未找到当前预计出账对应的来佣 字典值: csf_expected_fortune_status"
)
private
String
status
;
@Schema
(
description
=
"累积已发放港币金额"
)
private
BigDecimal
paidAmount
;
/**
* 出账状态-修改理由
*/
@Schema
(
description
=
"出账状态-修改理由"
)
private
String
statusDesc
;
@Schema
(
description
=
"累积已发放比例"
)
private
BigDecimal
paidRatio
;
/**
* 出账年月(估)
*/
@Schema
(
description
=
"出账年月(估)"
)
@JsonFormat
(
pattern
=
"yyyy-MM"
,
timezone
=
"GMT+8"
)
private
LocalDate
payoutDate
;
@Schema
(
description
=
"剩余发放比例"
)
private
BigDecimal
unpaidRatio
;
/**
* 出账年月(实)
*/
@Schema
(
description
=
"出账年月(实)"
)
@JsonFormat
(
pattern
=
"yyyy-MM"
,
timezone
=
"GMT+8"
)
private
LocalDate
actualPayoutDate
;
@Schema
(
description
=
"剩余保单记账金额"
)
private
BigDecimal
unpaidRuleAmount
;
/**
* 预计出账-已出账金额(HKD)
*/
@Schema
(
description
=
"预计出账-已出账金额(HKD)"
)
private
BigDecimal
paidAmount
;
@Schema
(
description
=
"剩余发放折合港币金额"
)
private
BigDecimal
unpaidRuleAmounthHkd
;
/**
* 预计出账-待出账金额
*/
@Schema
(
description
=
"预计出账-待出账金额"
)
private
BigDecimal
unpaidAmount
;
/**
* 预计出账-已出账金额比例 已出账金额/应出账金额
*/
@Schema
(
description
=
"预计出账-已出账金额比例 已出账金额/应出账金额"
)
private
BigDecimal
paidRatio
;
/**
* 预计出账-待出账比例 待出账金额/应出账金额
*/
@Schema
(
description
=
"预计出账-待出账比例 待出账金额/应出账金额"
)
private
BigDecimal
unpaidRatio
;
/**
* 备注
*/
@Schema
(
description
=
"原币→港币汇率"
)
private
BigDecimal
originalToHkdRate
;
@Schema
(
description
=
"发放币种金额"
)
private
BigDecimal
payoutAmount
;
@Schema
(
description
=
"期交保费"
)
private
BigDecimal
premium
;
@Schema
(
description
=
"产品计划 ID"
)
private
String
productLaunchBizId
;
@Schema
(
description
=
"产品计划"
)
private
String
productName
;
@Schema
(
description
=
"持有比例"
)
private
String
brokerRatio
;
@Schema
(
description
=
"备注"
)
private
String
remark
;
/**
* 创建人
*/
@Schema
(
description
=
"创建人"
)
private
String
creatorName
;
/**
* 创建时间
*/
@Schema
(
description
=
"创建时间"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
createTime
;
/**
* 更新时间(操作时间)
*/
@Schema
(
description
=
"更新时间"
)
@Schema
(
description
=
"更新时间(操作时间)"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
timezone
=
"GMT+8"
)
private
LocalDateTime
updateTime
;
...
...
yd-csf-service/src/main/java/com/yd/csf/service/model/ExpectedFortune.java
View file @
0052b908
...
...
@@ -164,6 +164,24 @@ public class ExpectedFortune implements Serializable {
private
String
ruleCurrency
;
/**
* 累积已发放保单记账金额
*/
@TableField
(
"paid_rule_amount"
)
private
BigDecimal
paidRuleAmount
;
/**
* 剩余保单记账金额
*/
@TableField
(
"unpaid_rule_amount"
)
private
BigDecimal
unpaidRuleAmount
;
/**
* 剩余发放折合港币金额
*/
@TableField
(
"unpaid_rule_amount_hkd"
)
private
BigDecimal
unpaidRuleAmountHkd
;
/**
* 出账状态 0=待出账 1=可出帐 2=可出帐,待检核 3=部分出账 4=保留 5=已失效 6=可出账, 已检核 7=未找到当前预计发佣对应的来佣 字典值: csf_expected_fortune_status
*/
@TableField
(
"status"
)
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
View file @
0052b908
...
...
@@ -785,12 +785,10 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
BigDecimal
hkdAmount
=
fortune
.
getRuleAmount
().
multiply
(
exchangeRate
);
fortune
.
setHkdAmount
(
hkdAmount
);
fortune
.
setCurrentPaymentAmount
(
hkdAmount
);
fortune
.
setCurrentPaymentHkdAmount
(
hkdAmount
);
// 默认发放币种、汇率、发放币种金额
fortune
.
setPayoutCurrency
(
"HKD"
);
fortune
.
setHkdToPayoutRate
(
BigDecimal
.
ONE
);
fortune
.
setPayoutAmount
(
hkdAmount
);
// 重新计算发放币种金额
BigDecimal
payoutAmount
=
hkdAmount
.
multiply
(
expectedFortune
.
getHkdToPayoutRate
());
fortune
.
setPayoutAmount
(
payoutAmount
);
// 更新预计发佣记录的港币金额
ExpectedFortune
update
=
new
ExpectedFortune
();
...
...
@@ -799,9 +797,7 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
update
.
setOriginalToHkdRate
(
exchangeRate
);
update
.
setHkdAmount
(
hkdAmount
);
update
.
setUnpaidAmount
(
hkdAmount
);
update
.
setPayoutCurrency
(
"HKD"
);
update
.
setHkdToPayoutRate
(
BigDecimal
.
ONE
);
update
.
setPayoutAmount
(
hkdAmount
);
update
.
setPayoutAmount
(
payoutAmount
);
updatedExpectedFortuneList
.
add
(
update
);
}
else
{
fortune
.
setExchangeRate
(
expectedFortune
.
getDefaultExchangeRate
());
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/ExpectedFortuneServiceImpl.java
View file @
0052b908
...
...
@@ -105,8 +105,6 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
Map
<
String
,
PolicyFollow
>
policyFollowMap
=
policyFollowService
.
queryPolicyFollowMap
(
policyNoList
);
for
(
ApiExpectedFortunePageResponse
vo
:
expectedFortuneList
)
{
// 出账币种名称
vo
.
setCurrencyName
(
"港币"
);
UserGradeDto
userGradeDto
=
userGradeMap
.
get
(
vo
.
getBrokerBizId
());
if
(
userGradeDto
!=
null
)
{
...
...
@@ -115,7 +113,6 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
PolicyFollow
policyFollow
=
policyFollowMap
.
get
(
vo
.
getPolicyNo
());
if
(
policyFollow
!=
null
)
{
vo
.
setInsuranceCompany
(
policyFollow
.
getInsuranceCompany
());
vo
.
setProductName
(
policyFollow
.
getProductName
());
}
}
...
...
@@ -161,7 +158,6 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
if
(
CollUtil
.
isNotEmpty
(
matchedList
))
{
// 设置实际出账记录的字段:待出账金额(估)、已出账比例、未出账比例、已出账金额
matchedList
.
forEach
(
actual
->
{
actual
.
setUnpaidAmount
(
expected
.
getUnpaidAmount
());
actual
.
setPaidRatio
(
expected
.
getPaidRatio
());
actual
.
setUnpaidRatio
(
expected
.
getUnpaidRatio
());
actual
.
setPaidAmount
(
expected
.
getPaidAmount
());
...
...
@@ -242,8 +238,6 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
ApiExpectedFortunePageResponse
vo
=
new
ApiExpectedFortunePageResponse
();
BeanUtils
.
copyProperties
(
ef
,
vo
);
vo
.
setCurrencyName
(
"港币"
);
String
ratio
=
finalBrokerRatioMap
.
get
(
ef
.
getBrokerBizId
());
vo
.
setCommissionRatio
(
ratio
);
...
...
@@ -254,7 +248,6 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
vo
.
setBrokerGradeName
(
userGradeDto
.
getGradeName
());
}
if
(
policy
!=
null
)
{
vo
.
setInsuranceCompany
(
policy
.
getInsuranceCompany
());
vo
.
setPremium
(
policy
.
getPaymentPremium
());
}
if
(
follow
!=
null
)
{
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneAccountServiceImpl.java
View file @
0052b908
...
...
@@ -119,7 +119,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
Long
loginUserId
=
currentLoginUser
.
getId
();
//查询转介人的内部编号列表信息
//
查询转介人的内部编号列表信息
List
<
String
>
brokerBizIdList
=
accountExportDTOList
.
stream
().
map
(
FortuneAccountExportDTO:
:
getBrokerBizId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
String
>
map
=
policyBrokerService
.
queryInternalCodeMap
(
brokerBizIdList
);
List
<
FortuneAccount
>
fortuneAccountList
=
new
ArrayList
<>();
...
...
@@ -169,13 +169,13 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
fortuneAccountList
.
add
(
fortuneAccount
);
}
//
保存出账
记录
//
1. 保存薪资
记录
this
.
saveBatch
(
fortuneAccountList
);
// 处理关联发佣记录
List
<
Fortune
>
updateFortuneList
=
new
ArrayList
<>();
// 处理关联预计发佣记录
List
<
String
>
expectedFortuneBizIdList
=
new
ArrayLis
t
<>();
Set
<
String
>
expectedFortuneBizIdList
=
new
HashSe
t
<>();
for
(
FortuneAccount
fortuneAccount
:
fortuneAccountList
)
{
String
fortuneAccountBizId
=
fortuneAccount
.
getFortuneAccountBizId
();
List
<
Fortune
>
fortuneList
=
fortuneAccount
.
getFortuneList
();
...
...
@@ -185,13 +185,8 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
updateFortune
.
setId
(
item
.
getId
());
updateFortune
.
setFortuneAccountBizId
(
fortuneAccountBizId
);
updateFortune
.
setStatus
(
FortuneStatusEnum
.
CHECKED
.
getItemValue
());
// 处理金额字段
if
(
BigDecimal
.
ZERO
.
compareTo
(
item
.
getHkdAmount
())
!=
0
)
{
updateFortune
.
setCurrentPaymentHkdAmount
(
item
.
getCurrentPaymentHkdAmount
());
updateFortune
.
setCurrentPaymentRatio
(
item
.
getCurrentPaymentHkdAmount
()
.
divide
(
item
.
getHkdAmount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)));
}
updateFortune
.
setReconciliationOperator
(
currentLoginUser
.
getRealName
());
updateFortuneList
.
add
(
updateFortune
);
// 处理关联预计发佣记录
expectedFortuneBizIdList
.
add
(
item
.
getExpectedFortuneBizId
());
...
...
@@ -199,27 +194,46 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
}
}
// 更新发佣记录的出账记录id
if
(
CollectionUtils
.
isNotEmpty
(
updateFortuneList
))
{
fortuneService
.
updateBatchById
(
updateFortuneList
);
}
// 更新预计发佣记录的出账状态
// 2. 更新预计发佣记录的出账状态
Map
<
String
,
ExpectedFortune
>
expectedFortuneMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
expectedFortuneBizIdList
))
{
// 查询预计发佣记录
List
<
ExpectedFortune
>
expectedFortuneList
=
expectedFortuneService
.
list
(
new
QueryWrapper
<
ExpectedFortune
>()
.
in
(
"expected_fortune_biz_id"
,
expectedFortuneBizIdList
));
// 转为 Map
expectedFortuneMap
=
expectedFortuneList
.
stream
()
.
collect
(
Collectors
.
toMap
(
ExpectedFortune:
:
getExpectedFortuneBizId
,
Function
.
identity
()));
List
<
ExpectedFortune
>
updateExpectedFortuneList
=
new
ArrayList
<>();
for
(
ExpectedFortune
expectedFortune
:
expectedFortuneList
)
{
ExpectedFortune
updateExpectedFortune
=
new
ExpectedFortune
();
updateExpectedFortune
.
setId
(
expectedFortune
.
getId
());
updateExpectedFortune
.
setStatus
(
FortuneStatusEnum
.
CHECKED
.
getItemValue
());
updateExpectedFortuneList
.
add
(
updateExpectedFortune
);
// 如果状态是 待出账,才修改
if
(
FortuneStatusEnum
.
WAIT
.
getItemValue
().
equals
(
expectedFortune
.
getStatus
()))
{
ExpectedFortune
updateExpectedFortune
=
new
ExpectedFortune
();
updateExpectedFortune
.
setId
(
expectedFortune
.
getId
());
updateExpectedFortune
.
setStatus
(
FortuneStatusEnum
.
CHECKED
.
getItemValue
());
updateExpectedFortuneList
.
add
(
updateExpectedFortune
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
updateExpectedFortuneList
))
{
expectedFortuneService
.
updateBatchById
(
updateExpectedFortuneList
);
}
expectedFortuneService
.
updateBatchById
(
updateExpectedFortuneList
);
}
// 3. 计算本次出账比例
for
(
Fortune
f
:
updateFortuneList
)
{
ExpectedFortune
ef
=
expectedFortuneMap
.
get
(
f
.
getExpectedFortuneBizId
());
if
(
ef
!=
null
)
{
BigDecimal
currentPaymentRatio
=
BigDecimal
.
ZERO
;
if
(
BigDecimal
.
ZERO
.
compareTo
(
ef
.
getRuleAmount
())
!=
0
)
{
currentPaymentRatio
=
f
.
getCurrentPaymentAmount
()
.
divide
(
ef
.
getRuleAmount
(),
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
));
}
f
.
setCurrentPaymentRatio
(
currentPaymentRatio
);
}
}
fortuneService
.
updateBatchById
(
updateFortuneList
);
}
/**
...
...
@@ -395,17 +409,17 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
.
eq
(
Fortune:
:
getStatus
,
FortuneStatusEnum
.
CHECKED
.
getItemValue
())
.
list
();
if
(
CollectionUtils
.
isNotEmpty
(
fortunes
))
{
fortunes
.
forEach
(
f
->
{
if
(
f
.
getCurrentPaymentHkdAmount
()
==
null
)
{
f
.
setCurrentPaymentHkdAmount
(
f
.
getHkdAmount
()
);
f
.
setCurrentPaymentRatio
(
BigDecimal
.
valueOf
(
100
));
}
f
.
setStatus
(
FortuneStatusEnum
.
SENT
.
getItemValue
());
// f.setActualPayoutDat
e(new Date());
f
.
setUpdaterId
(
loginUserId
.
toString
());
f
.
setUpdateTime
(
new
Date
()
);
}
);
fortuneService
.
updateBatchById
(
fortune
s
);
List
<
Fortune
>
fortuneUpdateList
=
new
ArrayList
<>();
for
(
Fortune
f
:
fortunes
)
{
Fortune
fortune
=
new
Fortune
(
);
fortune
.
setId
(
f
.
getId
(
));
fortune
.
setStatus
(
FortuneStatusEnum
.
SENT
.
getItemValue
());
f
ortune
.
setUpdaterId
(
loginUserId
.
toString
());
fortune
.
setUpdateTim
e
(
new
Date
());
f
ortuneUpdateList
.
add
(
fortune
);
}
fortuneService
.
updateBatchById
(
fortune
UpdateList
);
}
/* 4. 按 expected_fortune 维度重新汇总已出账金额 --------------------------*/
...
...
@@ -423,44 +437,77 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
.
last
(
"FOR UPDATE"
)
.
list
();
// 4.3 全量汇总:把同一 expected_fortune 下所有 fortune 的 current_payment_
hkd_amount
求和
Map
<
String
,
BigDecimal
>
paid
Map
=
fortuneService
.
lambdaQuery
()
// 4.3 全量汇总:把同一 expected_fortune 下所有 fortune 的 current_payment_
ratio
求和
Map
<
String
,
List
<
Fortune
>>
fortune
Map
=
fortuneService
.
lambdaQuery
()
.
in
(
Fortune:
:
getExpectedFortuneBizId
,
expectedIds
)
.
eq
(
Fortune:
:
getStatus
,
FortuneStatusEnum
.
SENT
.
getItemValue
())
.
list
()
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
Fortune:
:
getExpectedFortuneBizId
,
Collectors
.
mapping
(
Fortune:
:
getCurrentPaymentHkdAmount
,
Collectors
.
reducing
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
))));
.
collect
(
Collectors
.
groupingBy
(
Fortune:
:
getExpectedFortuneBizId
));
Map
<
String
,
BigDecimal
>
paidRatioMap
=
new
HashMap
<>();
Map
<
String
,
BigDecimal
>
paidMap
=
new
HashMap
<>();
Map
<
String
,
BigDecimal
>
paidRuleMap
=
new
HashMap
<>();
Map
<
String
,
BigDecimal
>
hkdAmountMap
=
new
HashMap
<>();
Set
<
String
>
keySet
=
fortuneMap
.
keySet
();
for
(
String
expectedFortuneBizId
:
keySet
)
{
List
<
Fortune
>
list
=
fortuneMap
.
get
(
expectedFortuneBizId
);
BigDecimal
paidRatio
=
BigDecimal
.
ZERO
;
BigDecimal
paid
=
BigDecimal
.
ZERO
;
BigDecimal
paidRule
=
BigDecimal
.
ZERO
;
BigDecimal
hkdAmount
=
BigDecimal
.
ZERO
;
for
(
Fortune
f
:
list
)
{
paidRatio
=
paidRatio
.
add
(
f
.
getCurrentPaymentRatio
());
paid
=
paid
.
add
(
f
.
getCurrentPaymentHkdAmount
());
paidRule
=
paidRule
.
add
(
f
.
getRuleAmount
());
hkdAmount
=
hkdAmount
.
add
(
f
.
getCurrentPaymentHkdAmount
());
}
paidRatioMap
.
put
(
expectedFortuneBizId
,
paidRatio
);
paidMap
.
put
(
expectedFortuneBizId
,
paid
);
paidRuleMap
.
put
(
expectedFortuneBizId
,
paidRule
);
hkdAmountMap
.
put
(
expectedFortuneBizId
,
hkdAmount
);
}
// 4.4 反写 expected_fortune
for
(
ExpectedFortune
ef
:
expectedList
)
{
BigDecimal
totalPaid
=
paidMap
.
getOrDefault
(
ef
.
getExpectedFortuneBizId
(),
BigDecimal
.
ZERO
);
// 累积已发放保单记账金额
BigDecimal
paidRule
=
paidRuleMap
.
getOrDefault
(
ef
.
getExpectedFortuneBizId
(),
BigDecimal
.
ZERO
);
BigDecimal
unpaidRule
=
ef
.
getRuleAmount
().
subtract
(
paidRule
);
// 剩余发放折合港币金额
BigDecimal
unpaidRuleAmountHkd
=
unpaidRule
.
multiply
(
ef
.
getDefaultExchangeRate
());
// 应发港币金额(估)
BigDecimal
hkdAmount
=
hkdAmountMap
.
getOrDefault
(
ef
.
getExpectedFortuneBizId
(),
BigDecimal
.
ZERO
);
BigDecimal
expectedHKD
=
hkdAmount
.
add
(
unpaidRuleAmountHkd
);
// 累计出账港币金额
BigDecimal
paid
=
paidMap
.
getOrDefault
(
ef
.
getExpectedFortuneBizId
(),
BigDecimal
.
ZERO
);
BigDecimal
totalAmount
=
ef
.
getHkdAmount
();
BigDecimal
unpaid
=
totalAmount
.
subtract
(
totalP
aid
);
BigDecimal
unpaid
=
totalAmount
.
subtract
(
p
aid
);
BigDecimal
paidRatio
=
BigDecimal
.
ZERO
;
if
(
totalAmount
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
paidRatio
=
totalPaid
.
divide
(
totalAmount
,
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
));
}
BigDecimal
unpaidRatio
=
BigDecimal
.
ZERO
;
if
(
totalAmount
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
unpaidRatio
=
unpaid
.
divide
(
totalAmount
,
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
));
}
// 累积已发放比例 = 累积:已发放保单记账金额/应发保单记账金额
BigDecimal
totalPaidRatio
=
paidRatioMap
.
getOrDefault
(
ef
.
getExpectedFortuneBizId
(),
BigDecimal
.
ZERO
);
BigDecimal
unpaidRatio
=
BigDecimal
.
valueOf
(
100
).
subtract
(
totalPaidRatio
);
String
newStatus
;
if
(
unpaid
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
if
(
unpaid
Ratio
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
newStatus
=
FortuneStatusEnum
.
SENT
.
getItemValue
();
// 全部完成
}
else
if
(
totalPaid
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
}
else
if
(
totalPaid
Ratio
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
newStatus
=
FortuneStatusEnum
.
PARTIAL_SENT
.
getItemValue
();
// 部分完成
}
else
{
newStatus
=
ef
.
getStatus
();
// 无变化
}
expectedFortuneService
.
lambdaUpdate
()
.
set
(
ExpectedFortune:
:
getPaidAmount
,
totalPaid
)
.
set
(
ExpectedFortune:
:
getPaidRuleAmount
,
paidRule
)
.
set
(
ExpectedFortune:
:
getUnpaidRuleAmount
,
unpaidRule
)
.
set
(
ExpectedFortune:
:
getUnpaidRuleAmountHkd
,
unpaidRuleAmountHkd
)
.
set
(
ExpectedFortune:
:
getHkdAmount
,
expectedHKD
)
.
set
(
ExpectedFortune:
:
getPaidAmount
,
paid
)
.
set
(
ExpectedFortune:
:
getUnpaidAmount
,
unpaid
)
.
set
(
ExpectedFortune:
:
getPaidRatio
,
p
aidRatio
)
.
set
(
ExpectedFortune:
:
getPaidRatio
,
totalP
aidRatio
)
.
set
(
ExpectedFortune:
:
getUnpaidRatio
,
unpaidRatio
)
.
set
(
ExpectedFortune:
:
getStatus
,
newStatus
)
.
set
(
ExpectedFortune:
:
getUpdaterId
,
loginUserId
.
toString
())
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
View file @
0052b908
...
...
@@ -979,7 +979,6 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
// 4. 生成新记录
List
<
Fortune
>
newFortuneList
=
new
ArrayList
<>();
List
<
ExpectedFortune
>
newExpectedFortuneList
=
new
ArrayList
<>();
Date
now
=
new
Date
();
...
...
@@ -1019,7 +1018,7 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
newFortune
.
setStatus
(
FortuneStatusEnum
.
CAN_SEND
.
getItemValue
());
newFortune
.
setIsPart
(
1
);
// newFortune.setPayoutDate(
);
newFortune
.
setPayoutDate
(
LocalDate
.
parse
(
splitDto
.
getPayoutYearMonth
()
+
"-01"
)
);
String
fortuneRemark
=
StringUtils
.
isBlank
(
splitDto
.
getRemark
())
?
""
:
splitDto
.
getRemark
();
if
(
StringUtils
.
isNotBlank
(
originalFortune
.
getRemark
()))
{
...
...
@@ -1038,24 +1037,13 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
newFortuneList
.
add
(
newFortune
);
}
// 5.
1
设置原始 fortune记录 is_part 为 2,表示该记录已被分期
// 5. 设置原始 fortune记录 is_part 为 2,表示该记录已被分期
this
.
lambdaUpdate
()
.
set
(
Fortune:
:
getIsPart
,
2
)
.
eq
(
Fortune:
:
getId
,
originalFortune
.
getId
())
.
update
();
// 5.2 设置原始 expected fortune记录 is_part 为 2,表示该记录已被分期
expectedFortuneService
.
lambdaUpdate
()
.
set
(
ExpectedFortune:
:
getIsPart
,
2
)
.
eq
(
ExpectedFortune:
:
getId
,
originalExpectedFortune
.
getId
())
.
update
();
// 6. 批量保存新记录
boolean
expectedSaveSuccess
=
expectedFortuneService
.
saveBatch
(
newExpectedFortuneList
);
if
(!
expectedSaveSuccess
)
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"分期预计出账记录保存失败"
);
}
boolean
fortuneSaveSuccess
=
this
.
saveBatch
(
newFortuneList
);
if
(!
fortuneSaveSuccess
)
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"分期出账记录保存失败"
);
...
...
@@ -1088,10 +1076,10 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
.
eq
(
Fortune:
:
getId
,
fortune
.
getId
())
.
update
();
expectedFortuneService
.
lambdaUpdate
()
.
set
(
ExpectedFortune:
:
getActualPayoutDate
,
actualPayoutDate
)
.
eq
(
ExpectedFortune:
:
getId
,
originalExpectedFortune
.
getId
())
.
update
();
//
expectedFortuneService.lambdaUpdate()
//
.set(ExpectedFortune::getActualPayoutDate, actualPayoutDate)
//
.eq(ExpectedFortune::getId, originalExpectedFortune.getId())
//
.update();
return
true
;
}
...
...
@@ -1145,20 +1133,20 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
.
update
();
// 更新 expected fortune 的字段
expectedFortuneService
.
lambdaUpdate
()
.
set
(
ExpectedFortune:
:
getRuleAmount
,
ruleAmount
)
.
set
(
ExpectedFortune:
:
getRuleCurrency
,
ruleCurrency
)
.
set
(
ExpectedFortune:
:
getDefaultExchangeRate
,
exchangeRate
)
.
set
(
ExpectedFortune:
:
getOriginalCurrency
,
originalCurrency
)
.
set
(
ExpectedFortune:
:
getOriginalAmount
,
originalAmount
)
.
set
(
ExpectedFortune:
:
getOriginalToHkdRate
,
originalToHkdRate
)
.
set
(
ExpectedFortune:
:
getPayoutCurrency
,
payoutCurrency
)
.
set
(
ExpectedFortune:
:
getPayoutAmount
,
payoutAmount
)
.
set
(
ExpectedFortune:
:
getHkdToPayoutRate
,
hkdToPayoutRate
)
.
set
(
ExpectedFortune:
:
getHkdAmount
,
hkdAmount
)
.
set
(
ExpectedFortune:
:
getUnpaidAmount
,
hkdAmount
)
.
eq
(
ExpectedFortune:
:
getId
,
originalExpectedFortune
.
getId
())
.
update
();
//
expectedFortuneService.lambdaUpdate()
//
.set(ExpectedFortune::getRuleAmount, ruleAmount)
//
.set(ExpectedFortune::getRuleCurrency, ruleCurrency)
//
.set(ExpectedFortune::getDefaultExchangeRate, exchangeRate)
//
.set(ExpectedFortune::getOriginalCurrency, originalCurrency)
//
.set(ExpectedFortune::getOriginalAmount, originalAmount)
//
.set(ExpectedFortune::getOriginalToHkdRate, originalToHkdRate)
//
.set(ExpectedFortune::getPayoutCurrency, payoutCurrency)
//
.set(ExpectedFortune::getPayoutAmount, payoutAmount)
//
.set(ExpectedFortune::getHkdToPayoutRate, hkdToPayoutRate)
//
.set(ExpectedFortune::getHkdAmount, hkdAmount)
//
.set(ExpectedFortune::getUnpaidAmount, hkdAmount)
//
.eq(ExpectedFortune::getId, originalExpectedFortune.getId())
//
.update();
return
true
;
}
...
...
@@ -1201,10 +1189,10 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
this
.
updateBatchById
(
updateFortuneList
);
// 更新预计 fortune 的字段
expectedFortuneService
.
lambdaUpdate
()
.
set
(
ExpectedFortune:
:
getActualPayoutDate
,
actualPayoutDate
)
.
in
(
ExpectedFortune:
:
getExpectedFortuneBizId
,
expectedFortuneBizIdList
)
.
update
();
//
expectedFortuneService.lambdaUpdate()
//
.set(ExpectedFortune::getActualPayoutDate, actualPayoutDate)
//
.in(ExpectedFortune::getExpectedFortuneBizId, expectedFortuneBizIdList)
//
.update();
return
String
.
format
(
"设置成功。已更新 %d 条数据,跳过 %d 条(已有实际出账年月)"
,
updateCount
,
skipCount
);
}
...
...
yd-csf-service/src/main/java/com/yd/csf/service/vo/ExpectedFortuneExportDTO.java
View file @
0052b908
...
...
@@ -131,13 +131,10 @@ public class ExpectedFortuneExportDTO {
dto
.
setAmount
(
vo
.
getHkdAmount
());
dto
.
setCurrency
(
"港币"
);
dto
.
setStatus
(
getStatusText
(
vo
.
getStatus
()));
dto
.
setStatusDesc
(
vo
.
getStatusDesc
());
dto
.
setInsuranceCompany
(
vo
.
getInsuranceCompany
());
dto
.
setProductName
(
vo
.
getProductName
());
dto
.
setPayoutDate
(
Convert
.
toDate
(
vo
.
getPayoutDate
()));
dto
.
setActualPayoutDate
(
Convert
.
toDate
(
vo
.
getActualPayoutDate
()));
dto
.
setPaidAmount
(
vo
.
getPaidAmount
());
dto
.
setUnpaidAmount
(
vo
.
getUnpaidAmount
());
dto
.
setPaidRatio
(
vo
.
getPaidRatio
());
dto
.
setUnpaidRatio
(
vo
.
getUnpaidRatio
());
dto
.
setRemark
(
vo
.
getRemark
());
...
...
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