package com.erp.finance.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.LocalDateTime;

/**
 * 收款记录 - 订单完成后自动生成
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("fin_income_record")
public class IncomeRecord {

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

    /** 收款单号 */
    private String incomeNo;

    /** 关联订单号 */
    private String orderNo;

    /** 平台短ID */
    private String shortId;

    /** 平台 */
    private String platform;

    /** 店铺ID */
    private Long shopId;

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

    /** 收款金额 */
    private BigDecimal amount;

    /** 优惠金额（从订单优惠中分摊） */
    private BigDecimal discountAmount;

    /** 实际到账金额 */
    private BigDecimal actualAmount;

    /** 支付方式 */
    private String paymentMethod;

    /** 支付时间 */
    private LocalDateTime paymentTime;

    /** 支付流水号 */
    private String transactionId;

    /** 收款账户 */
    private String accountNo;

    /** 账户名称 */
    private String accountName;

    /** 状态: pending/confirmed/frozen/cancelled */
    private String status;

    /** 来源: order/manual/recharge */
    private String source;

    /** 来源ID（如订单ID） */
    private Long sourceId;

    /** 备注 */
    private String remark;

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

    /** 创建人 */
    private Long createBy;

    /** 创建时间 */
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /** 更新人 */
    private Long updateBy;

    /** 更新时间 */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /** 逻辑删除 */
    @TableLogic
    private Integer deleted;

    // ============== 常量 ==============
    public static final String STATUS_PENDING = "pending";
    public static final String STATUS_CONFIRMED = "confirmed";
    public static final String STATUS_FROZEN = "frozen";
    public static final String STATUS_CANCELLED = "cancelled";

    public static final String SOURCE_ORDER = "order";
    public static final String SOURCE_MANUAL = "manual";
    public static final String SOURCE_RECHARGE = "recharge";
}
