package com.kmall.common.service.pay.global;

import com.kmall.common.service.pay.wxpay.CommonWxPayProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @author Scott Chen
 * @since 1.0
 * 2018-09-27
 */
@Component
public class CommonWxGlobalPayPropertiesBuilder {
    private static final Logger logger = LoggerFactory.getLogger(CommonWxGlobalPayPropertiesBuilder.class);

    @Autowired
    @Qualifier("commonWxGlobalPayProperties")
    private CommonWxGlobalPayProperties commonWxGlobalPayProperties;

    private static CommonWxGlobalPayProperties wxPayProp;

    /**
     * Bean 向静态变量赋值
     */
    @PostConstruct
    private void init(){
        logger.info("CommonWxPayProperties初始化开始......");
        wxPayProp = commonWxGlobalPayProperties;
    }

    public static CommonWxGlobalPayProperties instance(){
        logger.info("CommonWxPayProperties实例返回");
        return wxPayProp;
    }

}
