package com.hfkj.consumer;

import com.hfkj.entity.BsGasOilPriceTask;
import com.hfkj.entity.BsOrder;
import com.hfkj.model.order.OrderModel;
import com.hfkj.service.gas.BsGasOilPriceService;
import com.hfkj.service.gas.BsGasOilPriceTaskService;
import com.hfkj.service.order.BsOrderService;
import com.hfkj.sysenum.gas.GasTaskStatusEnum;
import com.hfkj.sysenum.order.OrderStatusEnum;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
@RocketMQMessageListener(consumerGroup = "task-oil-price-group", topic = "task-topic",selectorExpression = "oil-price")
public class TaskOilPriceConsumer implements RocketMQListener<String> {

    @Resource
    private BsGasOilPriceTaskService gasOilPriceTaskService;

    @Override
    public void onMessage(String oilPriceTaskId) {
        // 油价任务
        BsGasOilPriceTask task = gasOilPriceTaskService.getDetailById(Long.parseLong(oilPriceTaskId));
        if (task != null && task.getStatus().equals(GasTaskStatusEnum.status1.getStatus())) {
            // 任务处理
            gasOilPriceTaskService.businessHandle(task);
        }
    }
}
