fix: 支持零价系统渠道模型分发 (#303)

* docs(spec): 模型计费 - 记录零价免费模型设计

* fix(billing): 模型定价 - 支持零价免费模型

* fix(config): 系统模型目录 - 支持零价模型
This commit is contained in:
ahyang
2026-08-24 21:32:56 +08:00
committed by GitHub
parent 76035451f1
commit a23e399ccf
8 changed files with 79 additions and 28 deletions

View File

@@ -615,7 +615,7 @@ func (r *Repository) SettleBillingOrder(id string, providerRequestID string) err
if order.Status == model.BillingStatusRefunded {
return errors.New("billing order already refunded")
}
if order.BillingMode == "token" {
if order.BillingMode == "token" && !zeroPricedTokenOrder(order) {
usage, err := billingUsage(tx, id)
if err != nil {
return err
@@ -717,6 +717,13 @@ func (r *Repository) SettleBillingOrder(id string, providerRequestID string) err
})
}
func zeroPricedTokenOrder(order model.BillingOrder) bool {
return order.BillingMode == "token" &&
order.InputTokenPriceMicrocredits == 0 &&
order.OutputTokenPriceMicrocredits == 0 &&
order.CachedTokenPriceMicrocredits == 0
}
func (r *Repository) RefundBillingOrder(id string, errorText string) error {
return r.db.Transaction(func(tx *gorm.DB) error {
var order model.BillingOrder