mirror of
https://github.com/labring/sealos.git
synced 2026-11-03 20:53:57 +08:00
* change accountbalance struct add billing controller; add new query CRD: billingresordquery and pricequery, and query controller; modify the storage amount ratio to 1:1000000 optimize mongo query code * hide the old metering controller * add query gvk to debt webhook white list; monitor data table by day, eg: monitor_20230517; billing collection cancels the timing table and changes it to an index type table; optimize the billing logic and bill by the hour; optimize the use of gonanoid to generate 12-digit bill id; payment crd adds the PaymentMethod field, which is used to identify wechat or other billing methods in the future. * add resources controller workflow fix payment controller panic error add resources controller cluster image workflow
38 lines
1.4 KiB
Go
38 lines
1.4 KiB
Go
package database
|
||
|
||
import (
|
||
"context"
|
||
"time"
|
||
|
||
accountv1 "github.com/labring/sealos/controllers/account/api/v1"
|
||
"github.com/labring/sealos/controllers/pkg/common"
|
||
)
|
||
|
||
type Interface interface {
|
||
//InitDB() error
|
||
GetMeteringOwnerTimeResult(queryTime time.Time, queryCategories, queryProperties []string, queryOwner string) (*MeteringOwnerTimeResult, error)
|
||
GetBillingLastUpdateTime(owner string, _type accountv1.Type) (bool, time.Time, error)
|
||
SaveBillingsWithAccountBalance(accountBalanceSpec *accountv1.AccountBalanceSpec) error
|
||
QueryBillingRecords(billingRecordQuery *accountv1.BillingRecordQuery, owner string) error
|
||
GetUpdateTimeForCategoryAndPropertyFromMetering(category string, property string) (time.Time, error)
|
||
GetAllPricesMap() (map[string]common.Price, error)
|
||
GenerateMeteringData(startTime, endTime time.Time, prices map[string]common.Price) error
|
||
InsertMonitor(ctx context.Context, monitors ...*common.Monitor) error
|
||
Disconnect(ctx context.Context) error
|
||
Creator
|
||
}
|
||
|
||
type Creator interface {
|
||
CreateBillingIfNotExist() error
|
||
//suffix by day, eg: monitor_20200101
|
||
CreateMonitorTimeSeriesIfNotExist(collTime time.Time) error
|
||
CreateMeteringTimeSeriesIfNotExist() error
|
||
}
|
||
|
||
type MeteringOwnerTimeResult struct {
|
||
Owner string `bson:"owner"`
|
||
Time time.Time `bson:"time"`
|
||
Amount int64 `bson:"amount"`
|
||
Costs map[string]int64 `bson:"costs"`
|
||
}
|