package shop.alien.config.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component;

@Data
@Component
@RefreshScope
@ConfigurationProperties(prefix = "risk-control")
public class RiskControlProperties {

    /**
     * 洗钱嫌疑规则配置
     */
    private MoneyLaundering moneyLaundering = new MoneyLaundering();

    /**
     * 账号异常规则配置
     */
    private AccountAbnormal accountAbnormal = new AccountAbnormal();

    /**
     * 交易欺诈规则配置
     */
    private TradeFraud tradeFraud = new TradeFraud();

    /**
     * 异常发布规则配置
     */
    private AbnormalPublish abnormalPublish = new AbnormalPublish();

    @Data
    public static class MoneyLaundering {
        /**
         * 每天交易次数阈值
         */
        private int dailyCount = 5;

        /**
         * 每笔交易金额阈值(元)
         */
        private double amountThreshold = 200.0;

        /**
         * 风险类型
         */
        private String riskType = "洗钱嫌疑";

        /**
         * 检测指标
         */
        private String detectIndicator = "高频高价交易";
    }

    @Data
    public static class AccountAbnormal {
        /**
         * 24小时内同一设备/mac注册账号数量阈值
         */
        private int regCount24h = 3;

        /**
         * 风险类型
         */
        private String riskType = "账号异常";

        /**
         * 检测指标
         */
        private String detectIndicator = "同一设备24小时内注册超过3个账号";
    }

    @Data
    public static class TradeFraud {
        /**
         * 24小时内发布成功记录次数阈值
         */
        private int publishCount24h = 3;

        /**
         * 时间窗口（小时）
         */
        private int timeWindowHours = 24;

        /**
         * 风险类型
         */
        private String riskType = "交易欺诈";

        /**
         * 检测指标
         */
        private String detectIndicator = "用户频繁修改商品";
    }

    @Data
    public static class AbnormalPublish {
        /**
         * 24小时内发布同类商品数量阈值
         */
        private int sameCategoryCount24h = 10;
        
        /**
         * 时间窗口（小时）
         */
        private int timeWindowHours = 24;

        /**
         * 风险类型
         */
        private String riskType = "异常发布";

        /**
         * 检测指标
         */
        private String detectIndicator = "短时间大量发布同类商品";
    }
}