Commit 88bdc465 by jianan

出账检核-修改结算汇率

parent 8a909e9e
......@@ -920,15 +920,7 @@ public class ApiExpectedFortuneServiceImpl implements ApiExpectedFortuneService
}
// 查询最新一条有 payableNo 记录
ExpectedFortune latest = iExpectedFortuneService.getOne(
new QueryWrapper<ExpectedFortune>().isNotNull("payable_no").orderByDesc("id").last("LIMIT 1"),
true
);
//获取当前序号作为起点
int currentSeq = 0;
if (!Objects.isNull(latest)) {
currentSeq = Integer.parseInt(latest.getPayableNo().substring(12));
}
int currentSeq = iExpectedFortuneService.getPayableNoCurrentSeq();
List<ExpectedFortune> fortuneList = new ArrayList<>();
for (ExpectedFortuneAddRequest expectedFortuneDto : fortuneAddRequestList) {
......
......@@ -12,4 +12,7 @@ public class EditExchangeRateRequest {
@Schema(description = "结算汇率", requiredMode = Schema.RequiredMode.REQUIRED)
private BigDecimal exchangeRate;
@Schema(description = "港币出账金额", requiredMode = Schema.RequiredMode.REQUIRED)
private BigDecimal hkdAmount;
}
package com.yd.csf.service.service;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yd.csf.service.dto.*;
......@@ -48,5 +47,4 @@ public interface FortuneService extends IService<Fortune> {
Boolean editExchangeRate(EditExchangeRateRequest editExchangeRateRequest);
BigDecimal commissionExchangeRate(QueryCommissionExchangeRateRequest queryCommissionExchangeRateRequest);
}
......@@ -47,4 +47,6 @@ public interface IExpectedFortuneService extends IService<ExpectedFortune> {
void updateBatchByBizId(List<String> expectedFortuneBizIdList, String status);
ExpectedFortune getByBizId(String expectedFortuneBizId);
Integer getPayableNoCurrentSeq();
}
......@@ -180,4 +180,20 @@ public class ExpectedFortuneServiceImpl extends ServiceImpl<ExpectedFortuneMappe
public ExpectedFortune getByBizId(String expectedFortuneBizId) {
return this.getOne(new QueryWrapper<ExpectedFortune>().eq("expected_fortune_biz_id", expectedFortuneBizId));
}
@Override
public Integer getPayableNoCurrentSeq() {
ExpectedFortune latest = this.getOne(
new QueryWrapper<ExpectedFortune>().isNotNull("payable_no").orderByDesc("id").last("LIMIT 1"),
true
);
//获取当前序号作为起点
int currentSeq = 0;
if (!Objects.isNull(latest)) {
currentSeq = Integer.parseInt(latest.getPayableNo().substring(12));
}
return currentSeq;
}
}
......@@ -723,14 +723,22 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
.setScale(2, RoundingMode.HALF_UP)
);
fortune.setCurrentPaymentHkdAmount(fortune.getHkdAmount());
// 查询发佣类型名称
String fortuneName = queryByDict(fortuneAddRequest.getFortuneType());
fortune.setFortuneName(fortuneName);
if ("R".equals(fortuneAddRequest.getFortuneBizType())) {
if (policyMap.get(fortuneAddRequest.getPolicyNo()) == null) {
Policy policy = policyMap.get(fortuneAddRequest.getPolicyNo());
if (policy == null) {
throw new BusinessException(ResultCode.NULL_ERROR.getCode(), fortuneAddRequest.getPolicyNo() + " 保单号不存在");
}
ExpectedFortune expectedFortune = expectedFortuneMap.get(fortuneAddRequest.getPolicyNo() + "_" + fortuneAddRequest.getFortunePeriod() + "_" + fortuneAddRequest.getFortuneType());
if (expectedFortune == null) {
throw new BusinessException(ResultCode.NULL_ERROR.getCode(), fortuneAddRequest.getFortuneName() + " 预计出账不存在");
// 同步新增预计出账
expectedFortune = createExpectedFortune(fortuneAddRequest, policy, fortuneName);
// 保存
expectedFortuneService.save(expectedFortune);
}
fortune.setExpectedFortuneBizId(expectedFortune.getExpectedFortuneBizId());
fortune.setPolicyCurrency(expectedFortune.getPolicyCurrency());
......@@ -753,7 +761,6 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
// 生成发佣业务ID
fortune.setFortuneBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_FORTUNE.getCode()));
fortune.setCurrentPaymentAmount(fortuneAddRequest.getAmount());
fortune.setFortuneName(queryByDict(fortuneAddRequest.getFortuneType()));
fortune.setActualPayoutDate(fortuneAddRequest.getPayoutDate());
fortune.setIsPart(0);
fortuneList.add(fortune);
......@@ -767,6 +774,44 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
return true;
}
private ExpectedFortune createExpectedFortune(FortuneAddRequest fortuneAddRequest, Policy policy, String fortuneName) {
// 计算应付款编号 payableNo
Integer currentSeq = expectedFortuneService.getPayableNoCurrentSeq();
// 应付款编号(序号递增)
String payableNo = String.format("%s%s%s",
fortuneAddRequest.getFortuneType() + "-CSF",
LocalDate.now().getYear() % 100,
String.format("%06d", ++currentSeq));
// 创建 expectedFortune
ExpectedFortune expectedFortune = new ExpectedFortune();
BeanUtil.copyProperties(fortuneAddRequest, expectedFortune);
// 设置 policy 关联字段
expectedFortune.setInsuranceCompanyBizId(policy.getInsuranceCompanyBizId());
expectedFortune.setProductLaunchBizId(policy.getProductLaunchBizId());
expectedFortune.setPremium(policy.getPaymentPremium());
expectedFortune.setPolicyCurrency(policy.getCurrency());
// 预计发佣业务id
expectedFortune.setExpectedFortuneBizId(RandomStringGenerator.generateBizId16(CommonEnum.UID_TYPE_EXPECTED_FORTUNE.getCode()));
// 预计发佣类型名称
expectedFortune.setFortuneName(fortuneName);
// 应付款编号
expectedFortune.setPayableNo(payableNo);
// 已出帐金额、待出帐金额、已出帐比例、待出帐比例
expectedFortune.setPaidAmount(BigDecimal.ZERO);
// 转介人比例默认100%
expectedFortune.setBrokerRatio("100");
expectedFortune.setUnpaidAmount(expectedFortune.getHkdAmount());
expectedFortune.setPaidRatio(BigDecimal.ZERO);
expectedFortune.setUnpaidRatio(BigDecimal.valueOf(100));
return expectedFortune;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean splitFortune(FortuneSplitRequest fortuneSplitRequest) {
......@@ -989,11 +1034,6 @@ public class FortuneServiceImpl extends ServiceImpl<FortuneMapper, Fortune>
return null;
}
@Override
public BigDecimal commissionExchangeRate(QueryCommissionExchangeRateRequest queryCommissionExchangeRateRequest) {
return null;
}
private void validSplitFortune(FortuneSplitRequest fortuneSplitRequest) {
if (fortuneSplitRequest == null) {
throw new BusinessException(ResultCode.PARAM_CHECK_ERROR.getCode(), "分期出账请求不能为空");
......
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