mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-19 11:08:37 +00:00
refactor(relay): enhance remix logic for billing context extraction
- Updated the remix handling in ResolveOriginTask to prioritize extracting OtherRatios from the BillingContext of the original task if available. - Retained the previous logic for extracting seconds and size from task data as a fallback. - Improved clarity and maintainability of the remix logic by separating the new and old approaches.
This commit is contained in:
@@ -106,21 +106,29 @@ func ResolveOriginTask(c *gin.Context, info *relaycommon.RelayInfo) *dto.TaskErr
|
|||||||
|
|
||||||
// 提取 remix 参数(时长、分辨率 → OtherRatios)
|
// 提取 remix 参数(时长、分辨率 → OtherRatios)
|
||||||
if info.Action == constant.TaskActionRemix {
|
if info.Action == constant.TaskActionRemix {
|
||||||
var taskData map[string]interface{}
|
if originTask.PrivateData.BillingContext != nil {
|
||||||
_ = common.Unmarshal(originTask.Data, &taskData)
|
// 新的 remix 逻辑:直接从原始任务的 BillingContext 中提取 OtherRatios(如果存在)
|
||||||
secondsStr, _ := taskData["seconds"].(string)
|
for s, f := range originTask.PrivateData.BillingContext.OtherRatios {
|
||||||
seconds, _ := strconv.Atoi(secondsStr)
|
info.PriceData.AddOtherRatio(s, f)
|
||||||
if seconds <= 0 {
|
}
|
||||||
seconds = 4
|
} else {
|
||||||
}
|
// 旧的 remix 逻辑:直接从 task data 解析 seconds 和 size(如果存在)
|
||||||
sizeStr, _ := taskData["size"].(string)
|
var taskData map[string]interface{}
|
||||||
if info.PriceData.OtherRatios == nil {
|
_ = common.Unmarshal(originTask.Data, &taskData)
|
||||||
info.PriceData.OtherRatios = map[string]float64{}
|
secondsStr, _ := taskData["seconds"].(string)
|
||||||
}
|
seconds, _ := strconv.Atoi(secondsStr)
|
||||||
info.PriceData.OtherRatios["seconds"] = float64(seconds)
|
if seconds <= 0 {
|
||||||
info.PriceData.OtherRatios["size"] = 1
|
seconds = 4
|
||||||
if sizeStr == "1792x1024" || sizeStr == "1024x1792" {
|
}
|
||||||
info.PriceData.OtherRatios["size"] = 1.666667
|
sizeStr, _ := taskData["size"].(string)
|
||||||
|
if info.PriceData.OtherRatios == nil {
|
||||||
|
info.PriceData.OtherRatios = map[string]float64{}
|
||||||
|
}
|
||||||
|
info.PriceData.OtherRatios["seconds"] = float64(seconds)
|
||||||
|
info.PriceData.OtherRatios["size"] = 1
|
||||||
|
if sizeStr == "1792x1024" || sizeStr == "1024x1792" {
|
||||||
|
info.PriceData.OtherRatios["size"] = 1.666667
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user