From b426c6a7b15af6eef9e769efbf96b82392a39ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Fri, 19 Aug 2022 16:43:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(model):=E9=87=8D=E6=96=B0=E6=8C=89?= =?UTF-8?q?=E7=85=A7=E8=AE=BE=E8=AE=A1=E8=A6=81=E6=B1=82=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=85=AC=E7=A4=BA=E6=8A=A5=E8=A1=A8=E9=83=A8=E5=88=86=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/end_user_detail.go | 47 ++++++++++++++++++++++++--------------- model/report.go | 11 ++++++++- model/report_summary.go | 25 ++++++++++----------- model/will_diluted_fee.go | 3 ++- 4 files changed, 53 insertions(+), 33 deletions(-) diff --git a/model/end_user_detail.go b/model/end_user_detail.go index 01b31a8..4a6325d 100644 --- a/model/end_user_detail.go +++ b/model/end_user_detail.go @@ -4,28 +4,40 @@ import "github.com/shopspring/decimal" type EndUserDetail struct { CreatedAndModified `xorm:"extends"` - ReportId string `xorm:"varchar(120) pk not null" json:"-"` + ReportId string `xorm:"varchar(120) pk not null" json:"reportId"` + ParkId string `xorm:"varchar(120) pk not null" json:"parkId"` MeterId string `xorm:"meter_04kv_id varchar(120) pk not null" json:"meterId"` - Seq int64 `xorm:"bigint not null" json:"seq"` - Ratio decimal.Decimal `xorm:"numeric(8,4) not null" json:"ratio"` - LastPeriodCritical decimal.NullDecimal `xorm:"numeric(14,2)" json:"lastPeriodCritical"` - LastPeriodPeek decimal.NullDecimal `xorm:"numeric(14,2)" json:"lastPeriodPeek"` - LastPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null" json:"lastPeriodFlat"` - LastPeriodValley decimal.NullDecimal `xorm:"numeric(14,2)" json:"lastPeriodValley"` - CurrentPeriodCritical decimal.NullDecimal `xorm:"numeric(14,2)" json:"currentPeriodCritical"` - CurrentPeriodPeek decimal.NullDecimal `xorm:"numeric(14,2)" json:"currentPeriodPeek"` - CurrentPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null" json:"currentPeriodFlat"` - CurrentPeriodValley decimal.NullDecimal `xorm:"numeric(14,2)" json:"currentPeriodValley"` - AdjustCritical decimal.NullDecimal `xorm:"numeric(14,2)" json:"adjustCritical"` - AdjustPeek decimal.NullDecimal `xorm:"numeric(14,2)" json:"adjustPeek"` - AdjustFlat decimal.Decimal `xorm:"numeric(14,2) not null" json:"adjustFlat"` - AdjustValley decimal.NullDecimal `xorm:"numeric(14,2)" json:"adjustValley"` + Seq int64 `xorm:"bigint not null default 0" json:"seq"` + Ratio decimal.Decimal `xorm:"numeric(8,4) not null deafult 1" json:"ratio"` + Address *string `xorm:"varchar(100)" json:"address"` + CustomerName *string `xorm:"varchar(100)" json:"customerName"` + ContactName *string `xorm:"varchar(70)" json:"contactName"` + ContactPhone *string `xorm:"varchar(50)" json:"contactPhone"` + IsPublicMeter bool `xorm:"'public_meter' bool not null default false" json:"isPublicMeter"` + WillDilute bool `xorm:"'dilute' bool not null default false" json:"willDilute"` + LastPeriodOverall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodOverall"` + LastPeriodCritical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodCritical"` + LastPeriodPeek decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodPeek"` + LastPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodFlat"` + LastPeriodValley decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"lastPeriodValley"` + CurrentPeriodOverall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodOverall"` + CurrentPeriodCritical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodCritical"` + CurrentPeriodPeek decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodPeek"` + CurrentPeriodFlat decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodFlat"` + CurrentPeriodValley decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"currentPeriodValley"` + AdjustOverall decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustOverall"` + AdjustCritical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustCritical"` + AdjustPeek decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustPeek"` + AdjustFlat decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustFlat"` + AdjustValley decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustValley"` + Overall decimal.NullDecimal `xorm:"numeric(14,2)" json:"overall"` + OverallFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"overallFee"` Critical decimal.NullDecimal `xorm:"numeric(14,2)" json:"critical"` CriticalFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"criticalFee"` Peek decimal.NullDecimal `xorm:"numeric(14,2)" json:"peek"` PeekFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"peekFee"` - Flat decimal.Decimal `xorm:"numeric(14,2) not null" json:"flat"` - FlatFee decimal.Decimal `xorm:"numeric(18,8) not null" json:"flatFee"` + Flat decimal.NullDecimal `xorm:"numeric(14,2)" json:"flat"` + FlatFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"flatFee"` Valley decimal.NullDecimal `xorm:"numeric(14,2)" json:"valley"` ValleyFee decimal.NullDecimal `xorm:"numeric(18,8)" json:"valleyFee"` BasicFeeDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"basicFeeDiluted"` @@ -34,7 +46,6 @@ type EndUserDetail struct { LossFeeDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"lossFeeDiluted"` MaintenanceFeeDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"maintenanceFeeDiluted"` PublicConsumptionDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"publicConsumptionDiluted"` - ServiceFeeDiluted decimal.NullDecimal `xorm:"numeric(18,8)" json:"serviceFeeDiluted"` FinalCharge decimal.NullDecimal `xorm:"numeric(14,2)" json:"finalCharge"` } diff --git a/model/report.go b/model/report.go index 7bf6539..fbc9b3b 100644 --- a/model/report.go +++ b/model/report.go @@ -4,10 +4,10 @@ import "time" type Report struct { CreatedAndModified `xorm:"extends"` - Deleted `xorm:"extends"` Id string `xorm:"varchar(120) pk not null" json:"id"` ParkId string `xorm:"varchar(120) not null" json:"parkId"` Period time.Time `xorm:"date not null" json:"period" time_format:"simple_date" time_location:"shanghai"` + StepState Steps `xorm:"text not null json" json:"stepState"` Published bool `xorm:"bool not null default false" json:"published"` PublishedAt *time.Time `xorm:"timestampz" json:"publishedAt" time_format:"simple_datetime" time_location:"shanghai"` Withdraw int8 `xorm:"smallint not null default 0" json:"withdraw"` @@ -15,6 +15,15 @@ type Report struct { LastWithdrawAuditAt *time.Time `xorm:"timestampz" json:"lastWithdrawAuditAt" time_format:"simple_datetime" time_location:"shanghai"` } +type Steps struct { + Summary bool `json:"summary"` + WillDiluted bool `json:"willDiluted"` + Submeter bool `json:"submeter"` + Calculate bool `json:"calculate"` + Preview bool `json:"preview"` + Publish bool `json:"publish"` +} + func (Report) TableName() string { return "report" } diff --git a/model/report_summary.go b/model/report_summary.go index 2a620a2..bf607ea 100644 --- a/model/report_summary.go +++ b/model/report_summary.go @@ -4,33 +4,32 @@ import "github.com/shopspring/decimal" type ReportSummary struct { ReportId string `xorm:"varchar(120) pk not null" json:"-"` - Overall decimal.Decimal `xorm:"numeric(14,2) not null" json:"overall"` - OverallFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"overallFee"` + 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"` OverallPrice decimal.Decimal `xorm:"numeric(16,8)" json:"overallPrice"` - Critical decimal.Decimal `xorm:"numeric(14,2) not null" json:"critial"` - CriticalFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"criticalFee"` + Critical decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"critial"` + CriticalFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"criticalFee"` CriticalPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"criticalPrice"` - Peek decimal.Decimal `xorm:"numeric(14,2) not null" json:"peek"` - PeekFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"peekFee"` + Peek decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"peek"` + PeekFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"peekFee"` PeekPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"peekPrice"` - Flat decimal.NullDecimal `xorm:"numeric(14,2)" json:"flat"` - FlatFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"flatFee"` + Flat decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"flat"` + FlatFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"flatFee"` FlatPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"flatPrice"` - Valley decimal.Decimal `xorm:"numeric(14,2) not null" json:"valley"` - ValleyFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"valleyFee"` + Valley decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"valley"` + ValleyFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"valleyFee"` ValleyPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"valleyPrice"` Loss decimal.NullDecimal `xorm:"numeric(14,2)" json:"loss"` LossFee decimal.NullDecimal `xorm:"numeric(16,2)" json:"lossFee"` PublicConsumption decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumption"` PublicConsumptionFee decimal.NullDecimal `xorm:"numeric(14,2)" json:"publicConsumptionFee"` - BasicFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"basicFee"` + BasicFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"basicFee"` BasicDilutedPrice decimal.NullDecimal `xorm:"numeric(18,8)" json:"basicDilutedPrice"` - AdjustFee decimal.Decimal `xorm:"numeric(14,2) not null" json:"adjustFee"` + AdjustFee decimal.Decimal `xorm:"numeric(14,2) not null default 0" json:"adjustFee"` AdjustDilutedPrice decimal.NullDecimal `xorm:"numeric(18,8)" json:"adjustDilutedPrice"` MaintenanceDilutedPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"maintencanceDilutedPrice"` LossDilutedPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"lossDilutedPrice"` PublicConsumptionDilutedPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"publicConsumptionDilutedPrice"` - ServiceDilutedPrice decimal.NullDecimal `xorm:"numeric(16,8)" json:"serviceDilutedPrice"` } func (ReportSummary) TableName() string { diff --git a/model/will_diluted_fee.go b/model/will_diluted_fee.go index cca7d46..af466c5 100644 --- a/model/will_diluted_fee.go +++ b/model/will_diluted_fee.go @@ -6,8 +6,9 @@ type WillDilutedFee struct { CreatedAndModified `xorm:"extends"` Id string `xorm:"varchar(120) pk not null" json:"id"` ReportId string `xorm:"varchar(120) not null" json:"reportId"` + SourceId *string `xorm:"varchar(120)" json:"sourceId"` Name string `xorm:"varchar(50) not null" json:"name"` - Fee decimal.Decimal `xorm:"numeric(8,2) not null" json:"fee"` + Fee decimal.Decimal `xorm:"numeric(8,2) not null default 0" json:"fee"` Memo *string `xorm:"text" json:"memo"` }