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
906e0a3f
Commit
906e0a3f
authored
Jan 06, 2026
by
jianan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
前端对接问题修复69
parent
34843699
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
93 additions
and
68 deletions
+93
-68
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
+4
-6
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneAccountServiceImpl.java
+83
-62
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
+6
-0
No files found.
yd-csf-api/src/main/java/com/yd/csf/api/controller/ApiFortuneController.java
View file @
906e0a3f
...
@@ -202,10 +202,9 @@ public class ApiFortuneController {
...
@@ -202,10 +202,9 @@ public class ApiFortuneController {
if
(
CollectionUtils
.
isEmpty
(
fortuneDownloadRequest
.
getFortuneBizIdList
()))
{
if
(
CollectionUtils
.
isEmpty
(
fortuneDownloadRequest
.
getFortuneBizIdList
()))
{
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"请选择要出账的发佣数据"
);
throw
new
BusinessException
(
ResultCode
.
PARAMS_ERROR
.
getCode
(),
"请选择要出账的发佣数据"
);
}
}
try
{
fortuneService
.
downloadAccount
(
fortuneDownloadRequest
,
response
);
fortuneService
.
downloadAccount
(
fortuneDownloadRequest
,
response
);
return
Result
.
success
(
true
);
}
catch
(
Exception
e
)
{
// // 设置响应类型为 JSON,而不是文件流
// // 设置响应类型为 JSON,而不是文件流
// response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
// response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
// response.setContentType(MediaType.APPLICATION_JSON_VALUE);
// response.setContentType(MediaType.APPLICATION_JSON_VALUE);
...
@@ -218,11 +217,10 @@ public class ApiFortuneController {
...
@@ -218,11 +217,10 @@ public class ApiFortuneController {
//
//
// response.getWriter().write(new ObjectMapper().writeValueAsString(errorResult));
// response.getWriter().write(new ObjectMapper().writeValueAsString(errorResult));
log
.
error
(
"生成出账清单失败"
,
e
);
return
Result
.
success
(
true
);
return
Result
.
success
(
false
);
}
}
}
/**
/**
* 分页获取出账列表
* 分页获取出账列表
*
*
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneAccountServiceImpl.java
View file @
906e0a3f
package
com
.
yd
.
csf
.
service
.
service
.
impl
;
package
com
.
yd
.
csf
.
service
.
service
.
impl
;
import
java.math.RoundingMode
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -247,77 +248,97 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
...
@@ -247,77 +248,97 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
completeFortuneAccount
(
CompleteFortuneAccountRequest
completeFortuneAccountRequest
)
{
public
Boolean
completeFortuneAccount
(
CompleteFortuneAccountRequest
req
)
{
/* 1. 参数校验 & 查询 --------------------------------------------------*/
List
<
String
>
fortuneAccountBizIdList
=
completeFortuneAccountRequest
.
getFortuneAccountBizIdList
();
List
<
String
>
accountBizIds
=
req
.
getFortuneAccountBizIdList
();
List
<
FortuneAccount
>
fortuneAccountList
=
this
.
list
(
new
QueryWrapper
<
FortuneAccount
>().
in
(
"fortune_account_biz_id"
,
fortuneAccountBizIdList
));
if
(
CollectionUtils
.
isEmpty
(
accountBizIds
))
{
if
(
CollectionUtils
.
isEmpty
(
fortuneAccountList
))
{
throw
new
BusinessException
(
"出账清单不能为空"
);
throw
new
BusinessException
(
ResultCode
.
NULL_ERROR
.
getCode
(),
ResultCode
.
NULL_ERROR
.
getMessage
());
}
}
List
<
FortuneAccount
>
accountList
=
this
.
lambdaQuery
()
// 当前登录用户
.
in
(
FortuneAccount:
:
getFortuneAccountBizId
,
accountBizIds
)
AuthUserDto
currentLoginUser
=
SecurityUtil
.
getCurrentLoginUser
();
.
list
();
Long
loginUserId
=
currentLoginUser
.
getId
();
Long
loginUserId
=
SecurityUtil
.
getCurrentLoginUser
().
getId
();
// 更新 FortuneAccount 状态为已出账
for
(
FortuneAccount
fortuneAccount
:
fortuneAccountList
)
{
/* 2. 更新 FortuneAccount 状态为已出账 ----------------------------------*/
fortuneAccount
.
setStatus
(
FortuneAccountStatusEnum
.
SENT
.
getItemValue
());
accountList
.
forEach
(
a
->
{
fortuneAccount
.
setFortuneAccountDate
(
new
Date
());
a
.
setStatus
(
FortuneAccountStatusEnum
.
SENT
.
getItemValue
());
fortuneAccount
.
setUpdaterId
(
loginUserId
.
toString
());
a
.
setFortuneAccountDate
(
new
Date
());
fortuneAccount
.
setUpdateTime
(
new
Date
());
a
.
setUpdaterId
(
loginUserId
.
toString
());
a
.
setUpdateTime
(
new
Date
());
});
this
.
updateBatchById
(
accountList
);
/* 3. 取出关联的所有 fortune 并一次性更新为已出账 ------------------------*/
List
<
String
>
accountBizIdList
=
accountList
.
stream
()
.
map
(
FortuneAccount:
:
getFortuneAccountBizId
).
collect
(
Collectors
.
toList
());
List
<
Fortune
>
fortunes
=
fortuneService
.
lambdaQuery
()
.
in
(
Fortune:
:
getFortuneAccountBizId
,
accountBizIdList
)
.
eq
(
Fortune:
:
getStatus
,
FortuneStatusEnum
.
CHECKED
.
getItemValue
())
.
list
();
if
(
CollectionUtils
.
isNotEmpty
(
fortunes
))
{
fortunes
.
forEach
(
f
->
{
f
.
setStatus
(
FortuneStatusEnum
.
SENT
.
getItemValue
());
f
.
setUpdaterId
(
loginUserId
.
toString
());
f
.
setUpdateTime
(
new
Date
());
});
fortuneService
.
updateBatchById
(
fortunes
);
}
}
this
.
updateBatchById
(
fortuneAccountList
);
// 更新 Fortune 状态为已出账
/* 4. 按 expected_fortune 维度重新汇总已出账金额 --------------------------*/
List
<
String
>
accountBizIdList
=
fortuneAccountList
.
stream
().
map
(
FortuneAccount:
:
getFortuneAccountBizId
).
collect
(
Collectors
.
toList
());
// 4.1 收集所有涉及的 expectedFortuneBizId
List
<
Fortune
>
updateFortuneList
=
fortuneService
.
list
(
new
QueryWrapper
<
Fortune
>().
in
(
"fortune_account_biz_id"
,
accountBizIdList
));
Set
<
String
>
expectedIds
=
fortunes
.
stream
()
if
(
CollectionUtils
.
isNotEmpty
(
updateFortuneList
))
{
.
map
(
Fortune:
:
getExpectedFortuneBizId
)
for
(
Fortune
item
:
updateFortuneList
)
{
.
collect
(
Collectors
.
toSet
());
item
.
setStatus
(
FortuneStatusEnum
.
SENT
.
getItemValue
());
if
(
CollectionUtils
.
isEmpty
(
expectedIds
))
{
item
.
setUpdaterId
(
loginUserId
.
toString
());
return
true
;
// 没有对应预计出账,直接结束
item
.
setUpdateTime
(
new
Date
());
}
fortuneService
.
updateBatchById
(
updateFortuneList
);
}
}
// 更新预计出账记录
// 4.2 先锁再算
List
<
String
>
expectedFortuneBizIdList
=
updateFortuneList
.
stream
().
map
(
Fortune:
:
getExpectedFortuneBizId
).
collect
(
Collectors
.
toList
());
List
<
ExpectedFortune
>
expectedList
=
expectedFortuneService
.
lambdaQuery
()
if
(
CollectionUtils
.
isNotEmpty
(
expectedFortuneBizIdList
))
{
.
in
(
ExpectedFortune:
:
getExpectedFortuneBizId
,
expectedIds
)
List
<
ExpectedFortune
>
expectedFortuneList
=
expectedFortuneService
.
list
(
new
QueryWrapper
<
ExpectedFortune
>().
in
(
"expected_fortune_biz_id"
,
expectedFortuneBizIdList
));
.
last
(
"FOR UPDATE"
)
// 预计出账映射
.
list
();
Map
<
String
,
ExpectedFortune
>
expectedFortuneMap
=
expectedFortuneList
.
stream
()
.
collect
(
Collectors
.
toMap
(
ExpectedFortune:
:
getExpectedFortuneBizId
,
Function
.
identity
()));
// 4.3 全量汇总:把同一 expected_fortune 下所有 fortune 的 current_payment_amount 求和
// 遍历本次出账记录,更新预计出账记录
Map
<
String
,
BigDecimal
>
paidMap
=
fortuneService
.
lambdaQuery
()
for
(
Fortune
item
:
updateFortuneList
)
{
.
in
(
Fortune:
:
getExpectedFortuneBizId
,
expectedIds
)
ExpectedFortune
expectedFortune
=
expectedFortuneMap
.
get
(
item
.
getExpectedFortuneBizId
());
.
eq
(
Fortune:
:
getStatus
,
FortuneStatusEnum
.
SENT
.
getItemValue
())
if
(
Objects
.
nonNull
(
expectedFortune
))
{
.
list
()
BigDecimal
currentPaymentAmount
=
item
.
getCurrentPaymentAmount
();
// 本次出账金额
.
stream
()
BigDecimal
paidAmount
=
expectedFortune
.
getPaidAmount
();
// 已出账金额
.
collect
(
Collectors
.
groupingBy
(
Fortune:
:
getExpectedFortuneBizId
,
if
(
expectedFortune
.
getAmount
().
compareTo
(
paidAmount
.
add
(
currentPaymentAmount
))
==
0
)
{
Collectors
.
mapping
(
Fortune:
:
getCurrentPaymentAmount
,
// 已出账金额等于预计出账金额,更新状态为完成出账
Collectors
.
reducing
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
))));
expectedFortune
.
setPaidAmount
(
paidAmount
.
add
(
currentPaymentAmount
));
expectedFortune
.
setUnpaidAmount
(
BigDecimal
.
ZERO
);
// 4.4 反写 expected_fortune
expectedFortune
.
setStatus
(
FortuneStatusEnum
.
SENT
.
getItemValue
());
expectedList
.
forEach
(
ef
->
{
BigDecimal
totalPaid
=
paidMap
.
getOrDefault
(
ef
.
getExpectedFortuneBizId
(),
BigDecimal
.
ZERO
);
BigDecimal
totalAmount
=
ef
.
getAmount
();
BigDecimal
unpaid
=
totalAmount
.
subtract
(
totalPaid
);
String
newStatus
;
if
(
unpaid
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
newStatus
=
FortuneStatusEnum
.
SENT
.
getItemValue
();
// 全部完成
}
else
if
(
totalPaid
.
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
newStatus
=
FortuneStatusEnum
.
PARTIAL_SENT
.
getItemValue
();
// 部分完成
}
else
{
}
else
{
// 已出账金额小于预计出账金额,更新已出账金额
newStatus
=
ef
.
getStatus
();
// 无变化
expectedFortune
.
setPaidAmount
(
paidAmount
.
add
(
currentPaymentAmount
));
expectedFortune
.
setUnpaidAmount
(
expectedFortune
.
getAmount
().
subtract
(
paidAmount
.
add
(
currentPaymentAmount
)));
expectedFortune
.
setStatus
(
FortuneStatusEnum
.
PARTIAL_SENT
.
getItemValue
());
expectedFortune
.
setUpdaterId
(
loginUserId
.
toString
());
expectedFortune
.
setUpdateTime
(
LocalDateTime
.
now
());
}
}
// 更新预计出账记录
expectedFortuneService
.
lambdaUpdate
()
expectedFortuneService
.
lambdaUpdate
()
.
set
(
ExpectedFortune:
:
getPaidAmount
,
expectedFortune
.
getPaidAmount
())
.
set
(
ExpectedFortune:
:
getPaidAmount
,
totalPaid
)
.
set
(
ExpectedFortune:
:
getUnpaidAmount
,
expectedFortune
.
getUnpaidAmount
())
.
set
(
ExpectedFortune:
:
getUnpaidAmount
,
unpaid
)
.
set
(
ExpectedFortune:
:
getStatus
,
expectedFortune
.
getStatus
())
.
set
(
ExpectedFortune:
:
getPaidRatio
,
.
set
(
ExpectedFortune:
:
getUpdaterId
,
expectedFortune
.
getUpdaterId
())
totalPaid
.
divide
(
totalAmount
,
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)))
.
set
(
ExpectedFortune:
:
getUpdateTime
,
expectedFortune
.
getUpdateTime
())
.
set
(
ExpectedFortune:
:
getUnpaidRatio
,
.
eq
(
ExpectedFortune:
:
getId
,
expectedFortune
.
getId
())
unpaid
.
divide
(
totalAmount
,
4
,
RoundingMode
.
HALF_UP
).
multiply
(
BigDecimal
.
valueOf
(
100
)))
.
set
(
ExpectedFortune:
:
getStatus
,
newStatus
)
.
set
(
ExpectedFortune:
:
getUpdaterId
,
loginUserId
.
toString
())
.
set
(
ExpectedFortune:
:
getUpdateTime
,
LocalDateTime
.
now
())
.
eq
(
ExpectedFortune:
:
getId
,
ef
.
getId
())
.
update
();
.
update
();
}
});
}
}
return
true
;
return
true
;
}
}
...
...
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/FortuneServiceImpl.java
View file @
906e0a3f
...
@@ -187,6 +187,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
...
@@ -187,6 +187,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
if
(
currentPaymentAmount
.
compareTo
(
expectedFortune
.
getAmount
())
>
0
)
{
if
(
currentPaymentAmount
.
compareTo
(
expectedFortune
.
getAmount
())
>
0
)
{
throw
new
BusinessException
(
ResultCode
.
PARAM_CHECK_ERROR
.
getCode
(),
"出账金额不能大于应付款金额"
);
throw
new
BusinessException
(
ResultCode
.
PARAM_CHECK_ERROR
.
getCode
(),
"出账金额不能大于应付款金额"
);
}
}
if
(
StringUtils
.
isBlank
(
fortuneUpdateRequest
.
getCurrency
()))
{
throw
new
BusinessException
(
ResultCode
.
PARAM_CHECK_ERROR
.
getCode
(),
"出账币种不能为空"
);
}
}
}
// 获取当前登录用户
// 获取当前登录用户
...
@@ -319,6 +322,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
...
@@ -319,6 +322,9 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
if
(!
StringUtils
.
equals
(
fortune
.
getStatus
(),
FortuneStatusEnum
.
CHECKED
.
getItemValue
()))
{
if
(!
StringUtils
.
equals
(
fortune
.
getStatus
(),
FortuneStatusEnum
.
CHECKED
.
getItemValue
()))
{
validateMsg
.
append
(
fortune
.
getPolicyNo
()).
append
(
"-"
).
append
(
fortune
.
getBroker
()).
append
(
"未检核,不能生成出账记录; "
);
validateMsg
.
append
(
fortune
.
getPolicyNo
()).
append
(
"-"
).
append
(
fortune
.
getBroker
()).
append
(
"未检核,不能生成出账记录; "
);
}
}
if
(
StringUtils
.
equals
(
fortune
.
getStatus
(),
FortuneStatusEnum
.
SENT
.
getItemValue
()))
{
validateMsg
.
append
(
fortune
.
getPolicyNo
()).
append
(
"-"
).
append
(
fortune
.
getBroker
()).
append
(
"已完成出账,不能生成出账记录; "
);
}
}
}
if
(
StringUtils
.
isNotBlank
(
validateMsg
.
toString
()))
{
if
(
StringUtils
.
isNotBlank
(
validateMsg
.
toString
()))
{
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
validateMsg
.
toString
());
throw
new
BusinessException
(
ResultCode
.
FAIL
.
getCode
(),
validateMsg
.
toString
());
...
...
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