Helius
2021-09-25 61dedee5f412d8a29f5e3030216c67d4d89f98e3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package cc.mrbird.febs.rabbit.consumer;
 
import cc.mrbird.febs.mall.service.IApiMallOrderInfoService;
import cc.mrbird.febs.rabbit.constants.QueueConstants;
import cc.mrbird.febs.rabbit.enumerates.RabbitQueueEnum;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.Date;
 
/**
 * @author wzy
 * @date 2021-09-25
 **/
@Slf4j
@Component
public class AgentConsumer {
 
    @Autowired
    private IApiMallOrderInfoService orderInfoService;
 
    @RabbitListener(queues = QueueConstants.QUEUE_DEFAULT)
    public void agentReturn(Message message, Channel channel) {
        log.info("消费者:{}", new String(message.getBody()));
    }
 
    @RabbitListener(queues = "queue_order_delay")
    public void orderCancelDelay(String id) {
        log.info("订单超时支付自动取消:{}", id);
        orderInfoService.autoCancelOrder(Long.parseLong(id));
    }
}