fix: 修复视频任务不同分组可能导致补回额度计算错误 (#2030)
This commit is contained in:
@@ -137,14 +137,19 @@ func updateVideoSingleTask(ctx context.Context, adaptor channel.TaskAdaptor, cha
|
|||||||
if modelName, ok := taskData["model"].(string); ok && modelName != "" {
|
if modelName, ok := taskData["model"].(string); ok && modelName != "" {
|
||||||
// 获取模型价格和倍率
|
// 获取模型价格和倍率
|
||||||
modelRatio, hasRatioSetting, _ := ratio_setting.GetModelRatio(modelName)
|
modelRatio, hasRatioSetting, _ := ratio_setting.GetModelRatio(modelName)
|
||||||
|
|
||||||
// 只有配置了倍率(非固定价格)时才按 token 重新计费
|
// 只有配置了倍率(非固定价格)时才按 token 重新计费
|
||||||
if hasRatioSetting && modelRatio > 0 {
|
if hasRatioSetting && modelRatio > 0 {
|
||||||
// 获取用户和组的倍率信息
|
// 获取用户和组的倍率信息
|
||||||
user, err := model.GetUserById(task.UserId, false)
|
group := task.Group
|
||||||
if err == nil {
|
if group == "" {
|
||||||
groupRatio := ratio_setting.GetGroupRatio(user.Group)
|
user, err := model.GetUserById(task.UserId, false)
|
||||||
userGroupRatio, hasUserGroupRatio := ratio_setting.GetGroupGroupRatio(user.Group, user.Group)
|
if err == nil {
|
||||||
|
group = user.Group
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if group != "" {
|
||||||
|
groupRatio := ratio_setting.GetGroupRatio(group)
|
||||||
|
userGroupRatio, hasUserGroupRatio := ratio_setting.GetGroupGroupRatio(group, group)
|
||||||
|
|
||||||
var finalGroupRatio float64
|
var finalGroupRatio float64
|
||||||
if hasUserGroupRatio {
|
if hasUserGroupRatio {
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ type Task struct {
|
|||||||
TaskID string `json:"task_id" gorm:"type:varchar(191);index"` // 第三方id,不一定有/ song id\ Task id
|
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"` // 平台
|
Platform constant.TaskPlatform `json:"platform" gorm:"type:varchar(30);index"` // 平台
|
||||||
UserId int `json:"user_id" gorm:"index"`
|
UserId int `json:"user_id" gorm:"index"`
|
||||||
|
Group string `json:"group" gorm:"type:varchar(50)"` // 修正计费用
|
||||||
ChannelId int `json:"channel_id" gorm:"index"`
|
ChannelId int `json:"channel_id" gorm:"index"`
|
||||||
Quota int `json:"quota"`
|
Quota int `json:"quota"`
|
||||||
Action string `json:"action" gorm:"type:varchar(40);index"` // 任务类型, song, lyrics, description-mode
|
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 {
|
func InitTask(platform constant.TaskPlatform, relayInfo *commonRelay.RelayInfo) *Task {
|
||||||
t := &Task{
|
t := &Task{
|
||||||
UserId: relayInfo.UserId,
|
UserId: relayInfo.UserId,
|
||||||
|
Group: relayInfo.UsingGroup,
|
||||||
SubmitTime: time.Now().Unix(),
|
SubmitTime: time.Now().Unix(),
|
||||||
Status: TaskStatusNotStart,
|
Status: TaskStatusNotStart,
|
||||||
Progress: "0%",
|
Progress: "0%",
|
||||||
|
|||||||
Reference in New Issue
Block a user