package com.fzm.mall.server.front.receiver;

import com.fzm.mall.server.front.mq.MqConst;
import com.fzm.mall.server.front.order.service.IOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author tdz
 * @date 2021/03/04 14:51
 */
@Slf4j
@Component
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class OrderReceiver {
    private final IOrderService orderService;

    @RabbitListener(queues = {MqConst.QUEUE_MALL_ORDER})
    public void listener(String oid) {
        if (StringUtils.isBlank(oid)) {
            return;
        }
        log.debug("解析成功，进行支付订单超时处理: {}", oid);
        orderService.process(oid);
    }

}
