
package com.tmerclub.cloud.product.listener;

import cn.hutool.core.collection.CollUtil;
import com.tmerclub.cloud.api.product.dto.StockBillLogItemDTO;
import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import com.tmerclub.cloud.product.service.StockBillLogService;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 出入库操作监听
 *
 * @author tmerclub
 */
@Component
@RocketMQMessageListener(topic = RocketMqConstant.STOCK_BILL_LOG_TOPIC, consumerGroup = RocketMqConstant.STOCK_BILL_LOG_TOPIC)
public class StockBillLogConsumer implements RocketMQListener<List<StockBillLogItemDTO>> {

    @Autowired
    private StockBillLogService stockBillLogService;

    /**
     * 入库操作
     */
    @Override
    public void onMessage(List<StockBillLogItemDTO> message) {
        if (CollUtil.isEmpty(message)) {
            return;
        }
        stockBillLogService.generateStockLogOfOrderList(message);
    }
}
