
package com.tmerclub.cloud.product.listener;

import com.tmerclub.cloud.common.rocketmq.config.RocketMqConstant;
import com.tmerclub.cloud.product.service.SkuStockLockService;
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_UNLOCK_TOPIC_BY_ORDER_ID, consumerGroup = RocketMqConstant.STOCK_UNLOCK_TOPIC_BY_ORDER_ID)
public class StockUnlockConsumer implements RocketMQListener<List<Long>> {

    @Autowired
    private SkuStockLockService skuStockLockService;

    /**
     * 取消订单，直接解锁库存
     */
    @Override
    public void onMessage(List<Long> orderIds) {
        skuStockLockService.unlockStockByCancel(orderIds);
    }
}
