mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-14 20:33:40 +00:00
fix(billing): 统一计费代理类BillingChatServiceProxy
This commit is contained in:
@@ -18,6 +18,7 @@ import java.util.function.Consumer;
|
|||||||
/**
|
/**
|
||||||
* 统一计费代理类
|
* 统一计费代理类
|
||||||
* 自动处理所有ChatService的AI回复保存和计费逻辑
|
* 自动处理所有ChatService的AI回复保存和计费逻辑
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -31,12 +32,12 @@ public class BillingChatServiceProxy implements IChatService {
|
|||||||
// 🔥 在AI回复开始前检查余额是否充足
|
// 🔥 在AI回复开始前检查余额是否充足
|
||||||
if (!chatCostService.checkBalanceSufficient(chatRequest)) {
|
if (!chatCostService.checkBalanceSufficient(chatRequest)) {
|
||||||
String errorMsg = "余额不足,无法使用AI服务,请充值后再试";
|
String errorMsg = "余额不足,无法使用AI服务,请充值后再试";
|
||||||
log.warn("余额不足阻止AI回复,用户ID: {}, 模型: {}",
|
log.warn("余额不足阻止AI回复,用户ID: {}, 模型: {}",
|
||||||
chatRequest.getUserId(), chatRequest.getModel());
|
chatRequest.getUserId(), chatRequest.getModel());
|
||||||
throw new RuntimeException(errorMsg);
|
throw new RuntimeException(errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("余额检查通过,开始AI回复,用户ID: {}, 模型: {}",
|
log.debug("余额检查通过,开始AI回复,用户ID: {}, 模型: {}",
|
||||||
chatRequest.getUserId(), chatRequest.getModel());
|
chatRequest.getUserId(), chatRequest.getModel());
|
||||||
|
|
||||||
// 创建增强的SseEmitter,自动收集AI回复
|
// 创建增强的SseEmitter,自动收集AI回复
|
||||||
|
|||||||
Reference in New Issue
Block a user