|
|
@@ -77,7 +77,7 @@ public class CodexServiceImpl implements CodexService {
|
|
|
//sku 存在并且开启赠送codex
|
|
|
if (sku != null && sku.getIsCodex()) {
|
|
|
CodexUserPackageReq codexPackageReq = CodexUserPackageReq.builder()
|
|
|
- .userId(userId)
|
|
|
+ .userId(claudeCodeInfo.getUserId())
|
|
|
.planName(sku.getCodexPlanName())
|
|
|
.openaiDailyLimit(sku.getOpenaiDailyLimit())
|
|
|
.openaiQuota(sku.getOpenaiQuota())
|
|
|
@@ -106,7 +106,7 @@ public class CodexServiceImpl implements CodexService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- return CodexUserInfoView.ClaudeCodeInfo.builder().planName(claudeCodeUser.getPlanName()).relationId(claudeCodeUser.getRelationId()).codePoints(claudeCodeUser.getCodePoints()).codeCreditRecovery(claudeCodeUser.getCodeCreditRecovery()).expiryTime(claudeCodeUser.getExpiryTime()).renewSkuId(claudeCodeUser.getRenewSkuId()).renewExpiryTime(claudeCodeUser.getRenewExpiryTime()).build();
|
|
|
+ return CodexUserInfoView.ClaudeCodeInfo.builder().userId(claudeCodeUser.getUserId()).planName(claudeCodeUser.getPlanName()).relationId(claudeCodeUser.getRelationId()).codePoints(claudeCodeUser.getCodePoints()).codeCreditRecovery(claudeCodeUser.getCodeCreditRecovery()).expiryTime(claudeCodeUser.getExpiryTime()).renewSkuId(claudeCodeUser.getRenewSkuId()).renewExpiryTime(claudeCodeUser.getRenewExpiryTime()).build();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -210,7 +210,7 @@ public class CodexServiceImpl implements CodexService {
|
|
|
return null;
|
|
|
}
|
|
|
// 调用Codex API获取实时使用统计
|
|
|
- String usageUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/usage?period=%s", userId, period);
|
|
|
+ String usageUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/usage?period=%s", codexUser.getUserId(), period);
|
|
|
ClaudeCodeResp codexResp = executeCodexGetApi(usageUrl);
|
|
|
return codexResp;
|
|
|
}
|
|
|
@@ -240,7 +240,7 @@ public class CodexServiceImpl implements CodexService {
|
|
|
|
|
|
try {
|
|
|
// 调用Codex API更新每日限额
|
|
|
- String updateUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/users/%s/limit", userId);
|
|
|
+ String updateUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/users/%s/limit", codexUser.getUserId());
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("daily_limit", dailyLimit);
|
|
|
params.put("total_quota", totalQuota);
|
|
|
@@ -302,34 +302,6 @@ public class CodexServiceImpl implements CodexService {
|
|
|
throw new BusinessRuntimeException("获取系统指标失败");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public ClaudeCodeResp getUserDashboard(Long userId) {
|
|
|
- List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
- CodexUser codexUser = codexUserMapper.selectOne(Wrappers.lambdaQuery(CodexUser.class).in(CodexUser::getUserId, userIdList).last("limit 1"));
|
|
|
-
|
|
|
- if (codexUser == null) {
|
|
|
- throw new BusinessRuntimeException("用户未开通Codex服务");
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- // 调用Codex API获取用户仪表盘数据
|
|
|
- String dashboardUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/dashboard", userId);
|
|
|
- ClaudeCodeResp codexResp = executeCodexGetApi(dashboardUrl);
|
|
|
-
|
|
|
- if (codexResp == null) {
|
|
|
- log.error("获取用户{}仪表盘数据失败: API返回null", userId);
|
|
|
- throw new BusinessRuntimeException("获取用户仪表盘数据失败");
|
|
|
- }
|
|
|
-
|
|
|
- log.info("成功获取用户{}仪表盘数据", userId);
|
|
|
- return codexResp;
|
|
|
-
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("获取用户{}仪表盘数据异常, error={}", userId, StringUtil.getErrorText(e));
|
|
|
- throw new BusinessRuntimeException("获取用户仪表盘数据失败");
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public ClaudeCodeResp getJavaUserDashboard(Long userId) {
|
|
|
@@ -341,7 +313,7 @@ public class CodexServiceImpl implements CodexService {
|
|
|
}
|
|
|
|
|
|
// 调用Codex API获取用户控制台数据
|
|
|
- String dashboardUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/dashboard", userId);
|
|
|
+ String dashboardUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/dashboard", codexUser.getUserId());
|
|
|
ClaudeCodeResp codexResp = executeCodexGetApi(dashboardUrl);
|
|
|
return codexResp;
|
|
|
}
|
|
|
@@ -356,7 +328,7 @@ public class CodexServiceImpl implements CodexService {
|
|
|
}
|
|
|
|
|
|
// 调用Codex API获取用户分析数据
|
|
|
- String analyticsUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/analytics", userId);
|
|
|
+ String analyticsUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/analytics", codexUser.getUserId());
|
|
|
ClaudeCodeResp codexResp = executeCodexGetApi(analyticsUrl);
|
|
|
|
|
|
return codexResp;
|