diff --git a/model/end_user_detail.go b/model/end_user_detail.go index c50e509..96235bf 100644 --- a/model/end_user_detail.go +++ b/model/end_user_detail.go @@ -16,47 +16,47 @@ type EndUserDetail struct { ParkId string `bun:",pk,notnull" json:"parkId"` MeterId string `bun:"meter_04kv_id,pk,notnull" json:"meterId"` Seq int64 `bun:"type:bigint,notnull" json:"seq"` - Ratio decimal.Decimal `bun:",notnull" json:"ratio"` + Ratio decimal.Decimal `bun:"type:numeric,notnull" json:"ratio"` Address *string `json:"address"` CustomerName *string `json:"customerName"` ContactName *string `json:"contactName"` ContactPhone *string `json:"contactPhone"` IsPublicMeter bool `bun:"public_meter,notnull" json:"isPublicMeter"` WillDilute bool `bun:"dilute,notnull" json:"willDilute"` - LastPeriodOverall decimal.Decimal `bun:",notnull" json:"lastPeriodOverall"` - LastPeriodCritical decimal.Decimal `bun:",notnull" json:"lastPeriodCritical"` - LastPeriodPeak decimal.Decimal `bun:",notnull" json:"lastPeriodPeak"` - LastPeriodFlat decimal.Decimal `bun:",notnull" json:"lastPeriodFlat"` - LastPeriodValley decimal.Decimal `bun:",notnull" json:"lastPeriodValley"` - CurrentPeriodOverall decimal.Decimal `bun:",notnull" json:"currentPeriodOverall"` - CurrentPeriodCritical decimal.Decimal `bun:",notnull" json:"currentPeriodCritical"` - CurrentPeriodPeak decimal.Decimal `bun:",notnull" json:"currentPeriodPeak"` - CurrentPeriodFlat decimal.Decimal `bun:",notnull" json:"currentPeriodFlat"` - CurrentPeriodValley decimal.Decimal `bun:",notnull" json:"currentPeriodValley"` - AdjustOverall decimal.Decimal `bun:",notnull" json:"adjustOverall"` - AdjustCritical decimal.Decimal `bun:",notnull" json:"adjustCritical"` - AdjustPeak decimal.Decimal `bun:",notnull" json:"adjustPeak"` - AdjustFlat decimal.Decimal `bun:",notnull" json:"adjustFlat"` - AdjustValley decimal.Decimal `bun:",notnull" json:"adjustValley"` - Overall decimal.NullDecimal `json:"overall"` - OverallFee decimal.NullDecimal `json:"overallFee"` - OverallProportion decimal.Decimal `bun:",notnull" json:"-"` - Critical decimal.NullDecimal `json:"critical"` - CriticalFee decimal.NullDecimal `json:"criticalFee"` - Peak decimal.NullDecimal `json:"peak"` - PeakFee decimal.NullDecimal `json:"peakFee"` - Flat decimal.NullDecimal `json:"flat"` - FlatFee decimal.NullDecimal `json:"flatFee"` - Valley decimal.NullDecimal `json:"valley"` - ValleyFee decimal.NullDecimal `json:"valleyFee"` - BasicFeeDiluted decimal.NullDecimal `json:"basicFeeDiluted"` - AdjustFeeDiluted decimal.NullDecimal `json:"adjustFeeDiluted"` - LossDiluted decimal.NullDecimal `json:"lossDiluted"` - LossFeeDiluted decimal.NullDecimal `json:"lossFeeDiluted"` - MaintenanceFeeDiluted decimal.NullDecimal `json:"maintenanceFeeDiluted"` - PublicConsumptionDiluted decimal.NullDecimal `json:"publicConsumptionDiluted"` - FinalDiluted decimal.NullDecimal `json:"finalDiluted"` - FinalCharge decimal.NullDecimal `json:"finalCharge"` + LastPeriodOverall decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodOverall"` + LastPeriodCritical decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodCritical"` + LastPeriodPeak decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodPeak"` + LastPeriodFlat decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodFlat"` + LastPeriodValley decimal.Decimal `bun:"type:numeric,notnull" json:"lastPeriodValley"` + CurrentPeriodOverall decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodOverall"` + CurrentPeriodCritical decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodCritical"` + CurrentPeriodPeak decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodPeak"` + CurrentPeriodFlat decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodFlat"` + CurrentPeriodValley decimal.Decimal `bun:"type:numeric,notnull" json:"currentPeriodValley"` + AdjustOverall decimal.Decimal `bun:"type:numeric,notnull" json:"adjustOverall"` + AdjustCritical decimal.Decimal `bun:"type:numeric,notnull" json:"adjustCritical"` + AdjustPeak decimal.Decimal `bun:"type:numeric,notnull" json:"adjustPeak"` + AdjustFlat decimal.Decimal `bun:"type:numeric,notnull" json:"adjustFlat"` + AdjustValley decimal.Decimal `bun:"type:numeric,notnull" json:"adjustValley"` + Overall decimal.NullDecimal `bun:"type:numeric" json:"overall"` + OverallFee decimal.NullDecimal `bun:"type:numeric" json:"overallFee"` + OverallProportion decimal.Decimal `bun:"type:numeric,notnull" json:"-"` + Critical decimal.NullDecimal `bun:"type:numeric" json:"critical"` + CriticalFee decimal.NullDecimal `bun:"type:numeric" json:"criticalFee"` + Peak decimal.NullDecimal `bun:"type:numeric" json:"peak"` + PeakFee decimal.NullDecimal `bun:"type:numeric" json:"peakFee"` + Flat decimal.NullDecimal `bun:"type:numeric" json:"flat"` + FlatFee decimal.NullDecimal `bun:"type:numeric" json:"flatFee"` + Valley decimal.NullDecimal `bun:"type:numeric" json:"valley"` + ValleyFee decimal.NullDecimal `bun:"type:numeric" json:"valleyFee"` + BasicFeeDiluted decimal.NullDecimal `bun:"type:numeric" json:"basicFeeDiluted"` + AdjustFeeDiluted decimal.NullDecimal `bun:"type:numeric" json:"adjustFeeDiluted"` + LossDiluted decimal.NullDecimal `bun:"type:numeric" json:"lossDiluted"` + LossFeeDiluted decimal.NullDecimal `bun:"type:numeric" json:"lossFeeDiluted"` + MaintenanceFeeDiluted decimal.NullDecimal `bun:"type:numeric" json:"maintenanceFeeDiluted"` + PublicConsumptionDiluted decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionDiluted"` + FinalDiluted decimal.NullDecimal `bun:"type:numeric" json:"finalDiluted"` + FinalCharge decimal.NullDecimal `bun:"type:numeric" json:"finalCharge"` Initialize bool `bun:"-" json:"-"` Origin *Meter04KV `bun:"rel:belongs-to,join:park_id=park_id,join:meter_04kv_id=code" json:"-"` } diff --git a/model/maintenance_fee.go b/model/maintenance_fee.go index 7ff38fd..f49cfa3 100644 --- a/model/maintenance_fee.go +++ b/model/maintenance_fee.go @@ -15,7 +15,7 @@ type MaintenanceFee struct { Id string `bun:",pk,notnull" json:"id"` ParkId string `bun:",notnull" json:"parkId"` Name string `bun:",notnull" json:"name"` - Fee decimal.Decimal `bun:",notnull" json:"fee"` + Fee decimal.Decimal `bun:"type:numeric,notnull" json:"fee"` Memo *string `bun:"type:text" json:"memo"` Enabled bool `bun:",notnull" json:"enabled"` } diff --git a/model/meter_04kv.go b/model/meter_04kv.go index cad217a..585d769 100644 --- a/model/meter_04kv.go +++ b/model/meter_04kv.go @@ -17,7 +17,7 @@ type Meter04KV struct { CustomerName *string `json:"customerName" excel:"name"` ContactName *string `json:"contactName" excel:"contact"` ContactPhone *string `json:"contactPhone" excel:"phone"` - Ratio decimal.Decimal `bun:",notnull" json:"ratio" excel:"ratio"` + Ratio decimal.Decimal `bun:"type:numeric,notnull" json:"ratio" excel:"ratio"` Seq int64 `bun:"type:bigint,notnull" json:"seq" excel:"seq"` IsPublicMeter bool `bun:"public_meter,notnull" json:"isPublicMeter" excel:"public"` WillDilute bool `bun:"dilute,notnull" json:"willDilute" excel:"dilute"` diff --git a/model/park.go b/model/park.go index b7d048d..326ee6d 100644 --- a/model/park.go +++ b/model/park.go @@ -28,9 +28,9 @@ type Park struct { UserId string `bun:",notnull" json:"userId"` Name string `bun:",notnull" json:"name"` Abbr *string `json:"abbr"` - Area decimal.NullDecimal `json:"area"` - TenementQuantity decimal.NullDecimal `json:"tenement"` - Capacity decimal.NullDecimal `json:"capacity"` + Area decimal.NullDecimal `bun:"type:numeric" json:"area"` + TenementQuantity decimal.NullDecimal `bun:"type:numeric" json:"tenement"` + Capacity decimal.NullDecimal `bun:"type:numeric" json:"capacity"` Category int8 `bun:"type:smallint,notnull" json:"category"` SubmeterType int8 `bun:"meter_04kv_type,type:smallint,notnull" json:"meter04kvType"` Region *string `json:"region"` diff --git a/model/report_summary.go b/model/report_summary.go index 4c096b7..87f1b9c 100644 --- a/model/report_summary.go +++ b/model/report_summary.go @@ -10,55 +10,55 @@ import ( type ReportSummary struct { bun.BaseModel `bun:"table:report_summary,alias:rs"` ReportId string `bun:",pk,notnull" json:"-"` - Overall decimal.Decimal `bun:",notnull" json:"overall"` - OverallFee decimal.Decimal `bun:",notnull" json:"overallFee"` - ConsumptionFee decimal.NullDecimal `json:"consumptionFee"` - OverallPrice decimal.NullDecimal `json:"overallPrice"` - Critical decimal.Decimal `bun:",notnull" json:"critical"` - CriticalFee decimal.Decimal `bun:",notnull" json:"criticalFee"` - CriticalPrice decimal.NullDecimal `json:"criticalPrice"` - Peak decimal.Decimal `bun:",notnull" json:"peak"` - PeakFee decimal.Decimal `bun:",notnull" json:"peakFee"` - PeakPrice decimal.NullDecimal `json:"peakPrice"` - Flat decimal.Decimal `bun:",notnull" json:"flat"` - FlatFee decimal.Decimal `bun:",notnull" json:"flatFee"` - FlatPrice decimal.NullDecimal `json:"flatPrice"` - Valley decimal.Decimal `bun:",notnull" json:"valley"` - ValleyFee decimal.Decimal `bun:",notnull" json:"valleyFee"` - ValleyPrice decimal.NullDecimal `json:"valleyPrice"` - Loss decimal.NullDecimal `json:"loss"` - LossFee decimal.NullDecimal `json:"lossFee"` - LossProportion decimal.NullDecimal `json:"lossProportion"` - CustomerConsumption decimal.NullDecimal `json:"customerConsumption"` - CustomerConsumptionFee decimal.NullDecimal `json:"customerConsumptionFee"` - CustomerConsumptionCritical decimal.NullDecimal `json:"customerConsumptionCritical"` - CustomerConsumptionCriticalFee decimal.NullDecimal `json:"customerConsumptionCriticalFee"` - CustomerConsumptionPeak decimal.NullDecimal `json:"customerConsumptionPeak"` - CustomerConsumptionPeakFee decimal.NullDecimal `json:"customerConsumptionPeakFee"` - CustomerConsumptionFlat decimal.NullDecimal `json:"customerConsumptionFlat"` - CustomerConsumptionFlatFee decimal.NullDecimal `json:"customerConsumptionFlatFee"` - CustomerConsumptionValley decimal.NullDecimal `json:"customerConsumptionValley"` - CustomerConsumptionValleyFee decimal.NullDecimal `json:"customerConsumptionValleyFee"` - PublicConsumption decimal.NullDecimal `json:"publicConsumption"` - PublicConsumptionFee decimal.NullDecimal `json:"publicConsumptionFee"` - PublicConsumptionProportion decimal.NullDecimal `json:"publicConsumptionProportion"` - PublicConsumptionCritical decimal.NullDecimal `json:"publicConsumptionCritical"` - PublicConsumptionCriticalFee decimal.NullDecimal `json:"publicConsumptionCriticalFee"` - PublicConsumptionPeak decimal.NullDecimal `json:"publicConsumptionPeak"` - PublicConsumptionPeakFee decimal.NullDecimal `json:"publicConsumptionPeakFee"` - PublicConsumptionFlat decimal.NullDecimal `json:"publicConsumptionFlat"` - PublicConsumptionFlatFee decimal.NullDecimal `json:"publicConsumptionFlatFee"` - PublicConsumptionValley decimal.NullDecimal `json:"publicConsumptionValley"` - PublicConsumptionValleyFee decimal.NullDecimal `json:"publicConsumptionValleyFee"` - BasicFee decimal.Decimal `bun:",notnull" json:"basicFee"` - BasicDilutedPrice decimal.NullDecimal `json:"basicDilutedPrice"` - AdjustFee decimal.Decimal `bun:",notnull" json:"adjustFee"` - AdjustDilutedPrice decimal.NullDecimal `json:"adjustDilutedPrice"` - MaintenanceDilutedPrice decimal.NullDecimal `json:"maintencanceDilutedPrice"` - LossDilutedPrice decimal.NullDecimal `json:"lossDilutedPrice"` - PublicConsumptionDilutedPrice decimal.NullDecimal `json:"publicConsumptionDilutedPrice"` - MaintenanceOverall decimal.NullDecimal `json:"maintenanceOverall"` - FinalDilutedOverall decimal.NullDecimal `json:"finalDilutedOverall"` + Overall decimal.Decimal `bun:"type:numeric,notnull" json:"overall"` + OverallFee decimal.Decimal `bun:"type:numeric,notnull" json:"overallFee"` + ConsumptionFee decimal.NullDecimal `bun:"type:numeric" json:"consumptionFee"` + OverallPrice decimal.NullDecimal `bun:"type:numeric" json:"overallPrice"` + Critical decimal.Decimal `bun:"type:numeric,notnull" json:"critical"` + CriticalFee decimal.Decimal `bun:"type:numeric,notnull" json:"criticalFee"` + CriticalPrice decimal.NullDecimal `bun:"type:numeric" json:"criticalPrice"` + Peak decimal.Decimal `bun:"type:numeric,notnull" json:"peak"` + PeakFee decimal.Decimal `bun:"type:numeric,notnull" json:"peakFee"` + PeakPrice decimal.NullDecimal `bun:"type:numeric" json:"peakPrice"` + Flat decimal.Decimal `bun:"type:numeric,notnull" json:"flat"` + FlatFee decimal.Decimal `bun:"type:numeric,notnull" json:"flatFee"` + FlatPrice decimal.NullDecimal `bun:"type:numeric" json:"flatPrice"` + Valley decimal.Decimal `bun:"type:numeric,notnull" json:"valley"` + ValleyFee decimal.Decimal `bun:"type:numeric,notnull" json:"valleyFee"` + ValleyPrice decimal.NullDecimal `bun:"type:numeric" json:"valleyPrice"` + Loss decimal.NullDecimal `bun:"type:numeric" json:"loss"` + LossFee decimal.NullDecimal `bun:"type:numeric" json:"lossFee"` + LossProportion decimal.NullDecimal `bun:"type:numeric" json:"lossProportion"` + CustomerConsumption decimal.NullDecimal `bun:"type:numeric" json:"customerConsumption"` + CustomerConsumptionFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionFee"` + CustomerConsumptionCritical decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionCritical"` + CustomerConsumptionCriticalFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionCriticalFee"` + CustomerConsumptionPeak decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionPeak"` + CustomerConsumptionPeakFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionPeakFee"` + CustomerConsumptionFlat decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionFlat"` + CustomerConsumptionFlatFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionFlatFee"` + CustomerConsumptionValley decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionValley"` + CustomerConsumptionValleyFee decimal.NullDecimal `bun:"type:numeric" json:"customerConsumptionValleyFee"` + PublicConsumption decimal.NullDecimal `bun:"type:numeric" json:"publicConsumption"` + PublicConsumptionFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionFee"` + PublicConsumptionProportion decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionProportion"` + PublicConsumptionCritical decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionCritical"` + PublicConsumptionCriticalFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionCriticalFee"` + PublicConsumptionPeak decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionPeak"` + PublicConsumptionPeakFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionPeakFee"` + PublicConsumptionFlat decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionFlat"` + PublicConsumptionFlatFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionFlatFee"` + PublicConsumptionValley decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionValley"` + PublicConsumptionValleyFee decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionValleyFee"` + BasicFee decimal.Decimal `bun:"type:numeric,notnull" json:"basicFee"` + BasicDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"basicDilutedPrice"` + AdjustFee decimal.Decimal `bun:"type:numeric,notnull" json:"adjustFee"` + AdjustDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"adjustDilutedPrice"` + MaintenanceDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"maintencanceDilutedPrice"` + LossDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"lossDilutedPrice"` + PublicConsumptionDilutedPrice decimal.NullDecimal `bun:"type:numeric" json:"publicConsumptionDilutedPrice"` + MaintenanceOverall decimal.NullDecimal `bun:"type:numeric" json:"maintenanceOverall"` + FinalDilutedOverall decimal.NullDecimal `bun:"type:numeric" json:"finalDilutedOverall"` } func (s ReportSummary) Validate() (bool, error) { diff --git a/model/user_charges.go b/model/user_charges.go index 19cf64b..fc80c60 100644 --- a/model/user_charges.go +++ b/model/user_charges.go @@ -13,9 +13,9 @@ type UserCharge struct { Created `bun:"extend"` Seq int64 `bun:"type:bigint,pk,notnull,autoincrement" json:"seq"` UserId string `bun:",notnull" json:"userId"` - Fee decimal.NullDecimal `json:"fee"` - Discount decimal.NullDecimal `json:"discount"` - Amount decimal.NullDecimal `json:"amount"` + Fee decimal.NullDecimal `bun:"type:numeric" json:"fee"` + Discount decimal.NullDecimal `bun:"type:numeric" json:"discount"` + Amount decimal.NullDecimal `bun:"type:numeric" json:"amount"` ChargeTo Date `bun:"type:date,notnull" json:"chargeTo"` Settled bool `bun:",notnull" json:"settled"` SettledAt *time.Time `bun:"type:timestamptz" json:"settledAt" time_format:"simple_datetime" time_location:"shanghai"` diff --git a/model/user_detail.go b/model/user_detail.go index 8465885..3cd0190 100644 --- a/model/user_detail.go +++ b/model/user_detail.go @@ -20,7 +20,7 @@ type UserDetail struct { Address *string `json:"address"` Contact *string `json:"contact"` Phone *string `json:"phone"` - UnitServiceFee decimal.Decimal `bun:",notnull" json:"unitServiceFee"` + UnitServiceFee decimal.Decimal `bun:"type:numeric,notnull" json:"unitServiceFee"` ServiceExpiration Date `bun:"type:date,notnull" json:"serviceExpiration"` } diff --git a/model/will_diluted_fee.go b/model/will_diluted_fee.go index 16178cc..fe8d641 100644 --- a/model/will_diluted_fee.go +++ b/model/will_diluted_fee.go @@ -15,7 +15,7 @@ type WillDilutedFee struct { ReportId string `bun:",notnull" json:"reportId"` SourceId *string `json:"sourceId"` Name string `bun:",notnull" json:"name"` - Fee decimal.Decimal `bun:",notnull" json:"fee"` + Fee decimal.Decimal `bun:"type:numeric,notnull" json:"fee"` Memo *string `bun:"type:text" json:"memo"` Origin *MaintenanceFee `bun:"rel:belongs-to,join:source_id=id"` } diff --git a/service/end_user.go b/service/end_user.go index 00ed5c5..d0e46e4 100644 --- a/service/end_user.go +++ b/service/end_user.go @@ -154,7 +154,7 @@ func (_EndUserService) newVirtualExcelAnalysisError(err error) *excel.ExcelAnaly } func (es _EndUserService) BatchImportNonPVRegister(reportId string, file io.Reader) *exceptions.BatchError { - ctx, cancel := global.TimeoutContext() + ctx, cancel := global.TimeoutContext(120) defer cancel() errs := exceptions.NewBatchError() @@ -255,7 +255,7 @@ func (es _EndUserService) BatchImportNonPVRegister(reportId string, file io.Read } func (es _EndUserService) BatchImportPVRegister(reportId string, file io.Reader) *exceptions.BatchError { - ctx, cancel := global.TimeoutContext() + ctx, cancel := global.TimeoutContext(120) defer cancel() errs := exceptions.NewBatchError()