package com.bohuikeji.delivery.backstage.thread;

import com.bohuikeji.delivery.backstage.util.capacity.SFCityUtils;
import lombok.extern.slf4j.Slf4j;

/**
 * @author ：mmzs
 * @date ：Created in 2021/6/9 9:40
 * @description：订单回调通知线程
 * @modified By：
 * @version: $
 */
@Slf4j
public class sfOderCancelThread implements Runnable{
    private  String thirdNum;

    public sfOderCancelThread(String thirdNum) {
        this.thirdNum = thirdNum;
    }

    /**
     * 按策略进行重试
     */
    @Override
    public void run() {
        if(SFCityUtils.sfCancelOrder(thirdNum).getIntValue("error_code")==8130){
            for (int i = 1; i < 3; i++) {
                try {
                    Thread.sleep(i*i*3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    return;
                }
                log.error("顺丰订单取消返回：顺丰订单号：{}，取消次数：{}",thirdNum,i);
                if(SFCityUtils.sfCancelOrder(thirdNum).getIntValue("error_code")==0){
                    return;
                }
            }
        }
    }
}
