package com.dora.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;

import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.DecimalMax;
import jakarta.validation.constraints.Min;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 管理员收益设置相关DTO
 */
public class AdminRevenueDto {

    @Data
    @Schema(description = "收益设置响应")
    public static class RevenueSettingsResponse {
        @Schema(description = "内容创作者收益配置")
        private ContentCreatorRevenueSettings contentCreatorSettings;

        @Schema(description = "推广等级配置")
        private List<PromotionLevelDetail> promotionLevels;

        @Schema(description = "平台费率设置")
        private PlatformFeeSettings platformFeeSettings;

        @Schema(description = "工作流收益配置")
        private List<WorkflowRevenueLevel> workflowRevenueLevels;

        @Schema(description = "视频收益配置")
        private List<VideoRevenueLevel> videoRevenueLevels;

        @Schema(description = "最后更新时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime lastUpdateTime;

        @Schema(description = "更新人")
        private String updatedBy;
    }

    @Data
    @Schema(description = "内容创作者设置")
    public static class ContentCreatorSettings {
        @Schema(description = "课程内容创作者分成比例（%）")
        private BigDecimal courseCreatorRate;

        @Schema(description = "工作流创作者分成比例（%）")
        private BigDecimal workflowCreatorRate;

        @Schema(description = "视频播放分成比例（%）")
        private BigDecimal videoPlayRate;

        @Schema(description = "内容被购买分成比例（%）")
        private BigDecimal contentPurchaseRate;
    }

    @Data
    @Schema(description = "推广设置")
    public static class PromotionSettings {
        @Schema(description = "一级推广分成比例（%）")
        private BigDecimal level1Rate;

        @Schema(description = "二级推广分成比例（%）")
        private BigDecimal level2Rate;

        @Schema(description = "三级推广分成比例（%）")
        private BigDecimal level3Rate;

        @Schema(description = "推广有效期（天）")
        private Integer promotionValidDays;
    }

    @Data
    @Schema(description = "平台费率设置")
    public static class PlatformFeeSettings {
        @Schema(description = "平台手续费比例（%）")
        private BigDecimal platformFeeRate;

        @Schema(description = "最低提现金额")
        private BigDecimal minWithdrawAmount;

        @Schema(description = "提现手续费比例（%）")
        private BigDecimal withdrawFeeRate;

        @Schema(description = "提现手续费固定金额")
        private BigDecimal withdrawFixedFee;
    }

    @Data
    @Schema(description = "内容创作者收益设置")
    public static class ContentCreatorRevenueSettings {
        @Schema(description = "课程创作者基础分成比例（%）")
        private BigDecimal courseCreatorRate;

        @Schema(description = "工作流创作者基础分成比例（%）")
        private BigDecimal workflowCreatorRate;

        @Schema(description = "视频播放基础分成比例（%）")
        private BigDecimal videoPlayRate;

        @Schema(description = "内容购买分成比例（%）")
        private BigDecimal contentPurchaseRate;

        @Schema(description = "创作者奖励说明")
        private String creatorRewardDescription;
    }

    @Data
    @Schema(description = "推广等级详情")
    public static class PromotionLevelDetail {
        @Schema(description = "推广等级ID")
        private Long id;

        @Schema(description = "等级名称")
        private String levelName;

        @Schema(description = "最小付费粉丝数")
        private Integer minPaidFans;

        @Schema(description = "佣金比例（%）")
        private BigDecimal commissionRate;

        @Schema(description = "等级描述")
        private String description;

        @Schema(description = "创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime createTime;
    }

    @Data
    @Schema(description = "工作流收益等级")
    public static class WorkflowRevenueLevel {
        @Schema(description = "配置键")
        private String configKey;

        @Schema(description = "等级名称")
        private String levelName;

        @Schema(description = "目标复制次数")
        private Integer targetCount;

        @Schema(description = "奖励金额")
        private BigDecimal rewardAmount;

        @Schema(description = "佣金比例（%）")
        private BigDecimal commissionRate;

        @Schema(description = "配置值")
        private BigDecimal configValue;

        @Schema(description = "等级描述")
        private String description;
    }

    @Data
    @Schema(description = "视频收益等级")
    public static class VideoRevenueLevel {
        @Schema(description = "配置键")
        private String configKey;

        @Schema(description = "等级名称")
        private String levelName;

        @Schema(description = "目标观看次数")
        private Integer targetCount;

        @Schema(description = "奖励金额")
        private BigDecimal rewardAmount;

