From ac70adf92a4693af667828f85c2ecf0a6aa3089b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Fri, 9 Sep 2022 12:28:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(calculate):=E6=8A=A5=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E4=BC=9A=E6=A0=B9=E6=8D=AE=E5=9B=AD=E5=8C=BA?= =?UTF-8?q?=E7=9A=84=E4=B8=8D=E5=90=8C=E9=80=89=E6=8B=A9=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E7=9A=84=E8=AE=A1=E7=AE=97=E6=96=B9=E5=BC=8F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/calculate.go | 94 ++++++++++++++++++++++++++++++-------------- 1 file changed, 64 insertions(+), 30 deletions(-) diff --git a/service/calculate.go b/service/calculate.go index 7e8deec..1dee27d 100644 --- a/service/calculate.go +++ b/service/calculate.go @@ -91,36 +91,70 @@ func (_CalculateService) ComprehensivelyCalculateReport(reportId string) (err er } // 计算户表总电费和公共总电费以及相应的摊薄 - summary.CustomerConsumptionFee = decimal.NewNullDecimal( - summary.CustomerConsumption.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) - summary.CustomerConsumptionCriticalFee = decimal.NewNullDecimal( - summary.CustomerConsumptionCritical.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) - summary.CustomerConsumptionPeakFee = decimal.NewNullDecimal( - summary.CustomerConsumptionPeak.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) - summary.CustomerConsumptionFlatFee = decimal.NewNullDecimal( - summary.CustomerConsumptionFlat.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) - summary.CustomerConsumptionValleyFee = decimal.NewNullDecimal( - summary.CustomerConsumptionValley.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) - summary.PublicConsumptionFee = decimal.NewNullDecimal( - summary.PublicConsumption.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) - summary.PublicConsumptionCriticalFee = decimal.NewNullDecimal( - summary.PublicConsumptionCritical.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) - summary.PublicConsumptionPeakFee = decimal.NewNullDecimal( - summary.PublicConsumptionPeak.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) - summary.PublicConsumptionFlatFee = decimal.NewNullDecimal( - summary.PublicConsumptionFlat.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) - summary.PublicConsumptionValleyFee = decimal.NewNullDecimal( - summary.PublicConsumptionValley.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), - ) + if reportIndex.SubmeterType == model.CUSTOMER_METER_NON_PV { + summary.CustomerConsumptionFee = decimal.NewNullDecimal( + summary.CustomerConsumption.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.CustomerConsumptionCriticalFee = decimal.NewNullDecimal( + summary.CustomerConsumptionCritical.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.CustomerConsumptionPeakFee = decimal.NewNullDecimal( + summary.CustomerConsumptionPeak.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.CustomerConsumptionFlatFee = decimal.NewNullDecimal( + summary.CustomerConsumptionFlat.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.CustomerConsumptionValleyFee = decimal.NewNullDecimal( + summary.CustomerConsumptionValley.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionFee = decimal.NewNullDecimal( + summary.PublicConsumption.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionCriticalFee = decimal.NewNullDecimal( + summary.PublicConsumptionCritical.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionPeakFee = decimal.NewNullDecimal( + summary.PublicConsumptionPeak.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionFlatFee = decimal.NewNullDecimal( + summary.PublicConsumptionFlat.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionValleyFee = decimal.NewNullDecimal( + summary.PublicConsumptionValley.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + } + if reportIndex.SubmeterType == model.CUSTOMER_METER_PV { + summary.CustomerConsumptionFee = decimal.NewNullDecimal( + summary.CustomerConsumption.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.CustomerConsumptionCriticalFee = decimal.NewNullDecimal( + summary.CustomerConsumptionCritical.Decimal.Mul(summary.CriticalPrice.Decimal).RoundBank(2), + ) + summary.CustomerConsumptionPeakFee = decimal.NewNullDecimal( + summary.CustomerConsumptionPeak.Decimal.Mul(summary.PeakPrice.Decimal).RoundBank(2), + ) + summary.CustomerConsumptionFlatFee = decimal.NewNullDecimal( + summary.CustomerConsumptionFlat.Decimal.Mul(summary.FlatPrice.Decimal).RoundBank(2), + ) + summary.CustomerConsumptionValleyFee = decimal.NewNullDecimal( + summary.CustomerConsumptionValley.Decimal.Mul(summary.ValleyPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionFee = decimal.NewNullDecimal( + summary.PublicConsumption.Decimal.Mul(summary.OverallPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionCriticalFee = decimal.NewNullDecimal( + summary.PublicConsumptionCritical.Decimal.Mul(summary.CriticalPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionPeakFee = decimal.NewNullDecimal( + summary.PublicConsumptionPeak.Decimal.Mul(summary.PeakPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionFlatFee = decimal.NewNullDecimal( + summary.PublicConsumptionFlat.Decimal.Mul(summary.FlatPrice.Decimal).RoundBank(2), + ) + summary.PublicConsumptionValleyFee = decimal.NewNullDecimal( + summary.PublicConsumptionValley.Decimal.Mul(summary.ValleyPrice.Decimal).RoundBank(2), + ) + } if summary.Overall.Abs().GreaterThan(decimal.Zero) { summary.PublicConsumptionProportion = decimal.NewNullDecimal( summary.PublicConsumption.Decimal.Div(summary.Overall).RoundBank(15),