zoujiajian 1 سال پیش
والد
کامیت
0a37a6b876

+ 12 - 7
netflix-dao/src/main/java/com/cyksj/model/response/ClaudeCodePointsHistoryResp.java

@@ -1,5 +1,6 @@
 package com.cyksj.model.response;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -9,20 +10,24 @@ import java.util.List;
 @Getter
 @Setter
 public class ClaudeCodePointsHistoryResp {
-	/**
-	 * 每页数量
-	 */
-	private Long limit;
+
+	private List<Record> items;
+
 	/**
 	 * 当前页
 	 */
-	private Long page;
+	private Integer page;
+
+	@JsonProperty("page_size")
+	private Integer pageSize;
 
-	private List<Record> records;
 	/**
 	 * 总记录数
 	 */
-	private Long total;
+	private Integer total;
+
+	@JsonProperty("total_pages")
+	private Integer totalPages;
 
 	@Getter
 	@Setter

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

@@ -52,13 +52,13 @@ public interface ClaudeCodeService {
 
 	ClaudeCodePointsHistoryResp getUserPointsDetail(Long userId, String type, Integer page, Integer limit) throws Exception;
 
-	ClaudeCodeResp getUserPointsStatisticsData(Long userId) throws Exception;
+	ClaudeCodeResp getUserPointsStatisticsData(Long userId, Integer days) throws Exception;
 
 	ClaudeCodeResp getUserDashboard(Long userId) throws Exception;
 
 	ClaudeCodeResp getUserBalance(Long userId) throws Exception;
 
-	ClaudeCodeResp getCreditsAnalytics(Long userId, String start, String end, String tz, String page, String limit, String order, String type) throws Exception;
+	ClaudeCodeResp getCreditsAnalytics(Long userId, String start, String end, String tz, Integer page, Integer limit, String order, String type) throws Exception;
 
 	void invalidateUserCache(Long relationUserId);
 

+ 11 - 5
netflix-service/src/main/java/com/cyksj/service/claude/impl/ClaudeCodeServiceImpl.java

@@ -243,17 +243,18 @@ public class ClaudeCodeServiceImpl implements ClaudeCodeService {
 		if (claudeCodeUserId != null) {
 			String url = String.format(CLAUDE_CODE_API_PREFIX + "api/users/%s/credits/history?page=%s&limit=%s&type=%s", claudeCodeUserId, page, limit, type);
 			String responseBody = executeClaudeCodeGetApi(url);
-			ClaudeCodePointsHistoryResp historyResp = Jsons.parseObject(responseBody, ClaudeCodePointsHistoryResp.class);
+			ClaudeCodeResp claudeCodeResp = Jsons.parseObject(responseBody, ClaudeCodeResp.class);
+			ClaudeCodePointsHistoryResp historyResp = Jsons.parseObject(claudeCodeResp.getData(), ClaudeCodePointsHistoryResp.class);
 			return historyResp;
 		}
 		return null;
 	}
 
 	@Override
-	public ClaudeCodeResp getUserPointsStatisticsData(Long userId) throws Exception {
+	public ClaudeCodeResp getUserPointsStatisticsData(Long userId, Integer days) throws Exception {
 		Long claudeCodeUserId = getClaudeCodeUserId(userId);
 		if (claudeCodeUserId != null) {
-			String url = String.format(CLAUDE_CODE_API_PREFIX + "api/users/%s/usage/stats", claudeCodeUserId);
+			String url = String.format(CLAUDE_CODE_API_PREFIX + "api/users/%s/usage/stats?days=%s", claudeCodeUserId, days);
 			String responseBody = executeClaudeCodeGetApi(url);
 			ClaudeCodeResp claudeCodeResp = Jsons.parseObject(responseBody, ClaudeCodeResp.class);
 			return claudeCodeResp;
@@ -286,10 +287,15 @@ public class ClaudeCodeServiceImpl implements ClaudeCodeService {
 	}
 
 	@Override
-	public ClaudeCodeResp getCreditsAnalytics(Long userId, String start, String end, String tz, String page, String limit, String order, String type) throws Exception {
+	public ClaudeCodeResp getCreditsAnalytics(Long userId, String start, String end, String tz, Integer page, Integer limit, String order, String type) throws Exception {
 		Long claudeCodeUserId = getClaudeCodeUserId(userId);
+		if (start == null) {
+			DateTime now = DateTime.now();
+			start = DateUtil.offsetDay(now, -1).toString();
+			end = now.toString();
+		}
 		if (claudeCodeUserId != null) {
-			String url = String.format(CLAUDE_CODE_API_PREFIX + "api/users/%s/credits/analytics", claudeCodeUserId);
+			String url = String.format(CLAUDE_CODE_API_PREFIX + "api/users/%s/credits/analytics?start=%s&end=%s&tz=%s&page=%s&limit=%s&order=%s&type=%s", claudeCodeUserId, start, end, tz, page, limit, order, type);
 			String responseBody = executeClaudeCodeGetApi(url);
 			ClaudeCodeResp claudeCodeResp = Jsons.parseObject(responseBody, ClaudeCodeResp.class);
 			return claudeCodeResp;

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

@@ -109,7 +109,7 @@ public class ClaudeCodeController {
 	 * - `type` (string, optional): 积分类型过滤
 	 */
 	@GetMapping("/get/user/points/detail")
-	public Result<ClaudeCodePointsHistoryResp> getUserPointsDetail(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "10") Integer limit, String type) throws Exception {
+	public Result<ClaudeCodePointsHistoryResp> getUserPointsDetail(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit, String type) throws Exception {
 		long userId = StpUserUtil.getLoginIdAsLong();
 		ClaudeCodePointsHistoryResp resp = claudeCodeService.getUserPointsDetail(userId, type, page, limit);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(resp);
@@ -119,9 +119,9 @@ public class ClaudeCodeController {
 	 * 用户使用数据统计
 	 */
 	@GetMapping("/get/user/points/statistics/data")
-	public Result<ClaudeCodeResp> getUserPointsStatisticsData() throws Exception {
+	public Result<ClaudeCodeResp> getUserPointsStatisticsData(@RequestParam(defaultValue = "30") Integer days) throws Exception {
 		long userId = StpUserUtil.getLoginIdAsLong();
-		ClaudeCodeResp resp = claudeCodeService.getUserPointsStatisticsData(userId);
+		ClaudeCodeResp resp = claudeCodeService.getUserPointsStatisticsData(userId, days);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(resp);
 	}
 
@@ -159,7 +159,7 @@ public class ClaudeCodeController {
 	 * - `type` (string, optional): 明细类型过滤,`consume|purchase|recovery|refund|reward|adjustment|all`,默认 `all`
 	 */
 	@GetMapping("/get/credits/analytics")
-	public Result<ClaudeCodeResp> getCreditsAnalytics(String start, String end, String tz, String page, String limit, String order, String type) throws Exception {
+	public Result<ClaudeCodeResp> getCreditsAnalytics(String start, String end, @RequestParam(defaultValue = "Asia/Shanghai") String tz, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer limit, String order, String type) throws Exception {
 		long userId = StpUserUtil.getLoginIdAsLong();
 		ClaudeCodeResp resp = claudeCodeService.getCreditsAnalytics(userId, start, end, tz, page, limit, order, type);
 		return GatewayResponse.SUCCESS.newBuilder().toResult(resp);