15 lines
457 B
Go
15 lines
457 B
Go
package repository
|
|
|
|
import "yingce/backend/internal/model"
|
|
|
|
func billingChargeLimitApplies(order model.BillingOrder) bool {
|
|
return order.ChargeLimitSet || order.ChargeLimitMicrocredits > 0
|
|
}
|
|
|
|
func validateBillingChargeLimit(order model.BillingOrder, amount int64) error {
|
|
if amount < 0 || (billingChargeLimitApplies(order) && (order.ChargeLimitMicrocredits < 0 || amount > order.ChargeLimitMicrocredits)) {
|
|
return ErrBillingChargeLimit
|
|
}
|
|
return nil
|
|
}
|