package com.starry.admin.common.play.wx;

import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

@Data
@Configuration
@ConfigurationProperties(prefix = "wx.play")
@PropertySource(value = {"classpath:play.properties"})
public class WxPlayProperties implements InitializingBean {

    /**
     * 设置微信公众号或者小程序等的appid
     */
    private String appId;
    /**
     * 微信支付商户号
     */
    private String mchId;

    /**
     * 证书相对路径
     */
    private String privateKeyPath;

    /**
     * 证书相对路径
     */
    private String privateCertPath;

    /**
     * 下单回调地址
     */
    private String returnUrl;

    /**
     * 退款回调地址
     */
    private String refundUrl;


    /**
     * apiV3key
     */
    private String apiV3key;


    public static String APP_ID = "";
    public static String MCH_ID = "";
    public static String PRIVATE_KEY_PATH = "";
    public static String PRIVATE_CERT_PATH = "";
    public static String RETURN_URL = "";
    public static String REFUND_URL = "";
    public static String API_V3KEY = "";

    @Override
    public void afterPropertiesSet() {
        APP_ID = getAppId();
        MCH_ID = getMchId();
        PRIVATE_KEY_PATH = getPrivateKeyPath();
        PRIVATE_CERT_PATH = getPrivateCertPath();
        RETURN_URL = getReturnUrl();
        REFUND_URL = getRefundUrl();
        API_V3KEY = getApiV3key();
    }
}
