package com.erp.report.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * 采购订单统计实体
 * 对应数据库表：purchase_orders
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("purchase_orders")
public class PurchaseOrderEntity {

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

    private String poNo;
    
    private Long warehouseId;
    
    private Long supplierId;
    
    private Long brandId;
    
    private LocalDate expectedArrival;
    
    private String shippingMethod;
    
    private BigDecimal freight;
    
    private String category;
    
    private BigDecimal totalAmount;
    
    private String status; // draft, under_review, approved, rejected, completed
    
    private String remark;
    
    private String auditComment;
    
    private Boolean pushed;
    
    private String cloudSystem;
    
    private Boolean pushedToCloud;
    
    private LocalDateTime pushedAt;
    
    private String cloudResponse;

    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    @TableLogic
    private LocalDateTime deletedAt;

    /**
     * 获取状态标签
     */
    public String getStatusLabel() {
        return switch (status) {
            case "draft" -> "草稿";
            case "under_review" -> "待审核";
            case "approved" -> "已审核";
            case "rejected" -> "已驳回";
            case "completed" -> "已完成";
            default -> status;
        };
    }
}