        @Schema(description = "佣金比例（%）")
        private BigDecimal commissionRate;

        @Schema(description = "配置值")
        private BigDecimal configValue;

        @Schema(description = "等级描述")
        private String description;
    }



    @Data
    @Schema(description = "收益统计请求")
    public static class RevenueStatisticsRequest {
        @Schema(description = "统计周期", example = "daily")
        private String period = "daily";

        @Schema(description = "开始日期", example = "2024-01-01")
        private String startDate;

        @Schema(description = "结束日期", example = "2024-01-31")
        private String endDate;

        @Schema(description = "内容类型筛选", example = "course")
        private String contentType = "all";
    }

    @Data
    @Schema(description = "收益统计响应")
    public static class RevenueStatisticsResponse {
        @Schema(description = "总收益统计")
        private TotalRevenueStats totalStats;

        @Schema(description = "创作者收益统计")
        private CreatorRevenueStats creatorStats;

        @Schema(description = "推广收益统计")
        private PromotionRevenueStats promotionStats;

        @Schema(description = "平台收益统计")
        private PlatformRevenueStats platformStats;

        @Schema(description = "按日期统计")
        private List<DailyRevenueStats> dailyStats;
    }

    @Data
    @Schema(description = "总收益统计")
    public static class TotalRevenueStats {
        @Schema(description = "总收益金额")
        private BigDecimal totalRevenue;

        @Schema(description = "今日收益")
        private BigDecimal todayRevenue;

        @Schema(description = "本周收益")
        private BigDecimal weekRevenue;

        @Schema(description = "本月收益")
        private BigDecimal monthRevenue;

        @Schema(description = "收益增长率（%）")
        private BigDecimal growthRate;
    }

    @Data
    @Schema(description = "创作者收益统计")
    public static class CreatorRevenueStats {
        @Schema(description = "创作者总收益")
        private BigDecimal totalCreatorRevenue;

        @Schema(description = "课程收益")
        private BigDecimal courseRevenue;

        @Schema(description = "工作流收益")
        private BigDecimal workflowRevenue;

        @Schema(description = "视频播放收益")
        private BigDecimal videoRevenue;

        @Schema(description = "创作者数量")
        private Long creatorCount;
    }

    @Data
    @Schema(description = "推广收益统计")
    public static class PromotionRevenueStats {
        @Schema(description = "推广总收益")
        private BigDecimal totalPromotionRevenue;

        @Schema(description = "一级推广收益")
        private BigDecimal level1Revenue;

        @Schema(description = "二级推广收益")
        private BigDecimal level2Revenue;

        @Schema(description = "三级推广收益")
        private BigDecimal level3Revenue;

        @Schema(description = "推广人数")
        private Long promoterCount;
    }

    @Data
    @Schema(description = "平台收益统计")
    public static class PlatformRevenueStats {
        @Schema(description = "平台总收益")
        private BigDecimal totalPlatformRevenue;

        @Schema(description = "平台手续费收益")
        private BigDecimal platformFeeRevenue;

        @Schema(description = "提现手续费收益")
        private BigDecimal withdrawFeeRevenue;

        @Schema(description = "已提现金额")
        private BigDecimal withdrawnAmount;

        @Schema(description = "待提现金额")
        private BigDecimal pendingWithdrawAmount;
    }

    @Data
    @Schema(description = "日收益统计")
    public static class DailyRevenueStats {
        @Schema(description = "日期")
        private String date;

        @Schema(description = "总收益")
        private BigDecimal totalRevenue;

        @Schema(description = "创作者收益")
        private BigDecimal creatorRevenue;

        @Schema(description = "推广收益")
        private BigDecimal promotionRevenue;

        @Schema(description = "平台收益")
        private BigDecimal platformRevenue;
    }

    @Data
    @Schema(description = "分成设置响应")
    public static class CommissionSettingsResponse {
        @Schema(description = "推广分成配置")
        private List<PromotionLevelConfig> promotionLevels;

        @Schema(description = "内容分成配置")
        private List<ContentCommissionConfig> contentCommissions;

        @Schema(description = "最后更新时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime lastUpdateTime;
    }

    @Data
    @Schema(description = "推广等级配置")
    public static class PromotionLevelConfig {
        @Schema(description = "等级")
        private Integer level;

        @Schema(description = "等级名称")
        private String levelName;

        @Schema(description = "分成比例（%）")
        private BigDecimal commissionRate;

        @Schema(description = "最低推广人数要求")
        private Integer minPromotedUsers;

