package com.erp.order.settlement.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 结算报表实体
 * 按店铺、平台、周期等维度的结算汇总报表
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("settlement_report")
public class SettlementReport {

    @TableId(type = IdType.AUTO)
    private Long id;

    /** 报表编号 */
    private String reportNo;

    /** 报表类型: shop-店铺维度, platform-平台维度, period-周期维度 */
    private String reportType;

    /** 关联店铺ID（店铺维度时） */
    private Long shopId;

    /** 店铺名称 */
    private String shopName;

    /** 平台编码 */
    private String platform;

    /** 结算周期ID */
    private Long settlementPeriodId;

    /** 报表日期 */
    private LocalDate reportDate;

    /** 起始日期 */
    private LocalDate startDate;

    /** 结束日期 */
    private LocalDate endDate;

    /** 订单数量 */
    private Integer orderCount;

    /** 订单总金额 */
    private BigDecimal totalOrderAmount;

    /** 优惠总金额 */
    private BigDecimal totalDiscountAmount;

    /** 运费总金额 */
    private BigDecimal totalFreight;

    /** 平台佣金 */
    private BigDecimal platformFee;

    /** 实际结算金额 */
    private BigDecimal settlementAmount;

    /** 已结算金额 */
    private BigDecimal settledAmount;

    /** 待结算金额 */
    private BigDecimal pendingSettlementAmount;

    /** 已冻结金额 */
    private BigDecimal frozenAmount;

    /** 报表状态: generating-生成中, generated-已生成, confirmed-已确认 */
    private String reportStatus;

    /** 生成时间 */
    private LocalDateTime generatedAt;

    /** 确认时间 */
    private LocalDateTime confirmedAt;

    /** 确认人ID */
    private Long confirmedBy;

    /** 备注 */
    private String remark;

    /** 租户ID */
    private Long tenantId;

    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    @TableLogic
    private LocalDateTime deletedAt;

    /** 报表类型常量 */
    public static final String TYPE_SHOP = "shop";
    public static final String TYPE_PLATFORM = "platform";
    public static final String TYPE_PERIOD = "period";

    /** 报表状态常量 */
    public static final String STATUS_GENERATING = "generating";
    public static final String STATUS_GENERATED = "generated";
    public static final String STATUS_CONFIRMED = "confirmed";
}
