From 316553d81a30fd9e85d816002d30695395b5540b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Mon, 19 Jun 2023 17:30:17 +0800 Subject: [PATCH] =?UTF-8?q?enhance(report):=E6=9E=84=E5=BB=BA=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E6=95=B0=E6=8D=AE=E5=BA=93=E7=9B=B8=E5=85=B3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=96=87=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/calculate/calculate.go | 92 ++++++++++++++++++++++++++++++++++++ model/enums.go | 7 +++ repository/report.go | 19 ++++++++ vo/report.go | 1 + 4 files changed, 119 insertions(+) create mode 100644 model/calculate/calculate.go create mode 100644 repository/report.go create mode 100644 vo/report.go diff --git a/model/calculate/calculate.go b/model/calculate/calculate.go new file mode 100644 index 0000000..da5177c --- /dev/null +++ b/model/calculate/calculate.go @@ -0,0 +1,92 @@ +package calculate + +import ( + "electricity_bill_calc/model" + "electricity_bill_calc/types" + + "github.com/shopspring/decimal" +) + +type Reading struct { + ReadAt types.DateTime + Ratio decimal.Decimal + Overall decimal.Decimal + Critical decimal.Decimal + Peak decimal.Decimal + Flat decimal.Decimal + Valley decimal.Decimal +} + +type Pooling struct { + Code string + Detail model.ConsumptionUnit +} + +type Meter struct { + Code string + Detail model.MeterDetail + CoveredArea decimal.Decimal + LastTermReading *Reading + CurrentTermReading *Reading + Overall model.ConsumptionUnit + Critical model.ConsumptionUnit + Peak model.ConsumptionUnit + Flat model.ConsumptionUnit + Valley model.ConsumptionUnit + AdjustLoss model.ConsumptionUnit + PooledBasic model.ConsumptionUnit + PooledAdjust model.ConsumptionUnit + PooledLoss model.ConsumptionUnit + PooledPublic model.ConsumptionUnit + SharedPoolingProportion decimal.Decimal + Poolings []*Pooling +} + +type TenementCharge struct { + Tenement string + Overall model.ConsumptionUnit + Critical model.ConsumptionUnit + Peak model.ConsumptionUnit + Flat model.ConsumptionUnit + Valley model.ConsumptionUnit + BasicFee decimal.Decimal + AdjustFee decimal.Decimal + LossPooled decimal.Decimal + PublicPooled decimal.Decimal + FinalCharges decimal.Decimal + Submeters []*Meter + Poolings []*Meter +} + +type Summary struct { + ReportId string + OverallArea decimal.Decimal + Overall model.ConsumptionUnit + ConsumptionFee decimal.Decimal + Critical model.ConsumptionUnit + Peak model.ConsumptionUnit + Flat model.ConsumptionUnit + Valley model.ConsumptionUnit + Loss decimal.Decimal + LossFee decimal.Decimal + LossProportion decimal.Decimal + AuthoizeLoss model.ConsumptionUnit + BasicFee decimal.Decimal + BasicPooledPriceConsumption decimal.Decimal + BasicPooledPriceArea decimal.Decimal + AdjustFee decimal.Decimal + AdjustPooledPriceConsumption decimal.Decimal + AdjustPooledPriceArea decimal.Decimal + LossDilutedPrice decimal.Decimal + TotalConsumption decimal.Decimal + FinalDilutedOverall decimal.Decimal +} + +type PoolingSummary struct { + Tenement string + Meter string + TargetMeter string + Area decimal.NullDecimal + OverallAmount decimal.Decimal + PoolingProportion decimal.Decimal +} diff --git a/model/enums.go b/model/enums.go index 18eb8fe..79b5225 100644 --- a/model/enums.go +++ b/model/enums.go @@ -81,3 +81,10 @@ const ( REPORT_CALCULATE_TASK_STATUS_UNKNOWN_ERROR REPORT_CALCULATE_TASK_STATUS_UNEXISTS = 99 ) + +const ( + REPORT_WITHDRAW_NON int16 = iota + REPORT_WITHDRAW_APPLYING + REPORT_WITHDRAW_DENIED + REPORT_WITHDRAW_GRANTED +) diff --git a/repository/report.go b/repository/report.go new file mode 100644 index 0000000..4e251d6 --- /dev/null +++ b/repository/report.go @@ -0,0 +1,19 @@ +package repository + +import ( + "electricity_bill_calc/logger" + + "github.com/doug-martin/goqu/v9" + _ "github.com/doug-martin/goqu/v9/dialect/postgres" + "go.uber.org/zap" +) + +type _ReportRepository struct { + log *zap.Logger + ds goqu.DialectWrapper +} + +var ReportRepository = _ReportRepository{ + log: logger.Named("Repository", "Report"), + ds: goqu.Dialect("postgres"), +} diff --git a/vo/report.go b/vo/report.go new file mode 100644 index 0000000..d685e69 --- /dev/null +++ b/vo/report.go @@ -0,0 +1 @@ +package vo