        @Schema(description = "最低推广收益要求")
        private BigDecimal minPromotedRevenue;
    }

    @Data
    @Schema(description = "内容分成配置")
    public static class ContentCommissionConfig {
        @Schema(description = "内容类型")
        private String contentType;

        @Schema(description = "内容类型名称")
        private String contentTypeName;

        @Schema(description = "创作者分成比例（%）")
        private BigDecimal creatorRate;

        @Schema(description = "平台分成比例（%）")
        private BigDecimal platformRate;
    }

    @Data
    @Schema(description = "分成设置更新请求")
    public static class CommissionSettingsUpdateRequest {
        @Schema(description = "推广分成配置")
        private List<PromotionLevelConfigUpdate> promotionLevels;

        @Schema(description = "内容分成配置")
        private List<ContentCommissionConfigUpdate> contentCommissions;
    }

    @Data
    @Schema(description = "推广等级配置更新")
    public static class PromotionLevelConfigUpdate {
        @NotNull(message = "等级不能为空")
        @Schema(description = "等级")
        private Integer level;

        @DecimalMin(value = "0.00", message = "分成比例不能小于0")
        @DecimalMax(value = "100.00", message = "分成比例不能大于100")
        @Schema(description = "分成比例（%）")
        private BigDecimal commissionRate;

        @Min(value = 0, message = "最低推广人数不能小于0")
        @Schema(description = "最低推广人数要求")
        private Integer minPromotedUsers;

        @DecimalMin(value = "0.00", message = "最低推广收益不能小于0")
        @Schema(description = "最低推广收益要求")
        private BigDecimal minPromotedRevenue;
    }

    @Data
    @Schema(description = "内容分成配置更新")
    public static class ContentCommissionConfigUpdate {
        @Schema(description = "内容类型")
        private String contentType;

        @DecimalMin(value = "0.00", message = "创作者分成比例不能小于0")
        @DecimalMax(value = "100.00", message = "创作者分成比例不能大于100")
        @Schema(description = "创作者分成比例（%）")
        private BigDecimal creatorRate;

        @DecimalMin(value = "0.00", message = "平台分成比例不能小于0")
        @DecimalMax(value = "100.00", message = "平台分成比例不能大于100")
        @Schema(description = "平台分成比例（%）")
        private BigDecimal platformRate;
    }

    @Data
    @Schema(description = "提现设置响应")
    public static class WithdrawSettingsResponse {
        @Schema(description = "提现基本设置")
        private WithdrawBasicSettings basicSettings;

        @Schema(description = "提现手续费设置")
        private WithdrawFeeSettings feeSettings;

        @Schema(description = "提现限制设置")
        private WithdrawLimitSettings limitSettings;

        @Schema(description = "最后更新时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime lastUpdateTime;
    }

    @Data
    @Schema(description = "提现基本设置")
    public static class WithdrawBasicSettings {
        @Schema(description = "最低提现金额")
        private BigDecimal minAmount;

        @Schema(description = "最高提现金额")
        private BigDecimal maxAmount;

        @Schema(description = "是否开启自动审核")
        private Boolean autoApprove;

        @Schema(description = "自动审核金额上限")
        private BigDecimal autoApproveLimit;
    }

    @Data
    @Schema(description = "提现手续费设置")
    public static class WithdrawFeeSettings {
        @Schema(description = "手续费计算方式（PERCENTAGE/FIXED/BOTH）")
        private String feeType;

        @Schema(description = "手续费比例（%）")
        private BigDecimal feeRate;

        @Schema(description = "固定手续费金额")
        private BigDecimal fixedFee;

        @Schema(description = "最低手续费")
        private BigDecimal minFee;

        @Schema(description = "最高手续费")
        private BigDecimal maxFee;
    }

    @Data
    @Schema(description = "提现限制设置")
    public static class WithdrawLimitSettings {
        @Schema(description = "每日提现次数限制")
        private Integer dailyLimit;

        @Schema(description = "每月提现次数限制")
        private Integer monthlyLimit;

        @Schema(description = "每日提现金额限制")
        private BigDecimal dailyAmountLimit;

        @Schema(description = "每月提现金额限制")
        private BigDecimal monthlyAmountLimit;

        @Schema(description = "提现间隔时间（小时）")
        private Integer withdrawInterval;
    }

    @Data
    @Schema(description = "提现设置更新请求")
    public static class WithdrawSettingsUpdateRequest {
        @Schema(description = "提现基本设置")
        private WithdrawBasicSettingsUpdate basicSettings;

        @Schema(description = "提现手续费设置")
        private WithdrawFeeSettingsUpdate feeSettings;

        @Schema(description = "提现限制设置")
        private WithdrawLimitSettingsUpdate limitSettings;
    }

    @Data
    @Schema(description = "提现基本设置更新")
    public static class WithdrawBasicSettingsUpdate {
        @DecimalMin(value = "0.01", message = "最低提现金额必须大于0")
        @Schema(description = "最低提现金额")
        private BigDecimal minAmount;

        @DecimalMin(value = "0.01", message = "最高提现金额必须大于0")
        @Schema(description = "最高提现金额")
        private BigDecimal maxAmount;

        @Schema(description = "是否开启自动审核")
        private Boolean autoApprove;

        @DecimalMin(value = "0.00", message = "自动审核金额上限不能小于0")
        @Schema(description = "自动审核金额上限")
        private BigDecimal autoApproveLimit;
    }

    @Data
    @Schema(description = "提现手续费设置更新")
    public static class WithdrawFeeSettingsUpdate {
        @Schema(description = "手续费计算方式")
        private String feeType;

        @DecimalMin(value = "0.00", message = "手续费比例不能小于0")
        @DecimalMax(value = "100.00", message = "手续费比例不能大于100")
        @Schema(description = "手续费比例（%）")
        private BigDecimal feeRate;

        @DecimalMin(value = "0.00", message = "固定手续费不能小于0")
        @Schema(description = "固定手续费金额")
        private BigDecimal fixedFee;

        @DecimalMin(value = "0.00", message = "最低手续费不能小于0")
        @Schema(description = "最低手续费")
        private BigDecimal minFee;

        @DecimalMin(value = "0.00", message = "最高手续费不能小于0")
        @Schema(description = "最高手续费")
        private BigDecimal maxFee;
    }

    @Data
    @Schema(description = "提现限制设置更新")
    public static class WithdrawLimitSettingsUpdate {
        @Min(value = 1, message = "每日提现次数限制必须大于0")
        @Schema(description = "每日提现次数限制")
        private Integer dailyLimit;

        @Min(value = 1, message = "每月提现次数限制必须大于0")
        @Schema(description = "每月提现次数限制")
        private Integer monthlyLimit;

        @DecimalMin(value = "0.01", message = "每日提现金额限制必须大于0")
        @Schema(description = "每日提现金额限制")
        private BigDecimal dailyAmountLimit;

        @DecimalMin(value = "0.01", message = "每月提现金额限制必须大于0")
        @Schema(description = "每月提现金额限制")
        private BigDecimal monthlyAmountLimit;

        @Min(value = 1, message = "提现间隔时间必须大于0")
        @Schema(description = "提现间隔时间（小时）")
        private Integer withdrawInterval;
    }

    // ========================= 收益设置更新相关DTO =========================

    @Data
    @Schema(description = "收益设置更新请求")
    public static class RevenueSettingsUpdateRequest {
        @Schema(description = "工作流收益配置")
        private List<WorkflowRevenueConfig> workflowSettings;

        @Schema(description = "视频收益配置")
        private List<VideoRevenueConfig> videoSettings;

        @Schema(description = "推广收益配置")
        private List<PromotionRevenueConfig> promotionSettings;

        @Schema(description = "内容创作者分成设置")
        private ContentCreatorSettingsUpdate contentCreatorSettings;

        @Schema(description = "平台费率设置")
        private PlatformFeeSettingsUpdate platformFeeSettings;
    }

    @Data
    @Schema(description = "工作流收益配置")
    public static class WorkflowRevenueConfig {
        @NotNull(message = "等级不能为空")
        @Schema(description = "等级")
        private Integer level;

        @NotNull(message = "目标复制次数不能为空")
        @Min(value = 1, message = "目标复制次数必须大于0")
        @Schema(description = "目标复制次数")
        private Integer targetCount;

        @NotNull(message = "奖励金额不能为空")
        @DecimalMin(value = "0.01", message = "奖励金额必须大于0")
        @Schema(description = "奖励金额")
        private BigDecimal rewardAmount;

        @Schema(description = "是否启用")
        private Boolean enabled = true;
    }

    @Data
    @Schema(description = "视频收益配置")
    public static class VideoRevenueConfig {
        @NotNull(message = "等级不能为空")
        @Schema(description = "等级")
        private Integer level;

