package com.red.circle.other.infra.database.mongo.entity.bd;

import com.red.circle.other.infra.enums.BdSettlementStatus;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;

/**
 * 管理员工资结算记录.
 *
 * @author AI Assistant
 * @since 2025-12-13
 */
@Data
@Accessors(chain = true)
@Document("admin_salary_settlement_record")
public class AdminSalarySettlementRecord implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * ID.
     */
    @Id
    private String id;

    /**
     * 时间ID（用于排序）.
     */
    private Long timeId;

    /**
     * 系统来源.
     */
    private String sysOrigin;

    /**
     * 管理员用户 ID.
     */
    @Indexed
    private Long adminUserId;

    /**
     * 账期（yyyyMMdd 格式，如 20250101）.
     */
    @Indexed
    private Integer billBelong;

    /**
     * 账期标题（如 "2025-01-01 ~ 2025-01-15"）.
     */
    private String billTitle;

    /**
     * 业务号（幂等性保证）.
     */
    @Indexed(unique = true)
    private String bizNo;

    // ==================== RECHARGE_AGENT 政策数据 ====================

    /**
     * 充值代理充值金额（美元）.
     */
    private BigDecimal rechargeAgentAmount;

    /**
     * RECHARGE_AGENT 政策计算工资.
     */
    private BigDecimal rechargeAgentSalary;

    /**
     * RECHARGE_AGENT 命中的百分比.
     */
    private BigDecimal rechargeAgentPercentage;

    // ==================== BD_LEADER 政策数据 ====================

    /**
     * BD Leader 团队工资总和（美元）.
     */
    private BigDecimal bdLeaderTeamSalary;

    /**
     * BD Leader 政策计算工资.
     */
    private BigDecimal bdLeaderSalary;

    /**
     * BD Leader 命中的等级.
     */
    private Integer bdLeaderHitLevel;

    /**
     * BD Leader Basic Salary.
     */
    private BigDecimal bdLeaderBasicSalary;

    /**
     * BD Leader Reward Amount.
     */
    private BigDecimal bdLeaderRewardAmount;

    // ==================== BD_TEAM_SALARY 政策数据 ====================

    /**
     * BD 团队工资总和（美元）.
     */
    private BigDecimal bdTeamSalaryAmount;

    /**
     * BD_TEAM_SALARY 政策计算工资.
     */
    private BigDecimal bdTeamSalarySalary;

    /**
     * BD_TEAM_SALARY 命中的等级.
     */
    private Integer bdTeamSalaryHitLevel;

    /**
     * BD_TEAM_SALARY 提成比例.
     */
    private BigDecimal bdTeamSalaryCommissionRate;

    // ==================== BD_TEAM_RECHARGE 政策数据 ====================

    /**
     * BD 团队充值总和（美元）.
     */
    private BigDecimal bdTeamRechargeAmount;

    /**
     * BD_TEAM_RECHARGE 政策计算工资.
     */
    private BigDecimal bdTeamRechargeSalary;

    /**
     * BD_TEAM_RECHARGE 命中的等级.
     */
    private Integer bdTeamRechargeHitLevel;

    /**
     * BD_TEAM_RECHARGE 提成比例.
     */
    private BigDecimal bdTeamRechargeCommissionRate;

    // ==================== 最终结算结果 ====================

    /**
     * BD 政策最终工资（max(BD_TEAM_SALARY, BD_TEAM_RECHARGE)）.
     */
    private BigDecimal bdPolicyFinalSalary;

    /**
     * 命中的 BD 政策类型.
     */
    private String bdPolicyHitType;

    /**
     * 管理员总工资.
     */
    private BigDecimal totalSalary;

    /**
     * 结算状态.
     */
    private BdSettlementStatus status;

    /**
     * 失败原因.
     */
    private String failureReason;

    /**
     * 创建时间.
     */
    private Timestamp createTime;

    /**
     * 更新时间.
     */
    private Timestamp updateTime;
}
