package org.jeecg.modules.pay.config;

import com.github.binarywang.wxpay.service.WxPayService;
import lombok.extern.java.Log;
import org.jeecg.modules.pay.MpWxPayService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Log
@Configuration
public class WeixinConfig {

    @Resource
    WxPay wxPay;
    @Resource
    WxPayService wxPayService;

    @Bean
    public MpWxPayService mpWxPayService(){
        MpWxPayService mpWxPayService = new MpWxPayService();
        mpWxPayService.wxPay = wxPay;
        mpWxPayService.wxPayService = wxPayService;
        mpWxPayService.dev = true;
        log.info("MpWxPayService is regiterd (" + (mpWxPayService.dev?"dev":"prod") + ") as " + wxPay.mchId);
        return mpWxPayService;
    }
}
