package com.bohuikeji.delivery.backstage.listener.order;

import com.bohuikeji.delivery.backstage.service.ITOrderService;
import com.bohuikeji.delivery.backstage.service.third.ThirdUtils;
import com.bohuikeji.frame.module.admin.base.MqListener;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * 订单延时发送第三方监听业务处理
 * @author Admin
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class OrderSendThirdListener extends MqListener<Integer> {
    final ITOrderService orderService;

    /**
     * 获取当前配置环境prod
     * prod
     */
    @Value("${spring.profiles.active}")
    private String active;

    @Override
    public boolean onReceive(Integer orderId) {
        if("prod".equals(active)){
            //生产环境直接转发
            ThirdUtils.orderPlace(orderService.getById(orderId));
        }
        return false;
    }

    @Override
    public void onError(Integer msg, Exception e) {

    }
}
