common

package
v2.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Billing

func Billing(ctx context.Context, usage smodel.Usage, spend *common.Spend)

计算花费

func CalcNextNaturalResetAt added in v2.3.0

func CalcNextNaturalResetAt(now time.Time, cyclePeriod int, periodUnit string) int64

func CalcNextRelativeResetAt added in v2.3.0

func CalcNextRelativeResetAt(baseTime time.Time, cyclePeriod int, periodUnit string) int64

func CalcNextResetAt added in v2.3.0

func CalcNextResetAt(baseTime time.Time, cyclePeriod int, periodUnit string, resetMode string) int64

func ConvModelPricingToPrice

func ConvModelPricingToPrice(pricing common.Pricing) common.Pricing

转换模型定价成价格

func ConvModelPricingToRatio

func ConvModelPricingToRatio(pricing common.Pricing) common.Pricing

转换模型定价成倍率

func ConvPrice

func ConvPrice(ratio float64) float64

倍率转价格

func ConvQuotaUnit

func ConvQuotaUnit(quota float64) int

转换额度单位

func ConvQuotaUnitReverse

func ConvQuotaUnitReverse(quota int, n ...int) float64

转换额度单位(反向)

func ConvRatio

func ConvRatio(price float64) float64

价格转倍率

func ConvSpend

func ConvSpend(spend common.Spend) common.Spend

转换花费

func ConvTimeRulesToPercent added in v2.3.0

func ConvTimeRulesToPercent(rules []*common.TimeRule) []*common.TimeRule

转换时段规则成百分比

func ConvTimeRulesToRatio added in v2.3.0

func ConvTimeRulesToRatio(rules []*common.TimeRule) []*common.TimeRule

转换时段规则成倍率

func GetNextResetAt added in v2.3.0

func GetNextResetAt(isCycleResetQuota bool, cyclePeriod int, periodUnit string, resetMode string) int64

func GetVariableData

func GetVariableData(ctx context.Context, user *entity.User, reseller *entity.Reseller, siteConfig *entity.SiteConfig, variables []string) map[string]any

获取变量数据

func IsResetRuleChanged added in v2.3.0

func IsResetRuleChanged(oldIsCycleResetQuota bool, oldResetQuota int, oldCyclePeriod int, oldPeriodUnit string, oldResetMode string, newIsCycleResetQuota bool, newResetQuota int, newCyclePeriod int, newPeriodUnit string, newResetMode string) bool

func New

func New() service.ICommon

func ParseSecretKey

func ParseSecretKey(ctx context.Context, secretKey string) (int, int, error)

解析密钥

func RecordSpend

func RecordSpend(ctx context.Context, userId, appId int, appKey string, rid int, key string, spend common.Spend) error

记录花费

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL