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

/**
 * 订单对账记录实体
 * 记录每笔订单的对账核对结果
 * 
 * @author ERP Migration
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("order_reconciliation_record")
public class OrderReconciliationRecord {

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

    /** 对账单ID */
    private Long billId;

    /** 对账单号 */
    private String billNo;

    /** 平台订单号 */
    private String platformOrderSn;

    /** 内部订单ID */
    private Long orderId;

    /** 内部订单号 */
    private String orderShortId;

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

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

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

    /** 平台订单金额 */
    private BigDecimal platformOrderAmount;

    /** 内部订单金额 */
    private BigDecimal internalOrderAmount;

    /** 差异金额 */
    private BigDecimal differenceAmount;

    /** 核对状态: matched-已匹配, unmatched-未匹配, difference-有差异, missing-缺失 */
    private String checkStatus;

    /** 核对详情（JSON格式存储详细核对结果） */
    private String checkDetails;

    /** 核对时间 */
    private LocalDateTime checkTime;

    /** 备注 */
    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 STATUS_MATCHED = "matched";
    
    /** 未匹配 */
    public static final String STATUS_UNMATCHED = "unmatched";
    
    /** 有差异 */
    public static final String STATUS_DIFFERENCE = "difference";
    
    /** 缺失 */
    public static final String STATUS_MISSING = "missing";
}
