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

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

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

* fix(config): 系统模型目录 - 支持零价模型
This commit is contained in:
ahyang authored and GitHub committed 2026-08-24 21:32:56 +08:00
1 parent e56a33008a
commit a7a728d24a
8 files changed
+79 -28

No files matched your search

+8 -1
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