package com.bohuikeji.delivery.backstage.thread;

import com.bohuikeji.delivery.backstage.entity.TOpenCallback;
import com.bohuikeji.delivery.backstage.entity.TOpenCallbackLog;

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

    private  TOpenCallback callback;
    private  String orderStatus;

    public OrderCalLBackThread(TOpenCallback callback, String orderStatus) {
        this.callback = callback;
        this.orderStatus = orderStatus;
    }

    /**
     * 按策略进行重试
     */
    @Override
    public void run() {
        if(!TOpenCallbackLog.runCallBackAndSave(callback,orderStatus)){
            for (int i = 1; i < 5; i++) {
                try {
                    Thread.sleep(i*i*5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    return;
                }
                if(TOpenCallbackLog.runCallBackAndSave(callback,orderStatus)){
                    return;
                }
            }
        }
    }
}
