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
d644ef17
Commit
d644ef17
authored
Mar 06, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
24017a14
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
171 additions
and
68 deletions
+171
-68
yd-csf-api/src/main/java/com/yd/csf/api/response/basiclawcalculate/ApiExecuteBillingResponse.java
+15
-0
yd-csf-api/src/main/java/com/yd/csf/api/response/basiclawcalculate/ApiExecuteRewardResponse.java
+15
-0
yd-csf-api/src/main/java/com/yd/csf/api/service/ApiExpectedFortuneService.java
+8
-0
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
+133
-68
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/response/basiclawcalculate/ApiExecuteBillingResponse.java
0 → 100644
View file @
d644ef17
package
com
.
yd
.
csf
.
api
.
response
.
basiclawcalculate
;
import
com.yd.csf.api.dto.AlgorithmResDto
;
import
com.yd.csf.api.dto.ExecuteBillingDto
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
ApiExecuteBillingResponse
{
private
ExecuteBillingDto
dto
;
private
List
<
AlgorithmResDto
>
algorithmResDtoList
;
}
yd-csf-api/src/main/java/com/yd/csf/api/response/basiclawcalculate/ApiExecuteRewardResponse.java
0 → 100644
View file @
d644ef17
package
com
.
yd
.
csf
.
api
.
response
.
basiclawcalculate
;
import
com.yd.csf.api.dto.AlgorithmResDto
;
import
com.yd.csf.api.dto.ExecuteBillingDto
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
ApiExecuteRewardResponse
{
private
ExecuteBillingDto
dto
;
private
List
<
AlgorithmResDto
>
algorithmResDtoList
;
}
yd-csf-api/src/main/java/com/yd/csf/api/service/ApiExpectedFortuneService.java
View file @
d644ef17
...
...
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.yd.common.result.Result
;
import
com.yd.csf.api.dto.ApiExpectedFortunePageResponseVO
;
import
com.yd.csf.api.dto.PayableReportResponse
;
import
com.yd.csf.api.response.basiclawcalculate.ApiExecuteBillingResponse
;
import
com.yd.csf.api.response.basiclawcalculate.ApiExecuteRewardResponse
;
import
com.yd.csf.feign.request.expectedfortune.ApiExpectedFortunePageRequest
;
import
com.yd.csf.feign.request.expectedfortune.ApiGenerateExpectedFortuneRequest
;
import
com.yd.csf.feign.request.expectedfortune.ExpectedFortuneAddRequest
;
...
...
@@ -16,6 +18,8 @@ import com.yd.csf.service.model.CommissionRuleBinding;
import
com.yd.csf.service.model.ExpectedFortune
;
import
com.yd.csf.service.vo.ExpectedFortuneStatisticsVO
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.List
;
...
...
@@ -62,6 +66,10 @@ public interface ApiExpectedFortuneService {
Boolean
update
(
ExpectedFortuneUpdateRequest
request
);
void
generateExpectedFortuneBilling
(
List
<
ApiExecuteBillingResponse
>
billingResponses
);
void
generateExpectedFortuneReward
(
List
<
ApiExecuteRewardResponse
>
rewardResponses
);
Result
<
ApiExpectedFortunePageResponseVO
>
list
(
ApiExpectedFortunePageRequest
request
);
Boolean
add
(
List
<
ExpectedFortuneAddRequest
>
request
);
...
...
yd-csf-api/src/main/java/com/yd/csf/api/service/impl/ApiExpectedFortuneServiceImpl.java
View file @
d644ef17
...
...
@@ -18,11 +18,12 @@ import com.yd.common.result.Result;
import
com.yd.common.utils.RandomStringGenerator
;
import
com.yd.common.utils.RedisUtil
;
import
com.yd.csf.api.dto.*
;
import
com.yd.csf.api.response.basiclawcalculate.ApiExecuteRewardResponse
;
import
com.yd.csf.api.service.ApiBasicLawCalculateService
;
import
com.yd.csf.api.service.ApiExpectedFortuneLogService
;
import
com.yd.csf.api.service.ApiExpectedFortuneService
;
import
com.yd.csf.feign.dto.appointmentfile.ItineraryDto
;
import
com.yd.csf.feign.request.expectedfortune.*
;
import
com.yd.csf.api.response.basiclawcalculate.ApiExecuteBillingResponse
;
import
com.yd.csf.feign.response.expectedfortune.ApiExpectedFortunePageResponse
;
import
com.yd.csf.feign.response.expectedfortune.ApiGenerateExpectedFortuneResponse
;
import
com.yd.csf.service.dto.CommissionRuleBindingDto
;
...
...
@@ -46,10 +47,14 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.support.TransactionTemplate
;
import
org.springframework.util.CollectionUtils
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.Executor
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.math.BigDecimal
;
...
...
@@ -92,6 +97,12 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
@Resource
private
PolicyFollowService
policyFollowService
;
@Autowired
@Qualifier
(
"commonAsyncExecutor"
)
private
Executor
asyncExecutor
;
@Autowired
private
ApiExpectedFortuneService
self
;
/**
* 生成预计发佣
*
...
...
@@ -352,6 +363,10 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
// 使用编程式事务,确保方法内的事务一致性
return
transactionTemplate
.
execute
(
status
->
{
try
{
//收集-销售佣金计算结果集列表
List
<
ApiExecuteBillingResponse
>
billingResponses
=
new
ArrayList
<>();
//收集-非销售佣金计算结果集列表
List
<
ApiExecuteRewardResponse
>
rewardResponses
=
new
ArrayList
<>();
for
(
QueryPolicyAndBrokerDto
brokerDto
:
queryPolicyAndBrokerDtoList
)
{
Integer
paymentTerm
=
brokerDto
.
getPaymentTerm
();
if
(
Objects
.
isNull
(
paymentTerm
))
{
...
...
@@ -361,24 +376,38 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
List
<
CommissionRuleBinding
>
commissionRuleBindingList
=
brokerRelUserIdList
(
brokerDto
);
log
.
info
(
"同步处理-> 遍历保单转介人列表信息 -> 调用基本法算出预计发佣列表->commissionRuleBindingList:{}"
,
JSON
.
toJSONString
(
commissionRuleBindingList
));
for
(
int
i
=
1
;
i
<=
paymentTerm
;
i
++)
{
executeBilling
(
ExecuteBillingDto
.
builder
()
Result
<
List
<
ApiExecuteBillingResponse
>>
result
=
executeBilling
(
ExecuteBillingDto
.
builder
()
.
name
(
brokerDto
.
getBrokerName
())
.
policyAndBrokerDto
(
brokerDto
)
.
issueNumber
(
i
)
.
build
());
//收集-销售佣金计算结果集列表
billingResponses
.
addAll
(
result
.
getData
());
if
(!
CollectionUtils
.
isEmpty
(
commissionRuleBindingList
))
{
for
(
CommissionRuleBinding
binding
:
commissionRuleBindingList
)
{
executeReward
(
ExecuteBillingDto
.
builder
()
Result
<
List
<
ApiExecuteRewardResponse
>>
result1
=
executeReward
(
ExecuteBillingDto
.
builder
()
.
clientUserBizId
(
binding
.
getTargetId
())
.
name
(
binding
.
getTargetName
())
.
policyAndBrokerDto
(
brokerDto
)
.
issueNumber
(
i
)
.
build
());
//收集-非销售佣金计算结果集列表
rewardResponses
.
addAll
(
result1
.
getData
());
}
}
}
}
// 异步调用-销售佣金-保存预计发佣数据
CompletableFuture
<
Void
>
future1
=
CompletableFuture
.
runAsync
(
()
->
self
.
generateExpectedFortuneBilling
(
billingResponses
),
asyncExecutor
);
//异步调用-奖励佣金-保存预计发佣数据
CompletableFuture
<
Void
>
future2
=
CompletableFuture
.
runAsync
(
()
->
self
.
generateExpectedFortuneReward
(
rewardResponses
),
asyncExecutor
);
// 等待两个任务完成
// CompletableFuture.allOf(future1, future2).join();
//批量设置应付款编号
updatePayableNoBatch
(
policyNo
);
...
...
@@ -410,6 +439,92 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
}
/**
* 异步-销售佣金-保存预计发佣数据
* @param billingResponses
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
)
public
void
generateExpectedFortuneBilling
(
List
<
ApiExecuteBillingResponse
>
billingResponses
)
{
for
(
ApiExecuteBillingResponse
response
:
billingResponses
)
{
ExecuteBillingDto
dto
=
response
.
getDto
();
QueryPolicyAndBrokerDto
brokerDto
=
dto
.
getPolicyAndBrokerDto
();
List
<
AlgorithmResDto
>
algorithmResDtoList
=
response
.
getAlgorithmResDtoList
();
//生成保单预计发佣表记录 (销售佣金基本法)
generateExpectedFortune
(
GenerateExpectedFortuneDto
.
builder
()
//转介人绑定的基本法列表对应计算值
.
algorithmResDtoList
(
algorithmResDtoList
)
//保单发佣批次ID
//获得积分的转介人(业务员)姓名
.
broker
(
dto
.
getName
())
//获得积分的转介人(业务员)业务ID
.
brokerBizId
(
brokerDto
.
getBrokerBizId
())
//发佣币种
.
currency
(
brokerDto
.
getCurrency
())
//发佣期数
.
fortunePeriod
(
dto
.
getIssueNumber
())
//发佣总期数
.
fortuneTotalPeriod
(
brokerDto
.
getPaymentTerm
())
//发佣类型 TODO
// .fortuneType()
//发佣日期
.
payoutDate
(
calculateExpectedPayoutDate
(
brokerDto
.
getEffectiveDate
(),
dto
.
getIssueNumber
()))
//保单号
.
policyNo
(
brokerDto
.
getPolicyNo
())
//佣金发放状态 0=待出账 1=可出账 2=已出账
.
status
(
FortuneStatusEnum
.
WAIT
.
getItemValue
())
//期交保费
.
paymentPremium
(
brokerDto
.
getPaymentPremium
())
//所属团队 TODO
// .team()
//所属团队业务ID TODO
// .teamBizId()
.
build
());
}
}
/**
* 异步-奖励佣金-保存预计发佣数据
* @param rewardResponses
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
)
public
void
generateExpectedFortuneReward
(
List
<
ApiExecuteRewardResponse
>
rewardResponses
)
{
for
(
ApiExecuteRewardResponse
response
:
rewardResponses
)
{
List
<
AlgorithmResDto
>
algorithmResDtoList
=
response
.
getAlgorithmResDtoList
();
ExecuteBillingDto
dto
=
response
.
getDto
();
QueryPolicyAndBrokerDto
brokerDto
=
dto
.
getPolicyAndBrokerDto
();
//生成保单预计发佣表记录 (非销售佣金基本法)
generateExpectedFortune
(
GenerateExpectedFortuneDto
.
builder
()
//获得积分的用户绑定的基本法列表对应计算值
.
algorithmResDtoList
(
algorithmResDtoList
)
//保单发佣批次ID
//获得积分的用户姓名
.
broker
(
dto
.
getName
())
//获得积分的用户业务ID
.
brokerBizId
(
dto
.
getClientUserBizId
())
//发佣币种
.
currency
(
brokerDto
.
getCurrency
())
//发佣期数
.
fortunePeriod
(
dto
.
getIssueNumber
())
//发佣总期数
.
fortuneTotalPeriod
(
brokerDto
.
getPaymentTerm
())
//发佣类型 TODO
// .fortuneType()
//发佣日期 保单生效日期 + 3个月
.
payoutDate
(
calculateExpectedPayoutDate
(
brokerDto
.
getEffectiveDate
(),
dto
.
getIssueNumber
()))
//保单号
.
policyNo
(
brokerDto
.
getPolicyNo
())
//佣金发放状态 0=待出账 1=可出账 2=已出账
.
status
(
FortuneStatusEnum
.
WAIT
.
getItemValue
())
//期交保费
.
paymentPremium
(
brokerDto
.
getPaymentPremium
())
//所属团队 TODO
// .team()
//所属团队业务ID TODO
// .teamBizId()
.
build
());
}
}
/**
* 查询和当前转介人相关关系(推荐,一级管理,二级管理,辅导)的客户端用户ID列表数据
* @param brokerDto
* @return
...
...
@@ -461,7 +576,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
* @return
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
executeReward
(
ExecuteBillingDto
dto
)
{
public
Result
<
List
<
ApiExecuteRewardResponse
>>
executeReward
(
ExecuteBillingDto
dto
)
{
List
<
ApiExecuteRewardResponse
>
responses
=
new
ArrayList
<>();
QueryPolicyAndBrokerDto
brokerDto
=
dto
.
getPolicyAndBrokerDto
();
//构造销售佣金基本法项目的顺序下标值执行
List
<
Integer
>
executionOrderList
=
new
ArrayList
<>();
...
...
@@ -484,39 +600,12 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
.
isNegateExecutionOrderList
(
true
)
.
build
());
log
.
info
(
"执行获得积分用户的非销售佣金基本法项目->出参:{}"
,
JSON
.
toJSONString
(
result
));
ApiExecuteRewardResponse
response
=
new
ApiExecuteRewardResponse
();
response
.
setAlgorithmResDtoList
(
result
.
getData
());
response
.
setDto
(
dto
);
responses
.
add
(
response
);
//生成保单预计发佣表记录 (非销售佣金基本法)
generateExpectedFortune
(
GenerateExpectedFortuneDto
.
builder
()
//获得积分的用户绑定的基本法列表对应计算值
.
algorithmResDtoList
(
result
.
getData
())
//保单发佣批次ID
//获得积分的用户姓名
.
broker
(
dto
.
getName
())
//获得积分的用户业务ID
.
brokerBizId
(
dto
.
getClientUserBizId
())
//发佣币种
.
currency
(
brokerDto
.
getCurrency
())
//发佣期数
.
fortunePeriod
(
dto
.
getIssueNumber
())
//发佣总期数
.
fortuneTotalPeriod
(
brokerDto
.
getPaymentTerm
())
//发佣类型 TODO
// .fortuneType()
//发佣日期 保单生效日期 + 3个月
.
payoutDate
(
calculateExpectedPayoutDate
(
brokerDto
.
getEffectiveDate
(),
dto
.
getIssueNumber
()))
//保单号
.
policyNo
(
brokerDto
.
getPolicyNo
())
//佣金发放状态 0=待出账 1=可出账 2=已出账
.
status
(
FortuneStatusEnum
.
WAIT
.
getItemValue
())
//期交保费
.
paymentPremium
(
brokerDto
.
getPaymentPremium
())
//所属团队 TODO
// .team()
//所属团队业务ID TODO
// .teamBizId()
.
build
());
return
Result
.
success
();
return
Result
.
success
(
responses
);
}
private
static
LocalDate
calculateExpectedPayoutDate
(
LocalDate
effectiveDate
,
Integer
issueNumber
)
{
...
...
@@ -530,7 +619,8 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
* @return
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Result
executeBilling
(
ExecuteBillingDto
dto
)
{
public
Result
<
List
<
ApiExecuteBillingResponse
>>
executeBilling
(
ExecuteBillingDto
dto
)
{
List
<
ApiExecuteBillingResponse
>
responses
=
new
ArrayList
<>();
log
.
info
(
"执行 - 销售佣金(销售佣金基本法)——>入参:{}"
,
JSON
.
toJSONString
(
dto
));
QueryPolicyAndBrokerDto
brokerDto
=
dto
.
getPolicyAndBrokerDto
();
//构造销售佣金基本法项目的顺序下标值执行
...
...
@@ -553,40 +643,15 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
.
isNegateExecutionOrderList
(
false
)
.
build
());
ApiExecuteBillingResponse
response
=
new
ApiExecuteBillingResponse
();
response
.
setDto
(
dto
);
response
.
setAlgorithmResDtoList
(
result
.
getData
());
responses
.
add
(
response
);
log
.
info
(
"执行 - 销售佣金(销售佣金基本法)——>brokerDto:{}"
,
JSON
.
toJSONString
(
brokerDto
));
log
.
info
(
"执行 - 销售佣金(销售佣金基本法)——>policyBrokerAlgorithm——>result:{}"
,
JSON
.
toJSONString
(
result
));
//生成保单预计发佣表记录 (销售佣金基本法)
generateExpectedFortune
(
GenerateExpectedFortuneDto
.
builder
()
//转介人绑定的基本法列表对应计算值
.
algorithmResDtoList
(
result
.
getData
())
//保单发佣批次ID
//获得积分的转介人(业务员)姓名
.
broker
(
dto
.
getName
())
//获得积分的转介人(业务员)业务ID
.
brokerBizId
(
brokerDto
.
getBrokerBizId
())
//发佣币种
.
currency
(
brokerDto
.
getCurrency
())
//发佣期数
.
fortunePeriod
(
dto
.
getIssueNumber
())
//发佣总期数
.
fortuneTotalPeriod
(
brokerDto
.
getPaymentTerm
())
//发佣类型 TODO
// .fortuneType()
//发佣日期
.
payoutDate
(
calculateExpectedPayoutDate
(
brokerDto
.
getEffectiveDate
(),
dto
.
getIssueNumber
()))
//保单号
.
policyNo
(
brokerDto
.
getPolicyNo
())
//佣金发放状态 0=待出账 1=可出账 2=已出账
.
status
(
FortuneStatusEnum
.
WAIT
.
getItemValue
())
//期交保费
.
paymentPremium
(
brokerDto
.
getPaymentPremium
())
//所属团队 TODO
// .team()
//所属团队业务ID TODO
// .teamBizId()
.
build
());
return
Result
.
success
();
return
Result
.
success
(
responses
);
}
/**
...
...
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