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

import com.bohuikeji.delivery.backstage.entity.third.OrderDetailDO;
import com.bohuikeji.delivery.backstage.util.capacity.SfExpressUtils;
import com.bohuikeji.frame.module.admin.base.MqListener;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * 顺丰延时取消订单类
 * @author Admin
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class SfOrderCancelListener extends MqListener<OrderDetailDO> {
    /**
     * 接收到消息会调用此方法
     *
     * @param msg 消息体
     * @return 【保留返回值】暂无实际用途，后续可能用于支持消息失败重试
     */
    @Override
    public boolean onReceive(OrderDetailDO msg) throws IOException {
        SfExpressUtils.cancelOrder(msg.getOrderNumber(),msg.getThirdNum());
        return true;
    }

    /**
     * 当消费者业务代码出现异常时会调用该方法
     *
     * @param msg 消息体
     * @param e   异常信息
     */
    @Override
    public void onError(OrderDetailDO msg, Exception e) {

    }
}
