Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-backend
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
AutogeneralShanghai
yd-backend
Commits
b5d4e0ce
Commit
b5d4e0ce
authored
Nov 20, 2020
by
yao.xiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保留批次
parent
e67e8d7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
40 deletions
+70
-40
yd-api/src/main/java/com/yd/api/agms/service/impl/AgmsFortuneServiceImpl.java
+70
-40
No files found.
yd-api/src/main/java/com/yd/api/agms/service/impl/AgmsFortuneServiceImpl.java
View file @
b5d4e0ce
...
...
@@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.security.auth.login.LoginContext
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.OutputStream
;
...
...
@@ -101,6 +102,7 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
private
SendService
sendService
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
CommissionPayoutStatusUpdateResponseVO
commissionPayoutStatusUpdate
(
CommissionPayoutStatusUpdateRequestVO
requestVO
)
{
CommissionPayoutStatusUpdateResponseVO
responseVO
=
new
CommissionPayoutStatusUpdateResponseVO
();
CommonResult
commonResult
=
check
(
requestVO
);
...
...
@@ -283,7 +285,9 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
fortune
.
setCommissionPayoutStatus
(
paymentStatus
);
fortune
.
setCommissionPayoutBy
(
loginId
);
fortune
.
setCommissionPayoutAt
(
new
Date
());
fortune
.
setPayoutBatchId
(
payoutBatchId
);
if
(!
CommonUtil
.
isNullOrZero
(
payoutBatchId
)){
fortune
.
setPayoutBatchId
(
payoutBatchId
);
}
Long
withdrawId
=
fortune
.
getWithdrawedId
();
fortune
.
setWithdrawedId
(
null
);
fortune
.
setFortunePayedId
(
null
);
...
...
@@ -324,55 +328,59 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
Map
<
Long
,
List
<
AclCustomerFortune
>>
customerFortuneMap
=
changeCustomerFortunesByFieldName
(
fortunes
,
"customerId"
);
customerIds
=
customerFortuneMap
.
keySet
();
}
//如果customerIds为null,则此次需修改的withdraw提现金额为0
if
(
customerIds
.
isEmpty
()){
//修改withdraws/pays提现金额为0
updateWithdrawAmountToZero
(
withdraws
,
pays
,
loginId
);
return
;
}
//查询customerIds的基本财富信息(历史累积财富 已退保财富 已提现财富 等) customerId CustomerFortuneStatisticalInfo
Map
<
Long
,
CustomerFortuneStatisticalInfo
>
customerFortuneStatisticalMap
=
agmsFortuneDalService
.
findFortuneStatisticalByCustomers
(
customerIds
);
//按withdrawedId经行整理
Map
<
Long
,
List
<
AclCustomerFortune
>>
withdrawsFortunes
=
changeCustomerFortunesByFieldName
(
fortunes
,
"withdrawedId"
);
for
(
Map
.
Entry
<
Long
,
List
<
AclCustomerFortune
>>
withdrawsFortune:
withdrawsFortunes
.
entrySet
()){
for
(
AclCustomerFortuneWithdraw
withdraw
:
withdraws
)
{
//withdrawId
Long
withdrawId
=
withdraw
sFortune
.
getKey
();
Long
withdrawId
=
withdraw
.
getId
();
//需要重新计算withdraw根据的fortune记录
List
<
AclCustomerFortune
>
fortuneWithdraw
=
withdrawsFortune
.
getValue
();
List
<
AclCustomerFortune
>
fortuneWithdraw
=
withdrawsFortunes
.
get
(
withdrawId
);
if
(
fortuneWithdraw
.
isEmpty
())
{
updateWithdrawAmountToZero
(
withdraws
,
pays
,
loginId
);
continue
;
}
//统计此次提现总金额
BigDecimal
withdrawAmount
=
fortuneWithdraw
.
stream
()
.
map
(
item
->
item
.
getReferralAmount
()
==
null
?
BigDecimal
.
ZERO
:
item
.
getReferralAmount
())
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
//找到对应的withdraw记录
for
(
AclCustomerFortuneWithdraw
withdraw:
withdraws
){
if
(
withdraw
.
getId
().
equals
(
withdrawId
)){
//基本财富信息(历史累积财富 已退保财富 已提现财富 等)
CustomerFortuneStatisticalInfo
customerFortuneStatisticalInfo
=
customerFortuneStatisticalMap
.
get
(
withdraw
.
getCustomerId
());
//根据customerId查询未提现财富金额 可提现财富+不可体现财富+需修改的withdraw原提现金额
BigDecimal
withdrawBeforeAmount
=
customerFortuneStatisticalInfo
.
getCashableFortune
()
.
add
(
customerFortuneStatisticalInfo
.
getUncashableFortune
())
.
add
(
withdraw
.
getWithdrawAmount
());
//重新计算此次体现后剩余金额
BigDecimal
withdrawAfterAmount
=
withdrawBeforeAmount
.
subtract
(
withdrawAmount
);
//重新计算税额
BigDecimal
yearDrawnFortune
=
customerFortuneStatisticalInfo
.
getYearDrawnFortune
().
subtract
(
withdraw
.
getWithdrawAmount
());
BigDecimal
taxAmount
=
calcuPersonalTax
(
withdrawAmount
,
yearDrawnFortune
);
//可提现金额
BigDecimal
paidAmount
=
withdrawAmount
.
subtract
(
taxAmount
);
withdraw
.
setWithdrawBeforeAmount
(
withdrawBeforeAmount
);
withdraw
.
setWithdrawAmount
(
withdrawAmount
);
withdraw
.
setWithdrawAfterAmount
(
withdrawAfterAmount
);
withdraw
.
setTaxAmount
(
taxAmount
);
withdraw
.
setPaidAmount
(
paidAmount
);
withdraw
.
setCreatedBy
(
loginId
);
withdraw
.
setCreatedAt
(
new
Date
());
//找到对应的pay记录
for
(
AclCustomerFortunePay
pay:
pays
){
if
(
pay
.
getWithdrawId
().
equals
(
withdrawId
)){
pay
.
setWithdrawAmount
(
withdrawAmount
);
pay
.
setPayAmount
(
paidAmount
);
pay
.
setTaxAmount
(
taxAmount
);
pay
.
setUpdatedBy
(
loginId
);
pay
.
setUpdatedAt
(
new
Date
());
fortuneWithdraw
.
forEach
(
f
->
f
.
setFortunePayedId
(
pay
.
getId
()));
fortuneUpdates
.
addAll
(
fortuneWithdraw
);
}
}
//基本财富信息(历史累积财富 已退保财富 已提现财富 等)
CustomerFortuneStatisticalInfo
customerFortuneStatisticalInfo
=
customerFortuneStatisticalMap
.
get
(
withdraw
.
getCustomerId
());
//根据customerId查询未提现财富金额 可提现财富+不可体现财富+需修改的withdraw原提现金额
BigDecimal
withdrawBeforeAmount
=
customerFortuneStatisticalInfo
.
getCashableFortune
()
.
add
(
customerFortuneStatisticalInfo
.
getUncashableFortune
())
.
add
(
withdraw
.
getWithdrawAmount
());
//重新计算此次体现后剩余金额
BigDecimal
withdrawAfterAmount
=
withdrawBeforeAmount
.
subtract
(
withdrawAmount
);
//重新计算税额
BigDecimal
yearDrawnFortune
=
customerFortuneStatisticalInfo
.
getYearDrawnFortune
().
subtract
(
withdraw
.
getWithdrawAmount
());
BigDecimal
taxAmount
=
calcuPersonalTax
(
withdrawAmount
,
yearDrawnFortune
);
//可提现金额
BigDecimal
paidAmount
=
withdrawAmount
.
subtract
(
taxAmount
);
withdraw
.
setWithdrawBeforeAmount
(
withdrawBeforeAmount
);
withdraw
.
setWithdrawAmount
(
withdrawAmount
);
withdraw
.
setWithdrawAfterAmount
(
withdrawAfterAmount
);
withdraw
.
setTaxAmount
(
taxAmount
);
withdraw
.
setPaidAmount
(
paidAmount
);
withdraw
.
setCreatedBy
(
loginId
);
withdraw
.
setCreatedAt
(
new
Date
());
//找到对应的pay记录
for
(
AclCustomerFortunePay
pay
:
pays
)
{
if
(
pay
.
getWithdrawId
().
equals
(
withdrawId
))
{
pay
.
setWithdrawAmount
(
withdrawAmount
);
pay
.
setPayAmount
(
paidAmount
);
pay
.
setTaxAmount
(
taxAmount
);
pay
.
setUpdatedBy
(
loginId
);
pay
.
setUpdatedAt
(
new
Date
());
fortuneWithdraw
.
forEach
(
f
->
f
.
setFortunePayedId
(
pay
.
getId
()));
fortuneUpdates
.
addAll
(
fortuneWithdraw
);
}
}
}
...
...
@@ -386,6 +394,28 @@ public class AgmsFortuneServiceImpl implements AgmsFortuneService {
customerFortuneDalService
.
updateBatch
(
fortuneUpdates
);
}
private
void
updateWithdrawAmountToZero
(
List
<
AclCustomerFortuneWithdraw
>
withdraws
,
List
<
AclCustomerFortunePay
>
pays
,
Long
loginId
)
{
withdraws
.
forEach
(
w
->{
w
.
setWithdrawAmount
(
BigDecimal
.
ZERO
);
w
.
setWithdrawAfterAmount
(
w
.
getWithdrawBeforeAmount
());
w
.
setCreatedAt
(
new
Date
());
w
.
setCreatedBy
(
loginId
);
w
.
setTaxAmount
(
BigDecimal
.
ZERO
);
w
.
setPaidAmount
(
BigDecimal
.
ZERO
);
});
pays
.
forEach
(
pay
->{
pay
.
setWithdrawAmount
(
BigDecimal
.
ZERO
);
pay
.
setPayAmount
(
BigDecimal
.
ZERO
);
pay
.
setTaxAmount
(
BigDecimal
.
ZERO
);
pay
.
setUpdatedBy
(
loginId
);
pay
.
setUpdatedAt
(
new
Date
());
});
//批量更新withdraw记录
customerFortuneWithdrawDalService
.
updateAll
(
withdraws
);
//批量更新pay记录
customerFortunePayDalService
.
updateAll
(
pays
);
}
private
void
insertWithdraw
(
Map
<
Long
,
List
<
AclCustomerFortune
>>
newCustomerWithdrawMap
,
Long
loginId
)
{
if
(
newCustomerWithdrawMap
.
isEmpty
()){
return
;
...
...
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