
package com.tmerclub.cloud.distribution.listener;

import com.tmerclub.cloud.common.order.bo.PayNotifyBO;
import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import com.tmerclub.cloud.common.util.Json;
import com.tmerclub.cloud.distribution.service.DistributionOrderService;
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 cl
 * @date 2021-08-17 17:42:17
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.SHOP_WALLET_NOTIFY_SERVICE_TOPIC, consumerGroup = RocketMqConstant.ORDER_NOTIFY_DISTRIBUTION_GROUP)
public class OrderNotifyDistributionConsumer implements RocketMQListener<PayNotifyBO> {

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

    @Autowired
    private DistributionOrderService distributionOrderService;

    /**
     * 订单支付成功, 分销通知
     */
    @Override
    public void onMessage(PayNotifyBO payNotifyBO) {
        LOG.info("订单支付成功，分销分账... message: {}", Json.toJsonString(payNotifyBO));
        distributionOrderService.payNotifyDistributionOrder(payNotifyBO);
    }
}
