deduction

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnitTimeNoLimit = "NoLimit"
	UnitTimeYear    = "Year"
	UnitTimeMonth   = "Month"
	UnitTimeDay     = "Day"
	UnitTimeHour    = "Hour"
	UnitTimeMinute  = "Minute"

	ResetCycleNone    = 0
	ResetCycle1st     = 1
	ResetCycleMonthly = 2
	ResetCycleYear    = 3
)

Variables

View Source
var (
	ErrInvalidQuantity       = errors.New("order quantity cannot be zero or negative")
	ErrInvalidAmount         = errors.New("order amount cannot be negative")
	ErrInvalidTraffic        = errors.New("traffic values cannot be negative")
	ErrInvalidTimeRange      = errors.New("expire time must be after start time")
	ErrInvalidUnitTime       = errors.New("invalid unit time")
	ErrInvalidDeductionRatio = errors.New("deduction ratio must be between 0 and 100")
	ErrOverflow              = errors.New("calculation overflow")
)

Functions

func CalculateRemainingAmount

func CalculateRemainingAmount(sub Subscribe, order Order) (int64, error)

Types

type Order

type Order struct {
	Amount   int64
	Quantity int64
}

func (*Order) Validate

func (o *Order) Validate() error

type Subscribe

type Subscribe struct {
	StartTime      time.Time
	ExpireTime     time.Time
	Traffic        int64
	Download       int64
	Upload         int64
	UnitTime       string
	UnitPrice      int64
	ResetCycle     int64
	DeductionRatio int64
}

func (*Subscribe) Validate

func (s *Subscribe) Validate() error

Jump to

Keyboard shortcuts

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