mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
fix: 修复mj固定价格设置无效的问题
This commit is contained in:
parent
29dbdf01f0
commit
e2d994d73a
@ -109,7 +109,7 @@ func GetModelPrice(name string) float64 {
|
|||||||
}
|
}
|
||||||
price, ok := ModelPrice[name]
|
price, ok := ModelPrice[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
//SysError("model price not found: " + name)
|
SysError("model price not found: " + name)
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
return price
|
return price
|
||||||
|
@ -263,8 +263,6 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
action := midjRequest.Action
|
|
||||||
|
|
||||||
if relayMode == RelayModeMidjourneyImagine { //绘画任务,此类任务可重复
|
if relayMode == RelayModeMidjourneyImagine { //绘画任务,此类任务可重复
|
||||||
if midjRequest.Prompt == "" {
|
if midjRequest.Prompt == "" {
|
||||||
return &MidjourneyResponse{
|
return &MidjourneyResponse{
|
||||||
@ -296,7 +294,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
|
|||||||
Description: "index_can_only_be_1_2_3_4",
|
Description: "index_can_only_be_1_2_3_4",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
action = midjRequest.Action
|
//action = midjRequest.Action
|
||||||
mjId = midjRequest.TaskId
|
mjId = midjRequest.TaskId
|
||||||
} else if relayMode == RelayModeMidjourneySimpleChange {
|
} else if relayMode == RelayModeMidjourneySimpleChange {
|
||||||
if midjRequest.Content == "" {
|
if midjRequest.Content == "" {
|
||||||
@ -313,8 +311,9 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
mjId = params.ID
|
mjId = params.ID
|
||||||
action = params.Action
|
midjRequest.Action = params.Action
|
||||||
}
|
}
|
||||||
|
|
||||||
originTask := model.GetByMJId(userId, mjId)
|
originTask := model.GetByMJId(userId, mjId)
|
||||||
if originTask == nil {
|
if originTask == nil {
|
||||||
return &MidjourneyResponse{
|
return &MidjourneyResponse{
|
||||||
@ -391,8 +390,9 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
|
|||||||
} else {
|
} else {
|
||||||
requestBody = c.Request.Body
|
requestBody = c.Request.Body
|
||||||
}
|
}
|
||||||
mjAction := "mj_" + strings.ToLower(action)
|
mjAction := "mj_" + strings.ToLower(midjRequest.Action)
|
||||||
modelPrice := common.GetModelPrice(mjAction)
|
modelPrice := common.GetModelPrice(mjAction)
|
||||||
|
// 如果没有配置价格,则使用默认价格
|
||||||
if modelPrice == -1 {
|
if modelPrice == -1 {
|
||||||
defaultPrice, ok := DefaultModelPrice[mjAction]
|
defaultPrice, ok := DefaultModelPrice[mjAction]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -476,7 +476,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
|
|||||||
}
|
}
|
||||||
if quota != 0 {
|
if quota != 0 {
|
||||||
tokenName := c.GetString("token_name")
|
tokenName := c.GetString("token_name")
|
||||||
logContent := fmt.Sprintf("模型固定价格 %.2f,分组倍率 %.2f,操作 %s", modelPrice, groupRatio, action)
|
logContent := fmt.Sprintf("模型固定价格 %.2f,分组倍率 %.2f,操作 %s", modelPrice, groupRatio, midjRequest.Action)
|
||||||
model.RecordConsumeLog(ctx, userId, channelId, 0, 0, imageModel, tokenName, quota, logContent, tokenId, userQuota)
|
model.RecordConsumeLog(ctx, userId, channelId, 0, 0, imageModel, tokenName, quota, logContent, tokenId, userQuota)
|
||||||
model.UpdateUserUsedQuotaAndRequestCount(userId, quota)
|
model.UpdateUserUsedQuotaAndRequestCount(userId, quota)
|
||||||
channelId := c.GetInt("channel_id")
|
channelId := c.GetInt("channel_id")
|
||||||
@ -530,7 +530,7 @@ func relayMidjourneySubmit(c *gin.Context, relayMode int) *MidjourneyResponse {
|
|||||||
midjourneyTask := &model.Midjourney{
|
midjourneyTask := &model.Midjourney{
|
||||||
UserId: userId,
|
UserId: userId,
|
||||||
Code: midjResponse.Code,
|
Code: midjResponse.Code,
|
||||||
Action: action,
|
Action: midjRequest.Action,
|
||||||
MjId: midjResponse.Result,
|
MjId: midjResponse.Result,
|
||||||
Prompt: midjRequest.Prompt,
|
Prompt: midjRequest.Prompt,
|
||||||
PromptEn: "",
|
PromptEn: "",
|
||||||
|
Loading…
Reference in New Issue
Block a user