
package com.tmerclub.cloud.multishop.listener;

import com.tmerclub.cloud.api.user.bo.RechargeNotifyBO;
import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import com.tmerclub.cloud.common.util.Json;
import com.tmerclub.cloud.multishop.service.ShopWalletService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 余额充值回调
 *
 * @author chiley
 * @date 2022/07/01
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.SHOP_RECHARGE_NOTIFY_TOPIC, consumerGroup = RocketMqConstant.SHOP_RECHARGE_NOTIFY_TOPIC)
public class RechargeNotifyConsumer implements RocketMQListener<RechargeNotifyBO> {

    @Autowired
    private ShopWalletService shopWalletService;

    private static final Logger LOG = LoggerFactory.getLogger(RechargeNotifyConsumer.class);

    @Override
    public void onMessage(RechargeNotifyBO message) {
        LOG.info("商家余额充值回调开始... message: {}", Json.toJsonString(message));
        shopWalletService.rechargeSuccess(message);
    }
}
