Commit ca9d69dd by jianan

前端对接问题修复103

parent 61bc09e2
......@@ -45,7 +45,6 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
/**
......@@ -639,8 +638,11 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
fortune.setFortuneBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_FORTUNE.getCode()));
fortune.setId(null);
fortune.setFortuneBizType("R");
fortune.setExchangeRate(queryDefaultExchangeRate(fortune.getCurrency()));
fortune.setAmount(expectedFortune.getAmount());
fortune.setHkdAmount(expectedFortune.getAmount().multiply(fortune.getExchangeRate()));
fortune.setCurrentPaymentAmount(expectedFortune.getAmount());
fortune.setCurrentPaymentHkdAmount(fortune.getCurrentPaymentAmount().multiply(fortune.getExchangeRate()));
fortune.setExpectedFortuneBizId(expectedFortune.getExpectedFortuneBizId());
fortune.setStatus(FortuneStatusEnum.CAN_SEND.getItemValue());
fortune.setIsPart(0);
......@@ -664,6 +666,24 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
.collect(Collectors.toList());
}
private BigDecimal queryDefaultExchangeRate(String currency) {
if (StringUtils.isBlank(currency)) {
return BigDecimal.ONE;
}
if ("HKD".equalsIgnoreCase(currency)) {
return BigDecimal.valueOf(1);
}
Result<List<GetDictItemListByDictTypeResponse>> result = apiSysDictFeignClient.getDictItemListByDictType("csf_exchange_rate_hkd");
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(result.getData())) {
for (GetDictItemListByDictTypeResponse dictItem : result.getData()) {
if (StringUtils.equalsIgnoreCase(dictItem.getItemLabel(), currency)) {
return new BigDecimal(dictItem.getItemValue());
}
}
}
return BigDecimal.ONE;
}
/**
* 构建保单号+期次的唯一键
*/
......@@ -671,37 +691,6 @@ public class CommissionServiceImpl extends ServiceImpl<CommissionMapper, Commiss
return (policyNo == null ? "" : policyNo) + "|" + (period == null ? "" : period.toString());
}
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())
&& commission.getCommissionPeriod().equals(fortune.getFortunePeriod())
&& commission.getCommissionName().equals(fortune.getFortuneName())
) {
fortune.setCommissionBizId(commission.getCommissionBizId());
} else {
fortune.setStatus(FortuneStatusEnum.MATCH_FAIL.getItemValue());
fortune.setRemark("未找到当前预计发佣对应的来佣");
}
}
}
@Override
public Commission getByCommissionBizId(String commissionBizId) {
return this.getOne(new QueryWrapper<Commission>().eq("commission_biz_id", commissionBizId));
......
......@@ -571,7 +571,11 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
fortuneStatistics = fortuneStatisticsList.get(0);
}
// 计算差额
fortuneStatistics.setDifferenceAmount(fortuneStatistics.getPendingOutAmount().subtract(fortuneStatistics.getAvailableOutAmount()));
if (fortuneStatistics.getPendingOutAmount() != null && fortuneStatistics.getAvailableOutAmount() != null) {
fortuneStatistics.setDifferenceAmount(fortuneStatistics.getPendingOutAmount().subtract(fortuneStatistics.getAvailableOutAmount()));
} else {
fortuneStatistics.setDifferenceAmount(BigDecimal.ZERO);
}
return fortuneStatistics;
}
......
......@@ -293,7 +293,11 @@ public class FortuneVO implements Serializable {
FortuneVO fortuneVO = new FortuneVO();
BeanUtils.copyProperties(fortune, fortuneVO);
// 待出账比例
fortuneVO.setFortuneUnpaidRatio(BigDecimal.valueOf(100).subtract(fortuneVO.getCurrentPaymentRatio()));
if (fortuneVO.getCurrentPaymentRatio() != null) {
fortuneVO.setFortuneUnpaidRatio(BigDecimal.valueOf(100).subtract(fortuneVO.getCurrentPaymentRatio()));
} else {
fortuneVO.setFortuneUnpaidRatio(BigDecimal.valueOf(100));
}
return fortuneVO;
}
......
......@@ -68,7 +68,7 @@
(select sum(hkd_amount)
from expected_fortune where status = '0' and policy_no = f.policy_no
),0) AS pendingOutAmount,
SUM(CASE WHEN f.status = '6' THEN f.current_payment_hkd_amount ELSE 0 END) AS availableOutAmount,
SUM(CASE WHEN f.status in ('6','1') THEN f.current_payment_hkd_amount ELSE 0 END) AS availableOutAmount,
COUNT(DISTINCT f.policy_no) AS totalPolicyCount,
MAX(ce.expected_amount) AS totalInAmount,
MAX(ce.premium) AS totalPremium
......
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