
package com.tmerclub.cloud.payment.config;

import com.tmerclub.cloud.common.rocketmq.config.RocketMqAdapter;
import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * @author tmerclub
 * @date 2021/3/30
 */
@RefreshScope
@Configuration
public class RocketMqConfig {

    @Autowired
    private RocketMqAdapter rocketMqAdapter;

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderNotifyTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_NOTIFY_TOPIC);
    }


    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderSettledShopTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_SETTLED_SHOP_TOPIC);
    }


    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate userRechargeNotifyTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.USER_RECHARGE_NOTIFY_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate shopBalancePaySuccessTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SHOP_BALANCE_PAY_SUCCESS_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate shopRechargeNotifyTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SHOP_RECHARGE_NOTIFY_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate buyVipNotifyTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.BUY_VIP_NOTIFY_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderRefundSuccessTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ORDER_REFUND_SUCCESS_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate userScoreTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.SCORE_UNLOCK_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate platformTransferTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.PLATFORM_TRANSFER_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate allinPayBalanceOrderSuccessTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.ALLINPAY_BALANCE_ORDER_SUCCESS_TOPIC);
    }


}
