enhance(model):增加总表电度电费的字段。

This commit is contained in:
徐涛 2022-08-23 15:21:19 +08:00
parent 922659de94
commit 36854c8be6

View File

@ -10,6 +10,7 @@ type ReportSummary struct {
ReportId string `xorm:"varchar(120) pk not null" json:"-"` ReportId string `xorm:"varchar(120) pk not null" json:"-"`
Overall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"overall"` 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"` 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"` OverallPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"overallPrice"`
Critical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"critical"` 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"` 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() { 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) { if s.Critical.GreaterThan(decimal.Zero) {
s.CriticalPrice = decimal.NewNullDecimal(s.CriticalFee.Div(s.Critical).RoundBank(8)) s.CriticalPrice = decimal.NewNullDecimal(s.CriticalFee.Div(s.Critical).RoundBank(8))
} else { } else {