Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c6175c0b
authored
Oct 13, 2025
by
Xyfacai
Committed by
GitHub
Oct 13, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 修复视频任务不同分组可能导致补回额度计算错误 (#2030)
parent
0dfd8f27
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
controller/task_video.go
+10
-5
model/task.go
+2
-0
No files found.
controller/task_video.go
View file @
c6175c0b
...
@@ -137,14 +137,19 @@ func updateVideoSingleTask(ctx context.Context, adaptor channel.TaskAdaptor, cha
...
@@ -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
{
...
...
model/task.go
View file @
c6175c0b
...
@@ -46,6 +46,7 @@ type Task struct {
...
@@ -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 {
...
@@ -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%"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment