
package com.tmerclub.cloud.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 stockMqTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.STOCK_UNLOCK_TOPIC_BY_ORDER_ID);
    }


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

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

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

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

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

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

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderReceiptTemplate() {
        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.ORDER_RECEIPT_TOPIC);
    }

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

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate orderRefundTemplate() {
        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.ORDER_REFUND_TOPIC);
    }


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate stockBillLogPurchaseStorageTemplate() {
        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.STOCK_BILL_LOG_PURCHASE_STORAGE_TOPIC);
    }

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

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

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

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

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

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


    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate sendOrderToPurchaseNotifyToShopTemplate() {
        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.SEND_ORDER_TO_PURCHASE_NOTIFY_TO_SHOP_TOPIC);
    }

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

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

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate addPurchaseAmountLogTemplate() {
        return rocketMqAdapter.getTransactionTemplateByTopicName(RocketMqConstant.ADD_PURCHASE_AMOUNT_LOG_TOPIC);
    }
}
