zoujiajian 11 月之前
父節點
當前提交
95ff79d769

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/codex/CodexService.java

@@ -46,5 +46,5 @@ public interface CodexService {
     /**
      * 获取Java系统专用的用户OpenAI图表+明细联动数据
      */
-    ClaudeCodeResp getJavaUserAnalytics(Long userId);
+    ClaudeCodeResp getJavaUserAnalytics(Long userId, String start, String end);
 }

+ 9 - 2
netflix-service/src/main/java/com/cyksj/service/codex/impl/CodexServiceImpl.java

@@ -1,5 +1,6 @@
 package com.cyksj.service.codex.impl;
 
+import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.http.HttpResponse;
 import cn.hutool.http.HttpUtil;
@@ -319,7 +320,7 @@ public class CodexServiceImpl implements CodexService {
 	}
 	
 	@Override
-	public ClaudeCodeResp getJavaUserAnalytics(Long userId) {
+	public ClaudeCodeResp getJavaUserAnalytics(Long userId, String start, String end) {
 		List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
 		CodexUser codexUser = codexUserMapper.selectOne(Wrappers.lambdaQuery(CodexUser.class).in(CodexUser::getUserId, userIdList).last("limit 1"));
 
@@ -327,8 +328,14 @@ public class CodexServiceImpl implements CodexService {
 			return null;
 		}
 
+		if (start == null) {
+			DateTime now = DateTime.now();
+			start = DateUtil.offsetDay(now, -1).toString();
+			end = now.toString();
+		}
+
 		// 调用Codex API获取用户分析数据
-		String analyticsUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/analytics", codexUser.getUserId());
+		String analyticsUrl = String.format(Constant.CLAUDE_CODE_API_PREFIX + "api/openai/users/%s/analytics?start=%s&end=%s", codexUser.getUserId(), start, end);
 		ClaudeCodeResp codexResp = executeCodexGetApi(analyticsUrl);
 
 		return codexResp;

+ 2 - 2
netflix-web/src/main/java/com/cyksj/web/controller/codex/CodexController.java

@@ -72,9 +72,9 @@ public class CodexController {
      * 用户OpenAI图表+明细联动 (Java系统专用接口)
      */
     @GetMapping("/openai/users/analytics")
-    public ClaudeCodeResp getJavaUserAnalytics() {
+    public ClaudeCodeResp getJavaUserAnalytics(String start, String end) {
         long userId = StpUserUtil.getLoginIdAsLong();
-        ClaudeCodeResp analytics = codexService.getJavaUserAnalytics(userId);
+        ClaudeCodeResp analytics = codexService.getJavaUserAnalytics(userId, start, end);
         return analytics;
     }
 }