|
|
@@ -12,6 +12,7 @@ import com.google.gson.Gson;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.Iterator;
|
|
|
|
|
|
import javax.inject.Singleton;
|
|
|
|
|
|
@@ -31,7 +32,7 @@ public class OrderReportHelper {
|
|
|
private static Gson gson;
|
|
|
private static MemberRepository memberRepository;
|
|
|
|
|
|
- private static final long MAX_QUERY_TIME = 60 * 1000L;
|
|
|
+ private static final long MAX_QUERY_TIME = 30 * 60 * 1000L;
|
|
|
|
|
|
private OrderReportHelper() {
|
|
|
|
|
|
@@ -58,16 +59,22 @@ public class OrderReportHelper {
|
|
|
if (notReportedPayMap.size() == 0 || memberRepository == null) {
|
|
|
return;
|
|
|
}
|
|
|
- for (String orderId : notReportedPayMap.keySet()) {
|
|
|
+ Iterator<String> iterator = notReportedPayMap.keySet().iterator();
|
|
|
+ while (iterator.hasNext()) {
|
|
|
+ String orderId = iterator.next();
|
|
|
PayInfo payInfo = notReportedPayMap.get(orderId);
|
|
|
if (payInfo == null) {
|
|
|
continue;
|
|
|
}
|
|
|
+ if (TextUtils.isEmpty(orderId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (System.currentTimeMillis() - payInfo.getPayTime() > MAX_QUERY_TIME) {
|
|
|
- removeOderId(orderId);
|
|
|
+ iterator.remove();
|
|
|
+ save();
|
|
|
continue;
|
|
|
}
|
|
|
- memberRepository.getPayStatus(orderId).subscribe(new SingleObserver<Boolean>() {
|
|
|
+ memberRepository.getPayStatus(orderId, 10, 3).subscribe(new SingleObserver<Boolean>() {
|
|
|
@Override
|
|
|
public void onSubscribe(@NonNull Disposable d) {
|
|
|
|
|
|
@@ -77,7 +84,7 @@ public class OrderReportHelper {
|
|
|
public void onSuccess(@NonNull Boolean paySuccess) {
|
|
|
Log.d(TAG, "onSuccess: " + paySuccess + "--orderId:" + orderId);
|
|
|
if (BoxingUtil.boxing(paySuccess)) {
|
|
|
-// EventHelper.reportPay(payInfo.getPayAmount(), payInfo.getOrderId(), payInfo.getPayWay(), payInfo.getProduct());
|
|
|
+ EventHelper.reportPay(payInfo.getPayAmount(), payInfo.getOrderId(), payInfo.getPayWay(), payInfo.getProduct());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -85,11 +92,8 @@ public class OrderReportHelper {
|
|
|
public void onError(@NonNull Throwable e) {
|
|
|
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private static HashMap<String, PayInfo> toGsonMap(String jsonStr) {
|
|
|
@@ -112,9 +116,10 @@ public class OrderReportHelper {
|
|
|
return;
|
|
|
}
|
|
|
notReportedPayMap.put(orderId, new PayInfo(payAmount, orderId, payWay, product));
|
|
|
- KVUtils.getDefault().putString(RECORD_PAY_ORDER_ID_LIST, gson.toJson(notReportedPayMap));
|
|
|
+ save();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public static void removeOderId(String orderId) {
|
|
|
if (TextUtils.isEmpty(orderId)) {
|
|
|
return;
|
|
|
@@ -122,9 +127,12 @@ public class OrderReportHelper {
|
|
|
boolean contains = notReportedPayMap.containsKey(orderId);
|
|
|
if (contains) {
|
|
|
notReportedPayMap.remove(orderId);
|
|
|
- KVUtils.getDefault().putString(RECORD_PAY_ORDER_ID_LIST, gson.toJson(notReportedPayMap));
|
|
|
+ save();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private static void save() {
|
|
|
+ KVUtils.getDefault().putString(RECORD_PAY_ORDER_ID_LIST, gson.toJson(notReportedPayMap));
|
|
|
+ }
|
|
|
|
|
|
}
|