package com.ruoyi.web.modules.pay.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 微信支付平台配置（application.yml · wechat.pay）
 */
@Component
@ConfigurationProperties(prefix = "wechat.pay")
public class WeChatPayProperties
{
    /** 是否启用真实微信下单（false 时走 Mock 直付） */
    private boolean enabled = false;

    /** Mock 模式：pay 接口直接完成支付（兼容 v1 前端） */
    private boolean mock = true;

    private String appId;

    private String mchId;

    private String apiV3Key;

    private String merchantSerialNo;

    /** apiclient_key.pem 路径，支持 classpath: 或绝对路径 */
    private String privateKeyPath;

    /** 支付结果回调 URL（须公网 HTTPS） */
    private String notifyUrl;

    /** 微信平台公钥 PEM（验签回调；可从商户平台下载 platform cert） */
    private String platformPublicKeyPath;

    /** 回调验签开关（生产建议 true） */
    private boolean notifyVerifyEnabled = true;

    /** 回调时间戳容差（秒） */
    private int notifyTimestampToleranceSeconds = 300;

    public boolean isEnabled()
    {
        return enabled;
    }

    public void setEnabled(boolean enabled)
    {
        this.enabled = enabled;
    }

    public boolean isMock()
    {
        return mock;
    }

    public void setMock(boolean mock)
    {
        this.mock = mock;
    }

    public String getAppId()
    {
        return appId;
    }

    public void setAppId(String appId)
    {
        this.appId = appId;
    }

    public String getMchId()
    {
        return mchId;
    }

    public void setMchId(String mchId)
    {
        this.mchId = mchId;
    }

    public String getApiV3Key()
    {
        return apiV3Key;
    }

    public void setApiV3Key(String apiV3Key)
    {
        this.apiV3Key = apiV3Key;
    }

    public String getMerchantSerialNo()
    {
        return merchantSerialNo;
    }

    public void setMerchantSerialNo(String merchantSerialNo)
    {
        this.merchantSerialNo = merchantSerialNo;
    }

    public String getPrivateKeyPath()
    {
        return privateKeyPath;
    }

    public void setPrivateKeyPath(String privateKeyPath)
    {
        this.privateKeyPath = privateKeyPath;
    }

    public String getNotifyUrl()
    {
        return notifyUrl;
    }

    public void setNotifyUrl(String notifyUrl)
    {
        this.notifyUrl = notifyUrl;
    }

    public String getPlatformPublicKeyPath()
    {
        return platformPublicKeyPath;
    }

    public void setPlatformPublicKeyPath(String platformPublicKeyPath)
    {
        this.platformPublicKeyPath = platformPublicKeyPath;
    }

    public boolean isNotifyVerifyEnabled()
    {
        return notifyVerifyEnabled;
    }

    public void setNotifyVerifyEnabled(boolean notifyVerifyEnabled)
    {
        this.notifyVerifyEnabled = notifyVerifyEnabled;
    }

    public int getNotifyTimestampToleranceSeconds()
    {
        return notifyTimestampToleranceSeconds;
    }

    public void setNotifyTimestampToleranceSeconds(int notifyTimestampToleranceSeconds)
    {
        this.notifyTimestampToleranceSeconds = notifyTimestampToleranceSeconds;
    }

    public boolean isRealPayEnabled()
    {
        return enabled && !mock;
    }
}
