zoujiajian 1 год назад
Родитель
Сommit
bfd8ea96f4

+ 2 - 0
netflix-service/src/main/java/com/cyksj/service/claude/ClaudeCodeService.java

@@ -48,4 +48,6 @@ public interface ClaudeCodeService {
 	ClaudeCodeUserPackageView getUserPackage(long userId) throws Exception;
 
 	ClaudeCodePointsHistoryResp getUserPointsDetail(Long userId, String type, Integer page, Integer limit) throws Exception;
+
+	void getUserPointsStatisticsData(long userId) throws Exception;
 }

+ 8 - 4
netflix-service/src/main/java/com/cyksj/service/claude/impl/ClaudeCodeServiceImpl.java

@@ -110,11 +110,15 @@ public class ClaudeCodeServiceImpl implements ClaudeCodeService {
 	public ClaudeCodePointsHistoryResp getUserPointsDetail(Long userId, String type, Integer page, Integer limit) throws Exception {
 		String url = String.format(CLAUDE_CODE_API_PREFIX + "api/users/{userId}/credits/history?page=%s&limit=%s&type=%s", userId, page, limit, type);
 		String responseBody = executeClaudeCodeGetApi(url);
+		ClaudeCodePointsHistoryResp historyResp = Jsons.parseObject(responseBody, ClaudeCodePointsHistoryResp.class);
+		return historyResp;
+	}
+
+	@Override
+	public void getUserPointsStatisticsData(long userId) throws Exception {
+		String url = String.format(CLAUDE_CODE_API_PREFIX + "api/users/%s/usage/stats", userId);
+		String responseBody = executeClaudeCodeGetApi(url);
 		ClaudeCodeResp claudeCodeResp = Jsons.parseObject(responseBody, ClaudeCodeResp.class);
-		if (claudeCodeResp.getSuccess()) {
-			return Jsons.parseObject(responseBody, ClaudeCodePointsHistoryResp.class);
-		}
-		return null;
 	}
 
 	public void createOrUpdateClaudeCodeUserPackage(Long userId, String planName, Integer codePoints, Integer codeCreditRecovery, Date expiryTime) throws Exception {

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/claude/ClaudeCodeController.java

@@ -96,7 +96,7 @@ public class ClaudeCodeController {
 	 * 用户使用数据统计
 	 */
 	@GetMapping("/get/user/points/statistics/data")
-	public Result<String> getUserPointsStatisticsData() {
+	public Result<String> getUserPointsStatisticsData() throws Exception {
 		long userId = StpUserUtil.getLoginIdAsLong();
 		claudeCodeService.getUserPointsStatisticsData(userId);
 		return GatewayResponse.SUCCESS.newBuilder().toResult();