Commit 41d0a989 by jianan

应付款管理-已出账比例和待出账比例不对

parent d00b320f
......@@ -37,7 +37,7 @@ public class PolicyBroker implements Serializable {
private String brokerName;
/**
* 转介人业务ID(客户端用户表唯一业务ID)
* 转介人业务ID
*/
private String brokerBizId;
......
......@@ -285,6 +285,10 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
.list();
if (CollectionUtils.isNotEmpty(fortunes)) {
fortunes.forEach(f -> {
if (f.getCurrentPaymentHkdAmount() == null) {
f.setCurrentPaymentHkdAmount(f.getHkdAmount());
f.setCurrentPaymentRatio(BigDecimal.valueOf(100));
}
f.setStatus(FortuneStatusEnum.SENT.getItemValue());
f.setActualPayoutDate(new Date());
f.setUpdaterId(loginUserId.toString());
......@@ -308,20 +312,20 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
.last("FOR UPDATE")
.list();
// 4.3 全量汇总:把同一 expected_fortune 下所有 fortune 的 current_payment_amount 求和
// 4.3 全量汇总:把同一 expected_fortune 下所有 fortune 的 current_payment_hkd_amount 求和
Map<String, BigDecimal> paidMap = fortuneService.lambdaQuery()
.in(Fortune::getExpectedFortuneBizId, expectedIds)
.eq(Fortune::getStatus, FortuneStatusEnum.SENT.getItemValue())
.list()
.stream()
.collect(Collectors.groupingBy(Fortune::getExpectedFortuneBizId,
Collectors.mapping(Fortune::getCurrentPaymentAmount,
Collectors.mapping(Fortune::getCurrentPaymentHkdAmount,
Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
// 4.4 反写 expected_fortune
expectedList.forEach(ef -> {
BigDecimal totalPaid = paidMap.getOrDefault(ef.getExpectedFortuneBizId(), BigDecimal.ZERO);
BigDecimal totalAmount = ef.getAmount();
BigDecimal totalAmount = ef.getHkdAmount();
BigDecimal unpaid = totalAmount.subtract(totalPaid);
String newStatus;
......@@ -341,6 +345,7 @@ public class FortuneAccountServiceImpl extends ServiceImpl<FortuneAccountMapper,
.set(ExpectedFortune::getUnpaidRatio,
unpaid.divide(totalAmount, 4, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100)))
.set(ExpectedFortune::getStatus, newStatus)
.set(ExpectedFortune::getActualPayoutDate, new Date())
.set(ExpectedFortune::getUpdaterId, loginUserId.toString())
.set(ExpectedFortune::getUpdateTime, LocalDateTime.now())
.eq(ExpectedFortune::getId, ef.getId())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment