Commit bc814fa7 authored by zhang_z's avatar zhang_z

延长支付连接时间,增加重试次数;

增加营销计划的验证;
parent 6a2cc996
......@@ -27,7 +27,7 @@ public class Ms extends RealmObject implements BaseModel, BaseBean {
* @return 是否可用
*/
public boolean isAvailable(Vip vip) {
return checkMsByDate() && checkMsByWeek() && checkMsByTime() && checkMsByVip(vip);
return checkMsByStatus() && checkMsByDate() && checkMsByWeek() && checkMsByTime() && checkMsByVip(vip);
}
public interface OnApplyListener {
......@@ -105,6 +105,15 @@ public class Ms extends RealmObject implements BaseModel, BaseBean {
}
}
/**
* 验证启动状态
*
* @return 是否通过验证
*/
private boolean checkMsByStatus() {
return msStatus == null || msStatus == 0;
}
/**
* 验证日期
......
package com.xingdata.zxpay.api;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
public class Factory {
protected static <T> Observable<T> run(Observable<T> observable) {
return observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
}
package com.xingdata.zxpay.api;
import com.blankj.utilcode.util.LogUtils;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.ObservableSource;
import io.reactivex.functions.Function;
public class RetryHelper implements Function<Observable<Throwable>, ObservableSource<?>> {
private int retryCount;
private int retryTime;
private int nowCount = 0;
public RetryHelper(int retryCount, int retryTime) {
this.retryCount = retryCount;
this.retryTime = retryTime;
}
@Override
public ObservableSource<?> apply(Observable<Throwable> throwableObservable) throws Exception {
return throwableObservable.flatMap((Function<Throwable, ObservableSource<?>>) throwable -> {
if (throwable instanceof IOException) {
if (++nowCount <= retryCount) {
LogUtils.e("重试时间:" + retryTime + "重试:" + nowCount);
return Observable.timer(retryTime, TimeUnit.MILLISECONDS);
}
return Observable.error(throwable);
} else {
return Observable.error(throwable);
}
});
}
}
......@@ -6,6 +6,11 @@ class C {
*/
static final String VERSION = "V1.0";
/**
* 重试延迟时间
*/
static final int RETRY_DELAY_TIME = 60 * 1000;
/**
* 测试数据
*/
......
......@@ -5,17 +5,26 @@ import android.util.SparseArray;
import com.blankj.utilcode.util.TimeUtils;
import com.xingdata.zxpay.PayCenter;
import com.xingdata.zxpay.api.RetryHelper;
import java.text.SimpleDateFormat;
import java.util.Locale;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
public class Factory extends com.xingdata.zxpay.api.Factory {
private static SimpleDateFormat format = new SimpleDateFormat("yyyymmddhhmmss", Locale.getDefault());
private static SparseArray<String> orderMap = new SparseArray<>();
public static <T> Observable<T> run(Observable<T> observable) {
return observable.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.retryWhen(new RetryHelper(3, C.RETRY_DELAY_TIME));
}
/**
* 条码支付
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment