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

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

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 定额费率动态取值规则请求 VO
 */
@Schema(description = "管理后台 - 定额费率动态取值规则请求")
@Data
public class QuotaRateValueRulesReqVO {

    @Schema(description = "费率项ID", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "费率项ID不能为空")
    private Long rateItemId;

    @Schema(description = "阶梯规则列表")
    private List<TierRule> tiers;

    @Schema(description = "增量规则列表")
    private List<IncrementRule> increments;

    /**
     * 阶梯规则
     */
    @Data
    public static class TierRule {
        @Schema(description = "序号")
        private Integer seq;

        @Schema(description = "基数阈值", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull(message = "基数阈值不能为空")
        private BigDecimal threshold;

        @Schema(description = "比较方式：lte-小于等于，lt-小于，gte-大于等于，gt-大于", example = "lte")
        private String compareType;

        @Schema(description = "字段值映射，key为字段索引，value为字段值")
        private Map<String, BigDecimal> fieldValues;
    }

    /**
     * 增量规则
     */
    @Data
    public static class IncrementRule {
        @Schema(description = "序号")
        private Integer seq;

        @Schema(description = "步长（每增加多少）", requiredMode = Schema.RequiredMode.REQUIRED)
        @NotNull(message = "步长不能为空")
        private BigDecimal step;

        @Schema(description = "基础阈值（从哪个阈值开始计算增量）")
        private BigDecimal baseThreshold;

        @Schema(description = "字段增量映射，key为字段索引，value为增量值")
        private Map<String, BigDecimal> fieldIncrements;
    }
}
