21 lines
828 B
Go
21 lines
828 B
Go
package billing
|
|
|
|
import (
|
|
"errors"
|
|
"math"
|
|
)
|
|
|
|
const BailianWan30VideoModel = "wan3.0-video"
|
|
|
|
// CalculateBailianWan30ActualAmountFen bills successful output duration. This
|
|
// integration accepts image inputs only, so there are no input video seconds.
|
|
func CalculateBailianWan30ActualAmountFen(outputSeconds float64, standardUnitPriceFen int64, markupMultiplier float64) (int64, error) {
|
|
if math.IsNaN(outputSeconds) || math.IsInf(outputSeconds, 0) || outputSeconds <= 0 {
|
|
return 0, errors.New("Wan 3.0 output seconds must be positive")
|
|
}
|
|
if standardUnitPriceFen <= 0 || math.IsNaN(markupMultiplier) || math.IsInf(markupMultiplier, 0) || markupMultiplier < 1 {
|
|
return 0, errors.New("Wan 3.0 price or markup is invalid")
|
|
}
|
|
return int64(math.Ceil(outputSeconds * float64(standardUnitPriceFen) * markupMultiplier)), nil
|
|
}
|