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
3c6e35bd
Commit
3c6e35bd
authored
Nov 24, 2025
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新单跟进80
parent
b70d4af7
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
130 additions
and
6 deletions
+130
-6
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
+22
-3
yd-csf-service/src/main/java/com/yd/csf/service/dao/FortuneMapper.java
+5
-0
yd-csf-service/src/main/java/com/yd/csf/service/dto/FortuneStatisticsRequest.java
+15
-0
yd-csf-service/src/main/java/com/yd/csf/service/dto/FortuneStatisticsVO.java
+27
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/FortuneService.java
+3
-0
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
+28
-3
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
+11
-0
yd-csf-service/src/main/java/com/yd/csf/service/vo/FortuneVO.java
+6
-0
yd-csf-service/src/main/resources/mappers/FortuneMapper.xml
+13
-0
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
View file @
3c6e35bd
...
...
@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -411,7 +412,7 @@ public class ApiFortuneController {
*/
@PostMapping
(
"/list/page/vo"
)
@Operation
(
summary
=
"分页获取保单发佣列表"
)
public
Result
<
Page
<
FortuneVO
>>
listFortuneByPage
(
@RequestBody
FortuneQueryRequest
fortuneQueryRequest
,
public
Result
<
Map
<
String
,
Object
>>
listFortuneByPage
(
@RequestBody
FortuneQueryRequest
fortuneQueryRequest
,
HttpServletRequest
request
)
{
long
current
=
fortuneQueryRequest
.
getPageNo
();
long
size
=
fortuneQueryRequest
.
getPageSize
();
...
...
@@ -419,8 +420,26 @@ public class ApiFortuneController {
// 查询数据库
Page
<
Fortune
>
fortunePage
=
fortuneService
.
page
(
new
Page
<>(
current
,
size
),
fortuneService
.
getQueryWrapper
(
fortuneQueryRequest
));
// 获取封装类
return
Result
.
success
(
fortuneService
.
getFortuneVOPage
(
fortunePage
));
// 查询统计数据
FortuneStatisticsVO
statisticsVO
=
fortuneService
.
getFortuneStatistics
(
fortunePage
.
getRecords
().
stream
().
map
(
Fortune:
:
getId
).
collect
(
Collectors
.
toList
()));
// 组装返回结果
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"statisticsVO"
,
statisticsVO
);
result
.
put
(
"page"
,
fortuneService
.
getFortuneVOPage
(
fortunePage
));
return
Result
.
success
(
result
);
}
/**
* 计算统计数据 总出账金额、对应这些保单的总入账金额、总保单数
*/
@PostMapping
(
"/statistics"
)
@Operation
(
summary
=
"计算统计数据 总出账金额、对应这些保单的总入账金额、总保单数"
)
public
Result
<
FortuneStatisticsVO
>
getFortuneStatistics
(
@RequestBody
FortuneStatisticsRequest
statisticsRequest
)
{
if
(
CollectionUtils
.
isEmpty
(
statisticsRequest
.
getFortuneIdList
()))
{
return
Result
.
fail
(
ErrorCode
.
PARAMS_ERROR
.
getCode
(),
"fortuneId列表不能为空"
);
}
return
Result
.
success
(
fortuneService
.
getFortuneStatistics
(
statisticsRequest
.
getFortuneIdList
()));
}
}
yd-csf-service/src/main/java/com/yd/csf/service/dao/FortuneMapper.java
View file @
3c6e35bd
package
com
.
yd
.
csf
.
service
.
dao
;
import
com.yd.csf.service.dto.FortuneStatisticsVO
;
import
com.yd.csf.service.model.Fortune
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* @author Zhang Jianan
...
...
@@ -11,6 +15,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public
interface
FortuneMapper
extends
BaseMapper
<
Fortune
>
{
FortuneStatisticsVO
getFortuneStatistics
(
@Param
(
"fortuneIdList"
)
List
<
Long
>
fortuneIdList
);
}
...
...
yd-csf-service/src/main/java/com/yd/csf/service/dto/FortuneStatisticsRequest.java
0 → 100644
View file @
3c6e35bd
package
com
.
yd
.
csf
.
service
.
dto
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
FortuneStatisticsRequest
{
/**
* fortuneId 列表
*/
@Schema
(
description
=
"fortuneId 列表"
)
private
List
<
Long
>
fortuneIdList
;
}
yd-csf-service/src/main/java/com/yd/csf/service/dto/FortuneStatisticsVO.java
0 → 100644
View file @
3c6e35bd
package
com
.
yd
.
csf
.
service
.
dto
;
import
io.swagger.v3.oas.annotations.media.Schema
;
import
lombok.Data
;
import
java.math.BigDecimal
;
@Data
public
class
FortuneStatisticsVO
{
/**
* 总出账金额
*/
@Schema
(
description
=
"总出账金额"
)
private
BigDecimal
totalOutAmount
;
/**
* 总入账金额
*/
@Schema
(
description
=
"总入账金额"
)
private
BigDecimal
totalInAmount
;
/**
* 总保单数
*/
@Schema
(
description
=
"总保单数"
)
private
Long
totalPolicyCount
;
}
yd-csf-service/src/main/java/com/yd/csf/service/service/FortuneService.java
View file @
3c6e35bd
...
...
@@ -10,6 +10,7 @@ import com.yd.csf.service.vo.FortuneVO;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.List
;
/**
* @author Zhang Jianan
...
...
@@ -35,4 +36,6 @@ public interface FortuneService extends IService<Fortune> {
Boolean
addFortune
(
FortuneAddRequest
fortuneAddRequest
);
Fortune
queryOne
(
String
fortuneBizId
);
FortuneStatisticsVO
getFortuneStatistics
(
List
<
Long
>
fortuneIdList
);
}
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/CommissionServiceImpl.java
View file @
3c6e35bd
...
...
@@ -154,13 +154,13 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
List
<
ExpectedFortune
>
expectedFortuneList
=
iExpectedFortuneService
.
list
(
expectedFortuneQueryWrapper
);
if
(
CollectionUtils
.
isEmpty
(
expectedFortuneList
))
{
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"未找到
该保单对应的
预计发佣记录"
);
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
"未找到
保单对应的预计发佣记录,请先创建
预计发佣记录"
);
}
else
{
Set
<
String
>
expectedPolicyNoSet
=
expectedFortuneList
.
stream
().
map
(
ExpectedFortune:
:
getPolicyNo
).
collect
(
Collectors
.
toSet
());
// 获取没有预计发佣的保单号
Set
<
String
>
notExpectedPolicyNoSet
=
policyNoSet
.
stream
().
filter
(
policyNo
->
!
expectedPolicyNoSet
.
contains
(
policyNo
)).
collect
(
Collectors
.
toSet
());
if
(!
CollectionUtils
.
isEmpty
(
notExpectedPolicyNoSet
))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"未找到以下保单对应的预计发佣记录:"
+
String
.
join
(
","
,
notExpectedPolicyNoSet
));
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
"未找到以下保单对应的预计发佣记录
,请先创建预计发佣记录
:"
+
String
.
join
(
","
,
notExpectedPolicyNoSet
));
}
}
...
...
@@ -185,7 +185,13 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
// 6.删除旧的发佣记录
fortuneService
.
remove
(
new
QueryWrapper
<
Fortune
>().
in
(
"policy_no"
,
policyNoSet
));
// 7. 构建实际的初始发佣记录
// 7.1 查询所选保单号对应已发薪资记录
QueryWrapper
<
Fortune
>
fortuneQueryWrapper
=
new
QueryWrapper
<>();
fortuneQueryWrapper
.
in
(
"policy_no"
,
filteredExpectedFortuneList
.
stream
().
map
(
ExpectedFortune:
:
getPolicyNo
).
collect
(
Collectors
.
toList
()));
fortuneQueryWrapper
.
eq
(
"status"
,
FortuneStatusEnum
.
SENT
.
getItemValue
());
List
<
Fortune
>
policyPaidFortuneList
=
fortuneService
.
list
(
fortuneQueryWrapper
);
// 7.2 构建实际的初始发佣记录
List
<
Fortune
>
newFortuneList
=
new
ArrayList
<>();
for
(
ExpectedFortune
expectedFortune
:
filteredExpectedFortuneList
)
{
Fortune
fortune
=
new
Fortune
();
...
...
@@ -195,6 +201,8 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
fortune
.
setStatus
(
FortuneStatusEnum
.
WAIT
.
getItemValue
());
// 关联来佣业务ID
matchCommission
(
fortune
,
commissionList
);
// 扣减已发薪资
calculateCurrentFortune
(
fortune
,
policyPaidFortuneList
);
fortune
.
setCreateTime
(
new
Date
());
fortune
.
setUpdateTime
(
new
Date
());
...
...
@@ -211,6 +219,23 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
return
true
;
}
private
void
calculateCurrentFortune
(
Fortune
fortune
,
List
<
Fortune
>
policyPaidFortuneList
)
{
// 根据转介人分组
Map
<
String
,
List
<
Fortune
>>
brokerFortuneMap
=
policyPaidFortuneList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
Fortune:
:
getBrokerBizId
));
// 当前转介人已发薪资
List
<
Fortune
>
brokerFortuneList
=
brokerFortuneMap
.
getOrDefault
(
fortune
.
getBrokerBizId
(),
new
ArrayList
<>());
// 计算当前佣金条目已发薪资
BigDecimal
brokerPaidAmount
=
brokerFortuneList
.
stream
()
.
filter
(
item
->
StringUtils
.
equals
(
item
.
getFortuneName
(),
fortune
.
getFortuneName
())
&&
item
.
getFortunePeriod
().
equals
(
fortune
.
getFortunePeriod
()))
.
map
(
Fortune:
:
getNetAmount
)
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
// 计算当前发佣金额,需要扣减已发薪资
fortune
.
setAmount
(
fortune
.
getAmount
().
subtract
(
brokerPaidAmount
));
}
private
void
matchCommission
(
Fortune
fortune
,
List
<
Commission
>
commissionList
)
{
for
(
Commission
commission
:
commissionList
)
{
if
(
StringUtils
.
equals
(
commission
.
getPolicyNo
(),
fortune
.
getPolicyNo
())
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
View file @
3c6e35bd
...
...
@@ -21,6 +21,7 @@ import com.yd.csf.service.service.FortuneAccountService;
import
com.yd.csf.service.service.FortuneService
;
import
com.yd.csf.service.dao.FortuneMapper
;
import
com.yd.csf.service.vo.FortuneVO
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.stereotype.Service
;
...
...
@@ -297,6 +298,16 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
return
this
.
getOne
(
new
LambdaQueryWrapper
<
Fortune
>().
eq
(
Fortune:
:
getFortuneBizId
,
fortuneBizId
));
}
@Override
public
FortuneStatisticsVO
getFortuneStatistics
(
List
<
Long
>
fortuneIdList
)
{
if
(
CollectionUtils
.
isEmpty
(
fortuneIdList
))
{
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"fortuneId列表不能为空"
);
}
// 自定义查询
FortuneStatisticsVO
fortuneStatisticsVO
=
this
.
baseMapper
.
getFortuneStatistics
(
fortuneIdList
);
return
fortuneStatisticsVO
;
}
}
...
...
yd-csf-service/src/main/java/com/yd/csf/service/vo/FortuneVO.java
View file @
3c6e35bd
...
...
@@ -15,6 +15,12 @@ import java.util.Date;
public
class
FortuneVO
implements
Serializable
{
/**
* fortune id
*/
@Schema
(
description
=
"fortune id"
)
private
Long
fortuneId
;
/**
* 保单发佣业务id
*/
@Schema
(
description
=
"保单发佣业务id"
)
...
...
yd-csf-service/src/main/resources/mappers/FortuneMapper.xml
View file @
3c6e35bd
...
...
@@ -44,4 +44,17 @@
calculation_formula,remark,is_deleted,creator_id,updater_id,
create_time,update_time
</sql>
<select
id=
"getFortuneStatistics"
resultType=
"com.yd.csf.service.dto.FortuneStatisticsVO"
>
select
ifnull(f.amount,0) as totalOutAmount,
ifnull(c.amount,0) as totalInAmount,
count(distinct f.policy_no) as totalPolicyCount
from fortune f
left join commission c on f.commission_biz_id = c.commission_biz_id
where f.id in
<foreach
collection=
"fortuneIdList"
item=
"fortuneId"
open=
"("
close=
")"
separator=
","
>
#{fortuneId}
</foreach>
</select>
</mapper>
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