massive draft for payment process (UNCOMPLETE)
This commit is contained in:
56
models/common/pricing/pricing_profile.go
Normal file
56
models/common/pricing/pricing_profile.go
Normal file
@@ -0,0 +1,56 @@
|
||||
package pricing
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
"cloud.o-forge.io/core/oc-lib/tools"
|
||||
)
|
||||
|
||||
type PricingProfileITF interface {
|
||||
GetID() string
|
||||
GetPrice(quantity float64, val float64, start time.Time, end time.Time, request *tools.APIRequest, params ...string) (float64, error)
|
||||
IsBuying() bool
|
||||
GetOverrideStrategyValue() int
|
||||
}
|
||||
|
||||
type RefundType int
|
||||
|
||||
const (
|
||||
REFUND_DEAD_END RefundType = iota
|
||||
REFUND_ON_ERROR
|
||||
REFUND_ON_EARLY_END
|
||||
)
|
||||
|
||||
type AccessPricingProfile struct { // only use for acces such as : DATA && PROCESSING
|
||||
utils.DBObject
|
||||
DefaultRefund RefundType `json:"default_refund" bson:"default_refund"` // DefaultRefund is the default refund type of the pricing
|
||||
RefundRatio int32 `json:"refund_ratio" bson:"refund_ratio" default:"0"` // RefundRatio is the refund ratio if missing
|
||||
}
|
||||
|
||||
func (b *AccessPricingProfile) GetOverrideStrategyValue() int {
|
||||
return -1
|
||||
}
|
||||
|
||||
type ExploitPricingStrategy int
|
||||
|
||||
const (
|
||||
BASIC ExploitPricingStrategy = iota
|
||||
GARANTED_ON_DELAY
|
||||
GARANTED
|
||||
)
|
||||
|
||||
func (t ExploitPricingStrategy) String() string {
|
||||
return [...]string{"BASIC", "GARANTED_ON_DELAY", "GARANTED"}[t]
|
||||
}
|
||||
|
||||
type ExploitPricingProfile struct { // only use for exploit such as : STORAGE, COMPUTE, WORKFLOW
|
||||
AccessPricingProfile
|
||||
AdditionnalRefundTypes []RefundType `json:"refund_types" bson:"refund_types"` // RefundTypes is the refund types of the pricing
|
||||
|
||||
PrivilegeStrategy ExploitPricingStrategy `json:"privilege_strategy,omitempty" bson:"privilege_strategy,omitempty"` // Strategy is the strategy of the pricing
|
||||
GarantedDelaySecond uint
|
||||
|
||||
Exceeding bool
|
||||
ExceedingRatio int32 `json:"exceeding_ratio" bson:"exceeding_ratio" default:"0"` // ExceedingRatio is the exceeding ratio of the bill
|
||||
}
|
||||
Reference in New Issue
Block a user