From 36854c8be6bb413341ba2df10a1c31fdedbefb5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Tue, 23 Aug 2022 15:21:19 +0800 Subject: [PATCH] =?UTF-8?q?enhance(model):=E5=A2=9E=E5=8A=A0=E6=80=BB?= =?UTF-8?q?=E8=A1=A8=E7=94=B5=E5=BA=A6=E7=94=B5=E8=B4=B9=E7=9A=84=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/report_summary.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/model/report_summary.go b/model/report_summary.go index 3a2e206..52ad108 100644 --- a/model/report_summary.go +++ b/model/report_summary.go @@ -10,6 +10,7 @@ type ReportSummary struct { ReportId string `xorm:"varchar(120) pk not null" json:"-"` Overall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"overall"` OverallFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"overallFee"` + ConsumptionFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"consumptionFee"` OverallPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"overallPrice"` Critical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"critical"` CriticalFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"criticalFee"` @@ -74,7 +75,8 @@ func (s ReportSummary) Validate() (bool, error) { } func (s *ReportSummary) CalculatePrices() { - s.OverallPrice = decimal.NewNullDecimal(s.OverallFee.Div(s.Overall).RoundBank(8)) + s.ConsumptionFee = decimal.NewNullDecimal(s.OverallFee.Sub(s.BasicFee).Sub(s.AdjustFee)) + s.OverallPrice = decimal.NewNullDecimal(s.ConsumptionFee.Decimal.Div(s.Overall).RoundBank(8)) if s.Critical.GreaterThan(decimal.Zero) { s.CriticalPrice = decimal.NewNullDecimal(s.CriticalFee.Div(s.Critical).RoundBank(8)) } else {