        @NotNull(message = "目标播放次数不能为空")
        @Min(value = 1, message = "目标播放次数必须大于0")
        @Schema(description = "目标播放次数")
        private Integer targetCount;

        @NotNull(message = "奖励金额不能为空")
        @DecimalMin(value = "0.01", message = "奖励金额必须大于0")
        @Schema(description = "奖励金额")
        private BigDecimal rewardAmount;

        @Schema(description = "是否启用")
        private Boolean enabled = true;
    }

    @Data
    @Schema(description = "推广收益配置")
    public static class PromotionRevenueConfig {
        @NotNull(message = "等级不能为空")
        @Schema(description = "等级")
        private Integer level;

        @Schema(description = "等级名称")
        private String levelName;

        @NotNull(message = "最少粉丝数不能为空")
        @Min(value = 0, message = "最少粉丝数不能小于0")
        @Schema(description = "最少粉丝数")
        private Integer minFans;

        @NotNull(message = "提成比例不能为空")
        @DecimalMin(value = "0.00", message = "提成比例不能小于0")
        @DecimalMax(value = "100.00", message = "提成比例不能大于100")
        @Schema(description = "提成比例（%）")
        private BigDecimal commissionRate;

        @Schema(description = "是否启用")
        private Boolean enabled = true;
    }

    @Data
    @Schema(description = "内容创作者分成设置更新")
    public static class ContentCreatorSettingsUpdate {
        @DecimalMin(value = "0.00", message = "课程创作者分成比例不能小于0")
        @DecimalMax(value = "100.00", message = "课程创作者分成比例不能大于100")
        @Schema(description = "课程内容创作者分成比例（%）")
        private BigDecimal courseCreatorRate;

        @DecimalMin(value = "0.00", message = "工作流创作者分成比例不能小于0")
        @DecimalMax(value = "100.00", message = "工作流创作者分成比例不能大于100")
        @Schema(description = "工作流创作者分成比例（%）")
        private BigDecimal workflowCreatorRate;

        @DecimalMin(value = "0.00", message = "视频播放分成比例不能小于0")
        @DecimalMax(value = "100.00", message = "视频播放分成比例不能大于100")
        @Schema(description = "视频播放分成比例（%）")
        private BigDecimal videoPlayRate;

        @DecimalMin(value = "0.00", message = "内容购买分成比例不能小于0")
        @DecimalMax(value = "100.00", message = "内容购买分成比例不能大于100")
        @Schema(description = "内容购买分成比例（%）")
        private BigDecimal contentPurchaseRate;
    }

    @Data
    @Schema(description = "平台费率设置更新")
    public static class PlatformFeeSettingsUpdate {
        @DecimalMin(value = "0.00", message = "平台费率不能小于0")
        @DecimalMax(value = "100.00", message = "平台费率不能大于100")
        @Schema(description = "平台费率（%）")
        private BigDecimal platformFeeRate;

        @DecimalMin(value = "0.01", message = "最低提现金额必须大于0")
        @Schema(description = "最低提现金额")
        private BigDecimal minWithdrawAmount;

        @DecimalMin(value = "0.00", message = "提现手续费率不能小于0")
        @DecimalMax(value = "100.00", message = "提现手续费率不能大于100")
        @Schema(description = "提现手续费率（%）")
        private BigDecimal withdrawFeeRate;

        @DecimalMin(value = "0.00", message = "提现固定手续费不能小于0")
        @Schema(description = "提现固定手续费")
        private BigDecimal withdrawFixedFee;
    }

    // ========================= 简化的更新DTO =========================

    @Data
    @Schema(description = "简化提现设置更新请求")
    public static class SimpleWithdrawSettingsUpdateRequest {
        @DecimalMin(value = "0.01", message = "最低提现金额必须大于0")
        @Schema(description = "最低提现金额")
        private BigDecimal minWithdrawAmount;

        @DecimalMin(value = "0.00", message = "提现手续费率不能小于0")
        @DecimalMax(value = "100.00", message = "提现手续费率不能大于100")
        @Schema(description = "提现手续费率（%）")
        private BigDecimal withdrawFeeRate;

        @Min(value = 1, message = "处理天数不能小于1")
        @Schema(description = "提现处理天数")
        private Integer processingDays;
    }

    @Data
    @Schema(description = "推广等级设置")
    public static class PromotionLevelSetting {
        @NotNull(message = "等级不能为空")
        @Schema(description = "等级")
        private Integer level;

        @Schema(description = "等级名称")
        private String levelName;

