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_payment_record")
public class PaymentRecord {

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

    /** 付款单号 */
    private String paymentNo;

    /** 关联应付单号 */
    private String apNo;

    /** 关联应付单ID */
    private Long apId;

    /** 关联采购单号 */
    private String purchaseOrderNo;

    /** 供应商ID */
    private Long supplierId;

    /** 供应商名称 */
    private String supplierName;

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

    /** 付款方式: bank_transfer/alipay/wechat/cash/other */
    private String paymentMethod;

    /** 付款账户 */
    private String fromAccount;

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

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

    /** 银行流水号 */
    private String bankFlowNo;

    /** 付款状态: pending/processing/completed/failed */
    private String status;

    /** 付款用途: purchase/purchase_return/expense/other */
    private String purpose;

    /** 关联单据ID */
    private Long relatedId;

    /** 关联单据类型 */
    private String relatedType;

    /** 备注 */
    private String remark;

    /** 操作人 */
    private String operator;

    /** 租户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_PROCESSING = "processing";
    public static final String STATUS_COMPLETED = "completed";
    public static final String STATUS_FAILED = "failed";

    public static final String PURPOSE_PURCHASE = "purchase";
    public static final String PURPOSE_PURCHASE_RETURN = "purchase_return";
    public static final String PURPOSE_EXPENSE = "expense";
}
