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_period")
public class SettlementPeriod {

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

    /** 结算周期编号 */
    private String periodNo;

    /** 周期类型: weekly-周结, monthly-月结, daily-日结 */
    private String periodType;

    /** 周期开始日期 */
    private LocalDate startDate;

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

    /** 周期状态: open-开放, closed-已关闭, settled-已结算 */
    private String periodStatus;

    /** 周期内订单数 */
    private Integer orderCount;

    /** 周期内订单总金额 */
    private BigDecimal totalOrderAmount;

    /** 周期内结算金额 */
    private BigDecimal totalSettlementAmount;

    /** 周期内平台佣金 */
    private BigDecimal totalPlatformFee;

    /** 结算完成时间 */
    private LocalDateTime settlementTime;

    /** 结算确认人ID */
    private Long settleOperatorId;

    /** 结算确认人名称 */
    private String settleOperatorName;

    /** 备注 */
    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_WEEKLY = "weekly";
    public static final String TYPE_MONTHLY = "monthly";
    public static final String TYPE_DAILY = "daily";

    /** 周期状态常量 */
    public static final String STATUS_OPEN = "open";
    public static final String STATUS_CLOSED = "closed";
    public static final String STATUS_SETTLED = "settled";
}
