package cn.iocoder.yudao.module.bpm.controller.admin.business.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

@Schema(description = "管理后台 - 批量创建餐饮变更 Request VO")
@Data
public class CateringChangeBatchCreateReqVO {

    @Schema(description = "院区/机构 tenantId", requiredMode = Schema.RequiredMode.REQUIRED, example = "209")
    @NotNull(message = "tenantId不能为空")
    private Long tenantId;

    @Schema(description = "机构类型", example = "1")
    private Integer orgType = 1;

    @Schema(description = "变更生效日期", requiredMode = Schema.RequiredMode.REQUIRED, example = "2026-05-09")
    @NotNull(message = "变更生效日期不能为空")
    private LocalDate changeDate;

    @Schema(description = "变更原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "系统统一变更")
    @NotEmpty(message = "变更原因不能为空")
    private String reason;

    @Schema(description = "收费项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "固定费用-餐饮费")
    @NotEmpty(message = "收费项目名称不能为空")
    private String categoryName;

    @Schema(description = "变更文件(JSON字符串)", example = "[]")
    private String changeFiles = "[]";

    @Schema(description = "滞后至月份", example = "2026-01")
    private String hysteresisMonth;

    @Schema(description = "是否跳过重复申请(同长者同日期)", example = "true")
    private Boolean skipRepeat = Boolean.TRUE;

    @Schema(description = "是否沿用长者当前折扣信息", example = "true")
    private Boolean keepDiscount = Boolean.TRUE;

    @Schema(description = "匹配规则与目标餐饮项目列表", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "映射列表不能为空")
    private List<ItemMapping> mappings;

    @Data
    public static class ItemMapping {

        @Schema(description = "匹配的原费用项目id(优先使用)", example = "1803357950676461384")
        private Long originalOverheadChargeId;

        @Schema(description = "匹配的原费用项目名称(当 originalOverheadChargeId 为空时使用)", example = "普通食谱")
        private String originalName;

        @Schema(description = "匹配的原费用实际金额(当 originalOverheadChargeId 为空时使用)", example = "750")
        private BigDecimal originalActualAmount;

        @Schema(description = "新费用项目id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1803357950676463024")
        @NotNull(message = "新费用项目id不能为空")
        private Long expectOverheadChargeId;

        @Schema(description = "新费用项目名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "普通食谱")
        @NotEmpty(message = "新费用项目名称不能为空")
        private String expectName;

        @Schema(description = "新费用金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "900")
        @NotNull(message = "新费用金额不能为空")
        private BigDecimal amount;

        @Schema(description = "新费用实际金额(不传则按折扣规则自动计算)", example = "900")
        private BigDecimal actualAmount;
    }
}
