|
|
@@ -3,6 +3,7 @@ package com.kym.service.admin.impl;
|
|
|
import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
+import com.kym.common.exception.BusinessException;
|
|
|
import com.kym.common.utils.CommUtil;
|
|
|
import com.kym.entity.admin.InvestorInfo;
|
|
|
import com.kym.entity.admin.Statements;
|
|
|
@@ -50,7 +51,7 @@ public class StatementsServiceImpl extends ServiceImpl<StatementsMapper, Stateme
|
|
|
|
|
|
// 校验站点月统计信息已填写实际抄表电量和实际抄表电费金额
|
|
|
if (statMonthInfo.getActualPower() == null || statMonthInfo.getActualElecMoney() == null) {
|
|
|
- throw new RuntimeException("请先完善月统计实际抄表电量和实际抄表电费金额");
|
|
|
+ throw new BusinessException("请先完善月统计实际抄表电量和实际抄表电费金额");
|
|
|
}
|
|
|
|
|
|
// 站点关联客户和物业信息
|
|
|
@@ -59,19 +60,18 @@ public class StatementsServiceImpl extends ServiceImpl<StatementsMapper, Stateme
|
|
|
.list();
|
|
|
|
|
|
if (CommUtil.isEmptyOrNull(investorInfoList)) {
|
|
|
- throw new RuntimeException("请先完善站点相关投资者/物业信息");
|
|
|
+ throw new BusinessException("请先完善站点相关投资者/物业信息");
|
|
|
}
|
|
|
|
|
|
// 创建客户对账单
|
|
|
var res = investorInfoList.stream().map(investorInfo -> {
|
|
|
// 实际参与分成的服务费=总服务费-优惠金额-电损电费
|
|
|
- var actualServiceMoney = statMonthInfo.getServiceMoney()
|
|
|
- - statMonthInfo.getDiscountAmount()
|
|
|
- - (int) ((statMonthInfo.getActualElecMoney() - statMonthInfo.getElecMoney()) * investorInfo.getElecLossProportion());
|
|
|
+ var actualServiceMoney = statMonthInfo.getServiceMoney() - statMonthInfo.getDiscountAmount();
|
|
|
// 总电损电费
|
|
|
var elecLossMoney = statMonthInfo.getActualElecMoney() - statMonthInfo.getElecMoney();
|
|
|
+ var elecLossAmount = (int) (elecLossMoney * investorInfo.getElecLossProportion());
|
|
|
// 分成金额 = 实际参与分成的服务费 * 分成比例 - 电损金额 * 电损承担比例
|
|
|
- var splittingAmount = (int) (actualServiceMoney * investorInfo.getSplittingProportion()) - (int) (elecLossMoney * investorInfo.getElecLossProportion());
|
|
|
+ var splittingAmount = (int) (actualServiceMoney * investorInfo.getSplittingProportion()) - elecLossAmount;
|
|
|
return new Statements()
|
|
|
.setAdminUserId(investorInfo.getAdminUserId())
|
|
|
.setAdminUserName(investorInfo.getAdminUserName())
|
|
|
@@ -94,8 +94,8 @@ public class StatementsServiceImpl extends ServiceImpl<StatementsMapper, Stateme
|
|
|
.setElecLossProportion(investorInfo.getElecLossProportion()) // 电损承担比例
|
|
|
.setElecLossAmount((int) (elecLossMoney * investorInfo.getElecLossProportion())) // 电损承担金额
|
|
|
.setVatRate(investorInfo.getVatRate()) // 增值税率 0.06表示6%
|
|
|
- .setVatAmount((int) (splittingAmount * investorInfo.getVatRate())) // 增值税额(分)
|
|
|
- .setActualSplittingAmount(splittingAmount - (int) (splittingAmount * investorInfo.getVatRate())); // 实际分成金额(分)
|
|
|
+ .setVatAmount((int) (splittingAmount / (1 + investorInfo.getVatRate()) * investorInfo.getVatRate() * 1.12)) // 增值税额(分)
|
|
|
+ .setActualSplittingAmount(splittingAmount - (int) (splittingAmount / (1 + investorInfo.getVatRate()) * investorInfo.getVatRate() * 1.12)); // 实际分成金额(分)
|
|
|
}).toList();
|
|
|
saveBatch(res);
|
|
|
}
|