mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-03-30 02:42:29 +00:00
feat(mjp): update billing log for failed tasks
This commit is contained in:
@@ -181,8 +181,18 @@ func UpdateMidjourneyTaskBulk() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogError(ctx, "fail to increase user quota: "+err.Error())
|
logger.LogError(ctx, "fail to increase user quota: "+err.Error())
|
||||||
}
|
}
|
||||||
logContent := fmt.Sprintf("构图失败 %s,补偿 %s", task.MjId, logger.LogQuota(task.Quota))
|
model.RecordTaskBillingLog(model.RecordTaskBillingLogParams{
|
||||||
model.RecordLog(task.UserId, model.LogTypeSystem, logContent)
|
UserId: task.UserId,
|
||||||
|
LogType: model.LogTypeRefund,
|
||||||
|
Content: "",
|
||||||
|
ChannelId: task.ChannelId,
|
||||||
|
ModelName: service.CovertMjpActionToModelName(task.Action),
|
||||||
|
Quota: task.Quota,
|
||||||
|
Other: map[string]interface{}{
|
||||||
|
"task_id": task.MjId,
|
||||||
|
"reason": "构图失败",
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ func RelaySwapFace(c *gin.Context, info *relaycommon.RelayInfo) *dto.MidjourneyR
|
|||||||
if swapFaceRequest.SourceBase64 == "" || swapFaceRequest.TargetBase64 == "" {
|
if swapFaceRequest.SourceBase64 == "" || swapFaceRequest.TargetBase64 == "" {
|
||||||
return service.MidjourneyErrorWrapper(constant.MjRequestError, "sour_base64_and_target_base64_is_required")
|
return service.MidjourneyErrorWrapper(constant.MjRequestError, "sour_base64_and_target_base64_is_required")
|
||||||
}
|
}
|
||||||
modelName := service.CoverActionToModelName(constant.MjActionSwapFace)
|
modelName := service.CovertMjpActionToModelName(constant.MjActionSwapFace)
|
||||||
|
|
||||||
priceData := helper.ModelPriceHelperPerCall(c, info)
|
priceData := helper.ModelPriceHelperPerCall(c, info)
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ func RelayMidjourneySubmit(c *gin.Context, relayInfo *relaycommon.RelayInfo) *dt
|
|||||||
|
|
||||||
fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL)
|
fullRequestURL := fmt.Sprintf("%s%s", baseURL, requestURL)
|
||||||
|
|
||||||
modelName := service.CoverActionToModelName(midjRequest.Action)
|
modelName := service.CovertMjpActionToModelName(midjRequest.Action)
|
||||||
|
|
||||||
priceData := helper.ModelPriceHelperPerCall(c, relayInfo)
|
priceData := helper.ModelPriceHelperPerCall(c, relayInfo)
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CoverActionToModelName(mjAction string) string {
|
func CovertMjpActionToModelName(mjAction string) string {
|
||||||
modelName := "mj_" + strings.ToLower(mjAction)
|
modelName := "mj_" + strings.ToLower(mjAction)
|
||||||
if mjAction == constant.MjActionSwapFace {
|
if mjAction == constant.MjActionSwapFace {
|
||||||
modelName = "swap_face"
|
modelName = "swap_face"
|
||||||
@@ -70,7 +70,7 @@ func GetMjRequestModel(relayMode int, midjRequest *dto.MidjourneyRequest) (strin
|
|||||||
return "", MidjourneyErrorWrapper(constant.MjRequestError, "unknown_relay_action"), false
|
return "", MidjourneyErrorWrapper(constant.MjRequestError, "unknown_relay_action"), false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
modelName := CoverActionToModelName(action)
|
modelName := CovertMjpActionToModelName(action)
|
||||||
return modelName, nil, true
|
return modelName, nil, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user