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
9cfa9333
Commit
9cfa9333
authored
Dec 31, 2025
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
前端对接问题修复17
parent
c5fa57cb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
40 deletions
+51
-40
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiCommissionController.java
+3
-3
yd-csf-service/src/main/java/com/yd/csf/service/dto/GenerateFortuneRequest.java
+2
-6
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
+46
-31
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiCommissionController.java
View file @
9cfa9333
...
...
@@ -215,7 +215,7 @@ public class ApiCommissionController {
}
/**
* 生成实际出账(发佣)记录
,并设置检核日期
* 生成实际出账(发佣)记录
*
* @param generateFortuneRequest
* @param request
...
...
@@ -225,8 +225,8 @@ public class ApiCommissionController {
@Operation
(
summary
=
"生成实际出账(发佣)记录"
)
public
Result
<
Boolean
>
generateFortune
(
@RequestBody
GenerateFortuneRequest
generateFortuneRequest
,
HttpServletRequest
request
)
{
if
(
ObjectUtils
.
isEmpty
(
generateFortuneRequest
.
getPayoutYearMonth
()))
{
return
Result
.
fail
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"
预计出账年月
不能为空"
);
if
(
CollectionUtils
.
isEmpty
(
generateFortuneRequest
.
getCommissionBizIdList
()))
{
return
Result
.
fail
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"
入账业务id列表
不能为空"
);
}
return
Result
.
success
(
commissionService
.
generateFortune
(
generateFortuneRequest
));
}
...
...
yd-csf-service/src/main/java/com/yd/csf/service/dto/GenerateFortuneRequest.java
View file @
9cfa9333
...
...
@@ -10,13 +10,9 @@ import java.util.List;
@Data
public
class
GenerateFortuneRequest
{
//
@Schema(description = "入账业务id列表")
//
private List<String> commissionBizIdList;
@Schema
(
description
=
"入账业务id列表"
)
private
List
<
String
>
commissionBizIdList
;
// @Schema(description = "expected fortune id 列表")
// private List<Long> expectedFortuneIdList;
@Schema
(
description
=
"预计出账年月,格式:yyyy-MM"
)
@JsonFormat
(
pattern
=
"yyyy-MM"
)
private
LocalDate
payoutYearMonth
;
}
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
View file @
9cfa9333
...
...
@@ -332,48 +332,66 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
generateFortune
(
GenerateFortuneRequest
generateFortuneRequest
)
{
LocalDate
payoutYearMonth
=
generateFortuneRequest
.
getPayoutYearMonth
();
if
(
ObjectUtils
.
isEmpty
(
payoutYearMonth
))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"请选择预计出账年月"
);
List
<
String
>
commissionBizIdList
=
generateFortuneRequest
.
getCommissionBizIdList
();
List
<
Commission
>
commissions
=
this
.
lambdaQuery
().
in
(
Commission:
:
getCommissionBizId
,
commissionBizIdList
).
list
();
// 根据保单号,期数建立映射关系
Map
<
String
,
Commission
>
policyNoPeriodMap
=
commissions
.
stream
()
.
collect
(
Collectors
.
toMap
(
i
->
i
.
getPolicyNo
()
+
"_"
+
i
.
getCommissionPeriod
(),
commission
->
commission
));
// 校验来佣记录是否存在
if
(
CollectionUtils
.
isEmpty
(
commissions
))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"未找到对应的来佣记录,请先创建来佣记录"
);
}
// 1. 查询在预计出账年月的预计发佣记录,预计出账日期在预计出账年月的1号到最后一天
QueryWrapper
<
ExpectedFortune
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
between
(
"payout_date"
,
payoutYearMonth
.
withDayOfMonth
(
1
),
payoutYearMonth
.
withDayOfMonth
(
payoutYearMonth
.
lengthOfMonth
()));
List
<
ExpectedFortune
>
expectedFortuneList
=
iExpectedFortuneService
.
list
(
queryWrapper
);
for
(
Commission
commission
:
commissions
)
{
if
(
StringUtils
.
isBlank
(
commission
.
getPolicyNo
()))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"保单号不能为空"
);
}
}
if
(
CollectionUtils
.
isEmpty
(
expectedFortuneList
))
{
// 获取所有保单号
Set
<
String
>
policyNoSet
=
commissions
.
stream
()
.
map
(
Commission:
:
getPolicyNo
)
.
collect
(
Collectors
.
toSet
());
// 1.1 根据保单号查询的预计发佣记录
List
<
ExpectedFortune
>
expectedFortuneList
=
iExpectedFortuneService
.
lambdaQuery
()
.
in
(
ExpectedFortune:
:
getPolicyNo
,
policyNoSet
)
.
list
();
// 1.2 根据保单号和期数筛选符合的预计发佣记录
List
<
ExpectedFortune
>
filteredExpectedFortuneList
=
new
ArrayList
<>();
for
(
Commission
commission
:
commissions
)
{
String
policyNo
=
commission
.
getPolicyNo
();
Integer
commissionPeriod
=
commission
.
getCommissionPeriod
();
for
(
ExpectedFortune
expectedFortune
:
expectedFortuneList
)
{
if
(
expectedFortune
.
getPolicyNo
().
equals
(
policyNo
)
&&
expectedFortune
.
getFortunePeriod
().
equals
(
commissionPeriod
))
{
filteredExpectedFortuneList
.
add
(
expectedFortune
);
}
}
}
if
(
CollectionUtils
.
isEmpty
(
filteredExpectedFortuneList
))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"未找到保单对应的预计发佣记录,请先创建预计发佣记录"
);
}
// 2. 根据本次发佣日期,查询本期待发佣记录
QueryWrapper
<
Fortune
>
queryWrapperFortune
=
new
QueryWrapper
<>();
queryWrapperFortune
.
eq
(
"reconciliation_year_month"
,
payoutYearMonth
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM"
)));
List
<
Fortune
>
fortuneList
=
fortuneService
.
list
(
queryWrapperFortune
);
List
<
Fortune
>
fortuneList
=
fortuneService
.
lambdaQuery
()
.
in
(
Fortune:
:
getExpectedFortuneBizId
,
filteredExpectedFortuneList
.
stream
().
map
(
ExpectedFortune:
:
getExpectedFortuneBizId
).
collect
(
Collectors
.
toList
()))
.
list
(
);
// 2.1 校验是否有已出账的记录
for
(
Fortune
fortune
:
fortuneList
)
{
if
(
FortuneStatusEnum
.
SENT
.
getItemValue
().
equals
(
fortune
.
getStatus
()))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"已出账的记录不能重新出账"
);
if
(!
FortuneStatusEnum
.
WAIT
.
getItemValue
().
equals
(
fortune
.
getStatus
()))
{
Commission
commission
=
policyNoPeriodMap
.
get
(
fortune
.
getPolicyNo
()
+
"_"
+
fortune
.
getFortunePeriod
());
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"保单号为"
+
commission
.
getPolicyNo
()
+
",期数为"
+
commission
.
getCommissionPeriod
()
+
"已有出账,不能重新出账"
);
}
}
// 2.2 过滤掉 is_part = 1 的 fortune 记录
List
<
Fortune
>
filteredFortuneList
=
fortuneList
.
stream
()
.
filter
(
fortune
->
Integer
.
valueOf
(
0
).
equals
(
fortune
.
getIsPart
()))
.
collect
(
Collectors
.
toList
());
// 3.根据本次发佣日期,删除旧的发佣记录,以便重新计算
fortuneService
.
removeByIds
(
filteredFortuneList
);
// 4.根据保单号查询对应来佣记录
Set
<
String
>
policyNoSet
=
expectedFortuneList
.
stream
()
.
map
(
ExpectedFortune:
:
getPolicyNo
)
.
collect
(
Collectors
.
toSet
());
List
<
Commission
>
commissionList
=
this
.
list
(
new
QueryWrapper
<
Commission
>().
in
(
"policy_no"
,
policyNoSet
));
// List<Fortune> filteredFortuneList = fortuneList.stream()
// .filter(fortune -> Integer.valueOf(0).equals(fortune.getIsPart()))
// .collect(Collectors.toList());
// 5. 构建实际的初始发佣记录
List
<
Fortune
>
newFortuneList
=
buildNewFortunes
(
expectedFortuneList
,
commissionList
,
payoutYearMonth
.
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM"
))
);
List
<
Fortune
>
newFortuneList
=
buildNewFortunes
(
filteredExpectedFortuneList
,
commissions
);
// List<Fortune> newFortuneList = new ArrayList<>();
// for (ExpectedFortune expectedFortune : filteredExpectedFortuneList) {
// Fortune fortune = new Fortune();
...
...
@@ -416,8 +434,7 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
* 构建新的发佣记录
*/
private
List
<
Fortune
>
buildNewFortunes
(
List
<
ExpectedFortune
>
expectedFortuneList
,
List
<
Commission
>
commissionList
,
String
reconciliationYearMonth
)
{
List
<
Commission
>
commissionList
)
{
// 构建来佣记录映射,用于快速查找
Map
<
String
,
Commission
>
commissionByPolicyPeriod
=
commissionList
.
stream
()
.
collect
(
Collectors
.
toMap
(
...
...
@@ -436,8 +453,6 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
fortune
.
setExpectedFortuneBizId
(
expectedFortune
.
getExpectedFortuneBizId
());
fortune
.
setStatus
(
FortuneStatusEnum
.
CAN_SEND
.
getItemValue
());
fortune
.
setIsPart
(
0
);
// 检核日期
fortune
.
setReconciliationYearMonth
(
reconciliationYearMonth
);
// 关联来佣业务ID
String
key
=
buildPolicyPeriodKey
(
expectedFortune
.
getPolicyNo
(),
expectedFortune
.
getFortunePeriod
());
...
...
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