        @NotNull(message = "最少粉丝数不能为空")
        @Min(value = 0, message = "最少粉丝数不能小于0")
        @Schema(description = "最少粉丝数")
        private Integer minFans;

        @NotNull(message = "提成比例不能为空")
        @DecimalMin(value = "0.00", message = "提成比例不能小于0")
        @DecimalMax(value = "100.00", message = "提成比例不能大于100")
        @Schema(description = "提成比例（%）")
        private BigDecimal commissionRate;
    }

    // ========================= 热门内容统计DTO =========================

    @Data
    @Schema(description = "热门内容统计请求")
    public static class PopularContentRequest {
        @Schema(description = "开始日期", example = "2024-01-01")
        private String startDate;

        @Schema(description = "结束日期", example = "2024-01-31")
        private String endDate;

        @Min(value = 1, message = "每页大小必须大于0")
        @Schema(description = "每页大小", example = "10")
        private Integer limit = 10;
    }

    @Data
    @Schema(description = "最多使用工作流响应")
    public static class MostUsedWorkflowResponse {
        @Schema(description = "工作流列表")
        private List<WorkflowUsageStats> workflows;

        @Schema(description = "查询时间范围")
        private String dateRange;

        @Schema(description = "总计数据")
        private UsageSummary summary;
    }

    @Data
    @Schema(description = "最多观看视频响应")
    public static class MostViewedVideoResponse {
        @Schema(description = "视频列表")
        private List<VideoViewStats> videos;

        @Schema(description = "查询时间范围")
        private String dateRange;

        @Schema(description = "总计数据")
        private ViewSummary summary;
    }

    @Data
    @Schema(description = "工作流使用统计")
    public static class WorkflowUsageStats {
        @Schema(description = "工作流ID")
        private Long workflowId;

        @Schema(description = "工作流名称")
        private String workflowName;

        @Schema(description = "工作流描述")
        private String description;

        @Schema(description = "创作者名称")
        private String creatorName;

        @Schema(description = "创作者ID")
        private Long creatorId;

        @Schema(description = "封面图片")
        private String coverUrl;

        @Schema(description = "使用次数（不重复用户数）")
        private Integer usageCount;

        @Schema(description = "总下载次数（包括重复）")
        private Integer totalDownloads;

        @Schema(description = "产生收益金额")
        private BigDecimal revenueGenerated;

        @Schema(description = "是否免费")
        private Boolean isFree;

        @Schema(description = "价格")
        private BigDecimal price;

        @Schema(description = "分类")
        private String category;

        @Schema(description = "创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime createTime;

        @Schema(description = "最后使用时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime lastUsedTime;
    }

    @Data
    @Schema(description = "视频观看统计")
    public static class VideoViewStats {
        @Schema(description = "视频ID")
        private Long videoId;

        @Schema(description = "视频标题")
        private String title;

        @Schema(description = "视频描述")
        private String description;

        @Schema(description = "创作者名称")
        private String creatorName;

        @Schema(description = "创作者ID")
        private Long creatorId;

        @Schema(description = "封面图片")
        private String coverUrl;

        @Schema(description = "观看次数")
        private Integer viewCount;

        @Schema(description = "独立观看用户数")
        private Integer uniqueViewerCount;

        @Schema(description = "产生收益金额")
        private BigDecimal revenueGenerated;

        @Schema(description = "视频时长（秒）")
        private Integer duration;

        @Schema(description = "分类")
        private String category;

        @Schema(description = "是否公开")
        private Boolean isPublic;

        @Schema(description = "创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime createTime;

        @Schema(description = "最后观看时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime lastViewTime;
    }

    @Data
    @Schema(description = "使用情况汇总")
    public static class UsageSummary {
        @Schema(description = "总工作流数")
        private Integer totalWorkflows;

        @Schema(description = "总使用次数")
        private Integer totalUsages;

        @Schema(description = "总收益")
        private BigDecimal totalRevenue;

        @Schema(description = "平均每个工作流使用次数")
        private Double avgUsagePerWorkflow;
    }

    @Data
    @Schema(description = "观看情况汇总")
    public static class ViewSummary {
        @Schema(description = "总视频数")
        private Integer totalVideos;

        @Schema(description = "总观看次数")
        private Integer totalViews;

        @Schema(description = "总收益")
        private BigDecimal totalRevenue;

        @Schema(description = "平均每个视频观看次数")
        private Double avgViewsPerVideo;
    }
}
