package com.buy507.mall.component;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.buy507.mall.service.OmsOrderService;

/**
 * 自动确认收货消息的处理者
 */
@Component
@RabbitListener(queues = "mall.receiving.confirm")
public class AutoConfirmReceivingReceiver {
	
    private static Logger LOGGER = LoggerFactory.getLogger(AutoConfirmReceivingReceiver.class);
    
    @Autowired
    private OmsOrderService orderService;
    
    @RabbitHandler
    public void handle(Long orderId){
    	LOGGER.info("Confirm receiving receive orderId:{}", orderId);
    	orderService.confirmReceiving(orderId, true);
    }
}
