From c6175c0b46fa574a95304f2b0229e4f6406b4dad Mon Sep 17 00:00:00 2001 From: Xyfacai Date: Mon, 13 Oct 2025 15:17:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=B8=8D=E5=90=8C=E5=88=86=E7=BB=84=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E5=AF=BC=E8=87=B4=E8=A1=A5=E5=9B=9E=E9=A2=9D=E5=BA=A6?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF=20(#2030)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/task_video.go | 15 ++++++++++----- model/task.go | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/controller/task_video.go b/controller/task_video.go index 656bb4aa..cc99f78d 100644 --- a/controller/task_video.go +++ b/controller/task_video.go @@ -137,14 +137,19 @@ func updateVideoSingleTask(ctx context.Context, adaptor channel.TaskAdaptor, cha if modelName, ok := taskData["model"].(string); ok && modelName != "" { // 获取模型价格和倍率 modelRatio, hasRatioSetting, _ := ratio_setting.GetModelRatio(modelName) - // 只有配置了倍率(非固定价格)时才按 token 重新计费 if hasRatioSetting && modelRatio > 0 { // 获取用户和组的倍率信息 - user, err := model.GetUserById(task.UserId, false) - if err == nil { - groupRatio := ratio_setting.GetGroupRatio(user.Group) - userGroupRatio, hasUserGroupRatio := ratio_setting.GetGroupGroupRatio(user.Group, user.Group) + group := task.Group + if group == "" { + user, err := model.GetUserById(task.UserId, false) + if err == nil { + group = user.Group + } + } + if group != "" { + groupRatio := ratio_setting.GetGroupRatio(group) + userGroupRatio, hasUserGroupRatio := ratio_setting.GetGroupGroupRatio(group, group) var finalGroupRatio float64 if hasUserGroupRatio { diff --git a/model/task.go b/model/task.go index f47c4469..a8c3a7d4 100644 --- a/model/task.go +++ b/model/task.go @@ -46,6 +46,7 @@ type Task struct { TaskID string `json:"task_id" gorm:"type:varchar(191);index"` // 第三方id,不一定有/ song id\ Task id Platform constant.TaskPlatform `json:"platform" gorm:"type:varchar(30);index"` // 平台 UserId int `json:"user_id" gorm:"index"` + Group string `json:"group" gorm:"type:varchar(50)"` // 修正计费用 ChannelId int `json:"channel_id" gorm:"index"` Quota int `json:"quota"` Action string `json:"action" gorm:"type:varchar(40);index"` // 任务类型, song, lyrics, description-mode @@ -99,6 +100,7 @@ type SyncTaskQueryParams struct { func InitTask(platform constant.TaskPlatform, relayInfo *commonRelay.RelayInfo) *Task { t := &Task{ UserId: relayInfo.UserId, + Group: relayInfo.UsingGroup, SubmitTime: time.Now().Unix(), Status: TaskStatusNotStart, Progress: "0%",