package com.yhy.module.core.controller.admin.resource.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.yhy.module.core.dal.typehandler.PostgreSQLJsonbTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Map;
import lombok.Data;

@Schema(description = "管理后台 - 复合工料机 Response VO")
@Data
public class ResourceMergedRespVO {

    @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long id;

    @Schema(description = "复合工料机ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
    private Long mergedId;

    @Schema(description = "数据源ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "101")
    private Long sourceId;

    @Schema(description = "地区编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "GD")
    private String regionCode;

    @Schema(description = "定额消耗量", example = "1.0")
    private BigDecimal quotaConsumption;

    @Schema(description = "除税市场价", example = "52.00")
    private BigDecimal taxExclMarketPrice;

    @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
    private LocalDateTime createTime;

    // ========== 第四层工料机信息（JOIN 查询） ==========

    @Schema(description = "编码（来自catalog_item）", example = "0001")
    private String code;

    @Schema(description = "名称（来自catalog_item）", example = "综合人工")
    private String name;

    @Schema(description = "目录树节点ID（来自resource_item）", example = "1001")
    private Long catalogItemId;

    @Schema(description = "型号规格（来自resource_item）", example = "技术要求高的工种")
    private String spec;

    @Schema(description = "类别ID（来自resource_item）", example = "1")
    private Long categoryId;

    @Schema(description = "类别名称（来自resource_category）", example = "人工费")
    private String categoryName;

    @Schema(description = "单位（来自catalog_item）", example = "工日")
    private String unit;

    @Schema(description = "税率（来自resource_item）", example = "0.09")
    private BigDecimal taxRate;

    @Schema(description = "除税基价（来自resource_item）", example = "50.00")
    private BigDecimal taxExclBasePrice;

    @Schema(description = "含税基价（来自resource_item）", example = "54.50")
    private BigDecimal taxInclBasePrice;

    @Schema(description = "除税编制价（来自resource_item）", example = "55.00")
    private BigDecimal taxExclCompilePrice;

    @Schema(description = "含税编制价（来自resource_item）", example = "59.95")
    private BigDecimal taxInclCompilePrice;

    @Schema(description = "计算基数（来自resource_item）")
    @TableField(typeHandler = PostgreSQLJsonbTypeHandler.class)
    private Map<String, Object> calcBase;

    // ========== 虚拟字段（计算合价） ==========

    @Schema(description = "除税基价合价（虚拟字段）", example = "50.00")
    private BigDecimal taxExclBaseTotal;

    @Schema(description = "含税基价合价（虚拟字段）", example = "54.50")
    private BigDecimal taxInclBaseTotal;

    @Schema(description = "除税编制价合价（虚拟字段）", example = "55.00")
    private BigDecimal taxExclCompileTotal;

    @Schema(description = "含税编制价合价（虚拟字段）", example = "59.95")
    private BigDecimal taxInclCompileTotal;
}
