package com.erp.warehouse.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.Builder;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 入库单实体
 * 支持：采购入库、退货入库、调拨入库
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@TableName("inbound_order")
public class InboundOrder {

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

    /** 入库单号 */
    private String inboundNo;

    /** 入库类型: purchase=采购入库, return=退货入库, transfer=调拨入库 */
    private String inboundType;

    /** 仓库ID */
    private Long warehouseId;

    /** 关联单号（采购单号/退货单号/调拨单号） */
    private String relatedNo;

    /** 供应商ID（采购入库时） */
    private Long supplierId;

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

    /** 状态: pending=待入库, partial=部分入库, completed=已完成, cancelled=已取消 */
    private String status;

    /** 备注 */
    private String remark;

    /** 操作人ID */
    private Long operatorId;

    /** 操作人名称 */
    private String operatorName;

    /** 预计到货时间 */
    private LocalDateTime expectedTime;

    /** 实际入库时间 */
    private LocalDateTime inboundTime;

    /** 创建时间 */
    private LocalDateTime createTime;

    /** 更新时间 */
    private LocalDateTime updateTime;

    // ==================== 非数据库字段 ====================

    /** 入库明细（非持久化） */
    private List<InboundOrderItem> items;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Builder
    public static class InboundOrderItem {
        private Long id;
        private String skuCode;
        private String skuName;
        private Integer planQuantity;
        private Integer actualQuantity;
        private Integer acceptedQuantity;
        private Integer defectiveQuantity;
        private String remark;
    }
}
